@xopcai/xopc 0.0.469 → 0.0.470
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.
|
@@ -3,7 +3,7 @@ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{r as n}from"./d
|
|
|
3
3
|
|
|
4
4
|
`,aH=/\r\n/g,oH=`xopc.npmPendingRestart`;function sH(e){let t=e?.postUpdate;if(!t||typeof t!=`object`)return!1;let n=t.restart;if(!n||typeof n!=`object`)return!1;let r=n;return r.ok===!0&&[`in-process`,`daemon`,`unmanaged`].includes(String(r.mode))}function cH(e,t){try{sessionStorage.setItem(oH,JSON.stringify({installedVersion:e,automaticRestart:t}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e,automaticRestart:t}})),t&&window.dispatchEvent(new Event(`gateway-restart-initiated`))}var lH=typeof window<`u`&&window.electronAPI?.updater!==void 0;function uH(){return null}function dH(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(oH);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(oH)}catch{}}function fH(e){return dH(e.currentVersion),e}function pH(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(()=>uH()),[o,s]=(0,Z.useState)(lH?{state:`idle`}:uH()),c=(0,Z.useRef)(null),l=lH||i!==null;(0,Z.useEffect)(()=>{if(l)return;hH().then(e=>t(fH(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&fH({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(fH({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,Z.useEffect)(()=>{if(!lH)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,Z.useEffect)(()=>{},[]),(0,Z.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,Z.useCallback)(async()=>{if(l)return!1;try{let e=await S(T(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(fH(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,Z.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 S(T(`/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 gH(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){let t=sH(e);cH(e.installedVersion,t)}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,Z.useCallback)(()=>{if(lH){window.electronAPI.updater.check();return}},[i]),p=(0,Z.useCallback)(()=>{lH&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:lH?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var mH=null;async function hH(){return mH||(mH=(async()=>{let e=await S(T(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{mH=null}),mH)}async function gH(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(`
|
|
5
5
|
`)){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(aH,`
|
|
6
|
-
`);let c=r.split(iH);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 _H=`xopc.updateReminder.dismissed`,vH=typeof window<`u`&&window.electronAPI?.updater!==void 0,yH=`xopc:electron-update-recheck`;function bH(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(_H);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function xH(){let{npm:e,electron:t,isElectron:n,electronCheck:r,electronQuitAndInstall:i,runNpmUpdate:a,npmUpdateRunning:o}=pH(),[s,c]=(0,Z.useState)(bH),[l,u]=(0,Z.useState)({downloading:!1,electronError:!1}),[d,f]=(0,Z.useState)(()=>{if(typeof window>`u`||vH)return null;try{let e=sessionStorage.getItem(oH);if(!e)return null;let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;return n?{version:n,automatic:t.automaticRestart===!0}:null}catch{return null}}),p=(0,Z.useRef)(t?.state);p.current!==t?.state&&(p.current=t?.state,t?.state!==`downloading`&&l.downloading&&u(e=>({...e,downloading:!1})),t?.state!==`error`&&l.electronError&&u(e=>({...e,electronError:!1})));let m=(0,Z.useRef)(null);if(d&&e?.currentVersion===d.version&&m.current!==d.version){m.current=d.version;try{sessionStorage.removeItem(oH)}catch{}f(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(oH);if(!e){f(null);return}let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;f(n?{version:n,automatic:t.automaticRestart===!0}:null)}catch{f(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{u(e=>({...e,downloading:!1})),c(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(_H,JSON.stringify(t))}catch{}return t})};return window.addEventListener(yH,e),()=>window.removeEventListener(yH,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&c(e=>{let n={...e,npm:t};try{localStorage.setItem(_H,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let h=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?s.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!l.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&!l.electronError?{kind:`electron-error`,message:t.message?.trim()??``}:!n&&d&&e&&e.currentVersion!==d.version?d.automatic?{kind:`npm-restarting`,version:d.version}:{kind:`npm-restart-required`,version:d.version}:!n&&e?.updateAvailable&&e.latestVersion?s.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[s.npm,s.electronReady,t,l.downloading,l.electronError,n,e,d]);return{show:h,dismiss:(0,Z.useCallback)(()=>{if(h.kind===`electron-downloading`){u(e=>({...e,downloading:!0}));return}if(h.kind===`electron-error`){u(e=>({...e,electronError:!0}));return}if(h.kind===`npm-restart-required`||h.kind===`npm-restarting`){try{sessionStorage.removeItem(oH)}catch{}f(null);return}if(h.kind===`none`)return;let e={...s};h.kind===`npm`?e.npm=h.version:h.kind===`electron-ready`&&(e.electronReady=h.version);try{localStorage.setItem(_H,JSON.stringify(e))}catch{}c(e)},[s,h]),electronCheck:r,electronQuitAndInstall:i,runNpmUpdate:a,npmUpdateRunning:o}}var SH={version:`0.0.469`,commit:`e3cab6b970d422f4b282dd159774eb537a6cd7d4`,buildTimeIso:`2026-11-12T19:50:06.430Z`},CH=`https://github.com/xopcai/xopc`,wH=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),TH=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function EH(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?wH:TH).format(n)}catch{return n.toISOString()}}function DH({open:e,onOpenChange:t}){let n=D(e=>e.language),r=F(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:f}=pH(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),{data:x}=Nu(async()=>{let e=await O(T(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),S=(0,Z.useCallback)(e=>{e||(m(!1),g(!1),v(!1),b(null)),t(e)},[t]),C=(0,Z.useCallback)(async()=>{b(null);let e=F(n).updatePanel,t=await d();if(t.ok){jl({tone:`success`,title:e.updateSuccess,message:sH(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;b(`${r}: ${t.message}`)},[d,n]),w=SH.commit,E=n===`zh`?`zh-CN`:`en-US`,k=EH(SH.buildTimeIso,E),A=new Date().getFullYear(),j=i.copyright.replace(`{year}`,String(A));return(0,$.jsx)(ne,{open:e,onOpenChange:S,children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(ee,{className:Y(`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-overlay shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(V,{asChild:!0,children:(0,$.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,$.jsx)(ds,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(Rl,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(te,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(B,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:SH.version}),(0,$.jsx)(`button`,{type:`button`,className:Y(`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(yH)),m(!0),c()):(m(!0),v(!1),g(!0),(async()=>{let e=await l();g(!1),e||v(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(h||f),children:o&&s?.state===`checking`||!o&&h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(_a,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&p&&(0,$.jsx)(OH,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&p&&(0,$.jsx)(kH,{checking:h,checkFailed:_,npm:u,npmUpdateRunning:f,upgradeError:y,onUpgrade:C,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:w})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:k})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:x??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:CH,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:j})]})]})]})]})})}function OH(e){let t=(0,Q.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,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.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,$.jsx)(jr,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.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,$.jsx)(Eo,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.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,$.jsx)(pi,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.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,$.jsx)(pi,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.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,$.jsx)(Ar,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function kH(e){let t=(0,Q.c)(28),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,upgradeError:o,onUpgrade:s,d:c,tp:l}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===c.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesChecking})]}),t[1]=c.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ar,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===c.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesError})]}),t[4]=c.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===l.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:l.updateRunning})]}),t[7]=l.updateRunning,t[8]=n),n}if(o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ar,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;return t[10]===o?n=t[11]:(n=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-red-500 dark:text-red-400`,role:`alert`,children:[e,(0,$.jsx)(`span`,{children:o})]}),t[10]=o,t[11]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Eo,{className:`mt-0.5 size-3.5 shrink-0`}),t[12]=e):e=t[12];let n;t[13]!==i.latestVersion||t[14]!==l.reminderNpm?(n=l.reminderNpm.replace(`{{version}}`,i.latestVersion),t[13]=i.latestVersion,t[14]=l.reminderNpm,t[15]=n):n=t[15];let r;t[16]===n?r=t[17]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[16]=n,t[17]=r);let a;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(a=Y(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-on-accent`,`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[18]=a):a=t[18];let o;t[19]!==s||t[20]!==l.updateNow?(o=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:a,children:l.updateNow}),t[19]=s,t[20]=l.updateNow,t[21]=o):o=t[21];let c;return t[22]!==r||t[23]!==o?(c=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,o]}),t[22]=r,t[23]=o,t[24]=c):c=t[24],c}let u;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(jr,{className:`size-3.5`}),t[25]=u):u=t[25];let d;return t[26]===c.checkUpdatesUpToDate?d=t[27]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[u,(0,$.jsx)(`span`,{children:c.checkUpdatesUpToDate})]}),t[26]=c.checkUpdatesUpToDate,t[27]=d),d}var AH=Y(`flex w-full items-center gap-2 rounded-lg px-2.5 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-overlay`),jH=Y(`overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,`dark:border-edge`);function MH(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=Y(`touch-target flex w-full items-center justify-between gap-2 rounded-none 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-inset focus-visible:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=Y(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(_r,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function NH(e){let t=(0,Q.c)(220),{onNavigate:n,onAboutClick:r,onSupportClick:i,onDeviceConnectClick:a}=e,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=D(zH),d=D(RH),f=Wl(LH),p=Wl(IH),m=Bl(FH),h=Bl(PH),g;t[0]===u?g=t[1]:(g=F(u),t[0]=u,t[1]=g);let _=g,v=_.appearanceSettings,y=u===`zh`?v.langOptionZh:v.langOptionEn,x=f===`light`?v.themeOptionLight:f===`dark`?v.themeOptionDark:v.themeOptionSystem,S=m===`compact`?v.fontScaleCompact:m===`large`?v.fontScaleLarge:v.fontScaleDefault,C=typeof window<`u`?window.electronAPI?.pet:void 0,w=!!C,T=c?.visible?v.hideDesktopPet:v.showDesktopPet,E,O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{if(!C)return;let e=!1;C.getState().then(t=>{e||l(t)});let t=C.onStateChanged(t=>{e||l(t)});return()=>{e=!0,t()}},O=[C],t[2]=E,t[3]=O):(E=t[2],O=t[3]),(0,Z.useEffect)(E,O);let k;t[4]===c?.visible?k=t[5]:(k=async()=>{C&&(c?.visible?await C.hide():await C.show(),l(await C.getState()))},t[4]=c?.visible,t[5]=k);let A=k,j;t[6]===o?j=t[7]:(j=e=>Y(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,o===e?`block`:`hidden`),t[6]=o,t[7]=j);let M=j,N;t[8]===o?N=t[9]:(N=e=>Y(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,o===e?`pointer-events-auto`:`pointer-events-none`),t[8]=o,t[9]=N);let P=N,I;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>s(null),t[10]=I):I=t[10];let L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>s(`lang`),t[11]=L):L=t[11];let R=o===`lang`&&`bg-surface-hover`,z;t[12]===R?z=t[13]:(z=Y(AH,R),t[12]=R,t[13]=z);let B=o===`lang`,V;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Xi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=V):V=t[14];let H;t[15]===v.languageTitle?H=t[16]:(H=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.languageTitle}),t[15]=v.languageTitle,t[16]=H);let ee;t[17]===y?ee=t[18]:(ee=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:y}),t[17]=y,t[18]=ee);let te;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=te):te=t[19];let ne;t[20]!==z||t[21]!==B||t[22]!==H||t[23]!==ee?(ne=(0,$.jsxs)(`button`,{type:`button`,className:z,"aria-haspopup":`menu`,"aria-expanded":B,children:[V,H,ee,te]}),t[20]=z,t[21]=B,t[22]=H,t[23]=ee,t[24]=ne):ne=t[24];let U;t[25]===P?U=t[26]:(U=P(`lang`),t[25]=P,t[26]=U);let re;t[27]===U?re=t[28]:(re=(0,$.jsx)(`div`,{className:U,"aria-hidden":!0}),t[27]=U,t[28]=re);let W;t[29]===M?W=t[30]:(W=M(`lang`),t[29]=M,t[30]=W);let ie=u===`en`,G;t[31]===d?G=t[32]:(G=()=>d(`en`),t[31]=d,t[32]=G);let K;t[33]!==v.langOptionEn||t[34]!==ie||t[35]!==G?(K=(0,$.jsx)(MH,{selected:ie,label:v.langOptionEn,onSelect:G}),t[33]=v.langOptionEn,t[34]=ie,t[35]=G,t[36]=K):K=t[36];let ae=u===`zh`,q;t[37]===d?q=t[38]:(q=()=>d(`zh`),t[37]=d,t[38]=q);let oe;t[39]!==v.langOptionZh||t[40]!==ae||t[41]!==q?(oe=(0,$.jsx)(MH,{selected:ae,label:v.langOptionZh,onSelect:q}),t[39]=v.langOptionZh,t[40]=ae,t[41]=q,t[42]=oe):oe=t[42];let se;t[43]!==K||t[44]!==oe?(se=(0,$.jsxs)(`div`,{className:jH,children:[K,oe]}),t[43]=K,t[44]=oe,t[45]=se):se=t[45];let ce;t[46]!==v.languageTitle||t[47]!==W||t[48]!==se?(ce=(0,$.jsx)(`div`,{className:W,role:`menu`,"aria-label":v.languageTitle,children:se}),t[46]=v.languageTitle,t[47]=W,t[48]=se,t[49]=ce):ce=t[49];let le;t[50]!==ne||t[51]!==re||t[52]!==ce?(le=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:L,children:[ne,re,ce]}),t[50]=ne,t[51]=re,t[52]=ce,t[53]=le):le=t[53];let ue;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>s(`theme`),t[54]=ue):ue=t[54];let de=o===`theme`&&`bg-surface-hover`,J;t[55]===de?J=t[56]:(J=Y(AH,de),t[55]=de,t[56]=J);let fe=o===`theme`,pe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Xa,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=pe):pe=t[57];let me;t[58]===v.themeTitle?me=t[59]:(me=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.themeTitle}),t[58]=v.themeTitle,t[59]=me);let he;t[60]===x?he=t[61]:(he=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:x}),t[60]=x,t[61]=he);let ge;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=ge):ge=t[62];let _e;t[63]!==J||t[64]!==fe||t[65]!==me||t[66]!==he?(_e=(0,$.jsxs)(`button`,{type:`button`,className:J,"aria-haspopup":`menu`,"aria-expanded":fe,children:[pe,me,he,ge]}),t[63]=J,t[64]=fe,t[65]=me,t[66]=he,t[67]=_e):_e=t[67];let ve;t[68]===P?ve=t[69]:(ve=P(`theme`),t[68]=P,t[69]=ve);let ye;t[70]===ve?ye=t[71]:(ye=(0,$.jsx)(`div`,{className:ve,"aria-hidden":!0}),t[70]=ve,t[71]=ye);let be;t[72]===M?be=t[73]:(be=M(`theme`),t[72]=M,t[73]=be);let xe=f===`light`,Se;t[74]===p?Se=t[75]:(Se=()=>p(`light`),t[74]=p,t[75]=Se);let Ce;t[76]!==v.themeOptionLight||t[77]!==xe||t[78]!==Se?(Ce=(0,$.jsx)(MH,{selected:xe,label:v.themeOptionLight,onSelect:Se}),t[76]=v.themeOptionLight,t[77]=xe,t[78]=Se,t[79]=Ce):Ce=t[79];let we=f===`dark`,Te;t[80]===p?Te=t[81]:(Te=()=>p(`dark`),t[80]=p,t[81]=Te);let Ee;t[82]!==v.themeOptionDark||t[83]!==we||t[84]!==Te?(Ee=(0,$.jsx)(MH,{selected:we,label:v.themeOptionDark,onSelect:Te}),t[82]=v.themeOptionDark,t[83]=we,t[84]=Te,t[85]=Ee):Ee=t[85];let De=f===`system`,Oe;t[86]===p?Oe=t[87]:(Oe=()=>p(`system`),t[86]=p,t[87]=Oe);let ke;t[88]!==v.themeOptionSystem||t[89]!==De||t[90]!==Oe?(ke=(0,$.jsx)(MH,{selected:De,label:v.themeOptionSystem,onSelect:Oe}),t[88]=v.themeOptionSystem,t[89]=De,t[90]=Oe,t[91]=ke):ke=t[91];let Ae;t[92]!==Ce||t[93]!==Ee||t[94]!==ke?(Ae=(0,$.jsxs)(`div`,{className:jH,children:[Ce,Ee,ke]}),t[92]=Ce,t[93]=Ee,t[94]=ke,t[95]=Ae):Ae=t[95];let je;t[96]!==v.themeTitle||t[97]!==be||t[98]!==Ae?(je=(0,$.jsx)(`div`,{className:be,role:`menu`,"aria-label":v.themeTitle,children:Ae}),t[96]=v.themeTitle,t[97]=be,t[98]=Ae,t[99]=je):je=t[99];let Me;t[100]!==_e||t[101]!==ye||t[102]!==je?(Me=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:ue,children:[_e,ye,je]}),t[100]=_e,t[101]=ye,t[102]=je,t[103]=Me):Me=t[103];let Ne;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=()=>s(`font`),t[104]=Ne):Ne=t[104];let Pe=o===`font`&&`bg-surface-hover`,Fe;t[105]===Pe?Fe=t[106]:(Fe=Y(AH,Pe),t[105]=Pe,t[106]=Fe);let Ie=o===`font`,Le;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(eR,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Le):Le=t[107];let Re;t[108]===v.fontScaleTitle?Re=t[109]:(Re=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.fontScaleTitle}),t[108]=v.fontScaleTitle,t[109]=Re);let ze;t[110]===S?ze=t[111]:(ze=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[110]=S,t[111]=ze);let Be;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Be):Be=t[112];let Ve;t[113]!==Fe||t[114]!==Ie||t[115]!==Re||t[116]!==ze?(Ve=(0,$.jsxs)(`button`,{type:`button`,className:Fe,"aria-haspopup":`menu`,"aria-expanded":Ie,children:[Le,Re,ze,Be]}),t[113]=Fe,t[114]=Ie,t[115]=Re,t[116]=ze,t[117]=Ve):Ve=t[117];let He;t[118]===P?He=t[119]:(He=P(`font`),t[118]=P,t[119]=He);let Ue;t[120]===He?Ue=t[121]:(Ue=(0,$.jsx)(`div`,{className:He,"aria-hidden":!0}),t[120]=He,t[121]=Ue);let We;t[122]===M?We=t[123]:(We=M(`font`),t[122]=M,t[123]=We);let Ge=m===`compact`,Ke;t[124]===h?Ke=t[125]:(Ke=()=>h(`compact`),t[124]=h,t[125]=Ke);let qe;t[126]!==v.fontScaleCompact||t[127]!==Ge||t[128]!==Ke?(qe=(0,$.jsx)(MH,{selected:Ge,label:v.fontScaleCompact,onSelect:Ke}),t[126]=v.fontScaleCompact,t[127]=Ge,t[128]=Ke,t[129]=qe):qe=t[129];let Je=m==="default",Ye;t[130]===h?Ye=t[131]:(Ye=()=>h(`default`),t[130]=h,t[131]=Ye);let Xe;t[132]!==v.fontScaleDefault||t[133]!==Je||t[134]!==Ye?(Xe=(0,$.jsx)(MH,{selected:Je,label:v.fontScaleDefault,onSelect:Ye}),t[132]=v.fontScaleDefault,t[133]=Je,t[134]=Ye,t[135]=Xe):Xe=t[135];let Ze=m===`large`,Qe;t[136]===h?Qe=t[137]:(Qe=()=>h(`large`),t[136]=h,t[137]=Qe);let $e;t[138]!==v.fontScaleLarge||t[139]!==Ze||t[140]!==Qe?($e=(0,$.jsx)(MH,{selected:Ze,label:v.fontScaleLarge,onSelect:Qe}),t[138]=v.fontScaleLarge,t[139]=Ze,t[140]=Qe,t[141]=$e):$e=t[141];let et;t[142]!==qe||t[143]!==Xe||t[144]!==$e?(et=(0,$.jsxs)(`div`,{className:jH,children:[qe,Xe,$e]}),t[142]=qe,t[143]=Xe,t[144]=$e,t[145]=et):et=t[145];let tt;t[146]!==v.fontScaleTitle||t[147]!==We||t[148]!==et?(tt=(0,$.jsx)(`div`,{className:We,role:`menu`,"aria-label":v.fontScaleTitle,children:et}),t[146]=v.fontScaleTitle,t[147]=We,t[148]=et,t[149]=tt):tt=t[149];let nt;t[150]!==Ve||t[151]!==Ue||t[152]!==tt?(nt=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:Ne,children:[Ve,Ue,tt]}),t[150]=Ve,t[151]=Ue,t[152]=tt,t[153]=nt):nt=t[153];let rt;t[154]!==T||t[155]!==A?(rt=w?(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:()=>void A(),onMouseEnter:()=>s(null),onFocus:()=>s(null),children:[(0,$.jsx)(SA,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:T})]}):null,t[154]=T,t[155]=A,t[156]=rt):rt=t[156];let it;t[157]===a?it=t[158]:(it=()=>a?.(),t[157]=a,t[158]=it);let at,ot,st;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(at=()=>s(null),ot=()=>s(null),st=(0,$.jsx)(Ba,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[159]=at,t[160]=ot,t[161]=st):(at=t[159],ot=t[160],st=t[161]);let ct;t[162]===_.endpointToolsSettings.deviceAccess.flow.title?ct=t[163]:(ct=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.endpointToolsSettings.deviceAccess.flow.title}),t[162]=_.endpointToolsSettings.deviceAccess.flow.title,t[163]=ct);let lt;t[164]!==it||t[165]!==ct?(lt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:it,onMouseEnter:at,onFocus:ot,children:[st,ct]}),t[164]=it,t[165]=ct,t[166]=lt):lt=t[166];let ut;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[167]=ut):ut=t[167];let dt;t[168]===r?dt=t[169]:(dt=()=>r?.(),t[168]=r,t[169]=dt);let ft,pt,mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(ft=()=>s(null),pt=()=>s(null),mt=(0,$.jsx)(ca,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=ft,t[171]=pt,t[172]=mt):(ft=t[170],pt=t[171],mt=t[172]);let ht;t[173]===v.aboutApp?ht=t[174]:(ht=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.aboutApp}),t[173]=v.aboutApp,t[174]=ht);let gt;t[175]!==dt||t[176]!==ht?(gt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:dt,onMouseEnter:ft,onFocus:pt,children:[mt,ht]}),t[175]=dt,t[176]=ht,t[177]=gt):gt=t[177];let _t;t[178]===u?_t=t[179]:(_t=Zl(u),t[178]=u,t[179]=_t);let vt,yt,bt;t[180]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>s(null),yt=()=>s(null),bt=(0,$.jsx)(mn,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[180]=vt,t[181]=yt,t[182]=bt):(vt=t[180],yt=t[181],bt=t[182]);let xt;t[183]===_.sidebar.helpDocs?xt=t[184]:(xt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.sidebar.helpDocs}),t[183]=_.sidebar.helpDocs,t[184]=xt);let St;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,$.jsx)(hi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[185]=St):St=t[185];let Ct;t[186]!==_t||t[187]!==xt?(Ct=(0,$.jsxs)(`a`,{href:_t,target:`_blank`,rel:`noopener noreferrer`,className:AH,onMouseEnter:vt,onFocus:yt,children:[bt,xt,St]}),t[186]=_t,t[187]=xt,t[188]=Ct):Ct=t[188];let wt;t[189]===i?wt=t[190]:(wt=()=>i?.(),t[189]=i,t[190]=wt);let Tt,Et,Dt;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(Dt=()=>s(null),Tt=()=>s(null),Et=(0,$.jsx)(bO,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[191]=Tt,t[192]=Et,t[193]=Dt):(Tt=t[191],Et=t[192],Dt=t[193]);let Ot;t[194]===_.supportReport.menu?Ot=t[195]:(Ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.supportReport.menu}),t[194]=_.supportReport.menu,t[195]=Ot);let kt;t[196]!==Ot||t[197]!==wt?(kt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:wt,onMouseEnter:Dt,onFocus:Tt,children:[Et,Ot]}),t[196]=Ot,t[197]=wt,t[198]=kt):kt=t[198];let At,jt,Mt;t[199]===Symbol.for(`react.memo_cache_sentinel`)?(At=Y(AH,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),jt=()=>s(null),Mt=()=>s(null),t[199]=At,t[200]=jt,t[201]=Mt):(At=t[199],jt=t[200],Mt=t[201]);let Nt;t[202]===n?Nt=t[203]:(Nt=()=>n?.(),t[202]=n,t[203]=Nt);let Pt;t[204]===Symbol.for(`react.memo_cache_sentinel`)?(Pt=(0,$.jsx)(Io,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[204]=Pt):Pt=t[204];let Ft;t[205]===v.openFullPreferences?Ft=t[206]:(Ft=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:v.openFullPreferences}),t[205]=v.openFullPreferences,t[206]=Ft);let It;t[207]!==Nt||t[208]!==Ft?(It=(0,$.jsxs)(b,{to:`/settings/overview`,className:At,onMouseEnter:jt,onFocus:Mt,onClick:Nt,children:[Pt,Ft]}),t[207]=Nt,t[208]=Ft,t[209]=It):It=t[209];let Lt;return t[210]!==kt||t[211]!==It||t[212]!==le||t[213]!==Me||t[214]!==nt||t[215]!==rt||t[216]!==lt||t[217]!==gt||t[218]!==Ct?(Lt=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:I,children:[le,Me,nt,rt,lt,ut,gt,Ct,kt,It]}),t[210]=kt,t[211]=It,t[212]=le,t[213]=Me,t[214]=nt,t[215]=rt,t[216]=lt,t[217]=gt,t[218]=Ct,t[219]=Lt):Lt=t[219],Lt}function PH(e){return e.setPreference}function FH(e){return e.preference}function IH(e){return e.setPreference}function LH(e){return e.preference}function RH(e){return e.setLanguage}function zH(e){return e.language}var BH=`open-support-report`;function VH(e={}){window.dispatchEvent(new CustomEvent(BH,{detail:e}))}var HH=(0,Z.lazy)(()=>c(()=>import(`./device-pairing-wizard-eWeHH6Ru.js`).then(e=>e.n).then(e=>({default:e.DevicePairingWizard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])));function UH({collapsed:e=!1,onNavigate:t}){let n=F(D(e=>e.language)),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{c(()=>import(`./settings-page-bCW4rave.js`),__vite__mapDeps([52,1,2,3,4,5,6,53])),c(()=>import(`./sessions-page-CN9ESZdY.js`),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,55,11,56,13,57,58,59,60,61,62,63,64,20,21,31,65,66,34,22,25,26,27,28,67,68,69,14,70,71,72,73,74,75,76,77,78,19,79,80,23,44,81,82,24,49,45,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,15,99,100,47,48,101,102,42,103])),c(()=>import(`./logs-page-CH9amuGc.js`),__vite__mapDeps([104,1,2,3,4,5,6,7,8,9,105,11,66,34,20,21,22,25,26,27,28,106,84,88,14,107,108,109,110,111,76,63,19,79,31,80,112,113,24,36,45,114,115,116,117,118,10,119,13,98,15,99,100])),c(()=>import(`./automations-page-DqrAOReO.js`),__vite__mapDeps([120,2,1,121,4,3,5,6,7,8,9,122,11,123,124,125,20,21,22,23,126,34,105,10,66,25,26,27,28,102,12,35,127,128,57,110,42,129,130,14,131,75,19,29,30,31,36,132,133,134,58,135,48,136,111,76,137,99,138,78,64,139,140,141,142,143,79,80,144,145,146,147,112,113,82,148,44,81,24,149,150,90,84,114,151,91,62,92,49,45,93,152,85,86,87,116,117,118,119,13,115,153,154,155,156,157,158,159,160,161,15,107,162,163])),c(()=>import(`./capabilities-page-XgIRdqCb.js`),__vite__mapDeps([164,1,2,4,3,5,6,20,21,22,165,149,166,167,168,76,11,24,9,25,8,26,27,169]))},[]),(0,$.jsxs)(`div`,{className:Y(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[s?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(HH,{open:!0,onOpenChange:l})}):null,(0,$.jsxs)(ol,{open:r,onOpenChange:i,children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(b,{to:`/user-model`,onClick:()=>t?.(),className:`rounded-full outline-none ring-offset-surface-base transition-transform hover:opacity-95 active:scale-95 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 motion-reduce:active:scale-100`,title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(Pu,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted outline-none ring-offset-surface-base transition-colors`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)(Io,{className:`size-[17px]`,strokeWidth:1.5})})})]}):(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-1 rounded-xl p-1`,children:[(0,$.jsx)(b,{to:`/user-model`,onClick:()=>t?.(),className:Y(`flex size-10 shrink-0 items-center justify-center rounded-full text-left outline-none transition-transform duration-150 ease-out`,`hover:bg-surface-active/70`,`hover:opacity-95 active:scale-95`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(Pu,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left text-fg-muted transition-colors`,`outline-none hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:n.appearanceSettings.quickMenuHint})]}),(0,$.jsx)(Io,{className:`size-[18px] shrink-0`,strokeWidth:1.5})]})})]}),(0,$.jsx)(il,{children:(0,$.jsx)(al,{className:Y(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`end`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(NH,{onNavigate:()=>{i(!1),t?.()},onAboutClick:()=>{o(!0),i(!1)},onSupportClick:()=>{i(!1),VH()},onDeviceConnectClick:()=>{i(!1),l(!0)}})})})]}),(0,$.jsx)(DH,{open:a,onOpenChange:o})]})}function WH(e){return Zz[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var GH=`xopc-web-sidebar-nav-order`;function KH(){try{let e=JSON.parse(globalThis.localStorage?.getItem(GH)??`[]`);return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`))]:[]}catch{return[]}}var qH=k(e=>({order:KH(),setOrder:t=>{let n=[...new Set(t)];e({order:n});try{globalThis.localStorage?.setItem(GH,JSON.stringify(n))}catch{}}})),JH=`application/x-xopc-sidebar-nav`,YH=3,XH=[`work`,`capabilities`,`automation`,`apps`],ZH={work:sr,capabilities:da,automation:fs,apps:hg};function QH(e,t,n=!1){return Y(`flex w-full items-center text-sm font-medium 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`,n?`gap-2 rounded-md px-2 py-1.5 text-left leading-5`:e?`justify-center rounded-xl p-2.5 leading-6`:`gap-2 rounded-lg px-3 py-2.5 text-left leading-6 md:py-1.5`,t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}function $H(e){let t=(0,Q.c)(2),{Icon:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r),r}function eU(e){let t=(0,Q.c)(38),{collapsed:n,onNavigate:r,visibleLimit:i}=e,a=n!==void 0&&n,o=i===void 0?YH:i,{pathname:s}=m(),c=D(fU),l=F(c),d=l.productNavigation,f=u(`/chat/*`,s)?null:Yc(s),p=Fu(),{profile:h,displayName:g}=Vu(),_=ve(),[v,y]=(0,Z.useState)(!1),x=qH(dU),S=qH(uU),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),O=XH.map(e=>{let t=Xc.find(t=>t.id===e);return{id:`builtin:${e===`automation`?`automations`:e===`apps`?`localApps`:e}`,label:d.domains[e],to:t.path,Icon:ZH[e],active:f===e}}),k=p.flatMap(e=>e.activationEligible===!1?[]:(e.ui?.contributions?.pages??[]).filter(lU).map(t=>{let n=Mr(e.id,t);return{id:`ext:${e.id}:${t.id}`,label:t.title,to:n,Icon:t.navIcon?WH(t.navIcon)??So:So,active:s===n||s.startsWith(`${n}/`)}})),A=[...O,...k],j=new Map(A.map(cU)),M=[...new Set([...x,...j.keys()])].filter(e=>j.has(e)),N=M.map(e=>j.get(e)),P=Number.isFinite(o)?Math.min(A.length,Math.max(1,Math.round(o))):YH,I=N.slice(0,P),L=N.slice(P),R=L.filter(sU),z=L.filter(oU),B=L.some(aU),V;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{w(null),E(null)},t[0]=V):V=t[0];let H=V,ee=iU,te=(e,t)=>{let n=e.dataTransfer.getData(JH);if(!(!C||n!==C||!j.has(n))){if(e.preventDefault(),n!==t){let r=M.filter(e=>e!==n),i=t?r.indexOf(t)+ +!!ee(e):r.length;r.splice(i,0,n),S([...r,...x.filter(e=>!j.has(e))])}H(),y(!1)}},ne=(e,t)=>{let n=t!==void 0&&t;return(0,$.jsxs)(b,{to:e.to,"aria-current":e.active?`page`:void 0,className:Y(QH(a,e.active,n),C===e.id&&`opacity-40`,T?.id===e.id&&(T.after?`shadow-[inset_0_-2px_0_0_var(--color-accent)]`:`shadow-[inset_0_2px_0_0_var(--color-accent)]`)),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(JH,e.id),t.dataTransfer.effectAllowed=`move`,w(e.id)},onDragEnd:H,onDragOver:t=>{!C||C===e.id||(t.preventDefault(),t.dataTransfer.dropEffect=`move`,E({id:e.id,after:ee(t)}))},onDragLeave:()=>E(null),onDrop:t=>te(t,e.id),title:e.label,onMouseEnter:()=>pu(e.to),onFocus:()=>pu(e.to),onClick:()=>{y(!1),r?.()},children:[(0,$.jsx)($H,{Icon:e.Icon}),!a||n?(0,$.jsx)(`span`,{className:`truncate`,children:e.label}):null]},e.id)},U=s===`/personal`?`page`:void 0,re;t[1]!==a||t[2]!==s?(re=Y(`relative`,QH(a,s===`/personal`)),t[1]=a,t[2]=s,t[3]=re):re=t[3];let W=h?.appearance??`loopi`,ie=h?.agentId,G;t[4]!==W||t[5]!==ie?(G=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,"aria-hidden":!0,children:(0,$.jsx)(Uu,{appearance:W,agentId:ie,className:`size-5`})}),t[4]=W,t[5]=ie,t[6]=G):G=t[6];let K;t[7]!==a||t[8]!==g?(K=!a&&(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),t[7]=a,t[8]=g,t[9]=K):K=t[9];let q;t[10]!==a||t[11]!==c||t[12]!==_?(q=_>0&&(0,$.jsx)(`span`,{"aria-label":c===`zh`?`${_} 条未读消息`:`${_} unread messages`,className:Y(`shrink-0 rounded-full bg-accent/15 px-1.5 text-center text-[10px] font-semibold leading-5 tabular-nums text-accent`,a?`absolute right-0 top-0 min-w-4 leading-4`:`min-w-5`),children:Re(_)}),t[10]=a,t[11]=c,t[12]=_,t[13]=q):q=t[13];let oe;t[14]!==g||t[15]!==r||t[16]!==K||t[17]!==q||t[18]!==U||t[19]!==re||t[20]!==G?(oe=(0,$.jsxs)(b,{to:`/personal`,"aria-current":U,className:re,title:g,onMouseEnter:rU,onFocus:nU,onClick:r,children:[G,K,q]}),t[14]=g,t[15]=r,t[16]=K,t[17]=q,t[18]=U,t[19]=re,t[20]=G,t[21]=oe):oe=t[21];let se=s===`/space`?`page`:void 0,ce=s===`/space`,le;t[22]!==a||t[23]!==ce?(le=QH(a,ce),t[22]=a,t[23]=ce,t[24]=le):le=t[24];let ue;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)($H,{Icon:ae}),t[25]=ue):ue=t[25];let de;t[26]===a?de=t[27]:(de=a?null:(0,$.jsx)(`span`,{className:`truncate`,children:`Space`}),t[26]=a,t[27]=de);let J;t[28]!==r||t[29]!==se||t[30]!==le||t[31]!==de?(J=(0,$.jsxs)(b,{to:`/space`,"aria-current":se,className:le,title:`Space`,"aria-label":`Space`,onClick:r,children:[ue,de]}),t[28]=r,t[29]=se,t[30]=le,t[31]=de,t[32]=J):J=t[32];let fe=I.map(e=>ne(e)),pe=L.length>0?(0,$.jsxs)(ol,{open:v,onOpenChange:y,children:[(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onDragOver:e=>{C&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,E({id:`more`,after:!1}),y(!0))},onDragLeave:()=>E(null),onDrop:e=>te(e),"aria-label":l.sidebar.moreAppsAria,title:l.sidebar.moreApps,className:Y(`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`,a?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2.5 text-left md:py-1.5`,T?.id===`more`&&`ring-2 ring-accent`,v||B?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(mi,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),a?null:(0,$.jsx)(`span`,{className:`truncate`,children:l.sidebar.moreApps})]})}),(0,$.jsx)(il,{children:(0,$.jsx)(al,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:`z-50 max-h-[min(32rem,var(--radix-popover-content-available-height))] min-w-[14rem] max-w-[20rem] overflow-y-auto rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,onOpenAutoFocus:tU,children:(0,$.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":l.sidebar.moreAppsAria,children:[R.map(e=>ne(e,!0)),z.length>0?(0,$.jsxs)(`section`,{"aria-labelledby":`sidebar-more-extension-apps`,children:[(0,$.jsx)(`div`,{id:`sidebar-more-extension-apps`,className:`px-2 pb-1 pt-1.5 text-[11px] font-semibold tracking-wide text-fg-subtle`,children:l.sidebar.extensionAppsHeading}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:z.map(e=>ne(e,!0))})]}):null]})})})]}):null,me;return t[33]!==oe||t[34]!==J||t[35]!==fe||t[36]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[oe,J,fe,pe]}),t[33]=oe,t[34]=J,t[35]=fe,t[36]=pe,t[37]=me):me=t[37],me}function tU(e){return e.preventDefault()}function nU(){return pu(`/personal`)}function rU(){return pu(`/personal`)}function iU(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY>=t.top+t.height/2}function aU(e){return e.active}function oU(e){return e.id.startsWith(`ext:`)}function sU(e){return!e.id.startsWith(`ext:`)}function cU(e){return[e.id,e]}function lU(e){return e.showInNav}function uU(e){return e.setOrder}function dU(e){return e.order}function fU(e){return e.language}async function pU(){let e=[];for(let t=0;;){let n=await Es({limit:100,offset:t,sortBy:`name`,sortOrder:`asc`});if(e.push(...n.items),t+=n.items.length,!n.items.length||t>=n.total)return e}}var mU=`text-xs font-normal leading-5 text-fg-subtle`;function hU(e){let t=(0,Q.c)(17),{label:n,createLabel:r,onCreate:i,disabled:a,current:o,className:s}=e,c;t[0]===s?c=t[1]:(c=Y(`flex items-center justify-between px-4 pb-0.5`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,$.jsx)(`h2`,{className:mU,children:n}),t[2]=n,t[3]=l);let u=o&&`bg-surface-active text-fg`,d;t[4]===u?d=t[5]:(d=Y(`size-7 shrink-0 rounded-md p-0`,u),t[4]=u,t[5]=d);let f=o?`page`:void 0,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[6]=p):p=t[6];let m;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==d||t[11]!==f?(m=(0,$.jsx)(X,{variant:`ghost`,className:d,"aria-label":r,"aria-current":f,title:r,disabled:a,onClick:i,children:p}),t[7]=r,t[8]=a,t[9]=i,t[10]=d,t[11]=f,t[12]=m):m=t[12];let h;return t[13]!==c||t[14]!==l||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:c,children:[l,m]}),t[13]=c,t[14]=l,t[15]=m,t[16]=h):h=t[16],h}async function gU(e,t){for(let n=0;;n+=20){let r=await zs({agentId:e,sources:[`workbench`],purposes:[`chat`],activity:`manual`,excludeArchived:!0,rootConversationsOnly:!0,limit:20,offset:n}),i=r.items.find(e=>e.customData?.agentSetup!==!0&&!t.has(e.key));if(i||!r.hasMore)return i}}function _U({agents:e,defaultAgentId:t,activeConversationId:n,onNavigate:r}){let{sidebar:i,agentsSettings:a}=F(D(e=>e.language)),o=x(),{key:s,pathname:c,search:l}=m(),u=!!(n||c===`/chat/new`)&&new URLSearchParams(l).get(`agentSetup`)===`1`,{data:d}=le(n),f=u||d?.agentSetup?void 0:d?.agentId,{mutate:p}=hc(),h=E(e=>e.conversationId),[g,_]=(0,Z.useState)(),[v,y]=(0,Z.useState)(),b=(0,Z.useRef)(null),S=(0,Z.useRef)(new Set);(0,Z.useLayoutEffect)(()=>(_(void 0),y(void 0),()=>{b.current=null}),[s,h]);let C=e.filter(({id:e,purpose:t})=>e!==`main`&&e!==`task-router`&&!Ju(e)&&t!==`task_dispatcher`);async function w(e,t=!1){if(b.current)return;let i={};b.current=i,_(e),y(void 0);try{let a,s=null,c=!1;if(!t){n&&u&&S.current.add(n);let[t,r]=await Promise.all([gU(e,S.current),sc(e,S.current).catch(()=>void 0)]);r&&(!t||Date.parse(r.createdAt)>Date.parse(t.updatedAt))?a=r.conversationId:t&&(a=t.key,s=t.projectId??null)}if(b.current!==i)return;if(!a){let t=fc(pc(),e),n=await new ic().createSession({agentId:e,projectId:null,initialAgentConfig:t?{model:t.modelRef,thinkingLevel:t.thinkingLevel}:void 0});if(b.current!==i)return;a=n.key,c=!0,Ws.getState().setCommittedSnapshot(a,{messages:[],hasMore:!1,name:null})}if(a===n){r?.();return}p(Pt(h,a),{agentId:e,projectId:s},{revalidate:!1});let l=`/chat/${encodeURIComponent(a)}`;c?ju(o,l,void 0,r):(r?.(),o(l))}catch{b.current===i&&y(e)}finally{b.current===i&&(b.current=null,_(void 0))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hU,{label:i.sessionViewExperts,createLabel:i.createExpert,current:u,className:`px-2`,disabled:g!==void 0,onCreate:()=>ju(o,Ku(),{state:{forceNewChat:!0,agentId:t}},r)}),C.length===0?(0,$.jsx)(`p`,{className:`px-2 py-3 text-xs text-fg-muted`,children:i.expertsEmpty}):null,(0,$.jsx)(`ul`,{className:`space-y-0.5`,"aria-label":i.sessionViewExperts,children:C.map(e=>{let t=qu(e,a),n=Yu(e,a),r=i.expertNewConversation.replace(`{{name}}`,t),o=e.id===f;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:Y(`group relative flex min-w-0 items-center rounded-lg transition-colors duration-200 ease-out`,o?`bg-accent-soft before:pointer-events-none before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-accent`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg py-1.5 pl-2 pr-9 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait`,disabled:g!==void 0,"aria-busy":g===e.id,"aria-current":o?`page`:void 0,onClick:()=>void w(e.id),children:[(0,$.jsx)(Hu,{agentId:e.id,avatar:e.avatar,size:24,className:`size-6 shrink-0`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:t}),n?(0,$.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:n,children:n}):null]})]}),(0,$.jsx)(`div`,{className:Y(`absolute inset-y-0 right-1 z-10 flex items-center transition-opacity`,g!==e.id&&`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100`),children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(e.id,!0),disabled:g!==void 0,"aria-label":r,title:r,className:`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`,children:g===e.id?(0,$.jsx)(_a,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(Fa,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})]}),v===e.id?(0,$.jsx)(`p`,{role:`alert`,className:`px-2 py-1 text-xs text-fg-muted`,children:i.expertConversationError}):null]},e.id)})})]})}function vU(e,t){if(!e||typeof e!=`object`)return!0;let n=e.key??e.conversationId;return typeof n!=`string`||!n.trim()||!t.has(n)}var yU=(0,Z.createContext)({}),bU=(0,Z.memo)(function(e){let t=(0,Q.c)(27),{child:n,activeTaskId:r,onNavigate:i,sb:a}=e,o=m(),s;t[0]===n.activeConversationId?s=t[1]:(s=e=>n.activeConversationId?e.runs[n.activeConversationId]:void 0,t[0]=n.activeConversationId,t[1]=s);let c=Ce(s),l;t[2]!==n.activeConversationId||t[3]!==n.taskId||t[4]!==o?(l=n.activeConversationId?`/chat/task/${encodeURIComponent(n.taskId)}`:xa(`${o.pathname}${o.search}`,n.taskId),t[2]=n.activeConversationId,t[3]=n.taskId,t[4]=o,t[5]=l):l=t[5];let u=r===n.taskId&&`bg-surface-active text-fg`,d;t[6]===u?d=t[7]:(d=Y(`ml-8 flex min-h-8 items-center gap-2 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,u),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i?.(),t[8]=i,t[9]=f);let p;t[10]!==c||t[11]!==a?(p=c?.unread?(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":c.status===`failed`?a.taskSessionAgentFailed:a.taskSessionAgentCompleted}):null,t[10]=c,t[11]=a,t[12]=p):p=t[12];let h;t[13]===n.title?h=t[14]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[13]=n.title,t[14]=h);let g=n.runStatus??n.phase,_;t[15]!==a||t[16]!==g?(_=RU(g,a),t[15]=a,t[16]=g,t[17]=_):_=t[17];let v;t[18]===_?v=t[19]:(v=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:_}),t[18]=_,t[19]=v);let y;return t[20]!==v||t[21]!==l||t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==h?(y=(0,$.jsxs)(b,{to:l,className:d,onClick:f,children:[p,h,v]}),t[20]=v,t[21]=l,t[22]=d,t[23]=f,t[24]=p,t[25]=h,t[26]=y):y=t[26],y});function xU(e){return Vs(e).source!==`automation`}var SU=20,CU=12,wU=5,TU=60,EU=`application/x-xopc-sidebar-item`,DU=[`recent`,`projects`,`experts`],OU=`xopc-web-sidebar-session-view`,kU=`xopc-web-sidebar-session-view-order`;function AU(){try{let e=JSON.parse(globalThis.localStorage?.getItem(kU)??`null`);if(Array.isArray(e)){let t=[...new Set(e)].filter(e=>DU.some(t=>t===e));return[...t,...DU.filter(e=>!t.includes(e))]}}catch{}return[...DU]}function jU(){try{let e=globalThis.localStorage?.getItem(OU);return e===`projects`||e===`experts`?e:`recent`}catch{return`recent`}}function MU(e,t,n,r){let i=e.filter(e=>e!==t),a=i.indexOf(n);return a<0?e:(i.splice(a+ +!!r,0,t),i)}function NU(e,t,n){if(!t?.length)return e;let r=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({item:e,index:t,rank:r.get(n(e))})).sort((e,t)=>e.rank!==void 0&&t.rank!==void 0?e.rank-t.rank:e.rank===void 0?t.rank===void 0?e.index-t.index:-1:1).map(({item:e})=>e)}function PU({spec:e,children:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return e?(0,$.jsxs)(`div`,{draggable:!0,className:Y(`relative cursor-grab transition-[opacity,transform] duration-200 ease-out active:cursor-grabbing`,n&&`opacity-50`),onDragStart:t=>{r(!0),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(EU,JSON.stringify({containerId:e.containerId,itemId:e.itemId}))},onDragEnd:()=>{r(!1),a(null)},onDragOver:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();a(e.clientY>=t.top+t.height/2?`after`:`before`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(null)},onDrop:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>=n.top+n.height/2;a(null);try{let n=JSON.parse(t.dataTransfer.getData(EU));if(n.containerId!==e.containerId||n.itemId===e.itemId)return;e.onReorder(e.containerId,MU(e.itemIds,n.itemId,e.itemId,r))}catch{}},children:[i===`before`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 top-0 z-30 h-0.5 rounded-full bg-accent`}):null,t,i===`after`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 bottom-0 z-30 h-0.5 rounded-full bg-accent`}):null]}):t}function FU(e,t){return e.name?.trim()||t}function IU(e){let t=/^\/chat\/([^/]+)$/.exec(e);if(!t)return;let n=decodeURIComponent(t[1]);if(n!==`new`)return n}function LU(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function RU(e,t){return e===`running`||e===`active`||e===`verifying`?t.delegatedTaskRunning:e===`completed`||e===`succeeded`||e===`closed`?t.delegatedTaskCompleted:e===`failed`?t.delegatedTaskFailed:e===`backlog`||e===`ready`||e===`queued`||e===`waiting`?t.delegatedTaskWaiting:e}function zU(e){let t=new Date(e.updatedAt).getTime();return Number.isFinite(t)?t:0}function BU(e){let t=new Date;t.setHours(0,0,0,0);let n=new Date(t);n.setDate(n.getDate()-1);let r={today:[],yesterday:[],older:[]};for(let i of e){let e=zU(i);r[e>=t.getTime()?`today`:e>=n.getTime()?`yesterday`:`older`].push(i)}return r}function VU(e){return Y(`group relative flex min-h-8 w-full min-w-0 items-center rounded-lg pr-1 text-left text-sm leading-5 transition-colors duration-200 ease-out`,`pl-6`,`focus-within:outline-none`,e?`bg-accent-soft font-medium text-fg before:pointer-events-none before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-accent`:`font-normal text-fg-muted hover:bg-surface-hover hover:text-fg`)}var HU=Y(mU,`transition-colors hover:text-fg-muted`);function UU(e){let t=(0,Q.c)(5),{indented:n}=e,r=n!==void 0&&n&&`pl-6`,i;t[0]===r?i=t[1]:(i=Y(`flex items-center gap-2 p-1.5`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(ps,{className:`h-3 w-4/5 animate-none`}),(0,$.jsx)(ps,{className:`mt-1.5 h-2.5 w-2/5 animate-none`})]}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`div`,{className:i,children:a}),t[3]=i,t[4]=o),o}function WU(){let e=(0,Q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-14 animate-none`}),(0,$.jsx)(UU,{})]}),n=(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-16 animate-none`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-4`,"aria-busy":`true`,children:[t,(0,$.jsxs)(`div`,{children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(UU,{}),(0,$.jsx)(UU,{indented:!0}),(0,$.jsx)(UU,{indented:!0})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-12 animate-none`}),(0,$.jsx)(UU,{}),(0,$.jsx)(UU,{})]})]}),e[2]=r):r=e[2],r}var GU=(0,Z.memo)(function({session:e,isActive:t,onNavigate:n,mutate:r,onRequestRename:i,onRequestDelete:a,sb:o,sess:s,clipboard:c,defaultUnnamedTitle:l,contextLabel:u,sort:d}){let f=(0,Z.useContext)(yU)[e.key],p=m(),h=D(e=>e.language),g=Bs(e)?e.customData?.automationSetup:void 0,_=typeof g?.automationId==`string`&&g.automationId.trim()?g.automationId:void 0,v=new URLSearchParams(p.search),y=p.pathname===`/automations`&&v.get(`automation`)===_?v.get(`run`)??void 0:void 0,{data:x}=gc(_?[`sidebar-automation-history`,_,e.projectId??``]:null,()=>Wu.runs(1,_,{projectId:e.projectId}),{refreshInterval:15e3,revalidateOnFocus:!0}),S=!!(f?.items.length||x?.runs.length||y),C=/^\/chat\/task\/([^/]+)$/.exec(p.pathname)?.[1],w=!!y||(f?.items.some(e=>e.taskId===C||e.activeConversationId===IU(p.pathname))??!1),[T,E]=(0,Z.useState)(w);(0,Z.useEffect)(()=>{w&&E(!0)},[w]);let O=Vs(e),k=Bs(e)||O.source!==`workbench`||O.purpose!==`chat`,A=K(e,o.sessionFilters),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F=Me(e.key),I=Ce(t=>t.runs[e.key]),L=FU(e,l),R=e.status===`pinned`,z=F||!!I?.unread,B=async()=>{if(!N){P(!0);try{R?await Rs(e.key):await Ns(e.key),M(!1),r()}catch{}finally{P(!1)}}},V=async()=>{let t=await pl(e.key);if(M(!1),t){Ml(`success`,o.taskChatIdCopied,void 0,{duration:2e3});return}Ml(`warning`,c.copyFailed,void 0,{duration:4e3})};return(0,$.jsx)(PU,{spec:d,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:VU(t),children:[S?(0,$.jsx)(`button`,{type:`button`,className:`absolute left-0 flex size-6 items-center justify-center text-fg-subtle hover:text-fg`,"aria-label":_?T?o.automationRunsCollapse:o.automationRunsExpand:T?o.delegatedTasksCollapse:o.delegatedTasksExpand,"aria-expanded":T,onClick:()=>E(e=>!e),children:(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform`,!T&&`-rotate-90`),"aria-hidden":!0})}):null,(0,$.jsxs)(b,{to:`/chat/${encodeURIComponent(e.key)}`,className:Y(`min-w-0 flex-1 self-stretch rounded-lg py-1 outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`flex min-w-0 items-center gap-2`,z?`pr-[4.75rem]`:`pr-12`),title:[L,A,u].filter(Boolean).join(` — `),"aria-label":[L,A,u].filter(Boolean).join(` — `),"aria-current":t?`page`:void 0,onClick:()=>n?.(),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),i(e)},children:[k?(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,title:A,children:(0,$.jsx)(Hs,{sourceChannel:e.sourceChannel,session:e,className:`size-3.5`})}):null,(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L})]}),F?(0,$.jsxs)(`span`,{className:`pointer-events-none absolute right-2 top-1/2 z-10 flex size-2.5 -translate-y-1/2 items-center justify-center`,title:o.taskSessionAgentRunning,"aria-label":o.taskSessionAgentRunning,children:[(0,$.jsx)(`span`,{className:`absolute size-full animate-ping rounded-full bg-accent/70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative size-2 rounded-full bg-accent`,"aria-hidden":!0})]}):I?.unread?(0,$.jsx)(`span`,{className:Y(`pointer-events-none absolute right-2 top-1/2 z-10 size-2.5 -translate-y-1/2 rounded-full`,I.status===`failed`?`bg-red-500`:`bg-emerald-500`),title:I.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted,"aria-label":I.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted}):null,(0,$.jsxs)(`div`,{className:Y(`pointer-events-none absolute inset-y-0 z-10 flex items-center opacity-0 transition-opacity`,`group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,`[@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100`,z?`right-7`:`right-1`,(j||N)&&`pointer-events-auto opacity-100`),children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`,`disabled:cursor-wait`),"aria-label":R?s.unpin:s.pin,title:R?s.unpin:s.pin,"aria-pressed":R,disabled:N,onClick:()=>void B(),children:N?(0,$.jsx)(_a,{className:`size-4 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(mo,{className:`size-4 rotate-45`,fill:R?`currentColor`:`none`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(ol,{open:j,onOpenChange:M,children:[(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`),"aria-label":o.taskSessionMenuAria,title:o.taskSessionMenuAria,"aria-expanded":j,children:(0,$.jsx)(mi,{className:`size-4`,strokeWidth:2,"aria-hidden":!0})})}),(0,$.jsx)(il,{children:(0,$.jsxs)(al,{className:`z-50 w-[9.25rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>{M(!1),i(e)},children:[(0,$.jsx)(io,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskRename]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>void V(),children:[(0,$.jsx)(Gr,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskCopyChatId]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:()=>{M(!1),a(e.key)},children:[(0,$.jsx)(ts,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskDeleteTask]})]})})]})]})]}),T&&f?.items.map(e=>(0,$.jsx)(bU,{child:e,activeTaskId:C,onNavigate:n,sb:o},e.taskId)),T&&_?(0,$.jsx)(gr,{automationId:_,projectId:e.projectId,language:h,selectedRunId:y,runHref:t=>{let n=new URLSearchParams({automation:_,view:`execution`,run:t.id});return e.projectId&&n.set(`projectId`,e.projectId),`/automations?${n}`},onSelectRun:()=>n?.()}):null]})})});function KU(e){let t=(0,Q.c)(77),{project:n,onNavigate:r,onPinToggle:i,onRequestRename:a,onArchive:o,onRequestRemove:s,sb:c}=e,[l,u]=(0,Z.useState)(!1),d;t[0]!==n.effectiveWorkspaceRoot||t[1]!==n.workspaceRoot?(d=n.effectiveWorkspaceRoot?.trim()||n.workspaceRoot?.trim()||``,t[0]=n.effectiveWorkspaceRoot,t[1]=n.workspaceRoot,t[2]=d):d=t[2];let f=d,p=!!(f&&window.electronAPI?.shell?.openPath),m=!!n.pinnedAt,h;t[3]!==c.projectOpenInExplorerFailed||t[4]!==c.projectOpenInExplorerUnavailable||t[5]!==f?(h=async()=>{if(!f||!window.electronAPI?.shell?.openPath){Ml(`warning`,c.projectOpenInExplorerUnavailable,void 0,{duration:3500}),u(!1);return}let e=await window.electronAPI.shell.openPath(f);u(!1),e.ok===!1&&Ml(`warning`,e.error||c.projectOpenInExplorerFailed,void 0,{duration:4e3})},t[3]=c.projectOpenInExplorerFailed,t[4]=c.projectOpenInExplorerUnavailable,t[5]=f,t[6]=h):h=t[6];let g=h,_=l&&`opacity-100`,v;t[7]===_?v=t[8]:(v=Y(`relative z-10 flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,_,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[7]=_,t[8]=v);let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(mi,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=y):y=t[9];let x;t[10]!==l||t[11]!==c.projectMenuAria||t[12]!==v?(x=(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v,"aria-label":c.projectMenuAria,title:c.projectMenuAria,"aria-expanded":l,children:y})}),t[10]=l,t[11]=c.projectMenuAria,t[12]=v,t[13]=x):x=t[13];let S=`/projects/${encodeURIComponent(n.id)}`,C;t[14]===r?C=t[15]:(C=()=>{u(!1),r?.()},t[14]=r,t[15]=C);let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(hi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]!==c.projectOpen||t[18]!==S||t[19]!==C?(T=(0,$.jsxs)(b,{to:S,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:C,children:[w,c.projectOpen]}),t[17]=c.projectOpen,t[18]=S,t[19]=C,t[20]=T):T=t[20];let E;t[21]===n.workspaceRoot?E=t[22]:(E=n.workspaceRoot?.trim(),t[21]=n.workspaceRoot,t[22]=E);let D=!!E,O;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>u(!1),t[23]=O):O=t[23];let k;t[24]!==n.id||t[25]!==D?(k=(0,$.jsx)(Zu,{hasProjectFolder:D,projectId:n.id,onStarted:O,className:`flex w-full rounded-md px-2 py-1.5 text-left text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`}),t[24]=n.id,t[25]=D,t[26]=k):k=t[26];let A;t[27]!==i||t[28]!==n?(A=()=>{u(!1),i(n)},t[27]=i,t[28]=n,t[29]=A):A=t[29];let j;t[30]===m?j=t[31]:(j=m?(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(mo,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[30]=m,t[31]=j);let M=m?c.projectUnpin:c.projectPin,N;t[32]!==A||t[33]!==j||t[34]!==M?(N=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:A,children:[j,M]}),t[32]=A,t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]===g?P=t[37]:(P=()=>void g(),t[36]=g,t[37]=P);let F=!p,I=p?void 0:c.projectOpenInExplorerUnavailable,L;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Vi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[38]=L):L=t[38];let R;t[39]!==c.projectOpenInExplorer||t[40]!==P||t[41]!==F||t[42]!==I?(R=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:text-fg-subtle disabled:hover:bg-transparent`,onClick:P,disabled:F,title:I,children:[L,c.projectOpenInExplorer]}),t[39]=c.projectOpenInExplorer,t[40]=P,t[41]=F,t[42]=I,t[43]=R):R=t[43];let z;t[44]!==a||t[45]!==n?(z=()=>{u(!1),a(n)},t[44]=a,t[45]=n,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(io,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[47]=B):B=t[47];let V;t[48]!==c.projectRename||t[49]!==z?(V=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:z,children:[B,c.projectRename]}),t[48]=c.projectRename,t[49]=z,t[50]=V):V=t[50];let H;t[51]!==o||t[52]!==n?(H=()=>{u(!1),o(n)},t[51]=o,t[52]=n,t[53]=H):H=t[53];let ee;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ae,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[54]=ee):ee=t[54];let te;t[55]!==c.projectArchive||t[56]!==H?(te=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:H,children:[ee,c.projectArchive]}),t[55]=c.projectArchive,t[56]=H,t[57]=te):te=t[57];let ne;t[58]!==s||t[59]!==n?(ne=()=>{u(!1),s(n)},t[58]=s,t[59]=n,t[60]=ne):ne=t[60];let U;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ts,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[61]=U):U=t[61];let re;t[62]!==c.projectRemove||t[63]!==ne?(re=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:ne,children:[U,c.projectRemove]}),t[62]=c.projectRemove,t[63]=ne,t[64]=re):re=t[64];let W;t[65]!==T||t[66]!==k||t[67]!==N||t[68]!==R||t[69]!==V||t[70]!==te||t[71]!==re?(W=(0,$.jsx)(il,{children:(0,$.jsxs)(al,{className:`z-50 w-[12rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:qU,children:[T,k,N,R,V,te,re]})}),t[65]=T,t[66]=k,t[67]=N,t[68]=R,t[69]=V,t[70]=te,t[71]=re,t[72]=W):W=t[72];let ie;return t[73]!==l||t[74]!==W||t[75]!==x?(ie=(0,$.jsxs)(ol,{open:l,onOpenChange:u,children:[x,W]}),t[73]=l,t[74]=W,t[75]=x,t[76]=ie):ie=t[76],ie}function qU(e){return e.preventDefault()}function JU(e){let t=(0,Q.c)(70),{group:n,isExpanded:r,isCollapsed:i,activeConversationId:a,onToggleExpanded:o,onToggleCollapsed:s,onCreateProjectChat:c,onToggleProjectPin:l,onRequestProjectRename:u,onArchiveProject:d,onRequestProjectRemove:f,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,excludedConversationIds:x,projectSort:S,onReorder:C}=e,w;t[0]!==x||t[1]!==n.sessions?(w=x?n.sessions.filter(e=>!x.has(e.key)):n.sessions,t[0]=x,t[1]=n.sessions,t[2]=w):w=t[2];let T=w,E;t[3]!==r||t[4]!==T?(E=r?T:T.slice(0,wU),t[3]=r,t[4]=T,t[5]=E):E=t[5];let D=E,O=T.length>wU,k=n.sessionHasMore||O,A=r&&!n.sessionHasMore&&O,j;t[6]===a?j=t[7]:(j=e=>e.key===a,t[6]=a,t[7]=j);let M=T.some(j),N=n.project.name,P=M?`text-fg`:`text-fg-muted`,F;t[8]===P?F=t[9]:(F=Y(`group flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium leading-5`,P),t[8]=P,t[9]=F);let I;t[10]!==n.project.id||t[11]!==s?(I=()=>s(n.project.id),t[10]=n.project.id,t[11]=s,t[12]=I):I=t[12];let L=!i,R;t[13]===i?R=t[14]:(R=i?(0,$.jsx)(Hi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=i,t[14]=R);let z;t[15]===n.project.name?z=t[16]:(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.project.name}),t[15]=n.project.name,t[16]=z);let B;t[17]!==n.project.name||t[18]!==z||t[19]!==I||t[20]!==L||t[21]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 min-w-0 flex-1 items-center gap-1 text-left 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`,onClick:I,title:n.project.name,"aria-expanded":L,children:[R,z]}),t[17]=n.project.name,t[18]=z,t[19]=I,t[20]=L,t[21]=R,t[22]=B):B=t[22];let V;t[23]!==n.project||t[24]!==d||t[25]!==p||t[26]!==f||t[27]!==u||t[28]!==l||t[29]!==_?(V=(0,$.jsx)(KU,{project:n.project,onNavigate:p,onPinToggle:l,onRequestRename:u,onArchive:d,onRequestRemove:f,sb:_}),t[23]=n.project,t[24]=d,t[25]=p,t[26]=f,t[27]=u,t[28]=l,t[29]=_,t[30]=V):V=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[31]=H):H=t[31];let ee;t[32]!==n.project||t[33]!==c?(ee=()=>c(n.project),t[32]=n.project,t[33]=c,t[34]=ee):ee=t[34];let te;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=te):te=t[35];let ne;t[36]!==_.projectNewChat||t[37]!==ee?(ne=(0,$.jsx)(`button`,{type:`button`,className:H,onClick:ee,title:_.projectNewChat,"aria-label":_.projectNewChat,children:te}),t[36]=_.projectNewChat,t[37]=ee,t[38]=ne):ne=t[38];let U;t[39]!==B||t[40]!==V||t[41]!==ne||t[42]!==F?(U=(0,$.jsxs)(`div`,{className:F,children:[B,V,ne]}),t[39]=B,t[40]=V,t[41]=ne,t[42]=F,t[43]=U):U=t[43];let re;t[44]!==a||t[45]!==k||t[46]!==y||t[47]!==b||t[48]!==n.project.id||t[49]!==n.sessionLoading||t[50]!==i||t[51]!==m||t[52]!==p||t[53]!==C||t[54]!==g||t[55]!==h||t[56]!==o||t[57]!==_||t[58]!==v||t[59]!==A||t[60]!==T||t[61]!==D?(re=i?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D.map(e=>(0,$.jsx)(GU,{session:e,isActive:a===e.key,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,sort:{containerId:`project:${n.project.id}`,itemId:e.key,itemIds:T.map(YU),onReorder:C}},e.key)),k?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:()=>o(n.project.id),disabled:n.sessionLoading,"aria-busy":n.sessionLoading||void 0,children:[n.sessionLoading?(0,$.jsx)(_a,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,A&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),A?_.projectShowLess:_.projectShowMore]}):null]}),t[44]=a,t[45]=k,t[46]=y,t[47]=b,t[48]=n.project.id,t[49]=n.sessionLoading,t[50]=i,t[51]=m,t[52]=p,t[53]=C,t[54]=g,t[55]=h,t[56]=o,t[57]=_,t[58]=v,t[59]=A,t[60]=T,t[61]=D,t[62]=re):re=t[62];let W;t[63]!==n.project.name||t[64]!==U||t[65]!==re?(W=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":N,children:[U,re]}),t[63]=n.project.name,t[64]=U,t[65]=re,t[66]=W):W=t[66];let ie;return t[67]!==S||t[68]!==W?(ie=(0,$.jsx)(PU,{spec:S,children:W}),t[67]=S,t[68]=W,t[69]=ie):ie=t[69],ie}function YU(e){return e.key}function XU(e){let t=(0,Q.c)(49),{sessions:n,hasMore:r,loadingMore:i,isCollapsed:a,onToggleCollapsed:o,onCreateChat:s,onLoadMore:c,activeConversationId:l,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,excludedConversationIds:v,onReorder:y,sortable:b}=e,x=b===void 0||b,S;t[0]!==v||t[1]!==n?(S=v?n.filter(e=>!v.has(e.key)):n,t[0]=v,t[1]=n,t[2]=S):S=t[2];let C=S;if(C.length===0&&!r)return null;let w=m.inboxHeading,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=Y(`flex min-w-0 flex-1 items-center gap-1 px-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,HU),t[3]=T):T=t[3];let E=!a,D=m.inboxHeading,O=a&&`-rotate-90`,k;t[4]===O?k=t[5]:(k=Y(`size-3.5 transition-transform duration-150 ease-out`,O),t[4]=O,t[5]=k);let A;t[6]===k?A=t[7]:(A=(0,$.jsx)(vr,{className:k,strokeWidth:1.75,"aria-hidden":!0}),t[6]=k,t[7]=A);let j;t[8]!==o||t[9]!==m.inboxHeading||t[10]!==E||t[11]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:T,onClick:o,"aria-expanded":E,children:[D,A]}),t[8]=o,t[9]=m.inboxHeading,t[10]=E,t[11]=A,t[12]=j):j=t[12];let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==s?(P=(0,$.jsx)(`button`,{type:`button`,className:M,onClick:s,title:_,"aria-label":_,children:N}),t[15]=_,t[16]=s,t[17]=P):P=t[17];let F;t[18]!==j||t[19]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center pb-1`,children:[j,P]}),t[18]=j,t[19]=P,t[20]=F):F=t[20];let I=a&&`hidden`,L;t[21]===I?L=t[22]:(L=Y(`flex flex-col gap-0.5`,I),t[21]=I,t[22]=L);let R;t[23]!==l||t[24]!==g||t[25]!==_||t[26]!==d||t[27]!==u||t[28]!==y||t[29]!==p||t[30]!==f||t[31]!==m||t[32]!==h||t[33]!==x||t[34]!==C?(R=C.map(e=>(0,$.jsx)(GU,{session:e,isActive:l===e.key,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,sort:x?{containerId:`inbox`,itemId:e.key,itemIds:C.map(ZU),onReorder:y}:void 0},e.key)),t[23]=l,t[24]=g,t[25]=_,t[26]=d,t[27]=u,t[28]=y,t[29]=p,t[30]=f,t[31]=m,t[32]=h,t[33]=x,t[34]=C,t[35]=R):R=t[35];let z;t[36]!==r||t[37]!==i||t[38]!==c||t[39]!==m.projectShowMore?(z=r?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:c,disabled:i,"aria-busy":i||void 0,children:[i?(0,$.jsx)(_a,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(vr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),m.projectShowMore]}):null,t[36]=r,t[37]=i,t[38]=c,t[39]=m.projectShowMore,t[40]=z):z=t[40];let B;t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;return t[45]!==m.inboxHeading||t[46]!==F||t[47]!==B?(V=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":w,children:[F,B]}),t[45]=m.inboxHeading,t[46]=F,t[47]=B,t[48]=V):V=t[48],V}function ZU(e){return e.key}function QU(e){let t=(0,Q.c)(22),{sessions:n,activeConversationId:r,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,onReorder:f,projectNames:p}=e;if(n.length===0)return null;let m=l.pinnedSessions,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`px-2 pb-1`,mU),t[0]=h):h=t[0];let g;t[1]===l.pinnedSessions?g=t[2]:(g=(0,$.jsx)(`h2`,{className:h,children:l.pinnedSessions}),t[1]=l.pinnedSessions,t[2]=g);let _;t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==s||t[10]!==o||t[11]!==p||t[12]!==c||t[13]!==l||t[14]!==n?(_=n.map(e=>(0,$.jsx)(GU,{session:e,contextLabel:e.projectId?p?.get(e.projectId):void 0,isActive:r===e.key,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,sort:{containerId:`pinned`,itemId:e.key,itemIds:n.map($U),onReorder:f}},e.key)),t[3]=r,t[4]=u,t[5]=d,t[6]=a,t[7]=i,t[8]=f,t[9]=s,t[10]=o,t[11]=p,t[12]=c,t[13]=l,t[14]=n,t[15]=_):_=t[15];let v;t[16]===_?v=t[17]:(v=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_}),t[16]=_,t[17]=v);let y;return t[18]!==l.pinnedSessions||t[19]!==g||t[20]!==v?(y=(0,$.jsxs)(`section`,{className:`mb-3 flex flex-col gap-0.5`,"aria-label":m,children:[g,v]}),t[18]=l.pinnedSessions,t[19]=g,t[20]=v,t[21]=y):y=t[21],y}function $U(e){return e.key}function eW(e){let t=(0,Q.c)(4),{onNavigate:n,scrollHeader:r}=e,i=E(tW),a;return t[0]!==i||t[1]!==n||t[2]!==r?(a=(0,$.jsx)(nW,{gateway:i,onNavigate:n,scrollHeader:r},i),t[0]=i,t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function tW(e){return e.baseUrl}function nW({onNavigate:e,gateway:t,scrollHeader:n}){let r=D(e=>e.language),i=F(r),a=i.sidebar,o=i.sessions,s=i.projectsPage,c=i.chat.workingDirectory,l=E(e=>e.conversationId),u=E(e=>e.openTokenDialog),{data:d,error:f,mutate:p}=gc(l?[`gateway-chat-agents`,l]:null,Cc,{revalidateOnFocus:!1}),h=d?.defaultId??`main`;(0,Z.useEffect)(()=>{let e=()=>void p();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[p]);let{pathname:g}=m(),_=x(),v=IU(g),y=(0,Z.useMemo)(()=>Date.now()-TU*24*60*60*1e3,[]),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(``),[T,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(!1),[z,U]=(0,Z.useState)(``),[re,W]=(0,Z.useState)(``),[ie,G]=(0,Z.useState)(null),[K,ae]=(0,Z.useState)(!1),[q,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)(()=>v),[le,ue]=(0,Z.useState)(jU),[de,J]=(0,Z.useState)(AU),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(!1),[ge,_e]=(0,Z.useState)(()=>new Set),[ve,ye]=(0,Z.useState)(()=>new Set),[be,xe]=(0,Z.useState)({}),[Se,Ce]=(0,Z.useState)({}),[we,Te]=(0,Z.useState)(()=>new Set),[Ee,De]=(0,Z.useState)([]),[Oe,ke]=(0,Z.useState)(null),[Ae,je]=(0,Z.useState)(!1),[Me,Ne]=(0,Z.useState)({}),Pe=(0,Z.useRef)(new Set),Fe=td({initialPath:re,onPicked:W}),{data:Ie,size:Le,setSize:Re,isValidating:ze,mutate:Be}=vc((e,n)=>!l||n&&!n.projects.hasMore?null:[`sidebar-chat-list`,t,l,se??``,e],async([,,,e,t])=>Fs({projectLimit:CU,projectOffset:t*CU,sessionPreviewLimit:wU,inboxLimit:t===0?SU:1,inboxOffset:0,staleDays:TU,includeConversationId:e||void 0}),{keepPreviousData:!0,revalidateOnFocus:!1}),{data:Ve,error:He,size:Ue,setSize:We,isValidating:Ge,mutate:Ke}=vc((e,n)=>!l||n&&!n.hasMore?null:[`sidebar-recent-sessions`,t,l,e],([,,,e])=>zs({limit:SU,offset:e*SU,excludeArchived:!0,rootConversationsOnly:!0,excludeAutomationRuns:!0}),{revalidateOnFocus:!1}),qe=(0,Z.useMemo)(()=>{let e=new Map;for(let t of Ve??[])for(let n of t.items)!e.has(n.key)&&n.status!==`archived`&&xU(n)&&Vs(n).source!==`system`&&e.set(n.key,n);return[...e.values()].sort((e,t)=>zU(t)-zU(e))},[Ve]),Je=(0,Z.useMemo)(()=>{let e=Ie??[],t=[],n=new Set;for(let r of e)for(let e of r.projects.items){if(n.has(e.project.id))continue;n.add(e.project.id);let r=be[e.project.id],i=(r?.sessions??e.sessions).filter(xU);t.push({project:e.project,sessions:i,sessionTotal:r?.sessionTotal??e.sessionTotal,sessionHasMore:r?.hasMore??e.sessionHasMore,sessionLoading:we.has(e.project.id)})}return NU(t.map(e=>({...e,sessions:NU(e.sessions,Me[`project:${e.project.id}`],e=>e.key)})),Me.projects,e=>e.project.id)},[Ie,we,Me,be]),Ye=(0,Z.useMemo)(()=>{let e={};for(let t of Ve??[])Object.assign(e,t.childrenByConversationId);for(let t of Ie??[])Object.assign(e,t.childrenByConversationId);return{...e,...Se}},[Ie,Se,Ve]),Xe=Ie?.[0]?.inbox,Ze=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of[...Xe?.items??[],...Ee])t.has(n.key)||!xU(n)||(t.add(n.key),e.push(n));return e.sort((e,t)=>zU(t)-zU(e)),NU(e,Me.inbox??Ie?.[0]?.layouts.inbox?.itemIds,e=>e.key)},[Ie,Xe?.items,Ee,Me.inbox]),Qe=Oe??Xe?.hasMore??!1,$e=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of Je)for(let r of n.sessions)t.has(r.key)||(t.add(r.key),e.push(r));for(let n of Ze)t.has(n.key)||(t.add(n.key),e.push(n));return e},[Ze,Je]),et=(0,Z.useMemo)(()=>new Set([...$e,...qe].map(e=>e.key)),[$e,qe]),tt=Je.length>0||Ze.length>0||Qe,nt=(0,Z.useMemo)(()=>NU((Ie?.[0]?.pinned??[]).filter(xU),Me.pinned,e=>e.key),[Ie,Me.pinned]),rt=(0,Z.useMemo)(()=>new Set(nt.map(e=>e.key)),[nt]),it=(0,Z.useMemo)(()=>new Map(Je.map(({project:e})=>[e.id,e.name])),[Je]),at=[...qe,...nt].some(({projectId:e})=>e&&!it.has(e)),{data:ot,mutate:st}=gc(l&&(Ie||!ze)&&at?[`sidebar-project-names`,t,l]:null,pU,{revalidateOnFocus:!1}),ct=(0,Z.useMemo)(()=>new Map([...ot?.map(e=>[e.id,e.name])??[],...it]),[it,ot]),lt=BU(qe.filter(e=>e.status!==`pinned`&&!rt.has(e.key))),ut=lt.older.some(e=>e.key===v);(0,Z.useEffect)(()=>{ut&&pe(!0)},[v,ut]);let dt=!!(Ie&&Le>Ie.length),ft=(Ie?.[Ie.length-1])?.projects.hasMore??!1,pt=!!(l&&!Ie&&ze),mt=(0,Z.useCallback)(()=>{xe({}),De([]),ke(null),Ce({}),Be(),Ke()},[Be,Ke]),ht=(0,Z.useCallback)((e,t)=>{if(Pe.current.has(e))return;let n=Ie?.[0]?.layouts[e]?.revision??0;Ne(n=>({...n,[e]:t})),Pe.current.add(e),(async()=>{try{await Ps({containerId:e,itemIds:t,expectedRevision:n}),await Be()}catch{Ml(`warning`,r===`zh`?`未能保存侧栏顺序,已恢复原位置`:`Could not save sidebar order; the previous order was restored`,void 0,{duration:3500})}finally{Pe.current.delete(e),Ne(t=>{let n={...t};return delete n[e],n})}})()},[Ie,r,Be]),gt=(0,Z.useCallback)(e=>{let t=e.currentTarget;if(le!==`projects`||!ft||dt)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t;r-n-i>100||Re(Le+1)},[ft,dt,Re,Le,le]);(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{mt()},t=()=>{mt(),st()},n=()=>void Ke(),r=e=>{vU(e.detail,et)&&mt()};return window.addEventListener(`session-updated`,e),window.addEventListener(`session-created`,e),window.addEventListener(`project-updated`,t),window.addEventListener(`task-updated`,e),window.addEventListener(`session-transcript-updated`,r),window.addEventListener(`run-completed`,n),window.addEventListener(`agent-run-ended`,n),()=>{window.removeEventListener(`session-updated`,e),window.removeEventListener(`session-created`,e),window.removeEventListener(`project-updated`,t),window.removeEventListener(`task-updated`,e),window.removeEventListener(`session-transcript-updated`,r),window.removeEventListener(`run-completed`,n),window.removeEventListener(`agent-run-ended`,n)}},[l,mt,st,Ke,et]),(0,Z.useEffect)(()=>{le!==`projects`||!l||!v||!Ie||$e.some(e=>e.key===v)||ce(e=>e===v?e:v)},[v,Ie,$e,l,le]);let _t=(0,Z.useCallback)(e=>{S(e.key),w(FU(e,i.chat.newSession))},[i.chat.newSession]),vt=async()=>{if(!b)return;let e=C.trim();if(e)try{await Is(b,e),S(null),mt()}catch{}},yt=async e=>{try{await Ls(e),v===e&&_(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),mt()}catch{}},bt=(0,Z.useCallback)(e=>{A(e.id),M(e.name.trim())},[]),xt=async()=>{if(!k||!At)return;let e=j.trim();if(e)try{await As(k,e,At.version),A(null),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:k}}))}catch{}},St=(0,Z.useCallback)(async e=>{try{await js(e.id,e.version),g===`/projects/${encodeURIComponent(e.id)}`&&_(`/projects`),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[_,g,mt]),Ct=(0,Z.useCallback)(async e=>{try{e.pinnedAt?await Ts(e.id,e.version):await Ds(e.id,e.version),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[mt]),wt=async e=>{let t=e.id;try{await Os(t,e.version),g===`/projects/${encodeURIComponent(t)}`&&_(`/projects`),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:t}}))}catch{}},Tt=(0,Z.useCallback)(e=>{let t=Je.find(t=>t.project.id===e);if(t){if(ve.has(e)&&!t.sessionHasMore){ye(t=>{let n=new Set(t);return n.delete(e),n});return}ye(t=>{let n=new Set(t);return n.add(e),n}),!(!t.sessionHasMore||we.has(e))&&(Te(t=>new Set(t).add(e)),(async()=>{try{let n=await zs({projectId:e,limit:5e3,offset:0,updatedAfter:y,includePinned:!0,includeConversationId:v,rootConversationsOnly:!0,excludeAutomationRuns:!0});Ce(e=>({...e,...n.childrenByConversationId})),xe(r=>{let i=r[e]?.sessions??t.sessions,a=new Set(i.map(e=>e.key)),o=[...i];for(let e of n.items)a.has(e.key)||(a.add(e.key),o.push(e));let s=NU(o,Me[`project:${e}`]??Ie?.[0]?.layouts[`project:${e}`]?.itemIds,e=>e.key);return{...r,[e]:{sessions:s,sessionTotal:n.total,hasMore:!1}}})}finally{Te(t=>{let n=new Set(t);return n.delete(e),n})}})())}},[v,Ie,ve,we,Me,Je,y]),Et=(0,Z.useCallback)(e=>{_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Dt=(0,Z.useCallback)(()=>{!Qe||Ae||(je(!0),(async()=>{try{let e=await zs({unassigned:!0,limit:5e3,offset:0,updatedAfter:y,includePinned:!0,includeConversationId:v,rootConversationsOnly:!0,excludeAutomationRuns:!0});Ce(t=>({...t,...e.childrenByConversationId})),De(t=>{let n=new Set([...Xe?.items??[],...t].map(e=>e.key)),r=[...t];for(let t of e.items)n.has(t.key)||(n.add(t.key),r.push(t));return NU(r,Me.inbox??Ie?.[0]?.layouts.inbox?.itemIds,e=>e.key)}),ke(!1)}finally{je(!1)}})())},[v,Ie,Xe?.items,Qe,Ae,Me.inbox,y]),Ot=(0,Z.useCallback)(t=>{ju(_,Gu(t.id),{state:{forceNewChat:!0,agentId:t.defaultAgentId??h}},e)},[h,_,e]),kt=(0,Z.useCallback)(async e=>{e.preventDefault();let t=z.trim(),n=re.trim();if(!(!t||K)){ae(!0),G(null);try{let e=await ks({name:t,...n?{workspaceRoot:n}:{},autoUnderstand:!!n&&q});U(``),W(``),oe(!1),L(!1),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(!1)}}},[z,re,K,mt,q]),At=k?Je.find(e=>e.project.id===k)?.project:void 0,jt=N?Je.find(e=>e.project.id===N)?.project:void 0,Mt=Ve?.at(-1)?.hasMore??!1,Nt=!!(Ve&&Ue>Ve.length&&Ge),Pt={onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession},Ft=e=>{J(e);try{globalThis.localStorage?.setItem(kU,JSON.stringify(e))}catch{}},It={recent:{label:a.sessionViewRecent,icon:Yr},projects:{label:a.sessionViewProjects,icon:Hi},experts:{label:a.sessionViewExperts,icon:AR}},Lt=e=>{ue(e);try{globalThis.localStorage?.setItem(OU,e)}catch{}if(e!==`projects`||!v)return;let t=qe.find(e=>e.key===v)??$e.find(e=>e.key===v),n=t?.projectId;n?_e(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t}):t&&he(!1)},Rt=e=>(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,$.jsx)(GU,{session:e,contextLabel:e.projectId?ct.get(e.projectId):void 0,isActive:v===e.key,...Pt},e.key))}),zt=(e,t)=>t.length>0?(0,$.jsxs)(`section`,{"aria-label":e,children:[(0,$.jsx)(`h2`,{className:Y(`px-2 pb-1`,mU),children:e}),Rt(t)]}):null;return l?(0,$.jsx)(yU,{value:Ye,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,onScroll:gt,children:[n,(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(Kr,{"aria-label":a.sessionViewLabel,value:le,onChange:Lt,onReorder:Ft,flush:!0,buttonClassName:`h-8 min-w-0 px-1`,options:de.map(e=>({value:e,...It[e]}))})}),le===`experts`?null:(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(QU,{sessions:nt,projectNames:le===`recent`?ct:void 0,activeConversationId:v,...Pt,onReorder:ht})}),le===`experts`?(0,$.jsx)(`div`,{className:`px-2`,children:f&&!d?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:a.expertsLoadError}),(0,$.jsx)(X,{variant:`secondary`,onClick:()=>void p(),children:a.sessionFilters.retry})]}):d?(0,$.jsx)(_U,{agents:d.items,defaultAgentId:h,activeConversationId:v,onNavigate:e}):(0,$.jsx)(WU,{})}):le===`recent`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 px-2`,children:[!Ve&&!He?(0,$.jsx)(WU,{}):null,He?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:a.sessionFilters.error}),(0,$.jsx)(X,{variant:`secondary`,onClick:()=>void Ke(),children:a.sessionFilters.retry})]}):null,Ve&&!He&&!qe.length&&!nt.length&&!Mt?(0,$.jsx)(`p`,{className:`px-2 py-3 text-xs text-fg-muted`,children:a.taskListEmpty}):null,zt(a.timelineToday,lt.today),zt(a.timelineYesterday,lt.yesterday),lt.older.length>0||Mt?(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex w-full items-center gap-1 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,HU),"aria-expanded":fe,onClick:()=>pe(e=>!e),children:[(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform`,!fe&&`-rotate-90`),"aria-hidden":!0}),a.timelineOlder]}),fe?(0,$.jsxs)($.Fragment,{children:[Rt(lt.older),Nt?(0,$.jsx)(UU,{}):Mt&&!He?(0,$.jsx)(`button`,{type:`button`,className:`mx-2 rounded-lg px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>void We(Ue+1),children:a.sessionFilters.more}):null]}):null]}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(hU,{label:a.sessionViewProjects,createLabel:s.createTitle,onCreate:()=>L(!0)}),pt?(0,$.jsx)(WU,{}):tt?(0,$.jsxs)(`div`,{className:`flex flex-col px-2`,children:[Je.length>0?(0,$.jsx)(`div`,{className:`pb-1`,children:Je.map(t=>(0,$.jsx)(JU,{group:t,isExpanded:ve.has(t.project.id),isCollapsed:ge.has(t.project.id),activeConversationId:v,onToggleExpanded:Tt,onToggleCollapsed:Et,onCreateProjectChat:e=>void Ot(e),onToggleProjectPin:e=>void Ct(e),onRequestProjectRename:bt,onArchiveProject:e=>void St(e),onRequestProjectRemove:e=>P(e.id),onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,projectSort:{containerId:`projects`,itemId:t.project.id,itemIds:Je.map(e=>e.project.id),onReorder:ht},onReorder:ht},t.project.id))}):null,(0,$.jsx)(XU,{sessions:Ze.filter(e=>Vs(e).source!==`system`),hasMore:Qe,loadingMore:Ae,isCollapsed:me,onToggleCollapsed:()=>he(e=>!e),onCreateChat:()=>{ju(_,`/chat/new?projectScope=none`,{state:{forceNewChat:!0}},e)},onLoadMore:Dt,activeConversationId:v,onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,onReorder:ht}),Ze.some(e=>Vs(e).source===`system`)?(0,$.jsxs)(`details`,{className:`mt-3`,open:Ze.some(e=>e.key===v&&Vs(e).source===`system`),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs text-fg-muted`,children:r===`zh`?`系统活动`:`System activity`}),(0,$.jsx)(XU,{sessions:Ze.filter(e=>Vs(e).source===`system`),hasMore:!1,loadingMore:Ae,isCollapsed:!1,onToggleCollapsed:()=>void 0,onCreateChat:()=>{ju(_,`/chat/new?projectScope=none`,{state:{forceNewChat:!0}},e)},onLoadMore:Dt,activeConversationId:v,onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,onReorder:ht,sortable:!1})]}):null]}):(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-3 text-xs leading-relaxed text-fg-muted`,children:a.taskListEmpty})}),dt?(0,$.jsx)(UU,{}):ft?(0,$.jsx)(`button`,{type:`button`,className:`mx-4 rounded-lg px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>void Re(Le+1),children:a.sessionFilters.more}):null]})]}),(0,$.jsx)(ne,{open:I,onOpenChange:e=>{K||(L(e),e||G(null))},children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(30rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:s.createTitle}),(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:s.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:kt,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[s.projectName,(0,$.jsx)(`input`,{autoFocus:!0,className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:z,onChange:e=>U(e.target.value),maxLength:160})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:s.workspaceRoot}),(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Fe.pick,disabled:K||Fe.picking,children:[Fe.picking?(0,$.jsx)(_a,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:re?c.chooseFolder:c.selectWorkingDirectory}),(0,$.jsx)(`span`,{className:Y(`mt-0.5 block truncate font-mono text-xs font-normal`,re?`text-fg-muted`:`text-fg-subtle`),title:re||void 0,children:re||s.workspaceSelectionPlaceholder})]})]}),(0,$.jsx)(`p`,{className:`text-xs font-normal text-fg-muted`,children:s.workspaceSelectionHint})]}),(0,$.jsx)(Xu,{checked:q,onChange:oe,disabled:K||!re.trim()}),ie?(0,$.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:ie}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:K,children:s.cancel})}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:K||!z.trim(),children:K?s.home.creating:s.create})]})]})]})]})}),Fe.hasNativePicker?null:(0,$.jsx)(wr,{open:Fe.modalOpen,onOpenChange:Fe.setModalOpen,initialAbsolutePath:re||void 0,onConfirm:Fe.confirmPick,wd:c}),(0,$.jsx)(ne,{open:b!==null,onOpenChange:e=>!e&&S(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.taskRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-rename-input`,children:a.taskRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-rename-input`,type:`text`,value:C,onChange:e=>w(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,Ll,`dark:border-edge`),placeholder:i.chat.newSession,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),vt())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>S(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void vt(),disabled:!C.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(ne,{open:T!==null,onOpenChange:e=>!e&&O(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:o.deleteSessionTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:T?LU(o.deleteSessionMessage,{name:$e.find(e=>e.key===T)?.name?.trim()||i.chat.newSession}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>O(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{T&&yt(T),O(null)},children:o.delete})]})]})]})}),(0,$.jsx)(ne,{open:k!==null,onOpenChange:e=>!e&&A(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.projectRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-project-rename-input`,children:a.projectRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-project-rename-input`,type:`text`,value:j,onChange:e=>M(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,Ll,`dark:border-edge`),placeholder:At?.name??``,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),xt())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>A(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void xt(),disabled:!j.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(ne,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.projectRemoveTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:jt?LU(a.projectRemoveMessage,{name:jt.name}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>P(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{jt&&wt(jt),P(null)},children:a.projectRemove})]})]})]})})]})}):(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,children:[n,(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 px-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.taskListNeedToken}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-8 w-full text-xs font-medium`,onClick:()=>{u(),e?.()},children:a.taskListAddToken})]})})]})}var rW=42,iW=1,aW=4,oW=3,sW=`xopc-web-sidebar-visible-app-count-v2`;function cW(e){return Math.min(aW,Math.max(iW,e))}function lW(){try{let e=Number.parseInt(globalThis.localStorage?.getItem(sW)??``,10);return Number.isFinite(e)?cW(e):oW}catch{return oW}}function uW({onNavigate:e,collapsed:t=!1}){let n=F(D(e=>e.language)),[r,i]=(0,Z.useState)(lW),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{try{globalThis.localStorage?.setItem(sW,String(r))}catch{}},[r]);function o(e){e.preventDefault(),a.current={clientY:e.clientY,visibleCount:r},e.currentTarget.setPointerCapture(e.pointerId)}function s(e){let t=a.current;if(!t)return;let n=Math.round((e.clientY-t.clientY)/rW);i(cW(t.visibleCount+n))}function c(e){a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}function l(e){e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),i(e=>cW(e+1))):e.key===`ArrowUp`||e.key===`ArrowLeft`?(e.preventDefault(),i(e=>cW(e-1))):e.key===`Home`?(e.preventDefault(),i(iW)):e.key===`End`&&(e.preventDefault(),i(aW))}return(0,$.jsxs)(`div`,{className:`app-sidebar-content flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:Y(`flex min-h-0 flex-1 flex-col overflow-hidden`,t&&`hidden`),"aria-hidden":t?!0:void 0,children:(0,$.jsx)(eW,{onNavigate:e,scrollHeader:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`app-sidebar-sticky-surface sticky top-0 z-20 px-4 pt-1.5 pb-0.5`,children:(0,$.jsxs)(Mu,{to:`/chat/new`,state:{forceNewChat:!0},className:Y(`flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-6 transition-colors duration-200 ease-out md:py-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`text-fg-muted hover:bg-surface-hover hover:text-fg`),title:n.sidebar.newTask,onClick:()=>e?.(),children:[(0,$.jsx)(yo,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:n.sidebar.newTask})]})}),(0,$.jsx)(`nav`,{className:`px-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(eU,{onNavigate:e,visibleLimit:r})})}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":n.sidebar.resizeApps,"aria-valuemin":iW,"aria-valuemax":aW,"aria-valuenow":r,tabIndex:0,className:`group flex h-3 touch-none cursor-row-resize items-center px-4 focus-visible:outline-none`,title:n.sidebar.resizeApps,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onKeyDown:l,children:(0,$.jsx)(`span`,{className:`h-px w-full bg-transparent transition-colors group-focus-visible:bg-accent`})}),(0,$.jsx)(`div`,{className:`h-2`,"aria-hidden":!0})]})})}),t?(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto px-1.5 pb-2 pt-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(eU,{collapsed:!0,onNavigate:e,visibleLimit:oW})})}):null,(0,$.jsx)(UH,{collapsed:t,onNavigate:e})]})}var dW=`(min-width: 768px)`,fW=(0,Z.memo)(function(){let e=(0,Q.c)(42),t=D(pW),n;e[0]===t?n=e[1]:(n=F(t),e[0]=t,e[1]=n);let r=n,i=_e(mW),a=_e(hW),o=_e(gW),s=Le(_W),c=Le(vW),[l,u]=(0,Z.useState)(!1),d=vt({runtime:Se(),sidebarCollapsed:i,mobileNavOpen:s}),f;e[2]!==o||e[3]!==i?(f=e=>{if(i)return;e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),u(!0);let r=e.clientX,a=_e.getState().expandedWidthPx,s=e.pointerId,c=0,l=a,d=a,f=()=>{c=0,d=l,n?.style.setProperty(`--sidebar-expanded-px`,`${d}px`)},p=e=>{l=ze(a+(e.clientX-r)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(s)}catch{}u(!1),o(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},e[2]=o,e[3]=i,e[4]=f):f=e[4];let p=f,m,h;e[5]===c?(m=e[6],h=e[7]):(m=()=>{let e=e=>{e.key===`Escape`&&c(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[c],e[5]=c,e[6]=m,e[7]=h),(0,Z.useEffect)(m,h);let g,_;e[8]===c?(g=e[9],_=e[10]):(g=()=>{let e=window.matchMedia(dW),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},_=[c],e[8]=c,e[9]=g,e[10]=_),(0,Z.useEffect)(g,_);let v,y;e[11]===s?(v=e[12],y=e[13]):(v=()=>{if(!s||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},y=[s],e[11]=s,e[12]=v,e[13]=y),(0,Z.useEffect)(v,y);let b;e[14]!==r||e[15]!==s||e[16]!==c?(b=s?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":r.closeMenu,onClick:()=>c(!1)}):null,e[14]=r,e[15]=s,e[16]=c,e[17]=b):b=e[17];let x=l&&`sidebar-width-resizing`,S=s?`max-md:translate-x-0`:`max-md:-translate-x-full`,C=i?`md:w-0 md:overflow-hidden md:border-0`:`app-sidebar-expanded-width`,w;e[18]!==x||e[19]!==S||e[20]!==C?(w=Y(`app-sidebar-push app-chrome-sidebar flex min-h-0 shrink-0 flex-col overflow-hidden bg-transparent`,x,`max-md:fixed max-md:left-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:w-[min(16rem,85vw)]`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,S,`md:relative md:h-full md:translate-x-0`,C),e[18]=x,e[19]=S,e[20]=C,e[21]=w):w=e[21];let T=i&&!s?!0:void 0,E=i&&!s?!0:void 0,O;e[22]!==a||e[23]!==i?(O=i?void 0:{"--sidebar-expanded-px":`${a}px`},e[22]=a,e[23]=i,e[24]=O):O=e[24];let k=d.sidebarChromeVisible?(0,$.jsxs)(`div`,{className:Y(`sidebar-chrome-row flex min-w-0`,Il,d.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,d.sidebarLeadingInsetClass,i?`justify-center gap-1 px-1.5 max-md:flex`:Y(`justify-start gap-1`,d.sidebarLeadingInsetClass?`sidebar-chrome-row-darwin pr-3`:`px-3`),i&&`md:hidden`),children:[s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-8 shrink-0 rounded-xl p-0 md:hidden`,Fl),"aria-label":r.closeMenu,title:r.closeMenu,onClick:()=>c(!1),children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,d.sidebarQuickActionsVisible&&!i?(0,$.jsx)(zV,{sidebarToggleVariant:`sidebar`,className:`overflow-hidden`}):null]}):null,A;e[25]===c?A=e[26]:(A=(0,$.jsx)(uW,{collapsed:!1,onNavigate:()=>c(!1)}),e[25]=c,e[26]=A);let j;e[27]!==r||e[28]!==p||e[29]!==i?(j=i?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r.sidebar.resizeHandleAria,onPointerDown:p,className:Y(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`touch-none select-none`,Fl)}),e[27]=r,e[28]=p,e[29]=i,e[30]=j):j=e[30];let M;e[31]!==w||e[32]!==T||e[33]!==E||e[34]!==O||e[35]!==k||e[36]!==A||e[37]!==j?(M=(0,$.jsxs)(`aside`,{id:`app-sidebar`,className:w,"aria-hidden":T,"data-collapsed":E,style:O,children:[k,A,j]}),e[31]=w,e[32]=T,e[33]=E,e[34]=O,e[35]=k,e[36]=A,e[37]=j,e[38]=M):M=e[38];let N;return e[39]!==M||e[40]!==b?(N=(0,$.jsxs)($.Fragment,{children:[b,M]}),e[39]=M,e[40]=b,e[41]=N):N=e[41],N});function pW(e){return e.language}function mW(e){return e.collapsed}function hW(e){return e.expandedWidthPx}function gW(e){return e.setExpandedWidthPx}function _W(e){return e.mobileNavOpen}function vW(e){return e.setMobileNavOpen}function yW(e){if(typeof e!=`string`||e.length>8192)throw Error(`Invalid browser URL`);let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Use an HTTP or HTTPS address without embedded credentials`);return t.href}function bW(e,t){let n=e.trim();if(!n)return null;if(/^https?:\/\//i.test(n))return yW(n);if(/^(localhost|127(?:\.\d+){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(n))return yW(`http://${n}`);if(!/\s/.test(n)&&/^(?:[\w-]+\.)+[\w-]+(?::\d+)?(?:[/?#]|$)/i.test(n))return yW(`https://${n}`);if(/^[a-z][a-z\d+.-]*:/i.test(n))throw Error(`Only HTTP and HTTPS addresses are supported`);return t?{google:`https://www.google.com/search?q=`,bing:`https://www.bing.com/search?q=`,duckduckgo:`https://duckduckgo.com/?q=`}[t]+encodeURIComponent(n):null}var xW=k(e=>({tabs:{},update:t=>e(e=>({tabs:{...e.tabs,[t.workspaceTabId]:t}}))}));async function SW(e){let t=xW.getState().tabs[e];return t&&window.electronAPI?.browser&&!await window.electronAPI.browser.close(t.id)?!1:(xW.setState(t=>({tabs:Object.fromEntries(Object.entries(t.tabs).filter(([t])=>t!==e))})),!0)}E.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||t.conversationId&&e.conversationId!==t.conversationId)&&(xW.setState({tabs:{}}),window.electronAPI?.browser?.release().catch(()=>{}))});function CW(e,t,n){let r=(0,Q.c)(5),i,a;r[0]!==t||r[1]!==e||r[2]!==n?(i=()=>{let r=window.electronAPI?.browser,i=e.current;if(!r||!t||!i)return;let a=0,o=``,s=!1,c=()=>{if(a=0,s)return;let e=[...document.querySelectorAll(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-browser-occluder]`)].some(OW),l=[i.closest(`[data-right-workspace]`),i.closest(`[role="tabpanel"]`)].filter(Boolean).some(EW),u=i.getBoundingClientRect(),d=n&&!e&&!l&&i.getClientRects().length>0&&document.visibilityState===`visible`?{x:u.x,y:u.y,width:u.width,height:u.height}:null,f=JSON.stringify(d);f!==o&&(o=f,r.present(t,d).catch(TW)),l&&(a=requestAnimationFrame(c))},l=()=>{a||=requestAnimationFrame(c)},u=new ResizeObserver(l);u.observe(i);let d=new MutationObserver(l);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-hidden`,`data-state`]});let f=()=>{o=``,l()};return window.addEventListener(`focus`,f),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0),document.addEventListener(`visibilitychange`,l),l(),()=>{s=!0,cancelAnimationFrame(a),u.disconnect(),d.disconnect(),window.removeEventListener(`focus`,f),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),document.removeEventListener(`visibilitychange`,l),r.present(t,null).catch(wW)}},a=[t,e,n],r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,Z.useLayoutEffect)(i,a)}function wW(){}function TW(){}function EW(e){return e.getAnimations().some(DW)}function DW(e){return e.playState===`running`}function OW(e){return e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}function kW(e){let t=(0,Q.c)(94),{tab:n,scope:r,active:i}=e,a=(0,Z.useContext)(qi),o=D(jW)===`zh`,s=E(AW),c;t[0]===n.id?c=t[1]:(c=e=>e.tabs[n.id],t[0]=n.id,t[1]=c);let l=xW(c),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(n.initialUrl??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(!1),S=window.electronAPI?.browser,C,w;t[2]!==s||t[3]!==r||t[4]!==n.id||t[5]!==n.initialUrl?(C=()=>{if(!S||!s)return;let e=!1;return S.ensure({workspaceTabId:n.id,scope:r,identity:s}).then(async t=>{if(e){Object.values(tl.getState().panes).some(e=>e.tabs.some(e=>e.id===n.id))||await S.close(t.id);return}xW.getState().update(t),!t.url&&n.initialUrl&&await S.navigate(t.id,n.initialUrl)}).catch(t=>{e||_(String(t.message??t))}),()=>{e=!0}},w=[S,s,r,n.id,n.initialUrl],t[2]=s,t[3]=r,t[4]=n.id,t[5]=n.initialUrl,t[6]=C,t[7]=w):(C=t[6],w=t[7]),(0,Z.useEffect)(C,w);let T;t[8]!==m||t[9]!==l?(T=()=>{!m&&l?.url&&p(l.url)},t[8]=m,t[9]=l,t[10]=T):T=t[10];let O=l?.url,k;t[11]!==m||t[12]!==O?(k=[m,O],t[11]=m,t[12]=O,t[13]=k):k=t[13],(0,Z.useEffect)(T,k),CW(u,l?.id,i&&!!l?.url&&!l?.error&&!l?.crashed&&!b);let A,j;t[14]!==i||t[15]!==n.id?(A=()=>{if(!i)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),d.current?.focus(),d.current?.select())},t=e=>{e.detail===n.id&&(d.current?.focus(),d.current?.select())};return window.addEventListener(`browser-focus-address`,t),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`browser-focus-address`,t)}},j=[i,n.id],t[14]=i,t[15]=n.id,t[16]=A,t[17]=j):(A=t[16],j=t[17]),(0,Z.useEffect)(A,j);let M;t[18]!==f||t[19]!==v||t[20]!==l?(M=async function(e){let t=e===void 0?v:e;if(!(!S||!l))try{let e=bW(f,t);if(!e){x(!!f.trim());return}x(!1),_(``),h(!1),await S.navigate(l.id,e)}catch(e){let t=e;_(t instanceof Error?t.message:String(t))}},t[18]=f,t[19]=v,t[20]=l,t[21]=M):M=t[21];let N=M,P;t[22]===l?P=t[23]:(P=function(e){!S||!l||(_(``),S.command(l.id,e).catch(e=>_(e instanceof Error?e.message:String(e))))},t[22]=l,t[23]=P);let F=P;if(!i){let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{ref:u,hidden:!0}),t[24]=e):e=t[24],e}let I;t[25]===N?I=t[26]:(I=e=>{e.preventDefault(),N()},t[25]=N,t[26]=I);let L=o?`网页后退`:`Browser back`,R=!l?.canGoBack,z;t[27]===F?z=t[28]:(z=()=>F(`back`),t[27]=F,t[28]=z);let B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Ft,{className:`size-4`}),t[29]=B):B=t[29];let V;t[30]!==L||t[31]!==R||t[32]!==z?(V=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":L,disabled:R,onClick:z,children:B}),t[30]=L,t[31]=R,t[32]=z,t[33]=V):V=t[33];let H=o?`网页前进`:`Browser forward`,ee=!l?.canGoForward,te;t[34]===F?te=t[35]:(te=()=>F(`forward`),t[34]=F,t[35]=te);let ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(It,{className:`size-4`}),t[36]=ne):ne=t[36];let U;t[37]!==H||t[38]!==ee||t[39]!==te?(U=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":H,disabled:ee,onClick:te,children:ne}),t[37]=H,t[38]=ee,t[39]=te,t[40]=U):U=t[40];let re=l?.loading?o?`停止加载网页`:`Stop loading page`:o?`刷新网页`:`Reload page`,W=!l?.url&&!l?.loading,ie;t[41]!==F||t[42]!==l?.loading?(ie=()=>F(l?.loading?`stop`:`reload`),t[41]=F,t[42]=l?.loading,t[43]=ie):ie=t[43];let G;t[44]===l?.loading?G=t[45]:(G=l?.loading?(0,$.jsx)(ds,{className:`size-4`}):(0,$.jsx)(Oo,{className:`size-4`}),t[44]=l?.loading,t[45]=G);let K;t[46]!==re||t[47]!==W||t[48]!==ie||t[49]!==G?(K=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":re,disabled:W,onClick:ie,children:G}),t[46]=re,t[47]=W,t[48]=ie,t[49]=G,t[50]=K):K=t[50];let ae=o?`搜索或输入网址`:`Search or enter a URL`,q,oe,se;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>h(!0),oe=()=>h(!1),se=e=>p(e.target.value),t[51]=q,t[52]=oe,t[53]=se):(q=t[51],oe=t[52],se=t[53]);let ce=o?`搜索或输入网址`:`Search or enter a URL`,le;t[54]!==f||t[55]!==ae||t[56]!==ce?(le=(0,$.jsx)(`input`,{ref:d,"aria-label":ae,autoComplete:`off`,spellCheck:!1,value:f,onFocus:q,onBlur:oe,onChange:se,placeholder:ce,className:`h-9 min-w-0 flex-1 rounded-full border border-edge-subtle bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`}),t[54]=f,t[55]=ae,t[56]=ce,t[57]=le):le=t[57];let ue=a?.button,de=o?`在系统浏览器打开`:`Open in system browser`,J=!l?.url,fe;t[58]===l?fe=t[59]:(fe=()=>{l?.url&&window.electronAPI?.shell?.openExternalUrl(l.url).catch(e=>_(e instanceof Error?e.message:String(e)))},t[58]=l,t[59]=fe);let pe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(hi,{className:`size-4`}),t[60]=pe):pe=t[60];let me;t[61]!==de||t[62]!==J||t[63]!==fe?(me=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":de,disabled:J,onClick:fe,children:pe}),t[61]=de,t[62]=J,t[63]=fe,t[64]=me):me=t[64];let he;t[65]!==I||t[66]!==V||t[67]!==U||t[68]!==K||t[69]!==le||t[70]!==ue||t[71]!==me?(he=(0,$.jsxs)(`form`,{"data-workspace-toolbar":!0,className:`flex h-14 shrink-0 items-center gap-1 bg-surface-inset px-2`,onSubmit:I,children:[V,U,K,le,ue,me]}),t[65]=I,t[66]=V,t[67]=U,t[68]=K,t[69]=le,t[70]=ue,t[71]=me,t[72]=he):he=t[72];let ge;t[73]===g?ge=t[74]:(ge=g?(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:g}):null,t[73]=g,t[74]=ge);let _e;t[75]===l?_e=t[76]:(_e=l?.notice?(0,$.jsx)(`p`,{role:`status`,className:`border-b border-edge px-3 py-2 text-xs text-fg-muted`,children:l.notice}):null,t[75]=l,t[76]=_e);let ve;t[77]!==b||t[78]!==N||t[79]!==o?(ve=b?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":o?`选择搜索引擎`:`Choose a search engine`,className:`border-b border-edge p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:o?`选择搜索引擎后才会提交这次搜索。`:`Choose where to send this search.`}),(0,$.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[[`duckduckgo`,`google`,`bing`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 hover:bg-surface-hover`,onClick:()=>{y(e),N(e)},children:e===`duckduckgo`?`DuckDuckGo`:e===`google`?`Google`:`Bing`},e)),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(!1),children:o?`取消`:`Cancel`})]})]}):null,t[77]=b,t[78]=N,t[79]=o,t[80]=ve):ve=t[80];let ye;t[81]!==F||t[82]!==g||t[83]!==l||t[84]!==o?(ye=!l&&g?(0,$.jsx)(`div`,{className:`p-8 text-sm text-fg-muted`,children:o?`无法创建浏览器标签。关闭其他网页后重试。`:`Browser tab could not be created. Close another page and try again.`}):l?l.error?(0,$.jsxs)(`div`,{role:`alert`,className:`p-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.error}),(0,$.jsx)(`button`,{type:`button`,className:`mt-4 text-accent`,onClick:()=>F(`reload`),children:o?`重试`:`Retry`})]}):l.url?null:(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`size-9`}),(0,$.jsx)(`h2`,{className:`text-lg text-fg`,children:o?`浏览网页`:`Browse the web`}),(0,$.jsx)(`p`,{className:`text-sm`,children:o?`输入网址开始。网页内容不会自动发送到聊天。`:`Enter an address to begin. Pages are not automatically shared with chat.`})]}):(0,$.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,$.jsx)(ps,{className:`h-8 w-2/3`}),(0,$.jsx)(ps,{className:`h-40 w-full`})]}),t[81]=F,t[82]=g,t[83]=l,t[84]=o,t[85]=ye):ye=t[85];let be;t[86]===ye?be=t[87]:(be=(0,$.jsx)(`div`,{ref:u,className:`relative min-h-0 flex-1 overflow-hidden bg-surface-base`,"data-browser-surface":!0,children:ye}),t[86]=ye,t[87]=be);let xe;return t[88]!==he||t[89]!==ge||t[90]!==_e||t[91]!==ve||t[92]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-browser-tab":!0,children:[he,ge,_e,ve,be]}),t[88]=he,t[89]=ge,t[90]=_e,t[91]=ve,t[92]=be,t[93]=xe):xe=t[93],xe}function AW(e){return e.conversationId}function jW(e){return e.language}function MW(){let e=(0,Q.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(NW,t)}function NW(){return window.electronAPI?.browser?.onEvent(PW)}function PW(e){if(e.kind===`state`)xW.getState().update(e.state),tl.getState().updateBrowserTitle(e.state.workspaceTabId,e.state.title);else if(e.kind===`focus-address`)window.dispatchEvent(new CustomEvent(`browser-focus-address`,{detail:e.workspaceTabId}));else{let t=tl.getState();Object.values(t.panes).flatMap(IW).filter(FW).length<24&&t.openBrowser(e.url,e.scope,e.sourceTabId)}}function FW(e){return e.kind===`browser`}function IW(e){return e.tabs}var LW=(0,Z.memo)(function({elevated:e=!1,embedded:t=!1,scope:n,onCloseTree:r}){let i=F(D(e=>e.language)),{pathname:a,search:o}=m(),{conversationId:s}=f(),c=a.startsWith(`/chat`)&&s&&s!==`new`?decodeURIComponent(s):null,l=se(e=>e.open),u=t||l,d=(0,Z.useRef)(u),p=se(e=>e.setOpen),h=(0,Z.useCallback)(e=>{t?e||r?.():p(e)},[t,r,p]),g=se(e=>e.conversationIdOverride),_=se(e=>e.widthPx),v=se(e=>e.setWidthPx),y=n?n.conversationId??null:g??c,b=n?n.projectId??null:!y&&a.startsWith(`/chat`)?new URLSearchParams(o).get(`projectId`):null,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(``),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),[P,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),z=yc(e=>e.path),B=yc(e=>e.setPath),V=(0,Z.useCallback)(e=>{B(e,null,b,y)},[y,B,b]),H=Sd(e=>e.agentId),ee=n?.agentId??H,{tree:te,rootResource:ne,loading:U,error:re,loadRoot:W,loadChildren:ie,refreshDirectory:G,reset:K}=xd(ee,y,b),ae=y?`session:${y}`:b?`project:${b}`:`agent:${ee}`,q=(0,Z.useMemo)(()=>b?{projectId:b}:y==null?ee.trim()?{agentId:ee.trim()}:void 0:{conversationId:y},[y,b,ee]),oe=T.trim(),ce=tu(),le=(0,Z.useCallback)((e,t)=>{ot(e.dataTransfer,{name:t.name,path:t.path,...q})},[q]),{dialogOpen:ue,loading:de,result:J,error:fe,pendingParams:pe,createShareLink:me,confirmShareLink:he,handleOpenChange:ge}=hd(),_e=(0,Z.useCallback)(e=>{if(!u)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),S(!0);let r=e.clientX,i=se.getState().widthPx,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n?.style.setProperty(`--workspace-panel-px`,`${c}px`)},d=e=>{s=ct(i+(r-e.clientX)),o===0&&(o=window.requestAnimationFrame(l))},f=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}S(!1),v(c),window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[u,v]);(0,Z.useEffect)(()=>{!t&&!a.startsWith(`/chat`)&&h(!1)},[t,a,h]),(0,Z.useEffect)(()=>{let e=d.current;if(d.current=u,!u){K(),e&&!t&&V(null);return}t||V(null),W()},[t,u,ae,W,K,V]),(0,Z.useEffect)(()=>{if(!u||t)return;let e=e=>{if(e.key===`Escape`){if(C){e.preventDefault(),e.stopPropagation(),E(``),w(!1);return}yc.getState().path||h(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,C,u,h]),(0,Z.useEffect)(()=>{if(!u||!t&&!C||!oe){k([]),j(!1),N(null);return}let e=!1;j(!0),N(null),k([]);let n=window.setTimeout(()=>{cd(oe,q,50).then(t=>{e||k(t)}).catch(t=>{e||N(t instanceof Error?t.message:String(t))}).finally(()=>{e||j(!1)})},180);return()=>{e=!0,window.clearTimeout(n)}},[t,C,oe,u,q]),(0,Z.useEffect)(()=>{if(!u||t||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[t,u]);let ve=(0,Z.useCallback)(e=>{ie(e)},[ie]),ye=(0,Z.useCallback)(async(e,t,n)=>{switch(e){case`preview`:if(t.isDirectory)return;V(t.path);break;case`download`:if(t.isDirectory)return;try{let e=Ko(t.path);if(Go(qo(e))!==`text`)ud(e,await(await od(t.path,q)).arrayBuffer(),Ec(e)??`application/octet-stream`);else{let{content:n}=await sd(t.path,q);fd(e,n)}}catch{}break;case`copyPath`:try{await pl(t.path)&&Ml(`success`,i.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:await vd(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWith`:await vd(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await vd(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),i.workspace.openFileFailed);break;case`revealInFolder`:await vd(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),i.workspace.revealFileFailed);break;case`trash`:I(t);break;case`delete`:t.isDirectory||R(t);break;case`share`:await me({path:t.path,...t.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...q});break;default:break}},[me,i.workspace.openFileFailed,i.workspace.pathCopied,i.workspace.revealFileFailed,V,q]),be=(0,Z.useCallback)(async()=>{let e=P;if(!e)return;let n=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!n?.ok){Ml(`warning`,n?.error??i.workspace.trashFailed,void 0,{duration:4e3});return}!t&&z===e.path&&V(null),I(null),await W(),Ml(`success`,i.workspace.trashSuccess,void 0,{duration:2500})},[t,W,i.workspace.trashFailed,i.workspace.trashSuccess,P,z,V]),xe=(0,Z.useCallback)(async(e,t)=>{try{await Promise.all(e.map(e=>dd(e,t,q))),await G(t).catch(()=>void 0),Ml(`success`,i.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await G(t).catch(()=>void 0),Ml(`warning`,`${i.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[i.workspace.uploadFailed,i.workspace.uploadSuccess,G,q]),Se=(0,Z.useCallback)(async()=>{let e=L;if(e)try{await pd(e.fileId),!t&&z===e.path&&V(null),R(null);let n=e.path.lastIndexOf(`/`);await G(n<0?``:e.path.slice(0,n)).catch(()=>void 0),Ml(`success`,i.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Ml(`warning`,`${i.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t,i.workspace.deleteFailed,i.workspace.deleteSuccess,L,z,G,V]);return(0,$.jsxs)($.Fragment,{children:[u&&!t?(0,$.jsx)(`button`,{type:`button`,className:Y(`fixed inset-0 bg-scrim md:hidden`,e?`z-[109]`:`z-40`),"aria-label":i.closeMenu,onClick:()=>h(!1)}):null,(0,$.jsx)(`aside`,{id:t?void 0:`app-workspace-panel`,"aria-label":i.workspace.title,"aria-hidden":!u,className:t?`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-base`:Y(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:h-[100dvh] max-md:shadow-popover max-md:w-[min(20rem,92vw)]`,u?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,e&&u?`pointer-events-auto z-[110]`:`max-md:z-50`,!u&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,u&&`app-workspace-panel-expanded-width md:shrink-0`,u&&x&&`workspace-panel-rail-resizing`),style:!t&&u?{"--workspace-panel-px":`${_}px`}:void 0,children:u?(0,$.jsxs)(`div`,{className:Y(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.workspace.resizeHandleAria,onPointerDown:_e,className:Y(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 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`,x&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,Fl)}),(0,$.jsxs)(`div`,{className:Y(`flex h-11 shrink-0 items-center gap-2 px-4`,!t&&`border-b border-edge dark:border-edge`),children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:i.workspace.title}),ce?ne?(0,$.jsx)(li,{resourceId:ne.fileId,displayName:ne.name}):null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(Hi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:i.workspace.title})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-9 shrink-0 rounded-md p-0`,C&&`bg-surface-hover text-fg`),"aria-label":i.workspace.search,title:i.workspace.search,"aria-pressed":C,onClick:()=>w(!0),children:(0,$.jsx)(No,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(id,{className:`size-9 shrink-0 rounded-md p-0`,loading:U,label:i.cron.refresh,onClick:W}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":i.workspace.close,title:i.workspace.close,onClick:()=>h(!1),children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.75})})]})]}),t||C?(0,$.jsx)(`div`,{className:Y(`shrink-0 px-3 pb-2 pt-1`,!t&&`border-b border-edge`),children:(0,$.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(No,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:T,onChange:e=>E(e.target.value),placeholder:i.workspace.searchPlaceholder,"aria-label":i.workspace.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),!t||T?(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":i.workspace.clearSearch,title:i.workspace.clearSearch,onClick:()=>{E(``),w(!1)},children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,re?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,re]}):null,oe?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:A?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(ps,{className:`h-11 w-full`}),(0,$.jsx)(ps,{className:`h-11 w-full`}),(0,$.jsx)(ps,{className:`h-11 w-full`})]}):M?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,M]}):O.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:i.workspace.noSearchResults}):O.map(e=>(0,$.jsxs)(`button`,{type:`button`,draggable:!0,className:Y(`flex w-full min-w-0 cursor-grab items-center gap-2 px-3 py-2 text-left active:cursor-grabbing hover:bg-surface-hover`,z===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>V(e.path),onDragStart:t=>le(t,e),title:e.path,children:[(0,$.jsx)(Si,{name:e.name}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(ad,{tree:te,selectedPath:z,onSelectFile:e=>V(e),onExpandDir:ve,onAction:ye,onFileDragStart:le,onUploadFiles:(e,t)=>void xe(e,t),uploadDropHint:i.workspace.dropToUpload,actionLabels:{preview:i.workspace.preview,download:i.workspace.download,copyPath:i.workspace.copyPath,share:i.workspace.shareLink,delete:i.workspace.deleteFile,...ce?{openDefault:i.workspace.openSystemApp,openDirectory:i.workspace.openInFileManager,openWith:i.workspace.chooseApp,revealInFolder:i.workspace.revealInFolder,trash:i.workspace.moveToTrash,recommendedApps:i.workspace.recommendedApps,desktopUpdateRequired:i.workspace.desktopUpdateRequired}:{}},emptyHint:i.workspace.emptyDir})]}):null}),(0,$.jsx)(ls,{open:ue,onOpenChange:ge,loading:de,error:fe,result:J,pendingParams:pe,onConfirm:e=>void he(e)}),(0,$.jsx)(rd,{open:!!P,title:i.workspace.trashConfirmTitle,description:i.workspace.trashConfirmDescription.replace(`{{name}}`,P?.name??``),confirmLabel:i.workspace.moveToTrash,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void be(),onCancel:()=>I(null)}),(0,$.jsx)(rd,{open:!!L,title:i.workspace.deleteConfirmTitle,description:i.workspace.deleteConfirmDescription.replace(`{{name}}`,L?.name??``),confirmLabel:i.workspace.deleteFile,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void Se(),onCancel:()=>R(null)})]})}),RW=`xopc:side-chat-client-id`;function zW(){let e=sessionStorage.getItem(RW);if(e)return e;let t=crypto.randomUUID();return sessionStorage.setItem(RW,t),t}function BW(){return{"x-xopc-client-instance-id":zW()}}async function VW(e,t){return(await O(T(`/api/sessions/${encodeURIComponent(e)}/side-chats`),{method:`POST`,headers:BW(),body:JSON.stringify({clientInstanceId:zW(),selections:t})})).sideChat}async function HW(e){return(await O(T(`/api/side-chats/${e}`),{headers:BW()})).sideChat}async function UW(e){return(await O(T(`/api/side-chats/${e}/messages`),{headers:BW()})).messages}async function WW(e,t){return(await O(T(`/api/side-chats/${e}/config`),{method:`PATCH`,headers:BW(),body:JSON.stringify(t)})).sideChat}async function GW(e,t,n){return(await O(T(`/api/side-chats/${e}/inputs`),{method:`POST`,headers:BW(),body:JSON.stringify({content:t,attachments:n})})).payload.runId}async function KW(e,t){await O(T(`/api/side-chats/${e}/abort`),{method:`POST`,headers:BW(),body:JSON.stringify({runId:t})})}async function qW(e,t,n){await O(T(`/api/side-chats/${e}/clarify/${t}`),{method:`POST`,headers:BW(),body:JSON.stringify(n)})}async function JW(e){await O(T(`/api/side-chats/${e}`),{method:`DELETE`,headers:BW()})}async function YW(e){return(await O(T(`/api/side-chats/${e}/heartbeat`),{method:`POST`,headers:BW()})).sideChat}async function XW(e){return(await O(T(`/api/side-chats/${e}/extend`),{method:`POST`,headers:BW()})).sideChat}async function ZW(e){return O(T(`/api/side-chats/${e}/promote`),{method:`POST`,headers:BW()})}var QW=`xopc:side-chat-close-confirm-disabled:v1`,$W=()=>{},eG=[];function tG(){try{return localStorage.getItem(QW)===`true`}catch{return!1}}function nG(){try{localStorage.setItem(QW,`true`)}catch{}}function rG(e){return e.role===`user`?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
6
|
+
`);let c=r.split(iH);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 _H=`xopc.updateReminder.dismissed`,vH=typeof window<`u`&&window.electronAPI?.updater!==void 0,yH=`xopc:electron-update-recheck`;function bH(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(_H);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function xH(){let{npm:e,electron:t,isElectron:n,electronCheck:r,electronQuitAndInstall:i,runNpmUpdate:a,npmUpdateRunning:o}=pH(),[s,c]=(0,Z.useState)(bH),[l,u]=(0,Z.useState)({downloading:!1,electronError:!1}),[d,f]=(0,Z.useState)(()=>{if(typeof window>`u`||vH)return null;try{let e=sessionStorage.getItem(oH);if(!e)return null;let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;return n?{version:n,automatic:t.automaticRestart===!0}:null}catch{return null}}),p=(0,Z.useRef)(t?.state);p.current!==t?.state&&(p.current=t?.state,t?.state!==`downloading`&&l.downloading&&u(e=>({...e,downloading:!1})),t?.state!==`error`&&l.electronError&&u(e=>({...e,electronError:!1})));let m=(0,Z.useRef)(null);if(d&&e?.currentVersion===d.version&&m.current!==d.version){m.current=d.version;try{sessionStorage.removeItem(oH)}catch{}f(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(oH);if(!e){f(null);return}let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;f(n?{version:n,automatic:t.automaticRestart===!0}:null)}catch{f(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{u(e=>({...e,downloading:!1})),c(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(_H,JSON.stringify(t))}catch{}return t})};return window.addEventListener(yH,e),()=>window.removeEventListener(yH,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&c(e=>{let n={...e,npm:t};try{localStorage.setItem(_H,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let h=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?s.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!l.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&!l.electronError?{kind:`electron-error`,message:t.message?.trim()??``}:!n&&d&&e&&e.currentVersion!==d.version?d.automatic?{kind:`npm-restarting`,version:d.version}:{kind:`npm-restart-required`,version:d.version}:!n&&e?.updateAvailable&&e.latestVersion?s.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[s.npm,s.electronReady,t,l.downloading,l.electronError,n,e,d]);return{show:h,dismiss:(0,Z.useCallback)(()=>{if(h.kind===`electron-downloading`){u(e=>({...e,downloading:!0}));return}if(h.kind===`electron-error`){u(e=>({...e,electronError:!0}));return}if(h.kind===`npm-restart-required`||h.kind===`npm-restarting`){try{sessionStorage.removeItem(oH)}catch{}f(null);return}if(h.kind===`none`)return;let e={...s};h.kind===`npm`?e.npm=h.version:h.kind===`electron-ready`&&(e.electronReady=h.version);try{localStorage.setItem(_H,JSON.stringify(e))}catch{}c(e)},[s,h]),electronCheck:r,electronQuitAndInstall:i,runNpmUpdate:a,npmUpdateRunning:o}}var SH={version:`0.0.470`,commit:`87da7b6e4833fac60843a2f5adba0fcbb87b9836`,buildTimeIso:`2026-11-12T23:56:29.375Z`},CH=`https://github.com/xopcai/xopc`,wH=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),TH=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function EH(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?wH:TH).format(n)}catch{return n.toISOString()}}function DH({open:e,onOpenChange:t}){let n=D(e=>e.language),r=F(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:f}=pH(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),{data:x}=Nu(async()=>{let e=await O(T(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),S=(0,Z.useCallback)(e=>{e||(m(!1),g(!1),v(!1),b(null)),t(e)},[t]),C=(0,Z.useCallback)(async()=>{b(null);let e=F(n).updatePanel,t=await d();if(t.ok){jl({tone:`success`,title:e.updateSuccess,message:sH(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;b(`${r}: ${t.message}`)},[d,n]),w=SH.commit,E=n===`zh`?`zh-CN`:`en-US`,k=EH(SH.buildTimeIso,E),A=new Date().getFullYear(),j=i.copyright.replace(`{year}`,String(A));return(0,$.jsx)(ne,{open:e,onOpenChange:S,children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(ee,{className:Y(`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-overlay shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(V,{asChild:!0,children:(0,$.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,$.jsx)(ds,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(Rl,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(te,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(B,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:SH.version}),(0,$.jsx)(`button`,{type:`button`,className:Y(`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(yH)),m(!0),c()):(m(!0),v(!1),g(!0),(async()=>{let e=await l();g(!1),e||v(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(h||f),children:o&&s?.state===`checking`||!o&&h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(_a,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&p&&(0,$.jsx)(OH,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&p&&(0,$.jsx)(kH,{checking:h,checkFailed:_,npm:u,npmUpdateRunning:f,upgradeError:y,onUpgrade:C,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:w})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:k})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:x??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:CH,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:j})]})]})]})]})})}function OH(e){let t=(0,Q.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,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.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,$.jsx)(jr,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.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,$.jsx)(Eo,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.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,$.jsx)(pi,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.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,$.jsx)(pi,{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,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.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,$.jsx)(Ar,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function kH(e){let t=(0,Q.c)(28),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,upgradeError:o,onUpgrade:s,d:c,tp:l}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===c.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesChecking})]}),t[1]=c.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ar,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===c.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesError})]}),t[4]=c.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_a,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===l.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:l.updateRunning})]}),t[7]=l.updateRunning,t[8]=n),n}if(o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ar,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;return t[10]===o?n=t[11]:(n=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-red-500 dark:text-red-400`,role:`alert`,children:[e,(0,$.jsx)(`span`,{children:o})]}),t[10]=o,t[11]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Eo,{className:`mt-0.5 size-3.5 shrink-0`}),t[12]=e):e=t[12];let n;t[13]!==i.latestVersion||t[14]!==l.reminderNpm?(n=l.reminderNpm.replace(`{{version}}`,i.latestVersion),t[13]=i.latestVersion,t[14]=l.reminderNpm,t[15]=n):n=t[15];let r;t[16]===n?r=t[17]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[16]=n,t[17]=r);let a;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(a=Y(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-on-accent`,`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[18]=a):a=t[18];let o;t[19]!==s||t[20]!==l.updateNow?(o=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:a,children:l.updateNow}),t[19]=s,t[20]=l.updateNow,t[21]=o):o=t[21];let c;return t[22]!==r||t[23]!==o?(c=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,o]}),t[22]=r,t[23]=o,t[24]=c):c=t[24],c}let u;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(jr,{className:`size-3.5`}),t[25]=u):u=t[25];let d;return t[26]===c.checkUpdatesUpToDate?d=t[27]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[u,(0,$.jsx)(`span`,{children:c.checkUpdatesUpToDate})]}),t[26]=c.checkUpdatesUpToDate,t[27]=d),d}var AH=Y(`flex w-full items-center gap-2 rounded-lg px-2.5 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-overlay`),jH=Y(`overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,`dark:border-edge`);function MH(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=Y(`touch-target flex w-full items-center justify-between gap-2 rounded-none 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-inset focus-visible:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=Y(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(_r,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function NH(e){let t=(0,Q.c)(220),{onNavigate:n,onAboutClick:r,onSupportClick:i,onDeviceConnectClick:a}=e,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=D(zH),d=D(RH),f=Wl(LH),p=Wl(IH),m=Bl(FH),h=Bl(PH),g;t[0]===u?g=t[1]:(g=F(u),t[0]=u,t[1]=g);let _=g,v=_.appearanceSettings,y=u===`zh`?v.langOptionZh:v.langOptionEn,x=f===`light`?v.themeOptionLight:f===`dark`?v.themeOptionDark:v.themeOptionSystem,S=m===`compact`?v.fontScaleCompact:m===`large`?v.fontScaleLarge:v.fontScaleDefault,C=typeof window<`u`?window.electronAPI?.pet:void 0,w=!!C,T=c?.visible?v.hideDesktopPet:v.showDesktopPet,E,O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{if(!C)return;let e=!1;C.getState().then(t=>{e||l(t)});let t=C.onStateChanged(t=>{e||l(t)});return()=>{e=!0,t()}},O=[C],t[2]=E,t[3]=O):(E=t[2],O=t[3]),(0,Z.useEffect)(E,O);let k;t[4]===c?.visible?k=t[5]:(k=async()=>{C&&(c?.visible?await C.hide():await C.show(),l(await C.getState()))},t[4]=c?.visible,t[5]=k);let A=k,j;t[6]===o?j=t[7]:(j=e=>Y(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,o===e?`block`:`hidden`),t[6]=o,t[7]=j);let M=j,N;t[8]===o?N=t[9]:(N=e=>Y(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,o===e?`pointer-events-auto`:`pointer-events-none`),t[8]=o,t[9]=N);let P=N,I;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>s(null),t[10]=I):I=t[10];let L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>s(`lang`),t[11]=L):L=t[11];let R=o===`lang`&&`bg-surface-hover`,z;t[12]===R?z=t[13]:(z=Y(AH,R),t[12]=R,t[13]=z);let B=o===`lang`,V;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Xi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=V):V=t[14];let H;t[15]===v.languageTitle?H=t[16]:(H=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.languageTitle}),t[15]=v.languageTitle,t[16]=H);let ee;t[17]===y?ee=t[18]:(ee=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:y}),t[17]=y,t[18]=ee);let te;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=te):te=t[19];let ne;t[20]!==z||t[21]!==B||t[22]!==H||t[23]!==ee?(ne=(0,$.jsxs)(`button`,{type:`button`,className:z,"aria-haspopup":`menu`,"aria-expanded":B,children:[V,H,ee,te]}),t[20]=z,t[21]=B,t[22]=H,t[23]=ee,t[24]=ne):ne=t[24];let U;t[25]===P?U=t[26]:(U=P(`lang`),t[25]=P,t[26]=U);let re;t[27]===U?re=t[28]:(re=(0,$.jsx)(`div`,{className:U,"aria-hidden":!0}),t[27]=U,t[28]=re);let W;t[29]===M?W=t[30]:(W=M(`lang`),t[29]=M,t[30]=W);let ie=u===`en`,G;t[31]===d?G=t[32]:(G=()=>d(`en`),t[31]=d,t[32]=G);let K;t[33]!==v.langOptionEn||t[34]!==ie||t[35]!==G?(K=(0,$.jsx)(MH,{selected:ie,label:v.langOptionEn,onSelect:G}),t[33]=v.langOptionEn,t[34]=ie,t[35]=G,t[36]=K):K=t[36];let ae=u===`zh`,q;t[37]===d?q=t[38]:(q=()=>d(`zh`),t[37]=d,t[38]=q);let oe;t[39]!==v.langOptionZh||t[40]!==ae||t[41]!==q?(oe=(0,$.jsx)(MH,{selected:ae,label:v.langOptionZh,onSelect:q}),t[39]=v.langOptionZh,t[40]=ae,t[41]=q,t[42]=oe):oe=t[42];let se;t[43]!==K||t[44]!==oe?(se=(0,$.jsxs)(`div`,{className:jH,children:[K,oe]}),t[43]=K,t[44]=oe,t[45]=se):se=t[45];let ce;t[46]!==v.languageTitle||t[47]!==W||t[48]!==se?(ce=(0,$.jsx)(`div`,{className:W,role:`menu`,"aria-label":v.languageTitle,children:se}),t[46]=v.languageTitle,t[47]=W,t[48]=se,t[49]=ce):ce=t[49];let le;t[50]!==ne||t[51]!==re||t[52]!==ce?(le=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:L,children:[ne,re,ce]}),t[50]=ne,t[51]=re,t[52]=ce,t[53]=le):le=t[53];let ue;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>s(`theme`),t[54]=ue):ue=t[54];let de=o===`theme`&&`bg-surface-hover`,J;t[55]===de?J=t[56]:(J=Y(AH,de),t[55]=de,t[56]=J);let fe=o===`theme`,pe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Xa,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=pe):pe=t[57];let me;t[58]===v.themeTitle?me=t[59]:(me=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.themeTitle}),t[58]=v.themeTitle,t[59]=me);let he;t[60]===x?he=t[61]:(he=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:x}),t[60]=x,t[61]=he);let ge;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=ge):ge=t[62];let _e;t[63]!==J||t[64]!==fe||t[65]!==me||t[66]!==he?(_e=(0,$.jsxs)(`button`,{type:`button`,className:J,"aria-haspopup":`menu`,"aria-expanded":fe,children:[pe,me,he,ge]}),t[63]=J,t[64]=fe,t[65]=me,t[66]=he,t[67]=_e):_e=t[67];let ve;t[68]===P?ve=t[69]:(ve=P(`theme`),t[68]=P,t[69]=ve);let ye;t[70]===ve?ye=t[71]:(ye=(0,$.jsx)(`div`,{className:ve,"aria-hidden":!0}),t[70]=ve,t[71]=ye);let be;t[72]===M?be=t[73]:(be=M(`theme`),t[72]=M,t[73]=be);let xe=f===`light`,Se;t[74]===p?Se=t[75]:(Se=()=>p(`light`),t[74]=p,t[75]=Se);let Ce;t[76]!==v.themeOptionLight||t[77]!==xe||t[78]!==Se?(Ce=(0,$.jsx)(MH,{selected:xe,label:v.themeOptionLight,onSelect:Se}),t[76]=v.themeOptionLight,t[77]=xe,t[78]=Se,t[79]=Ce):Ce=t[79];let we=f===`dark`,Te;t[80]===p?Te=t[81]:(Te=()=>p(`dark`),t[80]=p,t[81]=Te);let Ee;t[82]!==v.themeOptionDark||t[83]!==we||t[84]!==Te?(Ee=(0,$.jsx)(MH,{selected:we,label:v.themeOptionDark,onSelect:Te}),t[82]=v.themeOptionDark,t[83]=we,t[84]=Te,t[85]=Ee):Ee=t[85];let De=f===`system`,Oe;t[86]===p?Oe=t[87]:(Oe=()=>p(`system`),t[86]=p,t[87]=Oe);let ke;t[88]!==v.themeOptionSystem||t[89]!==De||t[90]!==Oe?(ke=(0,$.jsx)(MH,{selected:De,label:v.themeOptionSystem,onSelect:Oe}),t[88]=v.themeOptionSystem,t[89]=De,t[90]=Oe,t[91]=ke):ke=t[91];let Ae;t[92]!==Ce||t[93]!==Ee||t[94]!==ke?(Ae=(0,$.jsxs)(`div`,{className:jH,children:[Ce,Ee,ke]}),t[92]=Ce,t[93]=Ee,t[94]=ke,t[95]=Ae):Ae=t[95];let je;t[96]!==v.themeTitle||t[97]!==be||t[98]!==Ae?(je=(0,$.jsx)(`div`,{className:be,role:`menu`,"aria-label":v.themeTitle,children:Ae}),t[96]=v.themeTitle,t[97]=be,t[98]=Ae,t[99]=je):je=t[99];let Me;t[100]!==_e||t[101]!==ye||t[102]!==je?(Me=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:ue,children:[_e,ye,je]}),t[100]=_e,t[101]=ye,t[102]=je,t[103]=Me):Me=t[103];let Ne;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=()=>s(`font`),t[104]=Ne):Ne=t[104];let Pe=o===`font`&&`bg-surface-hover`,Fe;t[105]===Pe?Fe=t[106]:(Fe=Y(AH,Pe),t[105]=Pe,t[106]=Fe);let Ie=o===`font`,Le;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(eR,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Le):Le=t[107];let Re;t[108]===v.fontScaleTitle?Re=t[109]:(Re=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.fontScaleTitle}),t[108]=v.fontScaleTitle,t[109]=Re);let ze;t[110]===S?ze=t[111]:(ze=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[110]=S,t[111]=ze);let Be;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Be):Be=t[112];let Ve;t[113]!==Fe||t[114]!==Ie||t[115]!==Re||t[116]!==ze?(Ve=(0,$.jsxs)(`button`,{type:`button`,className:Fe,"aria-haspopup":`menu`,"aria-expanded":Ie,children:[Le,Re,ze,Be]}),t[113]=Fe,t[114]=Ie,t[115]=Re,t[116]=ze,t[117]=Ve):Ve=t[117];let He;t[118]===P?He=t[119]:(He=P(`font`),t[118]=P,t[119]=He);let Ue;t[120]===He?Ue=t[121]:(Ue=(0,$.jsx)(`div`,{className:He,"aria-hidden":!0}),t[120]=He,t[121]=Ue);let We;t[122]===M?We=t[123]:(We=M(`font`),t[122]=M,t[123]=We);let Ge=m===`compact`,Ke;t[124]===h?Ke=t[125]:(Ke=()=>h(`compact`),t[124]=h,t[125]=Ke);let qe;t[126]!==v.fontScaleCompact||t[127]!==Ge||t[128]!==Ke?(qe=(0,$.jsx)(MH,{selected:Ge,label:v.fontScaleCompact,onSelect:Ke}),t[126]=v.fontScaleCompact,t[127]=Ge,t[128]=Ke,t[129]=qe):qe=t[129];let Je=m==="default",Ye;t[130]===h?Ye=t[131]:(Ye=()=>h(`default`),t[130]=h,t[131]=Ye);let Xe;t[132]!==v.fontScaleDefault||t[133]!==Je||t[134]!==Ye?(Xe=(0,$.jsx)(MH,{selected:Je,label:v.fontScaleDefault,onSelect:Ye}),t[132]=v.fontScaleDefault,t[133]=Je,t[134]=Ye,t[135]=Xe):Xe=t[135];let Ze=m===`large`,Qe;t[136]===h?Qe=t[137]:(Qe=()=>h(`large`),t[136]=h,t[137]=Qe);let $e;t[138]!==v.fontScaleLarge||t[139]!==Ze||t[140]!==Qe?($e=(0,$.jsx)(MH,{selected:Ze,label:v.fontScaleLarge,onSelect:Qe}),t[138]=v.fontScaleLarge,t[139]=Ze,t[140]=Qe,t[141]=$e):$e=t[141];let et;t[142]!==qe||t[143]!==Xe||t[144]!==$e?(et=(0,$.jsxs)(`div`,{className:jH,children:[qe,Xe,$e]}),t[142]=qe,t[143]=Xe,t[144]=$e,t[145]=et):et=t[145];let tt;t[146]!==v.fontScaleTitle||t[147]!==We||t[148]!==et?(tt=(0,$.jsx)(`div`,{className:We,role:`menu`,"aria-label":v.fontScaleTitle,children:et}),t[146]=v.fontScaleTitle,t[147]=We,t[148]=et,t[149]=tt):tt=t[149];let nt;t[150]!==Ve||t[151]!==Ue||t[152]!==tt?(nt=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:Ne,children:[Ve,Ue,tt]}),t[150]=Ve,t[151]=Ue,t[152]=tt,t[153]=nt):nt=t[153];let rt;t[154]!==T||t[155]!==A?(rt=w?(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:()=>void A(),onMouseEnter:()=>s(null),onFocus:()=>s(null),children:[(0,$.jsx)(SA,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:T})]}):null,t[154]=T,t[155]=A,t[156]=rt):rt=t[156];let it;t[157]===a?it=t[158]:(it=()=>a?.(),t[157]=a,t[158]=it);let at,ot,st;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(at=()=>s(null),ot=()=>s(null),st=(0,$.jsx)(Ba,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[159]=at,t[160]=ot,t[161]=st):(at=t[159],ot=t[160],st=t[161]);let ct;t[162]===_.endpointToolsSettings.deviceAccess.flow.title?ct=t[163]:(ct=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.endpointToolsSettings.deviceAccess.flow.title}),t[162]=_.endpointToolsSettings.deviceAccess.flow.title,t[163]=ct);let lt;t[164]!==it||t[165]!==ct?(lt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:it,onMouseEnter:at,onFocus:ot,children:[st,ct]}),t[164]=it,t[165]=ct,t[166]=lt):lt=t[166];let ut;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[167]=ut):ut=t[167];let dt;t[168]===r?dt=t[169]:(dt=()=>r?.(),t[168]=r,t[169]=dt);let ft,pt,mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(ft=()=>s(null),pt=()=>s(null),mt=(0,$.jsx)(ca,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=ft,t[171]=pt,t[172]=mt):(ft=t[170],pt=t[171],mt=t[172]);let ht;t[173]===v.aboutApp?ht=t[174]:(ht=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.aboutApp}),t[173]=v.aboutApp,t[174]=ht);let gt;t[175]!==dt||t[176]!==ht?(gt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:dt,onMouseEnter:ft,onFocus:pt,children:[mt,ht]}),t[175]=dt,t[176]=ht,t[177]=gt):gt=t[177];let _t;t[178]===u?_t=t[179]:(_t=Zl(u),t[178]=u,t[179]=_t);let vt,yt,bt;t[180]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>s(null),yt=()=>s(null),bt=(0,$.jsx)(mn,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[180]=vt,t[181]=yt,t[182]=bt):(vt=t[180],yt=t[181],bt=t[182]);let xt;t[183]===_.sidebar.helpDocs?xt=t[184]:(xt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.sidebar.helpDocs}),t[183]=_.sidebar.helpDocs,t[184]=xt);let St;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,$.jsx)(hi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[185]=St):St=t[185];let Ct;t[186]!==_t||t[187]!==xt?(Ct=(0,$.jsxs)(`a`,{href:_t,target:`_blank`,rel:`noopener noreferrer`,className:AH,onMouseEnter:vt,onFocus:yt,children:[bt,xt,St]}),t[186]=_t,t[187]=xt,t[188]=Ct):Ct=t[188];let wt;t[189]===i?wt=t[190]:(wt=()=>i?.(),t[189]=i,t[190]=wt);let Tt,Et,Dt;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(Dt=()=>s(null),Tt=()=>s(null),Et=(0,$.jsx)(bO,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[191]=Tt,t[192]=Et,t[193]=Dt):(Tt=t[191],Et=t[192],Dt=t[193]);let Ot;t[194]===_.supportReport.menu?Ot=t[195]:(Ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.supportReport.menu}),t[194]=_.supportReport.menu,t[195]=Ot);let kt;t[196]!==Ot||t[197]!==wt?(kt=(0,$.jsxs)(`button`,{type:`button`,className:AH,onClick:wt,onMouseEnter:Dt,onFocus:Tt,children:[Et,Ot]}),t[196]=Ot,t[197]=wt,t[198]=kt):kt=t[198];let At,jt,Mt;t[199]===Symbol.for(`react.memo_cache_sentinel`)?(At=Y(AH,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),jt=()=>s(null),Mt=()=>s(null),t[199]=At,t[200]=jt,t[201]=Mt):(At=t[199],jt=t[200],Mt=t[201]);let Nt;t[202]===n?Nt=t[203]:(Nt=()=>n?.(),t[202]=n,t[203]=Nt);let Pt;t[204]===Symbol.for(`react.memo_cache_sentinel`)?(Pt=(0,$.jsx)(Io,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[204]=Pt):Pt=t[204];let Ft;t[205]===v.openFullPreferences?Ft=t[206]:(Ft=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:v.openFullPreferences}),t[205]=v.openFullPreferences,t[206]=Ft);let It;t[207]!==Nt||t[208]!==Ft?(It=(0,$.jsxs)(b,{to:`/settings/overview`,className:At,onMouseEnter:jt,onFocus:Mt,onClick:Nt,children:[Pt,Ft]}),t[207]=Nt,t[208]=Ft,t[209]=It):It=t[209];let Lt;return t[210]!==kt||t[211]!==It||t[212]!==le||t[213]!==Me||t[214]!==nt||t[215]!==rt||t[216]!==lt||t[217]!==gt||t[218]!==Ct?(Lt=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:I,children:[le,Me,nt,rt,lt,ut,gt,Ct,kt,It]}),t[210]=kt,t[211]=It,t[212]=le,t[213]=Me,t[214]=nt,t[215]=rt,t[216]=lt,t[217]=gt,t[218]=Ct,t[219]=Lt):Lt=t[219],Lt}function PH(e){return e.setPreference}function FH(e){return e.preference}function IH(e){return e.setPreference}function LH(e){return e.preference}function RH(e){return e.setLanguage}function zH(e){return e.language}var BH=`open-support-report`;function VH(e={}){window.dispatchEvent(new CustomEvent(BH,{detail:e}))}var HH=(0,Z.lazy)(()=>c(()=>import(`./device-pairing-wizard-eWeHH6Ru.js`).then(e=>e.n).then(e=>({default:e.DevicePairingWizard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])));function UH({collapsed:e=!1,onNavigate:t}){let n=F(D(e=>e.language)),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{c(()=>import(`./settings-page-bCW4rave.js`),__vite__mapDeps([52,1,2,3,4,5,6,53])),c(()=>import(`./sessions-page-CN9ESZdY.js`),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,55,11,56,13,57,58,59,60,61,62,63,64,20,21,31,65,66,34,22,25,26,27,28,67,68,69,14,70,71,72,73,74,75,76,77,78,19,79,80,23,44,81,82,24,49,45,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,15,99,100,47,48,101,102,42,103])),c(()=>import(`./logs-page-CH9amuGc.js`),__vite__mapDeps([104,1,2,3,4,5,6,7,8,9,105,11,66,34,20,21,22,25,26,27,28,106,84,88,14,107,108,109,110,111,76,63,19,79,31,80,112,113,24,36,45,114,115,116,117,118,10,119,13,98,15,99,100])),c(()=>import(`./automations-page-DqrAOReO.js`),__vite__mapDeps([120,2,1,121,4,3,5,6,7,8,9,122,11,123,124,125,20,21,22,23,126,34,105,10,66,25,26,27,28,102,12,35,127,128,57,110,42,129,130,14,131,75,19,29,30,31,36,132,133,134,58,135,48,136,111,76,137,99,138,78,64,139,140,141,142,143,79,80,144,145,146,147,112,113,82,148,44,81,24,149,150,90,84,114,151,91,62,92,49,45,93,152,85,86,87,116,117,118,119,13,115,153,154,155,156,157,158,159,160,161,15,107,162,163])),c(()=>import(`./capabilities-page-XgIRdqCb.js`),__vite__mapDeps([164,1,2,4,3,5,6,20,21,22,165,149,166,167,168,76,11,24,9,25,8,26,27,169]))},[]),(0,$.jsxs)(`div`,{className:Y(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[s?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(HH,{open:!0,onOpenChange:l})}):null,(0,$.jsxs)(ol,{open:r,onOpenChange:i,children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(b,{to:`/user-model`,onClick:()=>t?.(),className:`rounded-full outline-none ring-offset-surface-base transition-transform hover:opacity-95 active:scale-95 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 motion-reduce:active:scale-100`,title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(Pu,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted outline-none ring-offset-surface-base transition-colors`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)(Io,{className:`size-[17px]`,strokeWidth:1.5})})})]}):(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-1 rounded-xl p-1`,children:[(0,$.jsx)(b,{to:`/user-model`,onClick:()=>t?.(),className:Y(`flex size-10 shrink-0 items-center justify-center rounded-full text-left outline-none transition-transform duration-150 ease-out`,`hover:bg-surface-active/70`,`hover:opacity-95 active:scale-95`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(Pu,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left text-fg-muted transition-colors`,`outline-none hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:n.appearanceSettings.quickMenuHint})]}),(0,$.jsx)(Io,{className:`size-[18px] shrink-0`,strokeWidth:1.5})]})})]}),(0,$.jsx)(il,{children:(0,$.jsx)(al,{className:Y(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`end`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(NH,{onNavigate:()=>{i(!1),t?.()},onAboutClick:()=>{o(!0),i(!1)},onSupportClick:()=>{i(!1),VH()},onDeviceConnectClick:()=>{i(!1),l(!0)}})})})]}),(0,$.jsx)(DH,{open:a,onOpenChange:o})]})}function WH(e){return Zz[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var GH=`xopc-web-sidebar-nav-order`;function KH(){try{let e=JSON.parse(globalThis.localStorage?.getItem(GH)??`[]`);return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`))]:[]}catch{return[]}}var qH=k(e=>({order:KH(),setOrder:t=>{let n=[...new Set(t)];e({order:n});try{globalThis.localStorage?.setItem(GH,JSON.stringify(n))}catch{}}})),JH=`application/x-xopc-sidebar-nav`,YH=3,XH=[`work`,`capabilities`,`automation`,`apps`],ZH={work:sr,capabilities:da,automation:fs,apps:hg};function QH(e,t,n=!1){return Y(`flex w-full items-center text-sm font-medium 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`,n?`gap-2 rounded-md px-2 py-1.5 text-left leading-5`:e?`justify-center rounded-xl p-2.5 leading-6`:`gap-2 rounded-lg px-3 py-2.5 text-left leading-6 md:py-1.5`,t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}function $H(e){let t=(0,Q.c)(2),{Icon:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r),r}function eU(e){let t=(0,Q.c)(38),{collapsed:n,onNavigate:r,visibleLimit:i}=e,a=n!==void 0&&n,o=i===void 0?YH:i,{pathname:s}=m(),c=D(fU),l=F(c),d=l.productNavigation,f=u(`/chat/*`,s)?null:Yc(s),p=Fu(),{profile:h,displayName:g}=Vu(),_=ve(),[v,y]=(0,Z.useState)(!1),x=qH(dU),S=qH(uU),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),O=XH.map(e=>{let t=Xc.find(t=>t.id===e);return{id:`builtin:${e===`automation`?`automations`:e===`apps`?`localApps`:e}`,label:d.domains[e],to:t.path,Icon:ZH[e],active:f===e}}),k=p.flatMap(e=>e.activationEligible===!1?[]:(e.ui?.contributions?.pages??[]).filter(lU).map(t=>{let n=Mr(e.id,t);return{id:`ext:${e.id}:${t.id}`,label:t.title,to:n,Icon:t.navIcon?WH(t.navIcon)??So:So,active:s===n||s.startsWith(`${n}/`)}})),A=[...O,...k],j=new Map(A.map(cU)),M=[...new Set([...x,...j.keys()])].filter(e=>j.has(e)),N=M.map(e=>j.get(e)),P=Number.isFinite(o)?Math.min(A.length,Math.max(1,Math.round(o))):YH,I=N.slice(0,P),L=N.slice(P),R=L.filter(sU),z=L.filter(oU),B=L.some(aU),V;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{w(null),E(null)},t[0]=V):V=t[0];let H=V,ee=iU,te=(e,t)=>{let n=e.dataTransfer.getData(JH);if(!(!C||n!==C||!j.has(n))){if(e.preventDefault(),n!==t){let r=M.filter(e=>e!==n),i=t?r.indexOf(t)+ +!!ee(e):r.length;r.splice(i,0,n),S([...r,...x.filter(e=>!j.has(e))])}H(),y(!1)}},ne=(e,t)=>{let n=t!==void 0&&t;return(0,$.jsxs)(b,{to:e.to,"aria-current":e.active?`page`:void 0,className:Y(QH(a,e.active,n),C===e.id&&`opacity-40`,T?.id===e.id&&(T.after?`shadow-[inset_0_-2px_0_0_var(--color-accent)]`:`shadow-[inset_0_2px_0_0_var(--color-accent)]`)),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(JH,e.id),t.dataTransfer.effectAllowed=`move`,w(e.id)},onDragEnd:H,onDragOver:t=>{!C||C===e.id||(t.preventDefault(),t.dataTransfer.dropEffect=`move`,E({id:e.id,after:ee(t)}))},onDragLeave:()=>E(null),onDrop:t=>te(t,e.id),title:e.label,onMouseEnter:()=>pu(e.to),onFocus:()=>pu(e.to),onClick:()=>{y(!1),r?.()},children:[(0,$.jsx)($H,{Icon:e.Icon}),!a||n?(0,$.jsx)(`span`,{className:`truncate`,children:e.label}):null]},e.id)},U=s===`/personal`?`page`:void 0,re;t[1]!==a||t[2]!==s?(re=Y(`relative`,QH(a,s===`/personal`)),t[1]=a,t[2]=s,t[3]=re):re=t[3];let W=h?.appearance??`loopi`,ie=h?.agentId,G;t[4]!==W||t[5]!==ie?(G=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,"aria-hidden":!0,children:(0,$.jsx)(Uu,{appearance:W,agentId:ie,className:`size-5`})}),t[4]=W,t[5]=ie,t[6]=G):G=t[6];let K;t[7]!==a||t[8]!==g?(K=!a&&(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),t[7]=a,t[8]=g,t[9]=K):K=t[9];let q;t[10]!==a||t[11]!==c||t[12]!==_?(q=_>0&&(0,$.jsx)(`span`,{"aria-label":c===`zh`?`${_} 条未读消息`:`${_} unread messages`,className:Y(`shrink-0 rounded-full bg-accent/15 px-1.5 text-center text-[10px] font-semibold leading-5 tabular-nums text-accent`,a?`absolute right-0 top-0 min-w-4 leading-4`:`min-w-5`),children:Re(_)}),t[10]=a,t[11]=c,t[12]=_,t[13]=q):q=t[13];let oe;t[14]!==g||t[15]!==r||t[16]!==K||t[17]!==q||t[18]!==U||t[19]!==re||t[20]!==G?(oe=(0,$.jsxs)(b,{to:`/personal`,"aria-current":U,className:re,title:g,onMouseEnter:rU,onFocus:nU,onClick:r,children:[G,K,q]}),t[14]=g,t[15]=r,t[16]=K,t[17]=q,t[18]=U,t[19]=re,t[20]=G,t[21]=oe):oe=t[21];let se=s===`/space`?`page`:void 0,ce=s===`/space`,le;t[22]!==a||t[23]!==ce?(le=QH(a,ce),t[22]=a,t[23]=ce,t[24]=le):le=t[24];let ue;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)($H,{Icon:ae}),t[25]=ue):ue=t[25];let de;t[26]===a?de=t[27]:(de=a?null:(0,$.jsx)(`span`,{className:`truncate`,children:`Space`}),t[26]=a,t[27]=de);let J;t[28]!==r||t[29]!==se||t[30]!==le||t[31]!==de?(J=(0,$.jsxs)(b,{to:`/space`,"aria-current":se,className:le,title:`Space`,"aria-label":`Space`,onClick:r,children:[ue,de]}),t[28]=r,t[29]=se,t[30]=le,t[31]=de,t[32]=J):J=t[32];let fe=I.map(e=>ne(e)),pe=L.length>0?(0,$.jsxs)(ol,{open:v,onOpenChange:y,children:[(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onDragOver:e=>{C&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,E({id:`more`,after:!1}),y(!0))},onDragLeave:()=>E(null),onDrop:e=>te(e),"aria-label":l.sidebar.moreAppsAria,title:l.sidebar.moreApps,className:Y(`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`,a?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2.5 text-left md:py-1.5`,T?.id===`more`&&`ring-2 ring-accent`,v||B?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(mi,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),a?null:(0,$.jsx)(`span`,{className:`truncate`,children:l.sidebar.moreApps})]})}),(0,$.jsx)(il,{children:(0,$.jsx)(al,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:`z-50 max-h-[min(32rem,var(--radix-popover-content-available-height))] min-w-[14rem] max-w-[20rem] overflow-y-auto rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,onOpenAutoFocus:tU,children:(0,$.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":l.sidebar.moreAppsAria,children:[R.map(e=>ne(e,!0)),z.length>0?(0,$.jsxs)(`section`,{"aria-labelledby":`sidebar-more-extension-apps`,children:[(0,$.jsx)(`div`,{id:`sidebar-more-extension-apps`,className:`px-2 pb-1 pt-1.5 text-[11px] font-semibold tracking-wide text-fg-subtle`,children:l.sidebar.extensionAppsHeading}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:z.map(e=>ne(e,!0))})]}):null]})})})]}):null,me;return t[33]!==oe||t[34]!==J||t[35]!==fe||t[36]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[oe,J,fe,pe]}),t[33]=oe,t[34]=J,t[35]=fe,t[36]=pe,t[37]=me):me=t[37],me}function tU(e){return e.preventDefault()}function nU(){return pu(`/personal`)}function rU(){return pu(`/personal`)}function iU(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY>=t.top+t.height/2}function aU(e){return e.active}function oU(e){return e.id.startsWith(`ext:`)}function sU(e){return!e.id.startsWith(`ext:`)}function cU(e){return[e.id,e]}function lU(e){return e.showInNav}function uU(e){return e.setOrder}function dU(e){return e.order}function fU(e){return e.language}async function pU(){let e=[];for(let t=0;;){let n=await Es({limit:100,offset:t,sortBy:`name`,sortOrder:`asc`});if(e.push(...n.items),t+=n.items.length,!n.items.length||t>=n.total)return e}}var mU=`text-xs font-normal leading-5 text-fg-subtle`;function hU(e){let t=(0,Q.c)(17),{label:n,createLabel:r,onCreate:i,disabled:a,current:o,className:s}=e,c;t[0]===s?c=t[1]:(c=Y(`flex items-center justify-between px-4 pb-0.5`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,$.jsx)(`h2`,{className:mU,children:n}),t[2]=n,t[3]=l);let u=o&&`bg-surface-active text-fg`,d;t[4]===u?d=t[5]:(d=Y(`size-7 shrink-0 rounded-md p-0`,u),t[4]=u,t[5]=d);let f=o?`page`:void 0,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[6]=p):p=t[6];let m;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==d||t[11]!==f?(m=(0,$.jsx)(X,{variant:`ghost`,className:d,"aria-label":r,"aria-current":f,title:r,disabled:a,onClick:i,children:p}),t[7]=r,t[8]=a,t[9]=i,t[10]=d,t[11]=f,t[12]=m):m=t[12];let h;return t[13]!==c||t[14]!==l||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:c,children:[l,m]}),t[13]=c,t[14]=l,t[15]=m,t[16]=h):h=t[16],h}async function gU(e,t){for(let n=0;;n+=20){let r=await zs({agentId:e,sources:[`workbench`],purposes:[`chat`],activity:`manual`,excludeArchived:!0,rootConversationsOnly:!0,limit:20,offset:n}),i=r.items.find(e=>e.customData?.agentSetup!==!0&&!t.has(e.key));if(i||!r.hasMore)return i}}function _U({agents:e,defaultAgentId:t,activeConversationId:n,onNavigate:r}){let{sidebar:i,agentsSettings:a}=F(D(e=>e.language)),o=x(),{key:s,pathname:c,search:l}=m(),u=!!(n||c===`/chat/new`)&&new URLSearchParams(l).get(`agentSetup`)===`1`,{data:d}=le(n),f=u||d?.agentSetup?void 0:d?.agentId,{mutate:p}=hc(),h=E(e=>e.conversationId),[g,_]=(0,Z.useState)(),[v,y]=(0,Z.useState)(),b=(0,Z.useRef)(null),S=(0,Z.useRef)(new Set);(0,Z.useLayoutEffect)(()=>(_(void 0),y(void 0),()=>{b.current=null}),[s,h]);let C=e.filter(({id:e,purpose:t})=>e!==`main`&&e!==`task-router`&&!Ju(e)&&t!==`task_dispatcher`);async function w(e,t=!1){if(b.current)return;let i={};b.current=i,_(e),y(void 0);try{let a,s=null,c=!1;if(!t){n&&u&&S.current.add(n);let[t,r]=await Promise.all([gU(e,S.current),sc(e,S.current).catch(()=>void 0)]);r&&(!t||Date.parse(r.createdAt)>Date.parse(t.updatedAt))?a=r.conversationId:t&&(a=t.key,s=t.projectId??null)}if(b.current!==i)return;if(!a){let t=fc(pc(),e),n=await new ic().createSession({agentId:e,projectId:null,initialAgentConfig:t?{model:t.modelRef,thinkingLevel:t.thinkingLevel}:void 0});if(b.current!==i)return;a=n.key,c=!0,Ws.getState().setCommittedSnapshot(a,{messages:[],hasMore:!1,name:null})}if(a===n){r?.();return}p(Pt(h,a),{agentId:e,projectId:s},{revalidate:!1});let l=`/chat/${encodeURIComponent(a)}`;c?ju(o,l,void 0,r):(r?.(),o(l))}catch{b.current===i&&y(e)}finally{b.current===i&&(b.current=null,_(void 0))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hU,{label:i.sessionViewExperts,createLabel:i.createExpert,current:u,className:`px-2`,disabled:g!==void 0,onCreate:()=>ju(o,Ku(),{state:{forceNewChat:!0,agentId:t}},r)}),C.length===0?(0,$.jsx)(`p`,{className:`px-2 py-3 text-xs text-fg-muted`,children:i.expertsEmpty}):null,(0,$.jsx)(`ul`,{className:`space-y-0.5`,"aria-label":i.sessionViewExperts,children:C.map(e=>{let t=qu(e,a),n=Yu(e,a),r=i.expertNewConversation.replace(`{{name}}`,t),o=e.id===f;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:Y(`group relative flex min-w-0 items-center rounded-lg transition-colors duration-200 ease-out`,o?`bg-accent-soft before:pointer-events-none before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-accent`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg py-1.5 pl-2 pr-9 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait`,disabled:g!==void 0,"aria-busy":g===e.id,"aria-current":o?`page`:void 0,onClick:()=>void w(e.id),children:[(0,$.jsx)(Hu,{agentId:e.id,avatar:e.avatar,size:24,className:`size-6 shrink-0`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:t}),n?(0,$.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:n,children:n}):null]})]}),(0,$.jsx)(`div`,{className:Y(`absolute inset-y-0 right-1 z-10 flex items-center transition-opacity`,g!==e.id&&`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100`),children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(e.id,!0),disabled:g!==void 0,"aria-label":r,title:r,className:`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`,children:g===e.id?(0,$.jsx)(_a,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(Fa,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})]}),v===e.id?(0,$.jsx)(`p`,{role:`alert`,className:`px-2 py-1 text-xs text-fg-muted`,children:i.expertConversationError}):null]},e.id)})})]})}function vU(e,t){if(!e||typeof e!=`object`)return!0;let n=e.key??e.conversationId;return typeof n!=`string`||!n.trim()||!t.has(n)}var yU=(0,Z.createContext)({}),bU=(0,Z.memo)(function(e){let t=(0,Q.c)(27),{child:n,activeTaskId:r,onNavigate:i,sb:a}=e,o=m(),s;t[0]===n.activeConversationId?s=t[1]:(s=e=>n.activeConversationId?e.runs[n.activeConversationId]:void 0,t[0]=n.activeConversationId,t[1]=s);let c=Ce(s),l;t[2]!==n.activeConversationId||t[3]!==n.taskId||t[4]!==o?(l=n.activeConversationId?`/chat/task/${encodeURIComponent(n.taskId)}`:xa(`${o.pathname}${o.search}`,n.taskId),t[2]=n.activeConversationId,t[3]=n.taskId,t[4]=o,t[5]=l):l=t[5];let u=r===n.taskId&&`bg-surface-active text-fg`,d;t[6]===u?d=t[7]:(d=Y(`ml-8 flex min-h-8 items-center gap-2 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,u),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i?.(),t[8]=i,t[9]=f);let p;t[10]!==c||t[11]!==a?(p=c?.unread?(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":c.status===`failed`?a.taskSessionAgentFailed:a.taskSessionAgentCompleted}):null,t[10]=c,t[11]=a,t[12]=p):p=t[12];let h;t[13]===n.title?h=t[14]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[13]=n.title,t[14]=h);let g=n.runStatus??n.phase,_;t[15]!==a||t[16]!==g?(_=RU(g,a),t[15]=a,t[16]=g,t[17]=_):_=t[17];let v;t[18]===_?v=t[19]:(v=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:_}),t[18]=_,t[19]=v);let y;return t[20]!==v||t[21]!==l||t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==h?(y=(0,$.jsxs)(b,{to:l,className:d,onClick:f,children:[p,h,v]}),t[20]=v,t[21]=l,t[22]=d,t[23]=f,t[24]=p,t[25]=h,t[26]=y):y=t[26],y});function xU(e){return Vs(e).source!==`automation`}var SU=20,CU=12,wU=5,TU=60,EU=`application/x-xopc-sidebar-item`,DU=[`recent`,`projects`,`experts`],OU=`xopc-web-sidebar-session-view`,kU=`xopc-web-sidebar-session-view-order`;function AU(){try{let e=JSON.parse(globalThis.localStorage?.getItem(kU)??`null`);if(Array.isArray(e)){let t=[...new Set(e)].filter(e=>DU.some(t=>t===e));return[...t,...DU.filter(e=>!t.includes(e))]}}catch{}return[...DU]}function jU(){try{let e=globalThis.localStorage?.getItem(OU);return e===`projects`||e===`experts`?e:`recent`}catch{return`recent`}}function MU(e,t,n,r){let i=e.filter(e=>e!==t),a=i.indexOf(n);return a<0?e:(i.splice(a+ +!!r,0,t),i)}function NU(e,t,n){if(!t?.length)return e;let r=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({item:e,index:t,rank:r.get(n(e))})).sort((e,t)=>e.rank!==void 0&&t.rank!==void 0?e.rank-t.rank:e.rank===void 0?t.rank===void 0?e.index-t.index:-1:1).map(({item:e})=>e)}function PU({spec:e,children:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return e?(0,$.jsxs)(`div`,{draggable:!0,className:Y(`relative cursor-grab transition-[opacity,transform] duration-200 ease-out active:cursor-grabbing`,n&&`opacity-50`),onDragStart:t=>{r(!0),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(EU,JSON.stringify({containerId:e.containerId,itemId:e.itemId}))},onDragEnd:()=>{r(!1),a(null)},onDragOver:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();a(e.clientY>=t.top+t.height/2?`after`:`before`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(null)},onDrop:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>=n.top+n.height/2;a(null);try{let n=JSON.parse(t.dataTransfer.getData(EU));if(n.containerId!==e.containerId||n.itemId===e.itemId)return;e.onReorder(e.containerId,MU(e.itemIds,n.itemId,e.itemId,r))}catch{}},children:[i===`before`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 top-0 z-30 h-0.5 rounded-full bg-accent`}):null,t,i===`after`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 bottom-0 z-30 h-0.5 rounded-full bg-accent`}):null]}):t}function FU(e,t){return e.name?.trim()||t}function IU(e){let t=/^\/chat\/([^/]+)$/.exec(e);if(!t)return;let n=decodeURIComponent(t[1]);if(n!==`new`)return n}function LU(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function RU(e,t){return e===`running`||e===`active`||e===`verifying`?t.delegatedTaskRunning:e===`completed`||e===`succeeded`||e===`closed`?t.delegatedTaskCompleted:e===`failed`?t.delegatedTaskFailed:e===`backlog`||e===`ready`||e===`queued`||e===`waiting`?t.delegatedTaskWaiting:e}function zU(e){let t=new Date(e.updatedAt).getTime();return Number.isFinite(t)?t:0}function BU(e){let t=new Date;t.setHours(0,0,0,0);let n=new Date(t);n.setDate(n.getDate()-1);let r={today:[],yesterday:[],older:[]};for(let i of e){let e=zU(i);r[e>=t.getTime()?`today`:e>=n.getTime()?`yesterday`:`older`].push(i)}return r}function VU(e){return Y(`group relative flex min-h-8 w-full min-w-0 items-center rounded-lg pr-1 text-left text-sm leading-5 transition-colors duration-200 ease-out`,`pl-6`,`focus-within:outline-none`,e?`bg-accent-soft font-medium text-fg before:pointer-events-none before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-accent`:`font-normal text-fg-muted hover:bg-surface-hover hover:text-fg`)}var HU=Y(mU,`transition-colors hover:text-fg-muted`);function UU(e){let t=(0,Q.c)(5),{indented:n}=e,r=n!==void 0&&n&&`pl-6`,i;t[0]===r?i=t[1]:(i=Y(`flex items-center gap-2 p-1.5`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(ps,{className:`h-3 w-4/5 animate-none`}),(0,$.jsx)(ps,{className:`mt-1.5 h-2.5 w-2/5 animate-none`})]}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`div`,{className:i,children:a}),t[3]=i,t[4]=o),o}function WU(){let e=(0,Q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-14 animate-none`}),(0,$.jsx)(UU,{})]}),n=(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-16 animate-none`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-4`,"aria-busy":`true`,children:[t,(0,$.jsxs)(`div`,{children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(UU,{}),(0,$.jsx)(UU,{indented:!0}),(0,$.jsx)(UU,{indented:!0})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ps,{className:`mb-1.5 h-2.5 w-12 animate-none`}),(0,$.jsx)(UU,{}),(0,$.jsx)(UU,{})]})]}),e[2]=r):r=e[2],r}var GU=(0,Z.memo)(function({session:e,isActive:t,onNavigate:n,mutate:r,onRequestRename:i,onRequestDelete:a,sb:o,sess:s,clipboard:c,defaultUnnamedTitle:l,contextLabel:u,sort:d}){let f=(0,Z.useContext)(yU)[e.key],p=m(),h=D(e=>e.language),g=Bs(e)?e.customData?.automationSetup:void 0,_=typeof g?.automationId==`string`&&g.automationId.trim()?g.automationId:void 0,v=new URLSearchParams(p.search),y=p.pathname===`/automations`&&v.get(`automation`)===_?v.get(`run`)??void 0:void 0,{data:x}=gc(_?[`sidebar-automation-history`,_,e.projectId??``]:null,()=>Wu.runs(1,_,{projectId:e.projectId}),{refreshInterval:15e3,revalidateOnFocus:!0}),S=!!(f?.items.length||x?.runs.length||y),C=/^\/chat\/task\/([^/]+)$/.exec(p.pathname)?.[1],w=!!y||(f?.items.some(e=>e.taskId===C||e.activeConversationId===IU(p.pathname))??!1),[T,E]=(0,Z.useState)(w);(0,Z.useEffect)(()=>{w&&E(!0)},[w]);let O=Vs(e),k=Bs(e)||O.source!==`workbench`||O.purpose!==`chat`,A=K(e,o.sessionFilters),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F=Me(e.key),I=Ce(t=>t.runs[e.key]),L=FU(e,l),R=e.status===`pinned`,z=F||!!I?.unread,B=async()=>{if(!N){P(!0);try{R?await Rs(e.key):await Ns(e.key),M(!1),r()}catch{}finally{P(!1)}}},V=async()=>{let t=await pl(e.key);if(M(!1),t){Ml(`success`,o.taskChatIdCopied,void 0,{duration:2e3});return}Ml(`warning`,c.copyFailed,void 0,{duration:4e3})};return(0,$.jsx)(PU,{spec:d,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:VU(t),children:[S?(0,$.jsx)(`button`,{type:`button`,className:`absolute left-0 flex size-6 items-center justify-center text-fg-subtle hover:text-fg`,"aria-label":_?T?o.automationRunsCollapse:o.automationRunsExpand:T?o.delegatedTasksCollapse:o.delegatedTasksExpand,"aria-expanded":T,onClick:()=>E(e=>!e),children:(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform`,!T&&`-rotate-90`),"aria-hidden":!0})}):null,(0,$.jsxs)(b,{to:`/chat/${encodeURIComponent(e.key)}`,className:Y(`min-w-0 flex-1 self-stretch rounded-lg py-1 outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`flex min-w-0 items-center gap-2`,z?`pr-[4.75rem]`:`pr-12`),title:[L,A,u].filter(Boolean).join(` — `),"aria-label":[L,A,u].filter(Boolean).join(` — `),"aria-current":t?`page`:void 0,onClick:()=>n?.(),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),i(e)},children:[k?(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,title:A,children:(0,$.jsx)(Hs,{sourceChannel:e.sourceChannel,session:e,className:`size-3.5`})}):null,(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L})]}),F?(0,$.jsxs)(`span`,{className:`pointer-events-none absolute right-2 top-1/2 z-10 flex size-2.5 -translate-y-1/2 items-center justify-center`,title:o.taskSessionAgentRunning,"aria-label":o.taskSessionAgentRunning,children:[(0,$.jsx)(`span`,{className:`absolute size-full animate-ping rounded-full bg-accent/70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative size-2 rounded-full bg-accent`,"aria-hidden":!0})]}):I?.unread?(0,$.jsx)(`span`,{className:Y(`pointer-events-none absolute right-2 top-1/2 z-10 size-2.5 -translate-y-1/2 rounded-full`,I.status===`failed`?`bg-red-500`:`bg-emerald-500`),title:I.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted,"aria-label":I.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted}):null,(0,$.jsxs)(`div`,{className:Y(`pointer-events-none absolute inset-y-0 z-10 flex items-center opacity-0 transition-opacity`,`group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,`[@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100`,z?`right-7`:`right-1`,(j||N)&&`pointer-events-auto opacity-100`),children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`,`disabled:cursor-wait`),"aria-label":R?s.unpin:s.pin,title:R?s.unpin:s.pin,"aria-pressed":R,disabled:N,onClick:()=>void B(),children:N?(0,$.jsx)(_a,{className:`size-4 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(mo,{className:`size-4 rotate-45`,fill:R?`currentColor`:`none`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(ol,{open:j,onOpenChange:M,children:[(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg 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`),"aria-label":o.taskSessionMenuAria,title:o.taskSessionMenuAria,"aria-expanded":j,children:(0,$.jsx)(mi,{className:`size-4`,strokeWidth:2,"aria-hidden":!0})})}),(0,$.jsx)(il,{children:(0,$.jsxs)(al,{className:`z-50 w-[9.25rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>{M(!1),i(e)},children:[(0,$.jsx)(io,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskRename]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>void V(),children:[(0,$.jsx)(Gr,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskCopyChatId]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:()=>{M(!1),a(e.key)},children:[(0,$.jsx)(ts,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskDeleteTask]})]})})]})]})]}),T&&f?.items.map(e=>(0,$.jsx)(bU,{child:e,activeTaskId:C,onNavigate:n,sb:o},e.taskId)),T&&_?(0,$.jsx)(gr,{automationId:_,projectId:e.projectId,language:h,selectedRunId:y,runHref:t=>{let n=new URLSearchParams({automation:_,view:`execution`,run:t.id});return e.projectId&&n.set(`projectId`,e.projectId),`/automations?${n}`},onSelectRun:()=>n?.()}):null]})})});function KU(e){let t=(0,Q.c)(77),{project:n,onNavigate:r,onPinToggle:i,onRequestRename:a,onArchive:o,onRequestRemove:s,sb:c}=e,[l,u]=(0,Z.useState)(!1),d;t[0]!==n.effectiveWorkspaceRoot||t[1]!==n.workspaceRoot?(d=n.effectiveWorkspaceRoot?.trim()||n.workspaceRoot?.trim()||``,t[0]=n.effectiveWorkspaceRoot,t[1]=n.workspaceRoot,t[2]=d):d=t[2];let f=d,p=!!(f&&window.electronAPI?.shell?.openPath),m=!!n.pinnedAt,h;t[3]!==c.projectOpenInExplorerFailed||t[4]!==c.projectOpenInExplorerUnavailable||t[5]!==f?(h=async()=>{if(!f||!window.electronAPI?.shell?.openPath){Ml(`warning`,c.projectOpenInExplorerUnavailable,void 0,{duration:3500}),u(!1);return}let e=await window.electronAPI.shell.openPath(f);u(!1),e.ok===!1&&Ml(`warning`,e.error||c.projectOpenInExplorerFailed,void 0,{duration:4e3})},t[3]=c.projectOpenInExplorerFailed,t[4]=c.projectOpenInExplorerUnavailable,t[5]=f,t[6]=h):h=t[6];let g=h,_=l&&`opacity-100`,v;t[7]===_?v=t[8]:(v=Y(`relative z-10 flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,_,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[7]=_,t[8]=v);let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(mi,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=y):y=t[9];let x;t[10]!==l||t[11]!==c.projectMenuAria||t[12]!==v?(x=(0,$.jsx)(sl,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v,"aria-label":c.projectMenuAria,title:c.projectMenuAria,"aria-expanded":l,children:y})}),t[10]=l,t[11]=c.projectMenuAria,t[12]=v,t[13]=x):x=t[13];let S=`/projects/${encodeURIComponent(n.id)}`,C;t[14]===r?C=t[15]:(C=()=>{u(!1),r?.()},t[14]=r,t[15]=C);let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(hi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]!==c.projectOpen||t[18]!==S||t[19]!==C?(T=(0,$.jsxs)(b,{to:S,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:C,children:[w,c.projectOpen]}),t[17]=c.projectOpen,t[18]=S,t[19]=C,t[20]=T):T=t[20];let E;t[21]===n.workspaceRoot?E=t[22]:(E=n.workspaceRoot?.trim(),t[21]=n.workspaceRoot,t[22]=E);let D=!!E,O;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>u(!1),t[23]=O):O=t[23];let k;t[24]!==n.id||t[25]!==D?(k=(0,$.jsx)(Zu,{hasProjectFolder:D,projectId:n.id,onStarted:O,className:`flex w-full rounded-md px-2 py-1.5 text-left text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`}),t[24]=n.id,t[25]=D,t[26]=k):k=t[26];let A;t[27]!==i||t[28]!==n?(A=()=>{u(!1),i(n)},t[27]=i,t[28]=n,t[29]=A):A=t[29];let j;t[30]===m?j=t[31]:(j=m?(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(mo,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[30]=m,t[31]=j);let M=m?c.projectUnpin:c.projectPin,N;t[32]!==A||t[33]!==j||t[34]!==M?(N=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:A,children:[j,M]}),t[32]=A,t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]===g?P=t[37]:(P=()=>void g(),t[36]=g,t[37]=P);let F=!p,I=p?void 0:c.projectOpenInExplorerUnavailable,L;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Vi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[38]=L):L=t[38];let R;t[39]!==c.projectOpenInExplorer||t[40]!==P||t[41]!==F||t[42]!==I?(R=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:text-fg-subtle disabled:hover:bg-transparent`,onClick:P,disabled:F,title:I,children:[L,c.projectOpenInExplorer]}),t[39]=c.projectOpenInExplorer,t[40]=P,t[41]=F,t[42]=I,t[43]=R):R=t[43];let z;t[44]!==a||t[45]!==n?(z=()=>{u(!1),a(n)},t[44]=a,t[45]=n,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(io,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[47]=B):B=t[47];let V;t[48]!==c.projectRename||t[49]!==z?(V=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:z,children:[B,c.projectRename]}),t[48]=c.projectRename,t[49]=z,t[50]=V):V=t[50];let H;t[51]!==o||t[52]!==n?(H=()=>{u(!1),o(n)},t[51]=o,t[52]=n,t[53]=H):H=t[53];let ee;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ae,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[54]=ee):ee=t[54];let te;t[55]!==c.projectArchive||t[56]!==H?(te=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:H,children:[ee,c.projectArchive]}),t[55]=c.projectArchive,t[56]=H,t[57]=te):te=t[57];let ne;t[58]!==s||t[59]!==n?(ne=()=>{u(!1),s(n)},t[58]=s,t[59]=n,t[60]=ne):ne=t[60];let U;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ts,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[61]=U):U=t[61];let re;t[62]!==c.projectRemove||t[63]!==ne?(re=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:ne,children:[U,c.projectRemove]}),t[62]=c.projectRemove,t[63]=ne,t[64]=re):re=t[64];let W;t[65]!==T||t[66]!==k||t[67]!==N||t[68]!==R||t[69]!==V||t[70]!==te||t[71]!==re?(W=(0,$.jsx)(il,{children:(0,$.jsxs)(al,{className:`z-50 w-[12rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:qU,children:[T,k,N,R,V,te,re]})}),t[65]=T,t[66]=k,t[67]=N,t[68]=R,t[69]=V,t[70]=te,t[71]=re,t[72]=W):W=t[72];let ie;return t[73]!==l||t[74]!==W||t[75]!==x?(ie=(0,$.jsxs)(ol,{open:l,onOpenChange:u,children:[x,W]}),t[73]=l,t[74]=W,t[75]=x,t[76]=ie):ie=t[76],ie}function qU(e){return e.preventDefault()}function JU(e){let t=(0,Q.c)(70),{group:n,isExpanded:r,isCollapsed:i,activeConversationId:a,onToggleExpanded:o,onToggleCollapsed:s,onCreateProjectChat:c,onToggleProjectPin:l,onRequestProjectRename:u,onArchiveProject:d,onRequestProjectRemove:f,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,excludedConversationIds:x,projectSort:S,onReorder:C}=e,w;t[0]!==x||t[1]!==n.sessions?(w=x?n.sessions.filter(e=>!x.has(e.key)):n.sessions,t[0]=x,t[1]=n.sessions,t[2]=w):w=t[2];let T=w,E;t[3]!==r||t[4]!==T?(E=r?T:T.slice(0,wU),t[3]=r,t[4]=T,t[5]=E):E=t[5];let D=E,O=T.length>wU,k=n.sessionHasMore||O,A=r&&!n.sessionHasMore&&O,j;t[6]===a?j=t[7]:(j=e=>e.key===a,t[6]=a,t[7]=j);let M=T.some(j),N=n.project.name,P=M?`text-fg`:`text-fg-muted`,F;t[8]===P?F=t[9]:(F=Y(`group flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium leading-5`,P),t[8]=P,t[9]=F);let I;t[10]!==n.project.id||t[11]!==s?(I=()=>s(n.project.id),t[10]=n.project.id,t[11]=s,t[12]=I):I=t[12];let L=!i,R;t[13]===i?R=t[14]:(R=i?(0,$.jsx)(Hi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=i,t[14]=R);let z;t[15]===n.project.name?z=t[16]:(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.project.name}),t[15]=n.project.name,t[16]=z);let B;t[17]!==n.project.name||t[18]!==z||t[19]!==I||t[20]!==L||t[21]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 min-w-0 flex-1 items-center gap-1 text-left 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`,onClick:I,title:n.project.name,"aria-expanded":L,children:[R,z]}),t[17]=n.project.name,t[18]=z,t[19]=I,t[20]=L,t[21]=R,t[22]=B):B=t[22];let V;t[23]!==n.project||t[24]!==d||t[25]!==p||t[26]!==f||t[27]!==u||t[28]!==l||t[29]!==_?(V=(0,$.jsx)(KU,{project:n.project,onNavigate:p,onPinToggle:l,onRequestRename:u,onArchive:d,onRequestRemove:f,sb:_}),t[23]=n.project,t[24]=d,t[25]=p,t[26]=f,t[27]=u,t[28]=l,t[29]=_,t[30]=V):V=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[31]=H):H=t[31];let ee;t[32]!==n.project||t[33]!==c?(ee=()=>c(n.project),t[32]=n.project,t[33]=c,t[34]=ee):ee=t[34];let te;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=te):te=t[35];let ne;t[36]!==_.projectNewChat||t[37]!==ee?(ne=(0,$.jsx)(`button`,{type:`button`,className:H,onClick:ee,title:_.projectNewChat,"aria-label":_.projectNewChat,children:te}),t[36]=_.projectNewChat,t[37]=ee,t[38]=ne):ne=t[38];let U;t[39]!==B||t[40]!==V||t[41]!==ne||t[42]!==F?(U=(0,$.jsxs)(`div`,{className:F,children:[B,V,ne]}),t[39]=B,t[40]=V,t[41]=ne,t[42]=F,t[43]=U):U=t[43];let re;t[44]!==a||t[45]!==k||t[46]!==y||t[47]!==b||t[48]!==n.project.id||t[49]!==n.sessionLoading||t[50]!==i||t[51]!==m||t[52]!==p||t[53]!==C||t[54]!==g||t[55]!==h||t[56]!==o||t[57]!==_||t[58]!==v||t[59]!==A||t[60]!==T||t[61]!==D?(re=i?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D.map(e=>(0,$.jsx)(GU,{session:e,isActive:a===e.key,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,sort:{containerId:`project:${n.project.id}`,itemId:e.key,itemIds:T.map(YU),onReorder:C}},e.key)),k?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:()=>o(n.project.id),disabled:n.sessionLoading,"aria-busy":n.sessionLoading||void 0,children:[n.sessionLoading?(0,$.jsx)(_a,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,A&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),A?_.projectShowLess:_.projectShowMore]}):null]}),t[44]=a,t[45]=k,t[46]=y,t[47]=b,t[48]=n.project.id,t[49]=n.sessionLoading,t[50]=i,t[51]=m,t[52]=p,t[53]=C,t[54]=g,t[55]=h,t[56]=o,t[57]=_,t[58]=v,t[59]=A,t[60]=T,t[61]=D,t[62]=re):re=t[62];let W;t[63]!==n.project.name||t[64]!==U||t[65]!==re?(W=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":N,children:[U,re]}),t[63]=n.project.name,t[64]=U,t[65]=re,t[66]=W):W=t[66];let ie;return t[67]!==S||t[68]!==W?(ie=(0,$.jsx)(PU,{spec:S,children:W}),t[67]=S,t[68]=W,t[69]=ie):ie=t[69],ie}function YU(e){return e.key}function XU(e){let t=(0,Q.c)(49),{sessions:n,hasMore:r,loadingMore:i,isCollapsed:a,onToggleCollapsed:o,onCreateChat:s,onLoadMore:c,activeConversationId:l,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,excludedConversationIds:v,onReorder:y,sortable:b}=e,x=b===void 0||b,S;t[0]!==v||t[1]!==n?(S=v?n.filter(e=>!v.has(e.key)):n,t[0]=v,t[1]=n,t[2]=S):S=t[2];let C=S;if(C.length===0&&!r)return null;let w=m.inboxHeading,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=Y(`flex min-w-0 flex-1 items-center gap-1 px-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,HU),t[3]=T):T=t[3];let E=!a,D=m.inboxHeading,O=a&&`-rotate-90`,k;t[4]===O?k=t[5]:(k=Y(`size-3.5 transition-transform duration-150 ease-out`,O),t[4]=O,t[5]=k);let A;t[6]===k?A=t[7]:(A=(0,$.jsx)(vr,{className:k,strokeWidth:1.75,"aria-hidden":!0}),t[6]=k,t[7]=A);let j;t[8]!==o||t[9]!==m.inboxHeading||t[10]!==E||t[11]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:T,onClick:o,"aria-expanded":E,children:[D,A]}),t[8]=o,t[9]=m.inboxHeading,t[10]=E,t[11]=A,t[12]=j):j=t[12];let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(yo,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==s?(P=(0,$.jsx)(`button`,{type:`button`,className:M,onClick:s,title:_,"aria-label":_,children:N}),t[15]=_,t[16]=s,t[17]=P):P=t[17];let F;t[18]!==j||t[19]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center pb-1`,children:[j,P]}),t[18]=j,t[19]=P,t[20]=F):F=t[20];let I=a&&`hidden`,L;t[21]===I?L=t[22]:(L=Y(`flex flex-col gap-0.5`,I),t[21]=I,t[22]=L);let R;t[23]!==l||t[24]!==g||t[25]!==_||t[26]!==d||t[27]!==u||t[28]!==y||t[29]!==p||t[30]!==f||t[31]!==m||t[32]!==h||t[33]!==x||t[34]!==C?(R=C.map(e=>(0,$.jsx)(GU,{session:e,isActive:l===e.key,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,sort:x?{containerId:`inbox`,itemId:e.key,itemIds:C.map(ZU),onReorder:y}:void 0},e.key)),t[23]=l,t[24]=g,t[25]=_,t[26]=d,t[27]=u,t[28]=y,t[29]=p,t[30]=f,t[31]=m,t[32]=h,t[33]=x,t[34]=C,t[35]=R):R=t[35];let z;t[36]!==r||t[37]!==i||t[38]!==c||t[39]!==m.projectShowMore?(z=r?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:c,disabled:i,"aria-busy":i||void 0,children:[i?(0,$.jsx)(_a,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(vr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),m.projectShowMore]}):null,t[36]=r,t[37]=i,t[38]=c,t[39]=m.projectShowMore,t[40]=z):z=t[40];let B;t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;return t[45]!==m.inboxHeading||t[46]!==F||t[47]!==B?(V=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":w,children:[F,B]}),t[45]=m.inboxHeading,t[46]=F,t[47]=B,t[48]=V):V=t[48],V}function ZU(e){return e.key}function QU(e){let t=(0,Q.c)(22),{sessions:n,activeConversationId:r,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,onReorder:f,projectNames:p}=e;if(n.length===0)return null;let m=l.pinnedSessions,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`px-2 pb-1`,mU),t[0]=h):h=t[0];let g;t[1]===l.pinnedSessions?g=t[2]:(g=(0,$.jsx)(`h2`,{className:h,children:l.pinnedSessions}),t[1]=l.pinnedSessions,t[2]=g);let _;t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==s||t[10]!==o||t[11]!==p||t[12]!==c||t[13]!==l||t[14]!==n?(_=n.map(e=>(0,$.jsx)(GU,{session:e,contextLabel:e.projectId?p?.get(e.projectId):void 0,isActive:r===e.key,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,sort:{containerId:`pinned`,itemId:e.key,itemIds:n.map($U),onReorder:f}},e.key)),t[3]=r,t[4]=u,t[5]=d,t[6]=a,t[7]=i,t[8]=f,t[9]=s,t[10]=o,t[11]=p,t[12]=c,t[13]=l,t[14]=n,t[15]=_):_=t[15];let v;t[16]===_?v=t[17]:(v=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_}),t[16]=_,t[17]=v);let y;return t[18]!==l.pinnedSessions||t[19]!==g||t[20]!==v?(y=(0,$.jsxs)(`section`,{className:`mb-3 flex flex-col gap-0.5`,"aria-label":m,children:[g,v]}),t[18]=l.pinnedSessions,t[19]=g,t[20]=v,t[21]=y):y=t[21],y}function $U(e){return e.key}function eW(e){let t=(0,Q.c)(4),{onNavigate:n,scrollHeader:r}=e,i=E(tW),a;return t[0]!==i||t[1]!==n||t[2]!==r?(a=(0,$.jsx)(nW,{gateway:i,onNavigate:n,scrollHeader:r},i),t[0]=i,t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function tW(e){return e.baseUrl}function nW({onNavigate:e,gateway:t,scrollHeader:n}){let r=D(e=>e.language),i=F(r),a=i.sidebar,o=i.sessions,s=i.projectsPage,c=i.chat.workingDirectory,l=E(e=>e.conversationId),u=E(e=>e.openTokenDialog),{data:d,error:f,mutate:p}=gc(l?[`gateway-chat-agents`,l]:null,Cc,{revalidateOnFocus:!1}),h=d?.defaultId??`main`;(0,Z.useEffect)(()=>{let e=()=>void p();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[p]);let{pathname:g}=m(),_=x(),v=IU(g),y=(0,Z.useMemo)(()=>Date.now()-TU*24*60*60*1e3,[]),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(``),[T,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(!1),[z,U]=(0,Z.useState)(``),[re,W]=(0,Z.useState)(``),[ie,G]=(0,Z.useState)(null),[K,ae]=(0,Z.useState)(!1),[q,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)(()=>v),[le,ue]=(0,Z.useState)(jU),[de,J]=(0,Z.useState)(AU),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(!1),[ge,_e]=(0,Z.useState)(()=>new Set),[ve,ye]=(0,Z.useState)(()=>new Set),[be,xe]=(0,Z.useState)({}),[Se,Ce]=(0,Z.useState)({}),[we,Te]=(0,Z.useState)(()=>new Set),[Ee,De]=(0,Z.useState)([]),[Oe,ke]=(0,Z.useState)(null),[Ae,je]=(0,Z.useState)(!1),[Me,Ne]=(0,Z.useState)({}),Pe=(0,Z.useRef)(new Set),Fe=td({initialPath:re,onPicked:W}),{data:Ie,size:Le,setSize:Re,isValidating:ze,mutate:Be}=vc((e,n)=>!l||n&&!n.projects.hasMore?null:[`sidebar-chat-list`,t,l,se??``,e],async([,,,e,t])=>Fs({projectLimit:CU,projectOffset:t*CU,sessionPreviewLimit:wU,inboxLimit:t===0?SU:1,inboxOffset:0,staleDays:TU,includeConversationId:e||void 0}),{keepPreviousData:!0,revalidateOnFocus:!1}),{data:Ve,error:He,size:Ue,setSize:We,isValidating:Ge,mutate:Ke}=vc((e,n)=>!l||n&&!n.hasMore?null:[`sidebar-recent-sessions`,t,l,e],([,,,e])=>zs({limit:SU,offset:e*SU,excludeArchived:!0,rootConversationsOnly:!0,excludeAutomationRuns:!0}),{revalidateOnFocus:!1}),qe=(0,Z.useMemo)(()=>{let e=new Map;for(let t of Ve??[])for(let n of t.items)!e.has(n.key)&&n.status!==`archived`&&xU(n)&&Vs(n).source!==`system`&&e.set(n.key,n);return[...e.values()].sort((e,t)=>zU(t)-zU(e))},[Ve]),Je=(0,Z.useMemo)(()=>{let e=Ie??[],t=[],n=new Set;for(let r of e)for(let e of r.projects.items){if(n.has(e.project.id))continue;n.add(e.project.id);let r=be[e.project.id],i=(r?.sessions??e.sessions).filter(xU);t.push({project:e.project,sessions:i,sessionTotal:r?.sessionTotal??e.sessionTotal,sessionHasMore:r?.hasMore??e.sessionHasMore,sessionLoading:we.has(e.project.id)})}return NU(t.map(e=>({...e,sessions:NU(e.sessions,Me[`project:${e.project.id}`],e=>e.key)})),Me.projects,e=>e.project.id)},[Ie,we,Me,be]),Ye=(0,Z.useMemo)(()=>{let e={};for(let t of Ve??[])Object.assign(e,t.childrenByConversationId);for(let t of Ie??[])Object.assign(e,t.childrenByConversationId);return{...e,...Se}},[Ie,Se,Ve]),Xe=Ie?.[0]?.inbox,Ze=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of[...Xe?.items??[],...Ee])t.has(n.key)||!xU(n)||(t.add(n.key),e.push(n));return e.sort((e,t)=>zU(t)-zU(e)),NU(e,Me.inbox??Ie?.[0]?.layouts.inbox?.itemIds,e=>e.key)},[Ie,Xe?.items,Ee,Me.inbox]),Qe=Oe??Xe?.hasMore??!1,$e=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of Je)for(let r of n.sessions)t.has(r.key)||(t.add(r.key),e.push(r));for(let n of Ze)t.has(n.key)||(t.add(n.key),e.push(n));return e},[Ze,Je]),et=(0,Z.useMemo)(()=>new Set([...$e,...qe].map(e=>e.key)),[$e,qe]),tt=Je.length>0||Ze.length>0||Qe,nt=(0,Z.useMemo)(()=>NU((Ie?.[0]?.pinned??[]).filter(xU),Me.pinned,e=>e.key),[Ie,Me.pinned]),rt=(0,Z.useMemo)(()=>new Set(nt.map(e=>e.key)),[nt]),it=(0,Z.useMemo)(()=>new Map(Je.map(({project:e})=>[e.id,e.name])),[Je]),at=[...qe,...nt].some(({projectId:e})=>e&&!it.has(e)),{data:ot,mutate:st}=gc(l&&(Ie||!ze)&&at?[`sidebar-project-names`,t,l]:null,pU,{revalidateOnFocus:!1}),ct=(0,Z.useMemo)(()=>new Map([...ot?.map(e=>[e.id,e.name])??[],...it]),[it,ot]),lt=BU(qe.filter(e=>e.status!==`pinned`&&!rt.has(e.key))),ut=lt.older.some(e=>e.key===v);(0,Z.useEffect)(()=>{ut&&pe(!0)},[v,ut]);let dt=!!(Ie&&Le>Ie.length),ft=(Ie?.[Ie.length-1])?.projects.hasMore??!1,pt=!!(l&&!Ie&&ze),mt=(0,Z.useCallback)(()=>{xe({}),De([]),ke(null),Ce({}),Be(),Ke()},[Be,Ke]),ht=(0,Z.useCallback)((e,t)=>{if(Pe.current.has(e))return;let n=Ie?.[0]?.layouts[e]?.revision??0;Ne(n=>({...n,[e]:t})),Pe.current.add(e),(async()=>{try{await Ps({containerId:e,itemIds:t,expectedRevision:n}),await Be()}catch{Ml(`warning`,r===`zh`?`未能保存侧栏顺序,已恢复原位置`:`Could not save sidebar order; the previous order was restored`,void 0,{duration:3500})}finally{Pe.current.delete(e),Ne(t=>{let n={...t};return delete n[e],n})}})()},[Ie,r,Be]),gt=(0,Z.useCallback)(e=>{let t=e.currentTarget;if(le!==`projects`||!ft||dt)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t;r-n-i>100||Re(Le+1)},[ft,dt,Re,Le,le]);(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{mt()},t=()=>{mt(),st()},n=()=>void Ke(),r=e=>{vU(e.detail,et)&&mt()};return window.addEventListener(`session-updated`,e),window.addEventListener(`session-created`,e),window.addEventListener(`project-updated`,t),window.addEventListener(`task-updated`,e),window.addEventListener(`session-transcript-updated`,r),window.addEventListener(`run-completed`,n),window.addEventListener(`agent-run-ended`,n),()=>{window.removeEventListener(`session-updated`,e),window.removeEventListener(`session-created`,e),window.removeEventListener(`project-updated`,t),window.removeEventListener(`task-updated`,e),window.removeEventListener(`session-transcript-updated`,r),window.removeEventListener(`run-completed`,n),window.removeEventListener(`agent-run-ended`,n)}},[l,mt,st,Ke,et]),(0,Z.useEffect)(()=>{le!==`projects`||!l||!v||!Ie||$e.some(e=>e.key===v)||ce(e=>e===v?e:v)},[v,Ie,$e,l,le]);let _t=(0,Z.useCallback)(e=>{S(e.key),w(FU(e,i.chat.newSession))},[i.chat.newSession]),vt=async()=>{if(!b)return;let e=C.trim();if(e)try{await Is(b,e),S(null),mt()}catch{}},yt=async e=>{try{await Ls(e),v===e&&_(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),mt()}catch{}},bt=(0,Z.useCallback)(e=>{A(e.id),M(e.name.trim())},[]),xt=async()=>{if(!k||!At)return;let e=j.trim();if(e)try{await As(k,e,At.version),A(null),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:k}}))}catch{}},St=(0,Z.useCallback)(async e=>{try{await js(e.id,e.version),g===`/projects/${encodeURIComponent(e.id)}`&&_(`/projects`),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[_,g,mt]),Ct=(0,Z.useCallback)(async e=>{try{e.pinnedAt?await Ts(e.id,e.version):await Ds(e.id,e.version),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[mt]),wt=async e=>{let t=e.id;try{await Os(t,e.version),g===`/projects/${encodeURIComponent(t)}`&&_(`/projects`),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:t}}))}catch{}},Tt=(0,Z.useCallback)(e=>{let t=Je.find(t=>t.project.id===e);if(t){if(ve.has(e)&&!t.sessionHasMore){ye(t=>{let n=new Set(t);return n.delete(e),n});return}ye(t=>{let n=new Set(t);return n.add(e),n}),!(!t.sessionHasMore||we.has(e))&&(Te(t=>new Set(t).add(e)),(async()=>{try{let n=await zs({projectId:e,limit:5e3,offset:0,updatedAfter:y,includePinned:!0,includeConversationId:v,rootConversationsOnly:!0,excludeAutomationRuns:!0});Ce(e=>({...e,...n.childrenByConversationId})),xe(r=>{let i=r[e]?.sessions??t.sessions,a=new Set(i.map(e=>e.key)),o=[...i];for(let e of n.items)a.has(e.key)||(a.add(e.key),o.push(e));let s=NU(o,Me[`project:${e}`]??Ie?.[0]?.layouts[`project:${e}`]?.itemIds,e=>e.key);return{...r,[e]:{sessions:s,sessionTotal:n.total,hasMore:!1}}})}finally{Te(t=>{let n=new Set(t);return n.delete(e),n})}})())}},[v,Ie,ve,we,Me,Je,y]),Et=(0,Z.useCallback)(e=>{_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Dt=(0,Z.useCallback)(()=>{!Qe||Ae||(je(!0),(async()=>{try{let e=await zs({unassigned:!0,limit:5e3,offset:0,updatedAfter:y,includePinned:!0,includeConversationId:v,rootConversationsOnly:!0,excludeAutomationRuns:!0});Ce(t=>({...t,...e.childrenByConversationId})),De(t=>{let n=new Set([...Xe?.items??[],...t].map(e=>e.key)),r=[...t];for(let t of e.items)n.has(t.key)||(n.add(t.key),r.push(t));return NU(r,Me.inbox??Ie?.[0]?.layouts.inbox?.itemIds,e=>e.key)}),ke(!1)}finally{je(!1)}})())},[v,Ie,Xe?.items,Qe,Ae,Me.inbox,y]),Ot=(0,Z.useCallback)(t=>{ju(_,Gu(t.id),{state:{forceNewChat:!0,agentId:t.defaultAgentId??h}},e)},[h,_,e]),kt=(0,Z.useCallback)(async e=>{e.preventDefault();let t=z.trim(),n=re.trim();if(!(!t||K)){ae(!0),G(null);try{let e=await ks({name:t,...n?{workspaceRoot:n}:{},autoUnderstand:!!n&&q});U(``),W(``),oe(!1),L(!1),mt(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(!1)}}},[z,re,K,mt,q]),At=k?Je.find(e=>e.project.id===k)?.project:void 0,jt=N?Je.find(e=>e.project.id===N)?.project:void 0,Mt=Ve?.at(-1)?.hasMore??!1,Nt=!!(Ve&&Ue>Ve.length&&Ge),Pt={onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession},Ft=e=>{J(e);try{globalThis.localStorage?.setItem(kU,JSON.stringify(e))}catch{}},It={recent:{label:a.sessionViewRecent,icon:Yr},projects:{label:a.sessionViewProjects,icon:Hi},experts:{label:a.sessionViewExperts,icon:AR}},Lt=e=>{ue(e);try{globalThis.localStorage?.setItem(OU,e)}catch{}if(e!==`projects`||!v)return;let t=qe.find(e=>e.key===v)??$e.find(e=>e.key===v),n=t?.projectId;n?_e(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t}):t&&he(!1)},Rt=e=>(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,$.jsx)(GU,{session:e,contextLabel:e.projectId?ct.get(e.projectId):void 0,isActive:v===e.key,...Pt},e.key))}),zt=(e,t)=>t.length>0?(0,$.jsxs)(`section`,{"aria-label":e,children:[(0,$.jsx)(`h2`,{className:Y(`px-2 pb-1`,mU),children:e}),Rt(t)]}):null;return l?(0,$.jsx)(yU,{value:Ye,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,onScroll:gt,children:[n,(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(Kr,{"aria-label":a.sessionViewLabel,value:le,onChange:Lt,onReorder:Ft,flush:!0,buttonClassName:`h-8 min-w-0 px-1`,options:de.map(e=>({value:e,...It[e]}))})}),le===`experts`?null:(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(QU,{sessions:nt,projectNames:le===`recent`?ct:void 0,activeConversationId:v,...Pt,onReorder:ht})}),le===`experts`?(0,$.jsx)(`div`,{className:`px-2`,children:f&&!d?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:a.expertsLoadError}),(0,$.jsx)(X,{variant:`secondary`,onClick:()=>void p(),children:a.sessionFilters.retry})]}):d?(0,$.jsx)(_U,{agents:d.items,defaultAgentId:h,activeConversationId:v,onNavigate:e}):(0,$.jsx)(WU,{})}):le===`recent`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 px-2`,children:[!Ve&&!He?(0,$.jsx)(WU,{}):null,He?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:a.sessionFilters.error}),(0,$.jsx)(X,{variant:`secondary`,onClick:()=>void Ke(),children:a.sessionFilters.retry})]}):null,Ve&&!He&&!qe.length&&!nt.length&&!Mt?(0,$.jsx)(`p`,{className:`px-2 py-3 text-xs text-fg-muted`,children:a.taskListEmpty}):null,zt(a.timelineToday,lt.today),zt(a.timelineYesterday,lt.yesterday),lt.older.length>0||Mt?(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex w-full items-center gap-1 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,HU),"aria-expanded":fe,onClick:()=>pe(e=>!e),children:[(0,$.jsx)(vr,{className:Y(`size-3.5 transition-transform`,!fe&&`-rotate-90`),"aria-hidden":!0}),a.timelineOlder]}),fe?(0,$.jsxs)($.Fragment,{children:[Rt(lt.older),Nt?(0,$.jsx)(UU,{}):Mt&&!He?(0,$.jsx)(`button`,{type:`button`,className:`mx-2 rounded-lg px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>void We(Ue+1),children:a.sessionFilters.more}):null]}):null]}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(hU,{label:a.sessionViewProjects,createLabel:s.createTitle,onCreate:()=>L(!0)}),pt?(0,$.jsx)(WU,{}):tt?(0,$.jsxs)(`div`,{className:`flex flex-col px-2`,children:[Je.length>0?(0,$.jsx)(`div`,{className:`pb-1`,children:Je.map(t=>(0,$.jsx)(JU,{group:t,isExpanded:ve.has(t.project.id),isCollapsed:ge.has(t.project.id),activeConversationId:v,onToggleExpanded:Tt,onToggleCollapsed:Et,onCreateProjectChat:e=>void Ot(e),onToggleProjectPin:e=>void Ct(e),onRequestProjectRename:bt,onArchiveProject:e=>void St(e),onRequestProjectRemove:e=>P(e.id),onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,projectSort:{containerId:`projects`,itemId:t.project.id,itemIds:Je.map(e=>e.project.id),onReorder:ht},onReorder:ht},t.project.id))}):null,(0,$.jsx)(XU,{sessions:Ze.filter(e=>Vs(e).source!==`system`),hasMore:Qe,loadingMore:Ae,isCollapsed:me,onToggleCollapsed:()=>he(e=>!e),onCreateChat:()=>{ju(_,`/chat/new?projectScope=none`,{state:{forceNewChat:!0}},e)},onLoadMore:Dt,activeConversationId:v,onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,onReorder:ht}),Ze.some(e=>Vs(e).source===`system`)?(0,$.jsxs)(`details`,{className:`mt-3`,open:Ze.some(e=>e.key===v&&Vs(e).source===`system`),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs text-fg-muted`,children:r===`zh`?`系统活动`:`System activity`}),(0,$.jsx)(XU,{sessions:Ze.filter(e=>Vs(e).source===`system`),hasMore:!1,loadingMore:Ae,isCollapsed:!1,onToggleCollapsed:()=>void 0,onCreateChat:()=>{ju(_,`/chat/new?projectScope=none`,{state:{forceNewChat:!0}},e)},onLoadMore:Dt,activeConversationId:v,onNavigate:e,mutate:mt,onRequestRename:_t,onRequestDelete:O,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:rt,onReorder:ht,sortable:!1})]}):null]}):(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-3 text-xs leading-relaxed text-fg-muted`,children:a.taskListEmpty})}),dt?(0,$.jsx)(UU,{}):ft?(0,$.jsx)(`button`,{type:`button`,className:`mx-4 rounded-lg px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>void Re(Le+1),children:a.sessionFilters.more}):null]})]}),(0,$.jsx)(ne,{open:I,onOpenChange:e=>{K||(L(e),e||G(null))},children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(30rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:s.createTitle}),(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:s.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:kt,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[s.projectName,(0,$.jsx)(`input`,{autoFocus:!0,className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:z,onChange:e=>U(e.target.value),maxLength:160})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:s.workspaceRoot}),(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Fe.pick,disabled:K||Fe.picking,children:[Fe.picking?(0,$.jsx)(_a,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:re?c.chooseFolder:c.selectWorkingDirectory}),(0,$.jsx)(`span`,{className:Y(`mt-0.5 block truncate font-mono text-xs font-normal`,re?`text-fg-muted`:`text-fg-subtle`),title:re||void 0,children:re||s.workspaceSelectionPlaceholder})]})]}),(0,$.jsx)(`p`,{className:`text-xs font-normal text-fg-muted`,children:s.workspaceSelectionHint})]}),(0,$.jsx)(Xu,{checked:q,onChange:oe,disabled:K||!re.trim()}),ie?(0,$.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:ie}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:K,children:s.cancel})}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:K||!z.trim(),children:K?s.home.creating:s.create})]})]})]})]})}),Fe.hasNativePicker?null:(0,$.jsx)(wr,{open:Fe.modalOpen,onOpenChange:Fe.setModalOpen,initialAbsolutePath:re||void 0,onConfirm:Fe.confirmPick,wd:c}),(0,$.jsx)(ne,{open:b!==null,onOpenChange:e=>!e&&S(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.taskRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-rename-input`,children:a.taskRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-rename-input`,type:`text`,value:C,onChange:e=>w(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,Ll,`dark:border-edge`),placeholder:i.chat.newSession,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),vt())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>S(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void vt(),disabled:!C.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(ne,{open:T!==null,onOpenChange:e=>!e&&O(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:o.deleteSessionTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:T?LU(o.deleteSessionMessage,{name:$e.find(e=>e.key===T)?.name?.trim()||i.chat.newSession}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>O(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{T&&yt(T),O(null)},children:o.delete})]})]})]})}),(0,$.jsx)(ne,{open:k!==null,onOpenChange:e=>!e&&A(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.projectRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-project-rename-input`,children:a.projectRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-project-rename-input`,type:`text`,value:j,onChange:e=>M(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,Ll,`dark:border-edge`),placeholder:At?.name??``,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),xt())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>A(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void xt(),disabled:!j.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(ne,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:a.projectRemoveTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:jt?LU(a.projectRemoveMessage,{name:jt.name}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>P(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{jt&&wt(jt),P(null)},children:a.projectRemove})]})]})]})})]})}):(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,children:[n,(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 px-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.taskListNeedToken}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-8 w-full text-xs font-medium`,onClick:()=>{u(),e?.()},children:a.taskListAddToken})]})})]})}var rW=42,iW=1,aW=4,oW=3,sW=`xopc-web-sidebar-visible-app-count-v2`;function cW(e){return Math.min(aW,Math.max(iW,e))}function lW(){try{let e=Number.parseInt(globalThis.localStorage?.getItem(sW)??``,10);return Number.isFinite(e)?cW(e):oW}catch{return oW}}function uW({onNavigate:e,collapsed:t=!1}){let n=F(D(e=>e.language)),[r,i]=(0,Z.useState)(lW),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{try{globalThis.localStorage?.setItem(sW,String(r))}catch{}},[r]);function o(e){e.preventDefault(),a.current={clientY:e.clientY,visibleCount:r},e.currentTarget.setPointerCapture(e.pointerId)}function s(e){let t=a.current;if(!t)return;let n=Math.round((e.clientY-t.clientY)/rW);i(cW(t.visibleCount+n))}function c(e){a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}function l(e){e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),i(e=>cW(e+1))):e.key===`ArrowUp`||e.key===`ArrowLeft`?(e.preventDefault(),i(e=>cW(e-1))):e.key===`Home`?(e.preventDefault(),i(iW)):e.key===`End`&&(e.preventDefault(),i(aW))}return(0,$.jsxs)(`div`,{className:`app-sidebar-content flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:Y(`flex min-h-0 flex-1 flex-col overflow-hidden`,t&&`hidden`),"aria-hidden":t?!0:void 0,children:(0,$.jsx)(eW,{onNavigate:e,scrollHeader:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`app-sidebar-sticky-surface sticky top-0 z-20 px-4 pt-1.5 pb-0.5`,children:(0,$.jsxs)(Mu,{to:`/chat/new`,state:{forceNewChat:!0},className:Y(`flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-6 transition-colors duration-200 ease-out md:py-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`text-fg-muted hover:bg-surface-hover hover:text-fg`),title:n.sidebar.newTask,onClick:()=>e?.(),children:[(0,$.jsx)(yo,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:n.sidebar.newTask})]})}),(0,$.jsx)(`nav`,{className:`px-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(eU,{onNavigate:e,visibleLimit:r})})}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":n.sidebar.resizeApps,"aria-valuemin":iW,"aria-valuemax":aW,"aria-valuenow":r,tabIndex:0,className:`group flex h-3 touch-none cursor-row-resize items-center px-4 focus-visible:outline-none`,title:n.sidebar.resizeApps,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onKeyDown:l,children:(0,$.jsx)(`span`,{className:`h-px w-full bg-transparent transition-colors group-focus-visible:bg-accent`})}),(0,$.jsx)(`div`,{className:`h-2`,"aria-hidden":!0})]})})}),t?(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto px-1.5 pb-2 pt-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(eU,{collapsed:!0,onNavigate:e,visibleLimit:oW})})}):null,(0,$.jsx)(UH,{collapsed:t,onNavigate:e})]})}var dW=`(min-width: 768px)`,fW=(0,Z.memo)(function(){let e=(0,Q.c)(42),t=D(pW),n;e[0]===t?n=e[1]:(n=F(t),e[0]=t,e[1]=n);let r=n,i=_e(mW),a=_e(hW),o=_e(gW),s=Le(_W),c=Le(vW),[l,u]=(0,Z.useState)(!1),d=vt({runtime:Se(),sidebarCollapsed:i,mobileNavOpen:s}),f;e[2]!==o||e[3]!==i?(f=e=>{if(i)return;e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),u(!0);let r=e.clientX,a=_e.getState().expandedWidthPx,s=e.pointerId,c=0,l=a,d=a,f=()=>{c=0,d=l,n?.style.setProperty(`--sidebar-expanded-px`,`${d}px`)},p=e=>{l=ze(a+(e.clientX-r)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(s)}catch{}u(!1),o(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},e[2]=o,e[3]=i,e[4]=f):f=e[4];let p=f,m,h;e[5]===c?(m=e[6],h=e[7]):(m=()=>{let e=e=>{e.key===`Escape`&&c(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[c],e[5]=c,e[6]=m,e[7]=h),(0,Z.useEffect)(m,h);let g,_;e[8]===c?(g=e[9],_=e[10]):(g=()=>{let e=window.matchMedia(dW),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},_=[c],e[8]=c,e[9]=g,e[10]=_),(0,Z.useEffect)(g,_);let v,y;e[11]===s?(v=e[12],y=e[13]):(v=()=>{if(!s||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},y=[s],e[11]=s,e[12]=v,e[13]=y),(0,Z.useEffect)(v,y);let b;e[14]!==r||e[15]!==s||e[16]!==c?(b=s?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":r.closeMenu,onClick:()=>c(!1)}):null,e[14]=r,e[15]=s,e[16]=c,e[17]=b):b=e[17];let x=l&&`sidebar-width-resizing`,S=s?`max-md:translate-x-0`:`max-md:-translate-x-full`,C=i?`md:w-0 md:overflow-hidden md:border-0`:`app-sidebar-expanded-width`,w;e[18]!==x||e[19]!==S||e[20]!==C?(w=Y(`app-sidebar-push app-chrome-sidebar flex min-h-0 shrink-0 flex-col overflow-hidden bg-transparent`,x,`max-md:fixed max-md:left-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:w-[min(16rem,85vw)]`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,S,`md:relative md:h-full md:translate-x-0`,C),e[18]=x,e[19]=S,e[20]=C,e[21]=w):w=e[21];let T=i&&!s?!0:void 0,E=i&&!s?!0:void 0,O;e[22]!==a||e[23]!==i?(O=i?void 0:{"--sidebar-expanded-px":`${a}px`},e[22]=a,e[23]=i,e[24]=O):O=e[24];let k=d.sidebarChromeVisible?(0,$.jsxs)(`div`,{className:Y(`sidebar-chrome-row flex min-w-0`,Il,d.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,d.sidebarLeadingInsetClass,i?`justify-center gap-1 px-1.5 max-md:flex`:Y(`justify-start gap-1`,d.sidebarLeadingInsetClass?`sidebar-chrome-row-darwin pr-3`:`px-3`),i&&`md:hidden`),children:[s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-8 shrink-0 rounded-xl p-0 md:hidden`,Fl),"aria-label":r.closeMenu,title:r.closeMenu,onClick:()=>c(!1),children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,d.sidebarQuickActionsVisible&&!i?(0,$.jsx)(zV,{sidebarToggleVariant:`sidebar`,className:`overflow-hidden`}):null]}):null,A;e[25]===c?A=e[26]:(A=(0,$.jsx)(uW,{collapsed:!1,onNavigate:()=>c(!1)}),e[25]=c,e[26]=A);let j;e[27]!==r||e[28]!==p||e[29]!==i?(j=i?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r.sidebar.resizeHandleAria,onPointerDown:p,className:Y(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`touch-none select-none`,Fl)}),e[27]=r,e[28]=p,e[29]=i,e[30]=j):j=e[30];let M;e[31]!==w||e[32]!==T||e[33]!==E||e[34]!==O||e[35]!==k||e[36]!==A||e[37]!==j?(M=(0,$.jsxs)(`aside`,{id:`app-sidebar`,className:w,"aria-hidden":T,"data-collapsed":E,style:O,children:[k,A,j]}),e[31]=w,e[32]=T,e[33]=E,e[34]=O,e[35]=k,e[36]=A,e[37]=j,e[38]=M):M=e[38];let N;return e[39]!==M||e[40]!==b?(N=(0,$.jsxs)($.Fragment,{children:[b,M]}),e[39]=M,e[40]=b,e[41]=N):N=e[41],N});function pW(e){return e.language}function mW(e){return e.collapsed}function hW(e){return e.expandedWidthPx}function gW(e){return e.setExpandedWidthPx}function _W(e){return e.mobileNavOpen}function vW(e){return e.setMobileNavOpen}function yW(e){if(typeof e!=`string`||e.length>8192)throw Error(`Invalid browser URL`);let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Use an HTTP or HTTPS address without embedded credentials`);return t.href}function bW(e,t){let n=e.trim();if(!n)return null;if(/^https?:\/\//i.test(n))return yW(n);if(/^(localhost|127(?:\.\d+){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(n))return yW(`http://${n}`);if(!/\s/.test(n)&&/^(?:[\w-]+\.)+[\w-]+(?::\d+)?(?:[/?#]|$)/i.test(n))return yW(`https://${n}`);if(/^[a-z][a-z\d+.-]*:/i.test(n))throw Error(`Only HTTP and HTTPS addresses are supported`);return t?{google:`https://www.google.com/search?q=`,bing:`https://www.bing.com/search?q=`,duckduckgo:`https://duckduckgo.com/?q=`}[t]+encodeURIComponent(n):null}var xW=k(e=>({tabs:{},update:t=>e(e=>({tabs:{...e.tabs,[t.workspaceTabId]:t}}))}));async function SW(e){let t=xW.getState().tabs[e];return t&&window.electronAPI?.browser&&!await window.electronAPI.browser.close(t.id)?!1:(xW.setState(t=>({tabs:Object.fromEntries(Object.entries(t.tabs).filter(([t])=>t!==e))})),!0)}E.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||t.conversationId&&e.conversationId!==t.conversationId)&&(xW.setState({tabs:{}}),window.electronAPI?.browser?.release().catch(()=>{}))});function CW(e,t,n){let r=(0,Q.c)(5),i,a;r[0]!==t||r[1]!==e||r[2]!==n?(i=()=>{let r=window.electronAPI?.browser,i=e.current;if(!r||!t||!i)return;let a=0,o=``,s=!1,c=()=>{if(a=0,s)return;let e=[...document.querySelectorAll(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-browser-occluder]`)].some(OW),l=[i.closest(`[data-right-workspace]`),i.closest(`[role="tabpanel"]`)].filter(Boolean).some(EW),u=i.getBoundingClientRect(),d=n&&!e&&!l&&i.getClientRects().length>0&&document.visibilityState===`visible`?{x:u.x,y:u.y,width:u.width,height:u.height}:null,f=JSON.stringify(d);f!==o&&(o=f,r.present(t,d).catch(TW)),l&&(a=requestAnimationFrame(c))},l=()=>{a||=requestAnimationFrame(c)},u=new ResizeObserver(l);u.observe(i);let d=new MutationObserver(l);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-hidden`,`data-state`]});let f=()=>{o=``,l()};return window.addEventListener(`focus`,f),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0),document.addEventListener(`visibilitychange`,l),l(),()=>{s=!0,cancelAnimationFrame(a),u.disconnect(),d.disconnect(),window.removeEventListener(`focus`,f),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),document.removeEventListener(`visibilitychange`,l),r.present(t,null).catch(wW)}},a=[t,e,n],r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,Z.useLayoutEffect)(i,a)}function wW(){}function TW(){}function EW(e){return e.getAnimations().some(DW)}function DW(e){return e.playState===`running`}function OW(e){return e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}function kW(e){let t=(0,Q.c)(94),{tab:n,scope:r,active:i}=e,a=(0,Z.useContext)(qi),o=D(jW)===`zh`,s=E(AW),c;t[0]===n.id?c=t[1]:(c=e=>e.tabs[n.id],t[0]=n.id,t[1]=c);let l=xW(c),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(n.initialUrl??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(!1),S=window.electronAPI?.browser,C,w;t[2]!==s||t[3]!==r||t[4]!==n.id||t[5]!==n.initialUrl?(C=()=>{if(!S||!s)return;let e=!1;return S.ensure({workspaceTabId:n.id,scope:r,identity:s}).then(async t=>{if(e){Object.values(tl.getState().panes).some(e=>e.tabs.some(e=>e.id===n.id))||await S.close(t.id);return}xW.getState().update(t),!t.url&&n.initialUrl&&await S.navigate(t.id,n.initialUrl)}).catch(t=>{e||_(String(t.message??t))}),()=>{e=!0}},w=[S,s,r,n.id,n.initialUrl],t[2]=s,t[3]=r,t[4]=n.id,t[5]=n.initialUrl,t[6]=C,t[7]=w):(C=t[6],w=t[7]),(0,Z.useEffect)(C,w);let T;t[8]!==m||t[9]!==l?(T=()=>{!m&&l?.url&&p(l.url)},t[8]=m,t[9]=l,t[10]=T):T=t[10];let O=l?.url,k;t[11]!==m||t[12]!==O?(k=[m,O],t[11]=m,t[12]=O,t[13]=k):k=t[13],(0,Z.useEffect)(T,k),CW(u,l?.id,i&&!!l?.url&&!l?.error&&!l?.crashed&&!b);let A,j;t[14]!==i||t[15]!==n.id?(A=()=>{if(!i)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),d.current?.focus(),d.current?.select())},t=e=>{e.detail===n.id&&(d.current?.focus(),d.current?.select())};return window.addEventListener(`browser-focus-address`,t),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`browser-focus-address`,t)}},j=[i,n.id],t[14]=i,t[15]=n.id,t[16]=A,t[17]=j):(A=t[16],j=t[17]),(0,Z.useEffect)(A,j);let M;t[18]!==f||t[19]!==v||t[20]!==l?(M=async function(e){let t=e===void 0?v:e;if(!(!S||!l))try{let e=bW(f,t);if(!e){x(!!f.trim());return}x(!1),_(``),h(!1),await S.navigate(l.id,e)}catch(e){let t=e;_(t instanceof Error?t.message:String(t))}},t[18]=f,t[19]=v,t[20]=l,t[21]=M):M=t[21];let N=M,P;t[22]===l?P=t[23]:(P=function(e){!S||!l||(_(``),S.command(l.id,e).catch(e=>_(e instanceof Error?e.message:String(e))))},t[22]=l,t[23]=P);let F=P;if(!i){let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{ref:u,hidden:!0}),t[24]=e):e=t[24],e}let I;t[25]===N?I=t[26]:(I=e=>{e.preventDefault(),N()},t[25]=N,t[26]=I);let L=o?`网页后退`:`Browser back`,R=!l?.canGoBack,z;t[27]===F?z=t[28]:(z=()=>F(`back`),t[27]=F,t[28]=z);let B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Ft,{className:`size-4`}),t[29]=B):B=t[29];let V;t[30]!==L||t[31]!==R||t[32]!==z?(V=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":L,disabled:R,onClick:z,children:B}),t[30]=L,t[31]=R,t[32]=z,t[33]=V):V=t[33];let H=o?`网页前进`:`Browser forward`,ee=!l?.canGoForward,te;t[34]===F?te=t[35]:(te=()=>F(`forward`),t[34]=F,t[35]=te);let ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(It,{className:`size-4`}),t[36]=ne):ne=t[36];let U;t[37]!==H||t[38]!==ee||t[39]!==te?(U=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":H,disabled:ee,onClick:te,children:ne}),t[37]=H,t[38]=ee,t[39]=te,t[40]=U):U=t[40];let re=l?.loading?o?`停止加载网页`:`Stop loading page`:o?`刷新网页`:`Reload page`,W=!l?.url&&!l?.loading,ie;t[41]!==F||t[42]!==l?.loading?(ie=()=>F(l?.loading?`stop`:`reload`),t[41]=F,t[42]=l?.loading,t[43]=ie):ie=t[43];let G;t[44]===l?.loading?G=t[45]:(G=l?.loading?(0,$.jsx)(ds,{className:`size-4`}):(0,$.jsx)(Oo,{className:`size-4`}),t[44]=l?.loading,t[45]=G);let K;t[46]!==re||t[47]!==W||t[48]!==ie||t[49]!==G?(K=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":re,disabled:W,onClick:ie,children:G}),t[46]=re,t[47]=W,t[48]=ie,t[49]=G,t[50]=K):K=t[50];let ae=o?`搜索或输入网址`:`Search or enter a URL`,q,oe,se;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>h(!0),oe=()=>h(!1),se=e=>p(e.target.value),t[51]=q,t[52]=oe,t[53]=se):(q=t[51],oe=t[52],se=t[53]);let ce=o?`搜索或输入网址`:`Search or enter a URL`,le;t[54]!==f||t[55]!==ae||t[56]!==ce?(le=(0,$.jsx)(`input`,{ref:d,"aria-label":ae,autoComplete:`off`,spellCheck:!1,value:f,onFocus:q,onBlur:oe,onChange:se,placeholder:ce,className:`h-9 min-w-0 flex-1 rounded-full border border-edge-subtle bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`}),t[54]=f,t[55]=ae,t[56]=ce,t[57]=le):le=t[57];let ue=a?.button,de=o?`在系统浏览器打开`:`Open in system browser`,J=!l?.url,fe;t[58]===l?fe=t[59]:(fe=()=>{l?.url&&window.electronAPI?.shell?.openExternalUrl(l.url).catch(e=>_(e instanceof Error?e.message:String(e)))},t[58]=l,t[59]=fe);let pe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(hi,{className:`size-4`}),t[60]=pe):pe=t[60];let me;t[61]!==de||t[62]!==J||t[63]!==fe?(me=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":de,disabled:J,onClick:fe,children:pe}),t[61]=de,t[62]=J,t[63]=fe,t[64]=me):me=t[64];let he;t[65]!==I||t[66]!==V||t[67]!==U||t[68]!==K||t[69]!==le||t[70]!==ue||t[71]!==me?(he=(0,$.jsxs)(`form`,{"data-workspace-toolbar":!0,className:`flex h-14 shrink-0 items-center gap-1 bg-surface-inset px-2`,onSubmit:I,children:[V,U,K,le,ue,me]}),t[65]=I,t[66]=V,t[67]=U,t[68]=K,t[69]=le,t[70]=ue,t[71]=me,t[72]=he):he=t[72];let ge;t[73]===g?ge=t[74]:(ge=g?(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:g}):null,t[73]=g,t[74]=ge);let _e;t[75]===l?_e=t[76]:(_e=l?.notice?(0,$.jsx)(`p`,{role:`status`,className:`border-b border-edge px-3 py-2 text-xs text-fg-muted`,children:l.notice}):null,t[75]=l,t[76]=_e);let ve;t[77]!==b||t[78]!==N||t[79]!==o?(ve=b?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":o?`选择搜索引擎`:`Choose a search engine`,className:`border-b border-edge p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:o?`选择搜索引擎后才会提交这次搜索。`:`Choose where to send this search.`}),(0,$.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[[`duckduckgo`,`google`,`bing`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 hover:bg-surface-hover`,onClick:()=>{y(e),N(e)},children:e===`duckduckgo`?`DuckDuckGo`:e===`google`?`Google`:`Bing`},e)),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(!1),children:o?`取消`:`Cancel`})]})]}):null,t[77]=b,t[78]=N,t[79]=o,t[80]=ve):ve=t[80];let ye;t[81]!==F||t[82]!==g||t[83]!==l||t[84]!==o?(ye=!l&&g?(0,$.jsx)(`div`,{className:`p-8 text-sm text-fg-muted`,children:o?`无法创建浏览器标签。关闭其他网页后重试。`:`Browser tab could not be created. Close another page and try again.`}):l?l.error?(0,$.jsxs)(`div`,{role:`alert`,className:`p-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.error}),(0,$.jsx)(`button`,{type:`button`,className:`mt-4 text-accent`,onClick:()=>F(`reload`),children:o?`重试`:`Retry`})]}):l.url?null:(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`size-9`}),(0,$.jsx)(`h2`,{className:`text-lg text-fg`,children:o?`浏览网页`:`Browse the web`}),(0,$.jsx)(`p`,{className:`text-sm`,children:o?`输入网址开始。网页内容不会自动发送到聊天。`:`Enter an address to begin. Pages are not automatically shared with chat.`})]}):(0,$.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,$.jsx)(ps,{className:`h-8 w-2/3`}),(0,$.jsx)(ps,{className:`h-40 w-full`})]}),t[81]=F,t[82]=g,t[83]=l,t[84]=o,t[85]=ye):ye=t[85];let be;t[86]===ye?be=t[87]:(be=(0,$.jsx)(`div`,{ref:u,className:`relative min-h-0 flex-1 overflow-hidden bg-surface-base`,"data-browser-surface":!0,children:ye}),t[86]=ye,t[87]=be);let xe;return t[88]!==he||t[89]!==ge||t[90]!==_e||t[91]!==ve||t[92]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-browser-tab":!0,children:[he,ge,_e,ve,be]}),t[88]=he,t[89]=ge,t[90]=_e,t[91]=ve,t[92]=be,t[93]=xe):xe=t[93],xe}function AW(e){return e.conversationId}function jW(e){return e.language}function MW(){let e=(0,Q.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(NW,t)}function NW(){return window.electronAPI?.browser?.onEvent(PW)}function PW(e){if(e.kind===`state`)xW.getState().update(e.state),tl.getState().updateBrowserTitle(e.state.workspaceTabId,e.state.title);else if(e.kind===`focus-address`)window.dispatchEvent(new CustomEvent(`browser-focus-address`,{detail:e.workspaceTabId}));else{let t=tl.getState();Object.values(t.panes).flatMap(IW).filter(FW).length<24&&t.openBrowser(e.url,e.scope,e.sourceTabId)}}function FW(e){return e.kind===`browser`}function IW(e){return e.tabs}var LW=(0,Z.memo)(function({elevated:e=!1,embedded:t=!1,scope:n,onCloseTree:r}){let i=F(D(e=>e.language)),{pathname:a,search:o}=m(),{conversationId:s}=f(),c=a.startsWith(`/chat`)&&s&&s!==`new`?decodeURIComponent(s):null,l=se(e=>e.open),u=t||l,d=(0,Z.useRef)(u),p=se(e=>e.setOpen),h=(0,Z.useCallback)(e=>{t?e||r?.():p(e)},[t,r,p]),g=se(e=>e.conversationIdOverride),_=se(e=>e.widthPx),v=se(e=>e.setWidthPx),y=n?n.conversationId??null:g??c,b=n?n.projectId??null:!y&&a.startsWith(`/chat`)?new URLSearchParams(o).get(`projectId`):null,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(``),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),[P,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),z=yc(e=>e.path),B=yc(e=>e.setPath),V=(0,Z.useCallback)(e=>{B(e,null,b,y)},[y,B,b]),H=Sd(e=>e.agentId),ee=n?.agentId??H,{tree:te,rootResource:ne,loading:U,error:re,loadRoot:W,loadChildren:ie,refreshDirectory:G,reset:K}=xd(ee,y,b),ae=y?`session:${y}`:b?`project:${b}`:`agent:${ee}`,q=(0,Z.useMemo)(()=>b?{projectId:b}:y==null?ee.trim()?{agentId:ee.trim()}:void 0:{conversationId:y},[y,b,ee]),oe=T.trim(),ce=tu(),le=(0,Z.useCallback)((e,t)=>{ot(e.dataTransfer,{name:t.name,path:t.path,...q})},[q]),{dialogOpen:ue,loading:de,result:J,error:fe,pendingParams:pe,createShareLink:me,confirmShareLink:he,handleOpenChange:ge}=hd(),_e=(0,Z.useCallback)(e=>{if(!u)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),S(!0);let r=e.clientX,i=se.getState().widthPx,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n?.style.setProperty(`--workspace-panel-px`,`${c}px`)},d=e=>{s=ct(i+(r-e.clientX)),o===0&&(o=window.requestAnimationFrame(l))},f=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}S(!1),v(c),window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[u,v]);(0,Z.useEffect)(()=>{!t&&!a.startsWith(`/chat`)&&h(!1)},[t,a,h]),(0,Z.useEffect)(()=>{let e=d.current;if(d.current=u,!u){K(),e&&!t&&V(null);return}t||V(null),W()},[t,u,ae,W,K,V]),(0,Z.useEffect)(()=>{if(!u||t)return;let e=e=>{if(e.key===`Escape`){if(C){e.preventDefault(),e.stopPropagation(),E(``),w(!1);return}yc.getState().path||h(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,C,u,h]),(0,Z.useEffect)(()=>{if(!u||!t&&!C||!oe){k([]),j(!1),N(null);return}let e=!1;j(!0),N(null),k([]);let n=window.setTimeout(()=>{cd(oe,q,50).then(t=>{e||k(t)}).catch(t=>{e||N(t instanceof Error?t.message:String(t))}).finally(()=>{e||j(!1)})},180);return()=>{e=!0,window.clearTimeout(n)}},[t,C,oe,u,q]),(0,Z.useEffect)(()=>{if(!u||t||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[t,u]);let ve=(0,Z.useCallback)(e=>{ie(e)},[ie]),ye=(0,Z.useCallback)(async(e,t,n)=>{switch(e){case`preview`:if(t.isDirectory)return;V(t.path);break;case`download`:if(t.isDirectory)return;try{let e=Ko(t.path);if(Go(qo(e))!==`text`)ud(e,await(await od(t.path,q)).arrayBuffer(),Ec(e)??`application/octet-stream`);else{let{content:n}=await sd(t.path,q);fd(e,n)}}catch{}break;case`copyPath`:try{await pl(t.path)&&Ml(`success`,i.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:await vd(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWith`:await vd(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await vd(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),i.workspace.openFileFailed);break;case`revealInFolder`:await vd(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),i.workspace.revealFileFailed);break;case`trash`:I(t);break;case`delete`:t.isDirectory||R(t);break;case`share`:await me({path:t.path,...t.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...q});break;default:break}},[me,i.workspace.openFileFailed,i.workspace.pathCopied,i.workspace.revealFileFailed,V,q]),be=(0,Z.useCallback)(async()=>{let e=P;if(!e)return;let n=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!n?.ok){Ml(`warning`,n?.error??i.workspace.trashFailed,void 0,{duration:4e3});return}!t&&z===e.path&&V(null),I(null),await W(),Ml(`success`,i.workspace.trashSuccess,void 0,{duration:2500})},[t,W,i.workspace.trashFailed,i.workspace.trashSuccess,P,z,V]),xe=(0,Z.useCallback)(async(e,t)=>{try{await Promise.all(e.map(e=>dd(e,t,q))),await G(t).catch(()=>void 0),Ml(`success`,i.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await G(t).catch(()=>void 0),Ml(`warning`,`${i.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[i.workspace.uploadFailed,i.workspace.uploadSuccess,G,q]),Se=(0,Z.useCallback)(async()=>{let e=L;if(e)try{await pd(e.fileId),!t&&z===e.path&&V(null),R(null);let n=e.path.lastIndexOf(`/`);await G(n<0?``:e.path.slice(0,n)).catch(()=>void 0),Ml(`success`,i.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Ml(`warning`,`${i.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t,i.workspace.deleteFailed,i.workspace.deleteSuccess,L,z,G,V]);return(0,$.jsxs)($.Fragment,{children:[u&&!t?(0,$.jsx)(`button`,{type:`button`,className:Y(`fixed inset-0 bg-scrim md:hidden`,e?`z-[109]`:`z-40`),"aria-label":i.closeMenu,onClick:()=>h(!1)}):null,(0,$.jsx)(`aside`,{id:t?void 0:`app-workspace-panel`,"aria-label":i.workspace.title,"aria-hidden":!u,className:t?`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-base`:Y(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:h-[100dvh] max-md:shadow-popover max-md:w-[min(20rem,92vw)]`,u?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,e&&u?`pointer-events-auto z-[110]`:`max-md:z-50`,!u&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,u&&`app-workspace-panel-expanded-width md:shrink-0`,u&&x&&`workspace-panel-rail-resizing`),style:!t&&u?{"--workspace-panel-px":`${_}px`}:void 0,children:u?(0,$.jsxs)(`div`,{className:Y(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.workspace.resizeHandleAria,onPointerDown:_e,className:Y(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 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`,x&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,Fl)}),(0,$.jsxs)(`div`,{className:Y(`flex h-11 shrink-0 items-center gap-2 px-4`,!t&&`border-b border-edge dark:border-edge`),children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:i.workspace.title}),ce?ne?(0,$.jsx)(li,{resourceId:ne.fileId,displayName:ne.name}):null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(Hi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:i.workspace.title})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-9 shrink-0 rounded-md p-0`,C&&`bg-surface-hover text-fg`),"aria-label":i.workspace.search,title:i.workspace.search,"aria-pressed":C,onClick:()=>w(!0),children:(0,$.jsx)(No,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(id,{className:`size-9 shrink-0 rounded-md p-0`,loading:U,label:i.cron.refresh,onClick:W}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":i.workspace.close,title:i.workspace.close,onClick:()=>h(!1),children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.75})})]})]}),t||C?(0,$.jsx)(`div`,{className:Y(`shrink-0 px-3 pb-2 pt-1`,!t&&`border-b border-edge`),children:(0,$.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(No,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:T,onChange:e=>E(e.target.value),placeholder:i.workspace.searchPlaceholder,"aria-label":i.workspace.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),!t||T?(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":i.workspace.clearSearch,title:i.workspace.clearSearch,onClick:()=>{E(``),w(!1)},children:(0,$.jsx)(ds,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,re?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,re]}):null,oe?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:A?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(ps,{className:`h-11 w-full`}),(0,$.jsx)(ps,{className:`h-11 w-full`}),(0,$.jsx)(ps,{className:`h-11 w-full`})]}):M?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,M]}):O.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:i.workspace.noSearchResults}):O.map(e=>(0,$.jsxs)(`button`,{type:`button`,draggable:!0,className:Y(`flex w-full min-w-0 cursor-grab items-center gap-2 px-3 py-2 text-left active:cursor-grabbing hover:bg-surface-hover`,z===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>V(e.path),onDragStart:t=>le(t,e),title:e.path,children:[(0,$.jsx)(Si,{name:e.name}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(ad,{tree:te,selectedPath:z,onSelectFile:e=>V(e),onExpandDir:ve,onAction:ye,onFileDragStart:le,onUploadFiles:(e,t)=>void xe(e,t),uploadDropHint:i.workspace.dropToUpload,actionLabels:{preview:i.workspace.preview,download:i.workspace.download,copyPath:i.workspace.copyPath,share:i.workspace.shareLink,delete:i.workspace.deleteFile,...ce?{openDefault:i.workspace.openSystemApp,openDirectory:i.workspace.openInFileManager,openWith:i.workspace.chooseApp,revealInFolder:i.workspace.revealInFolder,trash:i.workspace.moveToTrash,recommendedApps:i.workspace.recommendedApps,desktopUpdateRequired:i.workspace.desktopUpdateRequired}:{}},emptyHint:i.workspace.emptyDir})]}):null}),(0,$.jsx)(ls,{open:ue,onOpenChange:ge,loading:de,error:fe,result:J,pendingParams:pe,onConfirm:e=>void he(e)}),(0,$.jsx)(rd,{open:!!P,title:i.workspace.trashConfirmTitle,description:i.workspace.trashConfirmDescription.replace(`{{name}}`,P?.name??``),confirmLabel:i.workspace.moveToTrash,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void be(),onCancel:()=>I(null)}),(0,$.jsx)(rd,{open:!!L,title:i.workspace.deleteConfirmTitle,description:i.workspace.deleteConfirmDescription.replace(`{{name}}`,L?.name??``),confirmLabel:i.workspace.deleteFile,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void Se(),onCancel:()=>R(null)})]})}),RW=`xopc:side-chat-client-id`;function zW(){let e=sessionStorage.getItem(RW);if(e)return e;let t=crypto.randomUUID();return sessionStorage.setItem(RW,t),t}function BW(){return{"x-xopc-client-instance-id":zW()}}async function VW(e,t){return(await O(T(`/api/sessions/${encodeURIComponent(e)}/side-chats`),{method:`POST`,headers:BW(),body:JSON.stringify({clientInstanceId:zW(),selections:t})})).sideChat}async function HW(e){return(await O(T(`/api/side-chats/${e}`),{headers:BW()})).sideChat}async function UW(e){return(await O(T(`/api/side-chats/${e}/messages`),{headers:BW()})).messages}async function WW(e,t){return(await O(T(`/api/side-chats/${e}/config`),{method:`PATCH`,headers:BW(),body:JSON.stringify(t)})).sideChat}async function GW(e,t,n){return(await O(T(`/api/side-chats/${e}/inputs`),{method:`POST`,headers:BW(),body:JSON.stringify({content:t,attachments:n})})).payload.runId}async function KW(e,t){await O(T(`/api/side-chats/${e}/abort`),{method:`POST`,headers:BW(),body:JSON.stringify({runId:t})})}async function qW(e,t,n){await O(T(`/api/side-chats/${e}/clarify/${t}`),{method:`POST`,headers:BW(),body:JSON.stringify(n)})}async function JW(e){await O(T(`/api/side-chats/${e}`),{method:`DELETE`,headers:BW()})}async function YW(e){return(await O(T(`/api/side-chats/${e}/heartbeat`),{method:`POST`,headers:BW()})).sideChat}async function XW(e){return(await O(T(`/api/side-chats/${e}/extend`),{method:`POST`,headers:BW()})).sideChat}async function ZW(e){return O(T(`/api/side-chats/${e}/promote`),{method:`POST`,headers:BW()})}var QW=`xopc:side-chat-close-confirm-disabled:v1`,$W=()=>{},eG=[];function tG(){try{return localStorage.getItem(QW)===`true`}catch{return!1}}function nG(){try{localStorage.setItem(QW,`true`)}catch{}}function rG(e){return e.role===`user`?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
7
7
|
`).trim():``}function iG(e){return(e.attachments??[]).map(e=>e.name??``).filter(Boolean).join(`
|
|
8
8
|
`)}function aG(e,t){let n=e?.body?.code;if(n===`INVALID_REQUEST`){let n=e?.body?.error;return n===`clientInstanceId is required`?t.errorClientIdentity:typeof n==`string`&&n.trim()?`${t.errorInvalidRequest} ${n}`:t.errorInvalidRequest}return n===`NOT_FOUND`?t.errorNotFound:n===`CONFLICT`?t.errorConflict:n===`LIMIT_REACHED`?t.errorLimitReached:n===`CAPACITY_REACHED`?t.errorCapacity:n===`PARENT_NOT_FOUND`?t.parentMissing:n===`INTERNAL_ERROR`?t.failed:e instanceof Error?e.message:String(e)}function oG(e,t){let n=[...e];for(let[e,r]of t){let i=rG(r),a=iG(r),o=r.timestamp??0;if(n.some(e=>e.role===`user`&&rG(e)===i&&iG(e)===a&&Math.abs((e.timestamp??o)-o)<6e4)){t.delete(e);continue}let s=n.findIndex(e=>(e.timestamp??1/0)>o);s<0?n.push(r):n.splice(s,0,r)}return n}function sG({parentConversationId:e,embedded:t=!1,visible:n=!0}){let r=tl(t=>t.panes[e]),i=F(D(e=>e.language)).sideChat,a=Qe(t=>t.panes[e]?.open===!0),o=Qe(e=>e.tabs),s=Qe(e=>e.readings),c=(0,Z.useMemo)(()=>o.filter(t=>t.parentConversationId===e),[o,e]),l=Qe(t=>t.panes[e]?.activeId??null),u=t?r?.activeId?.replace(/^side:/,``):l,d=Qe(e=>e.pendingCreate),f=Qe(e=>e.requestCreate),p=Qe(e=>e.claimPendingCreate),m=Qe(e=>e.finishCreate),h=Qe(e=>e.addTab),g=Qe(e=>e.removeTab),_=Qe(e=>e.setActive),v=Qe(e=>e.setOpen),y=Qe(e=>e.widthPx),b=Qe(e=>e.setWidthPx),x=Qe(e=>e.setTabRunId),S=E(e=>e.conversationId),C=c.find(e=>e.id===u)??null,w=Qe(t=>!!t.creatingRequests[e]),[T,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!d||d.parentConversationId!==e)return;let n=p(e,d.requestId);if(!n)return;O(null);let r=E.getState();tl.getState().setNotice(e,``);let a=tl.getState().panes[e]?.activeId;VW(n.parentConversationId,n.selections).then(n=>{if(E.getState().conversationId!==r.conversationId||E.getState().baseUrl!==r.baseUrl)return;let i=Qe.getState().panes[n.parentConversationId]?.open===!0,o=tl.getState(),s=!t||o.scope===e&&o.panes[e]?.open===!0&&o.panes[e]?.activeId===a;h({id:n.id,parentConversationId:n.parentConversationId,title:`Side chat`},s),i||v(n.parentConversationId,!1)}).catch(n=>{O(aG(n,i)),t&&tl.getState().setNotice(e,aG(n,i))}).finally(()=>{m(n.parentConversationId,n.requestId)})},[h,p,t,m,i,e,d,v]);let[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(null),B=(0,Z.useCallback)(t=>{g(t),z(null),O(null),M(null),tl.getState().setNotice(e,``)},[e,g]),V=(0,Z.useCallback)(async n=>{let r=Qe.getState().tabs.find(e=>e.id===n)?.promotedConversationId;L(!0);try{r||await JW(n),B(n)}catch(r){let a=r?.status;a===404||a===410?B(n):(M(null),z(n),O(aG(r,i)),t&&tl.getState().setNotice(e,aG(r,i)))}finally{L(!1)}},[t,i,e,B]),H=(0,Z.useCallback)(e=>{let t=Qe.getState(),n=t.tabs.find(t=>t.id===e),r=t.readings[e],i=t.drafts[e];if(n?.promotedConversationId){V(e);return}if(r&&!r.messages.length&&!r.truncated&&!i?.text.trim()&&!i?.attachments.length&&!n?.runId||tG()){V(e);return}P(!1),M(e)},[V]),ee=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=Qe.getState().widthPx,r=e.pointerId;e.currentTarget.setPointerCapture(r),A(!0);let i=e=>{let r=Math.min(760,Math.max(360,n+t-e.clientX));document.getElementById(`app-side-chat-panel`)?.style.setProperty(`--side-chat-panel-px`,`${r}px`)},a=e=>{let r=Math.min(760,Math.max(360,n+t-e.clientX));b(r),A(!1),window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[b]);return(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.detail;c.some(e=>e.id===t)&&!I&&H(t)};return window.addEventListener(`workspace-close-sidechat`,e),()=>window.removeEventListener(`workspace-close-sidechat`,e)},[I,t,H,c]),!t&&!a?null:(0,$.jsxs)(`aside`,{id:!t||n?`app-side-chat-panel`:void 0,"aria-label":i.paneAria,className:Y(t?`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`:`relative flex min-h-0 shrink-0 flex-col overflow-hidden border-l border-edge bg-surface-base`,!t&&`max-md:fixed max-md:inset-y-0 max-md:right-0 max-md:z-50 max-md:w-[min(92vw,34rem)] max-md:shadow-popover`,!t&&`app-side-chat-expanded-width app-side-chat-panel-enter`,t&&!n&&`hidden`,k&&`side-chat-panel-resizing`),style:{"--side-chat-panel-px":`${y}px`},children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.resizeAria,onPointerDown:ee,className:`absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize touch-none md:block`}),(0,$.jsxs)(`div`,{"data-side-chat-header":!0,className:Y(`h-11 shrink-0 items-center gap-1 overflow-x-auto px-2`,t?`hidden`:`flex`),children:[c.map(e=>(0,$.jsxs)(`div`,{className:Y(`flex h-8 shrink-0 items-center rounded-lg pl-3 text-sm`,e.id===u?`bg-surface-hover text-fg`:`text-fg-muted`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`max-w-40 truncate`,onClick:()=>_(e.id),children:[e.title===`Side chat`?i.title:e.title,e.ended?` · ${e.ended===`promoted`?i.savedLabel:i.endedLabel}`:``]}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-md hover:bg-surface-active`,"aria-label":i.closeAria,onClick:()=>H(e.id),children:(0,$.jsx)(ds,{className:`size-3.5`})})]},e.id)),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.newAria,title:i.newAria,disabled:w,onClick:()=>f(e),children:(0,$.jsx)(yo,{className:`size-4`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto size-8 shrink-0 p-0`,"aria-label":i.closePaneAria,onClick:()=>v(e,!1),children:(0,$.jsx)(br,{className:`size-4`})})]}),T&&(C||t)?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-2 text-xs text-fg-muted`,role:`status`,children:[(0,$.jsx)(`p`,{children:T}),R?(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(`p`,{children:i.closeFailedDescription}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:I,onClick:()=>void V(R),children:i.retryClose}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:I,onClick:()=>{B(R)},children:i.closeLocalTab})]}):null,o.filter(e=>!e.ended).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`mr-2 mt-1 rounded border border-edge px-2 py-1`,onClick:()=>{_(e.id),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e.parentConversationId}}))},children:e.title===`Side chat`?i.title:e.title},e.id))]}):null,t?c.filter(e=>!e.ended||s[e.id]||n&&r?.activeId===`side:${e.id}`).map(t=>(0,$.jsx)(cG,{sideChatId:t.id,token:S??void 0,initialRunId:t.runId,onRunIdChange:x,parentConversationId:e,visible:n&&r?.activeId===`side:${t.id}`},`${t.id}:${S??``}`)):C?(0,$.jsx)(cG,{sideChatId:C.id,token:S??void 0,initialRunId:C.runId,onRunIdChange:x,parentConversationId:e},`${C.id}:${S??``}`):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-8 text-center`,children:[(0,$.jsx)(Fa,{className:`mb-4 size-10 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm leading-6 text-fg-muted`,children:i.temporaryDescription}),w?(0,$.jsx)(ps,{className:`mt-4 h-4 w-32`}):null,T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-4 text-xs text-red-600 dark:text-red-400`,role:`alert`,children:T}),(0,$.jsx)(X,{className:`mt-3`,disabled:w,onClick:()=>f(e),children:i.retryCreate})]}):null]}),(0,$.jsx)(rd,{open:j!==null,title:c.find(e=>e.id===j)?.runId?i.stopCloseTitle:i.closeConfirmTitle,description:c.find(e=>e.id===j)?.runId?i.stopCloseDescription:i.closeConfirmDescription,confirmLabel:c.find(e=>e.id===j)?.runId?i.stopCloseAction:i.closeConfirmAction,cancelLabel:i.closeConfirmCancel,checkboxLabel:i.closeConfirmDontAskAgain,checkboxChecked:N,onCheckboxCheckedChange:P,destructive:!0,onConfirm:()=>{if(I)return;let e=j;e&&(N&&nG(),P(!1),V(e))},onCancel:()=>{M(null),P(!1)}})]})}function cG({sideChatId:e,token:t,initialRunId:n,onRunIdChange:r,parentConversationId:i,visible:a=!0}){let o=m(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(()=>Qe.getState().readings[e]?.messages??[]),d=Qe(t=>t.drafts[e]?.text??``),f=Qe(t=>t.drafts[e]?.attachments??eG),p=(0,Z.useCallback)(t=>Qe.getState().setDraftText(e,t),[e]),h=(0,Z.useCallback)(t=>{Qe.getState().setDraftAttachments(e,t)},[e]),[g,_]=(0,Z.useState)(()=>Qe.getState().tabs.find(t=>t.id===e)?.ended),[v,y]=(0,Z.useState)(!g),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=b||S!==null,[T,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(()=>Qe.getState().tabs.find(t=>t.id===e)?.promotedConversationId),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(``),[H,ee]=(0,Z.useState)(Date.now),[te,ne]=(0,Z.useState)(0),U=Qe(t=>t.tabs.find(t=>t.id===e)?.fresh),re=Qe(t=>t.readings[e]?.truncated??!1),W=(0,Z.useRef)(!0),ie=(0,Z.useRef)(g),G=(0,Z.useRef)(E.getState()),K=(0,Z.useCallback)(()=>G.current.conversationId===E.getState().conversationId&&G.current.baseUrl===E.getState().baseUrl,[]),ae=(0,Z.useCallback)(()=>W.current&&K(),[K]);(0,Z.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let[q,oe]=(0,Z.useState)(!!n),[se,ce]=(0,Z.useState)(n),[le,de]=(0,Z.useState)(null),[fe,me]=(0,Z.useState)(null),[he,ge]=(0,Z.useState)(!1),[_e,ve]=(0,Z.useState)(null),ye=(0,Z.useRef)(!1),be=(0,Z.useRef)(0),xe=(0,Z.useRef)(0),Se=(0,Z.useRef)(!1),Ce=(0,Z.useRef)(!1),we=(0,Z.useRef)(new Map),Te=F(D(e=>e.language)),Ee=Te.sideChat,De=jd({conversationId:e,chat:Te.chat,initialAttachments:f,onAttachmentsChange:h}),Oe=J({receiveExternalFill:!1,conversationId:e,disabled:!a||!!g||w,initialValue:d,onValueChange:p,autoFocusKey:a?e:null,shouldSyncSelectionRef:ye}),ke=(0,Z.useRef)({}),{scrollRef:Ae,atBottom:je,registerListContentRef:Me,scrollToBottom:Pe,onScroll:Ie}=He({hasToken:!0,showSessionLoading:!1,conversationId:e,chatMessages:l,streaming:q,hasMore:!1,loadingMore:!1,loadMoreMessages:$W});(0,Z.useEffect)(()=>{ae()&&(l.length||!v)&&Qe.getState().rememberMessages(e,l)},[l,v,e,ae]);let Le=(0,Z.useCallback)(t=>{!ae()||ie.current||(ie.current=t,be.current+=1,_(t),oe(!1),ce(void 0),me(null),c(null),V(``),de(null),x(!1),C(null),y(!1),u(e=>ft(e).messages),Qe.getState().markEnded(e,t))},[ae,e]),Re=(0,Z.useCallback)(e=>{if(!ae()||Ce.current)return;let t=e;if(t.body?.code===`EXPIRED`||t.status===410)Le(t.body?.reason===`waiting`?`waiting`:`idle`);else if(t.status===404||t.body?.code===`NOT_FOUND`)Le(`unavailable`);else{let n=t.status===void 0||t.status>=500||t.status===408||t.status===429;x(n),C(n?null:aG(e,Ee))}y(!1)},[Le,ae,Ee]),ze=(0,Z.useCallback)(t=>{if(!ae()||ie.current)return;let n=t.serverNow?Date.parse(t.serverNow):0;n&&n<xe.current||(xe.current=n,c(t),x(!1),C(null),t.serverNow&&ne(Date.parse(t.serverNow)-Date.now()),ee(Date.now()),oe(t.status!==`idle`),ce(t.runId),r(e,t.runId),me(t.clarification??null))},[ae,r,e]),Ve=(0,Z.useCallback)(async()=>{let t=be.current;try{let[n,r]=await Promise.all([HW(e),UW(e)]);if(!ae()||ie.current)return;be.current===t&&(ze(n),u(oG(ac(r),we.current))),y(!1)}catch(e){Re(e)}},[ze,Re,ae,e]);(0,Z.useEffect)(()=>{if(g)return;Ve();let t=!1,n=async()=>{if(t||ie.current)return;t=!0;let n=be.current;try{let t=await YW(e);t&&n===be.current&&ze(t)}catch(e){Re(e)}finally{t=!1}},r=window.setInterval(()=>{ee(Date.now()),n()},3e4),i=()=>{document.visibilityState!==`hidden`&&Ve()};return window.addEventListener(`online`,i),window.addEventListener(`pageshow`,i),document.addEventListener(`visibilitychange`,i),()=>{window.clearInterval(r),window.removeEventListener(`online`,i),window.removeEventListener(`pageshow`,i),document.removeEventListener(`visibilitychange`,i)}},[g,Ve,ze,Re,e]),(0,Z.useEffect)(()=>{if(!g)return kc(`side-chat:${zW()}:${e}`,{onEvent:e=>{e.event===`expired`&&Le(e.data?.reason===`waiting`?`waiting`:`idle`)},onGap:()=>Ve()})},[g,Le,Ve,e]),(0,Z.useEffect)(()=>{if(!B)return;let e=window.setTimeout(()=>V(``),5e3);return()=>window.clearTimeout(e)},[B]);let Ue=(0,Z.useRef)(0),We=(0,Z.useRef)(a);We.current=a;let Ge=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{a&&(Ue.current=l.length,Ge.current=!1),Qe.getState().setTabStatus(e,{waiting:!!fe,disconnected:b,unread:!a&&(Ge.current||l.length>Ue.current)})},[fe,b,l,se,e,a]);let qe=s?.expiresAt?Date.parse(s.expiresAt)-(H+te):1/0,Je=!g&&!w&&qe<=5*6e4,Ye=async()=>{if(!(T||ie.current)){O(!0);try{let t=await XW(e);if(!ae()||ie.current)return;ze(t),de(null),V(Ee.extended)}catch(e){let t=e.status;(t===404||t===410)&&Re(e),ie.current||de(Ee.extendFailed)}finally{O(!1)}}},Xe=async()=>{let t=i??Qe.getState().tabs.find(t=>t.id===e)?.parentConversationId;if(!(!t||k)){A(!0),de(null);try{let n=await VW(t,[]);if(!K())return;Qe.getState().replaceTab(e,{id:n.id,parentConversationId:t,title:`Side chat`})}catch(e){if(!ae())return;e.body?.code===`PARENT_NOT_FOUND`&&z(!0),de(aG(e,Ee))}finally{A(!1)}}},Ze=(0,Z.useCallback)(e=>{be.current+=1,u(t=>{let n=structuredClone(t),r=n.at(-1);return r?.role!==`assistant`&&(r={role:`assistant`,content:[],timestamp:Date.now()},n.push(r)),e(r),n})},[]);(0,Z.useEffect)(()=>{if(!(!se||g))return kc(`run:${se}`,{onEvent:t=>{if(!ae()||ie.current)return;We.current||(Ge.current=!0);let n=t.data?.payload??{};t.event===`assistant_message_start`?Ze(()=>{}):t.event===`assistant_delta`?Ze(e=>Us(e.content,String(n.delta??``),String(n.messageId??``))):t.event===`thinking_delta`?Ze(e=>ec(e.content,String(n.delta??``),!0)):t.event===`thinking_end`?Ze(e=>oc(e.content)):t.event===`tool_start`?Ze(e=>Ks(e.content,String(n.toolName??`tool`),n.args,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`tool_end`?Ze(e=>qs(e.content,String(n.toolName??`tool`),n.status===`error`,n.result,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`clarify_request`?(me({...Xs(n),expiresAt:typeof n.expiresAt==`number`?n.expiresAt:void 0,requestId:String(n.requestId??``),kind:n.kind===`approval`?`approval`:`input`,question:String(n.question??``)}),ve(null),Ve()):t.event===`error`?de(String(n.message??Ee.failed)):t.event===`run_end`&&(oe(!1),ce(void 0),r(e,void 0),me(null),Ve())},onGap:()=>Ve()})},[g,ae,Ze,r,Ve,se,e,Ee.failed]);let $e=()=>{let t=d.trim(),n=De.wireAttachmentsPayload();if(!t&&n.length===0||q||Se.current||ie.current||w)return;if(et(t)>262144){de(Ee.draftTooLong);return}let i={text:d,attachments:[...De.attachmentsRef.current]};Se.current=!0,Oe.resetEditor(),De.clearAttachments(),de(null),be.current+=1;let a=crypto.randomUUID(),o={role:`user`,content:[{type:`text`,text:t}],attachments:i.attachments,timestamp:Date.now(),renderKey:`side-chat-user:${a}`};we.current.set(a,o),u(e=>[...e,o]),oe(!0),GW(e,t,n).then(t=>{!K()||ie.current||(Qe.getState().setTabRunId(e,t),ae()&&(ce(t),r(e,t)))}).catch(t=>{if(!K())return;let n=Qe.getState();if(!ae()&&!n.tabs.some(t=>t.id===e))return;let r=Qe.getState().drafts[e]??{text:``,attachments:[]},s={text:r.text?`${i.text}\n${r.text}`:i.text,attachments:[...i.attachments,...r.attachments]};ae()?(Oe.resetEditor({nextText:s.text}),De.setAttachments(s.attachments)):(p(s.text),h(s.attachments)),we.current.delete(a);let c=n.readings[e];if(c&&n.rememberMessages(e,c.messages.filter(e=>e.renderKey!==o.renderKey)),!ae())return;u(e=>e.filter(e=>e.renderKey!==o.renderKey)),oe(!1);let l=t.status;l===404||l===410?Re(t):de(aG(t,Ee))}).finally(()=>{Se.current=!1})},tt=async t=>{if(!(!fe||ie.current)){ge(!0),ve(null);try{await qW(e,fe.requestId,t),me(null),Ve()}catch(e){e.status===410?Re(e):ve(aG(e,Ee))}finally{ge(!1)}}},rt=async()=>{try{await KW(e,se),ae()&&me(null)}catch(e){if(!ae())return;let t=e.status;t===404||t===410?Re(e):de(aG(e,Ee))}},it=(0,Z.useCallback)(e=>{Oe.resetEditor({nextText:e,focus:!0})},[Oe.resetEditor]),at=`${o.pathname}${o.search}`,ot=(0,Z.useCallback)(async e=>{try{let t=await ia(e.trim(),`web`);Ml(`success`,Te.chat.messageSavedToNote,void 0,{href:Na(at,t.id)})}catch(e){throw Ml(`error`,e instanceof Error?e.message:Te.notes.quickCaptureFailed),e}},[at,Te.chat.messageSavedToNote,Te.notes.quickCaptureFailed]),st=(0,Z.useCallback)(async()=>{if(!(Ce.current||q||ie.current||l.length===0)){Ce.current=!0,M(!0),P(!1),de(null);try{let t=await ZW(e);if(!K())return;ie.current=`promoted`,_(`promoted`),L(t.conversationId),oe(!1),ce(void 0),me(null),c(null),r(e,void 0),Qe.getState().markPromoted(e,t.conversationId),Ml(`success`,Ee.savedTitle,void 0,{href:`/chat/${encodeURIComponent(t.conversationId)}`})}catch(e){if(!ae())return;de(aG(e,Ee)||Ee.saveFailed)}finally{Ce.current=!1,ae()&&M(!1)}}},[ae,l.length,r,q,K,e,Ee]),ct=(0,Z.useCallback)(()=>{if(d.trim()||f.length){P(!0);return}st()},[f.length,d,st]),lt=(0,Z.useCallback)(async t=>{let n=await WW(e,t);ae()&&!ie.current&&c(n)},[ae,e]);return ke.current={adapters:[],send:$e,runBusy:q,pendingFollowUpsCount:0,editingFollowUpId:null,onCancelEditFollowUp:()=>{},attachmentsLen:De.attachments.length,contextRefsLen:0,isComposing:Oe.isComposing,valueRef:Oe.valueRef,adjustHeight:Oe.adjustHeight,editorRef:Oe.editorRef},(0,$.jsxs)(`div`,{hidden:!a,className:Y(`relative min-h-0 flex-1 flex-col`,a?`flex`:`hidden`),children:[(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{ref:Ae,"data-side-chat-scroll-viewport":!0,onScroll:Ie,className:`chat-messages h-full overflow-y-auto overflow-x-hidden px-5 py-4 [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,children:[v&&!l.length?(0,$.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-label":Ee.creating,children:[(0,$.jsx)(ps,{className:`ml-auto h-12 w-3/4`}),(0,$.jsx)(ps,{className:`h-4 w-full`}),(0,$.jsx)(ps,{className:`h-4 w-4/5`})]}):l.length&&a?(0,$.jsx)(Mt,{messages:l,authToken:t,conversationId:e,workspaceConversationId:i,streaming:q,progress:null,reasoningLevel:`on`,registerListContentRef:Me,deleteRoundDisabled:q||!!g,onSaveAssistantAsNote:ot,onEditUserMessage:g?void 0:e=>it(rG(e)),responseFeedbackEnabled:!1}):g?null:(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center text-center`,children:[(0,$.jsx)(Fa,{className:`mb-4 size-9 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Ee.title}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:U?Ee.freshContext:Ee.emptyDescription}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-xs leading-5 text-fg-muted`,children:Ee.temporaryDescription})]}),re&&g?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:Ee.partialReading}):null]}),(0,$.jsx)(Dt,{visible:!je,onClick:()=>Pe(!0),edge:`bottom`,running:q})]}),b&&!g?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:Ee.connectionLost}):null,B?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:B}):null,Je?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-4 py-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:qe<=0?Ee.verifying:Ee.expiring.replace(`{{minutes}}`,String(Math.max(1,Math.ceil(qe/6e4))))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto h-8 text-xs`,disabled:T||qe<=0,onClick:()=>void Ye(),children:Ee.keepAlive})]}):null,fe&&!g?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-3 pt-3`,children:(0,$.jsx)(Be,{prompt:{...fe,durable:!1},submitting:he,submitError:_e,labels:Te.chat,onSubmit:tt,onAgentDecide:()=>tt({response:{text:`Use your best judgment and continue without additional user input.`}}),onCancel:rt})}):null,S||le?(0,$.jsx)(`p`,{role:`alert`,className:`border-t border-edge px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:S??le}):null,g===`promoted`&&I?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:Ee.savedTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Ee.savedDescription}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:I}}))},children:Ee.openSavedChat})]})}):g?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:g===`unavailable`?Ee.unavailableTitle:Ee.expiredTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:R?Ee.parentMissing:g===`waiting`?Ee.waitExpired:l.length?Ee.expiredDescription:Ee.unavailableDescription}),d||f.length?(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`label`,{htmlFor:`side-chat-draft-${e}`,className:`text-xs text-fg-muted`,children:Ee.unsentDraft}),(0,$.jsx)(kd,{attachments:f,topPadded:!1,onRemove:De.removeAttachment,className:`mt-1 rounded-t-lg`}),d?(0,$.jsx)(`textarea`,{id:`side-chat-draft-${e}`,value:d,onChange:e=>p(nt(e.target.value)),rows:3,className:`mt-1 w-full resize-y rounded-lg border border-edge bg-surface-base p-2 text-sm`}):null]}):null,(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,disabled:k,onClick:()=>{R?i&&Qe.getState().setOpen(i,!1):Xe()},children:R?Ee.closePaneAria:k?Ee.creating:d.trim()||f.length?Ee.newWithDraft:Ee.newAria}),l.length&&!R?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Ee.replaceHint}):null]})}):(0,$.jsx)(`form`,{"data-side-chat-composer":!0,onSubmit:e=>{e.preventDefault(),$e()},className:`shrink-0 p-3`,children:(0,$.jsxs)(Fe,{dragging:De.isDragging,onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,De.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&De.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),De.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&De.processFiles(Array.from(t))},children:[(0,$.jsx)(`input`,{ref:De.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&De.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsx)(kd,{attachments:De.attachments,topPadded:!1,onRemove:De.removeAttachment}),s?.context.selections.length?(0,$.jsxs)(`div`,{className:`mx-3 mt-3 inline-flex h-8 max-w-[calc(100%-1.5rem)] self-start items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg-muted sm:mx-4`,title:s.context.selections.map(e=>e.label||e.text).join(`
|
|
9
9
|
`),children:[(0,$.jsx)(Ke,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:(s.context.selections.length===1?Ee.selectionCount_one:Ee.selectionCount_other).replace(`{{count}}`,String(s.context.selections.length))})]}):null,(0,$.jsx)(`div`,{className:s?.context.selections.length?`px-3 sm:px-4`:`px-3 pt-1 sm:px-4`,children:(0,$.jsx)(pe,{editorRef:Oe.editorRef,disabled:w,placeholder:Te.chat.typeMessage,onWireInput:(e,t)=>{let n=nt(e);et(e)>262144&&de(Ee.draftTooLong),Oe.onWireInput(n,Math.min(t,n.length))},adjustHeight:Oe.adjustHeight,processFiles:De.processFiles,processPastedText:De.processPastedText,setIsComposing:Oe.setIsComposing,kbdRef:ke,chatMessages:Te.chat})}),(0,$.jsxs)(kt,{children:[(0,$.jsx)(Ne,{disabled:w,runBusy:q,attachmentCount:De.attachments.length,maxAttachments:10,chat:Te.chat,onPickFiles:()=>De.fileInputRef.current?.click()}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,"aria-label":Ee.saveAsChat,title:q?Ee.saveBusy:Ee.saveAsChat,disabled:j||q||w||l.length===0,onClick:ct,children:[(0,$.jsx)(Mo,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`max-sm:hidden`,children:j?Ee.savingChat:Ee.saveAsChat})]}),(0,$.jsx)(`div`,{className:`ml-auto min-w-0`,children:s?(0,$.jsx)(mc,{chat:Te.chat,sessionModel:s.config.modelRef,modelDisabled:w,onModelChange:(e,t)=>lt({modelRef:e,thinkingLevel:t}),thinkingLevel:s.config.thinkingLevel,thinkingDisabled:w,onThinkingChange:e=>lt({thinkingLevel:e})}):null}),(0,$.jsx)(ue,{disabled:w||et(d)>262144,voiceActive:!1,runBusy:q,hasDraft:!!d.trim()||De.attachments.length>0,showSteeringInterrupt:!1,chat:Te.chat,onSend:$e,onAbort:()=>void rt()})]})]})}),(0,$.jsx)(rd,{open:N,title:Ee.saveDraftTitle,description:Ee.saveDraftDescription,confirmLabel:Ee.saveDraftAction,cancelLabel:Ee.closeConfirmCancel,onConfirm:()=>void st(),onCancel:()=>P(!1)})]})}var lG=`flex min-w-0 flex-1 items-start gap-3 rounded-xl p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`;function uG(e){let t=(0,Q.c)(53),{item:n,scope:r,zh:i,sourceHref:a,onSource:o}=e,{artifact:s,reference:c,task:l}=n,u=s?.title??c?.title??n.id,d=s?.kind===`site`||s?.mimeType===`text/html`||c?.kind===`local_app`||c?.kind===`chat_preview`,f;t[0]!==s?.kind||t[1]!==c?.kind||t[2]!==d||t[3]!==u||t[4]!==i?(f=d?i?`网页`:`Web page`:s?.kind===`document`||c?.kind===`note`?i?`文档`:`Document`:u.match(/\.([a-z0-9]{1,8})$/i)?.[1].toUpperCase()??(i?`文件`:`File`),t[0]=s?.kind,t[1]=c?.kind,t[2]=d,t[3]=u,t[4]=i,t[5]=f):f=t[5];let p=f,m;t[6]!==d||t[7]!==u?(m=(0,$.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-xl bg-surface-inset text-fg-muted`,"aria-hidden":!0,children:d?(0,$.jsx)(Xi,{className:`size-4`}):(0,$.jsx)(Si,{name:u})}),t[6]=d,t[7]=u,t[8]=m):m=t[8];let h;t[9]===u?h=t[10]:(h=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:u,children:u}),t[9]=u,t[10]=h);let g=l?.title??(i?`对话`:`Conversation`),_;t[11]!==p||t[12]!==g?(_=(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-xs text-fg-muted`,children:[p,` · `,g]}),t[11]=p,t[12]=g,t[13]=_):_=t[13];let v;t[14]===n.createdAt?v=t[15]:(v=new Date(n.createdAt).toISOString(),t[14]=n.createdAt,t[15]=v);let y=i?`zh`:`en`,x;t[16]!==n.createdAt||t[17]!==y?(x=Qd(n.createdAt,y),t[16]=n.createdAt,t[17]=y,t[18]=x):x=t[18];let S;t[19]!==v||t[20]!==x?(S=(0,$.jsx)(`time`,{className:`mt-0.5 block text-xs text-fg-subtle`,dateTime:v,children:x}),t[19]=v,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==h||t[23]!==_||t[24]!==S?(C=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[h,_,S]}),t[22]=h,t[23]=_,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==C||t[27]!==m?(w=(0,$.jsxs)($.Fragment,{children:[m,C]}),t[26]=C,t[27]=m,t[28]=w):w=t[28];let T=w,E=l?.conversationId??r,D;t[29]!==T||t[30]!==n||t[31]!==r||t[32]!==a||t[33]!==E||t[34]!==i?(D=(0,$.jsx)(tf,{item:n,workspaceScope:r,conversationId:E,backgroundPath:a,zh:i,className:lG,children:T}),t[29]=T,t[30]=n,t[31]=r,t[32]=a,t[33]=E,t[34]=i,t[35]=D):D=t[35];let O;t[36]!==a||t[37]!==l?(O=l?Sa(a,l.id):a,t[36]=a,t[37]=l,t[38]=O):O=t[38];let k;t[39]!==n.turnId||t[40]!==l?(k=l?{focusTaskResults:l.id,taskPreview:{id:l.id,title:l.title}}:{personalSourceTurnId:n.turnId},t[39]=n.turnId,t[40]=l,t[41]=k):k=t[41];let A=l?ku:void 0,j=l?ku:void 0,M=i?`回到来源 · ${u}`:`Go to source · ${u}`,N=i?`回到来源`:`Go to source`,P;t[42]!==o||t[43]!==O||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==M||t[48]!==N?(P=(0,$.jsx)(b,{to:O,state:k,onPointerEnter:A,onFocus:j,onClick:o,"aria-label":M,className:`mt-1 shrink-0 rounded-lg px-2 py-2 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:N}),t[42]=o,t[43]=O,t[44]=k,t[45]=A,t[46]=j,t[47]=M,t[48]=N,t[49]=P):P=t[49];let F;return t[50]!==D||t[51]!==P?(F=(0,$.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1`,children:[D,P]}),t[50]=D,t[51]=P,t[52]=F):F=t[52],F}function dG(e){let t=(0,Q.c)(64),{scope:n,zh:r,enabled:i,active:a,id:o,labelledBy:s,sourceHref:c,onSource:l}=e,u=E(hG),d;t[0]!==i||t[1]!==u||t[2]!==n?(d=(e,t)=>{let r=e===0?0:t?.nextOffset;return i&&r!=null?[n,u,r]:null},t[0]=i,t[1]=u,t[2]=n,t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={shouldRetryOnError:!1},t[4]=f):f=t[4];let{data:p,error:m,isValidating:h,setSize:g,size:_,mutate:v}=vc(d,mG,f),y;t[5]!==g||t[6]!==_?(y=()=>{g(_+1)},t[5]=g,t[6]=_,t[7]=y):y=t[7];let b=y,x;t[8]===p?x=t[9]:(x=p?.at(-1)?.nextOffset,t[8]=p,t[9]=x);let S=x!=null,{listRef:C,loadMoreRef:w}=so(a&&S&&!h&&!m,b);fo(i?n:void 0,v);let T,D,O,k,A,j,M,N,P;if(t[10]!==a||t[11]!==p||t[12]!==o||t[13]!==s||t[14]!==C||t[15]!==l||t[16]!==n||t[17]!==c||t[18]!==r){let e=new Set;T=(p??[]).flatMap(pG).filter(t=>{let{id:n}=t;return e.has(n)?!1:(e.add(n),!0)}),M=C,N=!a,P=`tabpanel`,D=o,O=s,k=`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6 pt-3 [scrollbar-gutter:stable] sm:px-6`,A=`space-y-2`;let i;t[28]!==l||t[29]!==n||t[30]!==c||t[31]!==r?(i=e=>(0,$.jsx)(uG,{item:e,scope:n,zh:r,sourceHref:c,onSource:l},e.id),t[28]=l,t[29]=n,t[30]=c,t[31]=r,t[32]=i):i=t[32],j=T.map(i),t[10]=a,t[11]=p,t[12]=o,t[13]=s,t[14]=C,t[15]=l,t[16]=n,t[17]=c,t[18]=r,t[19]=T,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M,t[26]=N,t[27]=P}else T=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25],N=t[26],P=t[27];let F;t[33]!==A||t[34]!==j?(F=(0,$.jsx)(`ul`,{className:A,children:j}),t[33]=A,t[34]=j,t[35]=F):F=t[35];let I;t[36]!==p||t[37]!==h||t[38]!==_?(I=h&&(!p||_>p.length)?(0,$.jsx)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:(p?[0]:[0,1,2]).map(fG)}):null,t[36]=p,t[37]=h,t[38]=_,t[39]=I):I=t[39];let L;t[40]!==m||t[41]!==v||t[42]!==r?(L=m?(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 px-2 text-sm text-accent-fg underline`,onClick:()=>void v(),children:r?`加载失败,重试`:`Loading failed. Try again`}):null,t[40]=m,t[41]=v,t[42]=r,t[43]=L):L=t[43];let R;t[44]!==p||t[45]!==m||t[46]!==T||t[47]!==r?(R=p&&!T.length&&!m?(0,$.jsxs)(`div`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:[(0,$.jsx)(Pi,{className:`mx-auto mb-3 size-5`,"aria-hidden":!0}),r?`对话和任务生成的文件、网页和文档会出现在这里。`:`Files, web pages, and documents created in conversations and tasks will appear here.`]}):null,t[44]=p,t[45]=m,t[46]=T,t[47]=r,t[48]=R):R=t[48];let z;t[49]!==S||t[50]!==w?(z=S?(0,$.jsx)(`div`,{ref:w,className:`h-px`,"aria-hidden":!0}):null,t[49]=S,t[50]=w,t[51]=z):z=t[51];let B;return t[52]!==D||t[53]!==O||t[54]!==k||t[55]!==F||t[56]!==I||t[57]!==L||t[58]!==R||t[59]!==z||t[60]!==M||t[61]!==N||t[62]!==P?(B=(0,$.jsxs)(`div`,{ref:M,hidden:N,role:P,id:D,"aria-labelledby":O,className:k,children:[F,I,L,R,z]}),t[52]=D,t[53]=O,t[54]=k,t[55]=F,t[56]=I,t[57]=L,t[58]=R,t[59]=z,t[60]=M,t[61]=N,t[62]=P,t[63]=B):B=t[63],B}function fG(e){return(0,$.jsx)(ps,{className:`h-16 rounded-xl`},e)}function pG(e){return e.items}async function mG(e){let[,,t]=e;return(await O(T(`/api/personal-agent/activity?view=deliverables&limit=15&offset=${t}`))).payload}function hG(e){return e.conversationId}var gG=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),_G={zh:new Intl.DateTimeFormat(`zh-CN`,{month:`numeric`,day:`numeric`}),en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`})};function vG(e,t,n=!1,r=new Date){if(n||new Date(e).toDateString()===r.toDateString())return gG.format(e);let i=new Date(r);return i.setDate(r.getDate()-1),new Date(e).toDateString()===i.toDateString()?t?`昨天`:`Yesterday`:_G[t?`zh`:`en`].format(e)}function yG(e,t,n=new Date){if(new Date(e).toDateString()===n.toDateString())return`${t?`今天`:`Today`} ${gG.format(e)}`;let r=new Date(n);return r.setDate(n.getDate()+1),new Date(e).toDateString()===r.toDateString()?`${t?`明天`:`Tomorrow`} ${gG.format(e)}`:$d(e,t?`zh`:`en`)}var bG=`/api/personal-agent/schedules`,xG=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function SG(e=``,t,n){return O(T(bG+e),{method:t,body:n?JSON.stringify(n):void 0})}function CG({scope:e,visible:t,zh:n}){let r=E(e=>e.conversationId),i=n?`zh`:`en`,{automations:a,cron:o}=F(i),{data:s,error:c,mutate:l}=gc(t&&e!==`new`?[bG,e,r]:null,()=>SG(),{refreshInterval:15e3}),[u,d]=(0,Z.useState)(null),f=[...s?.payload??[]].sort((e,t)=>(e.state.nextRunAtMs??1/0)-(t.state.nextRunAtMs??1/0)||t.updatedAtMs-e.updatedAtMs);return(0,$.jsxs)(`section`,{className:`space-y-1`,"aria-label":n?`定时任务`:`Scheduled tasks`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg-muted`,children:[n?`定时任务`:`Scheduled tasks`,!s&&!c&&t?(0,$.jsx)(ps,{className:`h-2.5 w-10`}):null]}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 gap-1 px-2 text-xs`,disabled:e===`new`,onClick:()=>d(`new`),children:[(0,$.jsx)(yo,{className:`size-4`,"aria-hidden":!0}),n?`新建`:`New`]})]}),c?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void l(),className:`px-2 py-2 text-sm text-accent-fg underline`,children:n?`加载失败,重试`:`Loading failed. Try again`}):null,f.length?(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:f.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(e),className:`flex w-full min-w-0 items-start gap-2.5 rounded-xl px-2 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 grid size-5 shrink-0 place-items-center text-fg-muted`,children:(0,$.jsx)(lr,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm leading-5 font-medium text-fg`,title:e.name,children:e.name}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.trigger.kind===`schedule`&&e.trigger.schedule.kind===`once`?a.trigger.once:ur(e.trigger,a,o,i)}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:fr(e)?n?`已触发`:`Triggered`:e.enabled?e.state.nextRunAtMs?yG(e.state.nextRunAtMs,n):dr(e,a,i):a.paused})]})]})]})},e.id))}):null,u?(0,$.jsx)(wG,{zh:n,schedule:u===`new`?void 0:u,onClose:()=>d(null),onSaved:()=>{l(),d(null)}},u===`new`?`new`:u.id):null]})}function wG({zh:e,schedule:t,onClose:n,onSaved:r}){let i=e?`zh`:`en`,a=F(i).automations,[o,s]=(0,Z.useState)(()=>{if(!t)return qd;let e=Kd(t),n=/^([0-9]+) ([0-9]+) \* \* 1-5$/.exec(e.cronExpr);return{...e,instruction:t.action.instruction,time:n?`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`:e.time}}),c=/^([0-9]+) ([0-9]+) \* \* 1-5$/.exec(o.cronExpr),[l,u]=(0,Z.useState)(()=>o.triggerMode===`cron`&&c?`weekdays`:o.triggerMode),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(!1),[m,h]=(0,Z.useState)(``),g=e=>s(t=>({...t,...e})),_=t?`/${encodeURIComponent(t.id)}`:``;async function v(e){if(!p.current){p.current=!0,f(!0),h(``);try{await e(),r()}catch(e){h(e instanceof Error?e.message:a.feedback.actionFailed)}finally{p.current=!1,f(!1)}}}function y(e){e.preventDefault(),v(async()=>{if(l===`once`&&!(new Date(o.onceAt).getTime()>Date.now()))throw Error(a.experience.futureTime);let e=Jd({...o,triggerMode:l===`weekdays`?`weekly`:l,weekday:l===`weekdays`?`1-5`:o.weekday}).trigger;if(e.kind!==`schedule`)return;let n={name:o.name,instruction:o.instruction,locale:i,schedule:e.schedule};t?await SG(_,`PATCH`,{...n,expectedRevision:t.updatedAtMs}):await SG(``,`POST`,n)})}return(0,$.jsx)(ne,{open:!0,onOpenChange:e=>{!e&&!d&&n()},children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`fixed inset-0 z-[110] bg-black/45`}),(0,$.jsxs)(ee,{onKeyDown:e=>e.stopPropagation(),className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[111] flex h-[min(36rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(te,{className:`font-semibold text-fg`,children:t?e?`编辑定时任务`:`Edit scheduled task`:e?`新建定时任务`:`New scheduled task`}),(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:d,"aria-label":e?`关闭`:`Close`,children:(0,$.jsx)(ds,{className:`size-4`})})})]}),(0,$.jsx)(B,{className:`sr-only`,children:e?`指定 Personal Agent 要做的事和执行时间。`:`Choose what your Personal Agent should do and when.`}),(0,$.jsxs)(`form`,{onSubmit:y,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-5`,children:[(0,$.jsxs)(`fieldset`,{disabled:d,className:`space-y-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a.form.name,(0,$.jsx)(`input`,{required:!0,maxLength:100,className:xG,value:o.name,onChange:e=>g({name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[e?`要做什么`:`What should the agent do?`,(0,$.jsx)(`textarea`,{required:!0,maxLength:5e4,rows:3,className:xG,value:o.instruction,onChange:e=>g({instruction:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[e?`频率`:`Repeat`,(0,$.jsxs)(Er,{value:l,onChange:e=>u(e.target.value),children:[(0,$.jsx)(Dr,{value:`once`,children:a.trigger.once}),(0,$.jsx)(Dr,{value:`daily`,children:a.trigger.daily}),(0,$.jsx)(Dr,{value:`weekdays`,children:e?`工作日`:`Weekdays`}),(0,$.jsx)(Dr,{value:`weekly`,children:a.trigger.weekly}),o.triggerMode===`interval`?(0,$.jsx)(Dr,{value:`interval`,children:e?`固定间隔`:`Fixed interval`}):null,o.triggerMode===`cron`&&!c?(0,$.jsx)(Dr,{value:`cron`,children:e?`自定义`:`Custom`}):null]})]}),l===`once`?(0,$.jsx)(rf,{label:a.form.onceAt,disabled:d,value:o.onceAt,defaultTime:o.time,onChange:e=>g({onceAt:e})}):l===`cron`?(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[e?`定时规则`:`Cron expression`,(0,$.jsx)(`input`,{required:!0,className:xG,value:o.cronExpr,onChange:e=>g({cronExpr:e.target.value})})]}):l===`interval`?(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[e?`间隔`:`Interval`,(0,$.jsx)(`input`,{type:`number`,required:!0,min:`1`,className:xG,value:o.intervalValue,onChange:e=>g({intervalValue:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[e?`单位`:`Unit`,(0,$.jsxs)(Er,{value:o.intervalUnit,onChange:e=>g({intervalUnit:e.target.value}),children:[(0,$.jsx)(Dr,{value:`minute`,children:e?`分钟`:`Minutes`}),(0,$.jsx)(Dr,{value:`hour`,children:e?`小时`:`Hours`}),(0,$.jsx)(Dr,{value:`day`,children:e?`天`:`Days`}),(0,$.jsx)(Dr,{value:`week`,children:e?`周`:`Weeks`})]})]})]}):(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{children:a.form.time}),(0,$.jsx)(Zd,{disabled:d,value:o.time,onChange:e=>g({time:e}),ariaLabel:a.form.time})]}),l===`weekly`?(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a.form.day,(0,$.jsx)(Er,{value:o.weekday,onChange:e=>g({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,$.jsx)(Dr,{value:String(t),children:a.weekdays[e]},e))})]}):null,l===`interval`?null:(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l===`once`?qd.timezone:o.timezone||qd.timezone})]}),m?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:m}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t&&!fr(t)?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:d,onClick:()=>void v(()=>SG(_,`PATCH`,{enabled:!t.enabled,expectedRevision:t.updatedAtMs})),children:t.enabled?e?`暂停`:`Pause`:e?`恢复`:`Resume`}):null,t?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:d,onClick:()=>void v(()=>SG(`${_}/run`,`POST`)),children:e?`立即运行`:`Run now`}):null]}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:d||!o.name.trim()||!o.instruction.trim(),children:e?`保存`:`Save`})]})]})]})]})})}var TG=`flex min-w-0 items-start gap-2.5 rounded-xl px-2 py-2 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,EG=`mt-0.5 grid size-5 shrink-0 place-items-center text-fg-muted`;function DG(e,t){let n=new Date;n.setHours(0,0,0,0);let r=new Date(n);r.setDate(n.getDate()-1);let i=new Date(n);i.setDate(n.getDate()-(n.getDay()+6)%7);let a=new Date(n.getFullYear(),n.getMonth(),1),o=new Intl.DateTimeFormat(t?`zh-CN`:`en-US`,{year:`numeric`,month:`long`}),s=new Intl.DateTimeFormat(t?`zh-CN`:`en-US`,{month:`long`}),c=new Set,l=new Map;for(let u of[...e].sort((e,t)=>t.updatedAt-e.updatedAt)){if(c.has(u.id))continue;c.add(u.id);let e=u.updatedAt>=+n?t?`今天`:`Today`:u.updatedAt>=+r?t?`昨天`:`Yesterday`:u.updatedAt>=+i?t?`本周`:`This week`:u.updatedAt>=+a?t?`本月`:`This month`:u.updatedAt>0?(new Date(u.updatedAt).getFullYear()===n.getFullYear()?s:o).format(u.updatedAt):t?`更早`:`Earlier`,d=l.get(e);d?d.items.push(u):l.set(e,{title:e,dateInHeading:u.updatedAt>=+r,items:[u]})}return[...l.values()]}function OG(e){let t=(0,Q.c)(82),{item:n,zh:r,scope:i,personalHref:a,dateInHeading:o,onNavigate:s}=e,c,l,u,d,f,p,m,h;if(t[0]!==n||t[1]!==r){let[e,i]=uo(n,r);l=e,c=n.phase===`closed`&&n.resolution===`done`;let a=n.attention?Lo:c?Nr:n.phase===`closed`?Yr:ga;h=n.operationalState===`running`||n.operationalState===`verifying`,t[10]===a?m=t[11]:(m=(0,$.jsx)(`span`,{className:EG,"aria-hidden":!0,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.7})}),t[10]=a,t[11]=m),f=`min-w-0 flex-1`,t[12]===n.title?p=t[13]:(p=(0,$.jsx)(`span`,{className:`block truncate text-sm leading-5 font-medium text-fg`,title:n.title,children:n.title}),t[12]=n.title,t[13]=p),d=`flex items-center gap-1.5 text-xs leading-5 text-fg-muted`,u=Y(`size-1.5 shrink-0 rounded-full`,i),t[0]=n,t[1]=r,t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h}else c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9];let g;t[14]===u?g=t[15]:(g=(0,$.jsx)(`span`,{className:u,"aria-hidden":!0}),t[14]=u,t[15]=g);let _;t[16]===l?_=t[17]:(_=(0,$.jsx)(`span`,{className:`truncate`,children:l}),t[16]=l,t[17]=_);let v;t[18]!==o||t[19]!==n.updatedAt||t[20]!==r?(v=n.updatedAt>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`time`,{className:`shrink-0 text-fg-subtle`,dateTime:new Date(n.updatedAt).toISOString(),title:Qd(n.updatedAt,r?`zh`:`en`),children:vG(n.updatedAt,r,o)})]}):null,t[18]=o,t[19]=n.updatedAt,t[20]=r,t[21]=v):v=t[21];let y;t[22]!==d||t[23]!==g||t[24]!==_||t[25]!==v?(y=(0,$.jsxs)(`span`,{className:d,children:[g,_,v]}),t[22]=d,t[23]=g,t[24]=_,t[25]=v,t[26]=y):y=t[26];let x;t[27]!==f||t[28]!==p||t[29]!==y?(x=(0,$.jsxs)(`span`,{className:f,children:[p,y]}),t[27]=f,t[28]=p,t[29]=y,t[30]=x):x=t[30];let S;t[31]!==x||t[32]!==m?(S=(0,$.jsxs)($.Fragment,{children:[m,x]}),t[31]=x,t[32]=m,t[33]=S):S=t[33];let C=S,w,T,E,D,O,k,A,j,M,N;if(t[34]!==C||t[35]!==n.artifact||t[36]!==n.id||t[37]!==n.prompt||t[38]!==n.title||t[39]!==s||t[40]!==a||t[41]!==c||t[42]!==i||t[43]!==h){N=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(TG,h&&`bg-surface-hover/75`);if(n.prompt){let r;t[54]===n.prompt.id?r=t[55]:(r={focusClarification:n.prompt.id},t[54]=n.prompt.id,t[55]=r),N=(0,$.jsx)(b,{to:n.prompt.conversationId===i?a:`/chat/${encodeURIComponent(n.prompt.conversationId)}`,state:r,onClick:s,className:e,children:C});break bb0}T=n.artifact,M=`flex min-w-0 items-center gap-1`,w=b,t[56]!==n.id||t[57]!==a?(E=Sa(a,n.id),t[56]=n.id,t[57]=a,t[58]=E):E=t[58];let r;t[59]!==n.id||t[60]!==n.title?(r={id:n.id,title:n.title},t[59]=n.id,t[60]=n.title,t[61]=r):r=t[61];let o=c?n.id:void 0;t[62]!==r||t[63]!==o?(D={taskPreview:r,focusTaskResults:o},t[62]=r,t[63]=o,t[64]=D):D=t[64],O=ku,k=ku,A=s,j=Y(e,`flex-1 active:bg-surface-hover`)}t[34]=C,t[35]=n.artifact,t[36]=n.id,t[37]=n.prompt,t[38]=n.title,t[39]=s,t[40]=a,t[41]=c,t[42]=i,t[43]=h,t[44]=w,t[45]=T,t[46]=E,t[47]=D,t[48]=O,t[49]=k,t[50]=A,t[51]=j,t[52]=M,t[53]=N}else w=t[44],T=t[45],E=t[46],D=t[47],O=t[48],k=t[49],A=t[50],j=t[51],M=t[52],N=t[53];if(N!==Symbol.for(`react.early_return_sentinel`))return N;let P;t[65]!==w||t[66]!==C||t[67]!==E||t[68]!==D||t[69]!==O||t[70]!==k||t[71]!==A||t[72]!==j?(P=(0,$.jsx)(w,{to:E,state:D,onPointerEnter:O,onFocus:k,onClick:A,className:j,children:C}),t[65]=w,t[66]=C,t[67]=E,t[68]=D,t[69]=O,t[70]=k,t[71]=A,t[72]=j,t[73]=P):P=t[73];let F;t[74]!==T||t[75]!==i||t[76]!==r?(F=T?(0,$.jsx)(`button`,{type:`button`,title:T.title,"aria-label":`${r?`打开`:`Open`} ${T.title}`,className:`grid size-8 shrink-0 place-items-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>tl.getState().openFile({attachment:Tc(T),conversationId:i},i),children:(0,$.jsx)(eo,{className:`size-4`,"aria-hidden":!0})}):null,t[74]=T,t[75]=i,t[76]=r,t[77]=F):F=t[77];let I;return t[78]!==M||t[79]!==P||t[80]!==F?(I=(0,$.jsxs)(`div`,{className:M,children:[P,F]}),t[78]=M,t[79]=P,t[80]=F,t[81]=I):I=t[81],I}function kG(e){let t=(0,Q.c)(7),{title:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h3`,{className:`px-2 text-xs font-semibold text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`section`,{className:`space-y-1`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function AG(e){let t=(0,Q.c)(158),{scope:n,zh:r,closeOnNavigate:i,visible:a,onNavigate:o}=e,s=i!==void 0&&i,c=a===void 0||a,[l,u]=(0,Z.useState)(`tasks`),[d,f]=(0,Z.useState)(!1),p=(0,Z.useId)(),h=m(),g;if(t[0]!==s||t[1]!==h.search){let e=new URLSearchParams(h.search);e.delete(ka),s&&e.delete(`workspaceTab`),g=e.toString(),t[0]=s,t[1]=h.search,t[2]=g}else g=t[2];let _=g,v=_?`${h.pathname}?${_}`:h.pathname,{work:y,workError:x,prompt:S,refreshWork:C,avatarState:w,summary:T,attentionCount:E}=lo(n,r),D=l===`tasks`,{items:O,error:k,loading:A,hasMore:j,loadMore:M,retry:N}=ao(n,y,D),{listRef:P,loadMoreRef:F}=so(c&&j&&!A&&!k,M),{profile:I,displayName:L}=Vu(),R,z,B,V,H,ee,te,ne,U,re,W,ie,G,K,ae,q,oe,se,ce;if(t[3]!==E||t[4]!==w||t[5]!==s||t[6]!==y||t[7]!==L||t[8]!==x||t[9]!==O||t[10]!==P||t[11]!==C||t[12]!==o||t[13]!==p||t[14]!==v||t[15]!==I?.agentId||t[16]!==I?.appearance||t[17]!==S||t[18]!==n||t[19]!==T||t[20]!==l||t[21]!==D||t[22]!==c||t[23]!==r){let e=y?.current??[],i=new Set(e.map(PG)),a=e.filter(co),d=new Set(a.map(NG)),m=e.filter(e=>!d.has(e.id)),h=MG,g;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>!h(e),t[43]=g):g=t[43];let _=m.filter(g),k=DG([...m.filter(h),...O.filter(e=>!i.has(e.id))],r),A=po(S)&&!a.some(e=>e.prompt?.id===S.id)?S:null,j;t[44]!==s||t[45]!==o||t[46]!==n?(j=o??(s?()=>tl.getState().setOpen(!1,n):void 0),t[44]=s,t[45]=o,t[46]=n,t[47]=j):j=t[47],R=j;let M;t[48]!==R||t[49]!==v||t[50]!==n||t[51]!==r?(M=(e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsx)(OG,{item:e,zh:r,scope:n,personalHref:v,dateInHeading:t!==void 0&&t,onNavigate:R})},e.id),t[48]=R,t[49]=v,t[50]=n,t[51]=r,t[52]=M):M=t[52];let N=M,F=r?`任务`:`Tasks`,le;t[53]===F?le=t[54]:(le={id:`tasks`,label:F,Icon:ga},t[53]=F,t[54]=le);let ue=r?`交付物`:`Deliverables`,de;t[55]===ue?de=t[56]:(de={id:`deliverables`,label:ue,Icon:lt},t[55]=ue,t[56]=de);let J;t[57]!==le||t[58]!==de?(J=[le,de],t[57]=le,t[58]=de,t[59]=J):J=t[59];let fe=J,pe=!e.length&&!y?.total&&!A;re=`flex min-h-0 flex-1 flex-col overflow-hidden`,W=r?`派发的任务`:`Delegated tasks`;let me=I?.appearance??`loopi`,he=I?.agentId,ge;t[60]!==w||t[61]!==me||t[62]!==he?(ge=(0,$.jsx)(Uu,{appearance:me,agentId:he,activity:w,className:`size-full`}),t[60]=w,t[61]=me,t[62]=he,t[63]=ge):ge=t[63];let _e;t[64]===v?_e=t[65]:(_e={settingsBackPath:v},t[64]=v,t[65]=_e);let ve=r?`编辑助手资料`:`Edit assistant profile`,ye;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(io,{className:`size-3.5`,strokeWidth:1.8,"aria-hidden":!0}),t[66]=ye):ye=t[66];let be;t[67]!==_e||t[68]!==ve?(be=(0,$.jsx)(b,{to:`/settings/personal`,state:_e,"aria-label":ve,className:`absolute bottom-0 right-0 grid size-9 place-items-center rounded-full border-[3px] border-surface-base bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:ye}),t[67]=_e,t[68]=ve,t[69]=be):be=t[69];let xe;t[70]!==ge||t[71]!==be?(xe=(0,$.jsxs)(`div`,{className:`relative grid size-[7.5rem] place-items-center rounded-full border border-edge-subtle bg-surface-inset sm:size-32`,children:[ge,be]}),t[70]=ge,t[71]=be,t[72]=xe):xe=t[72];let Se;t[73]===L?Se=t[74]:(Se=(0,$.jsx)(`h2`,{className:`mt-3 max-w-full truncate text-[1.375rem] leading-7 font-semibold text-fg`,children:L}),t[73]=L,t[74]=Se);let Ce;t[75]!==w||t[76]!==T?(Ce=T?(0,$.jsxs)(`p`,{className:`mt-1 flex min-h-5 items-center justify-center gap-1.5 text-sm text-fg-muted`,title:T,children:[w===`idle`?null:(0,$.jsx)(`span`,{className:Y(`size-1.5 shrink-0 rounded-full`,w===`waiting`?`bg-warning`:`bg-accent`),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:T})]}):null,t[75]=w,t[76]=T,t[77]=Ce):Ce=t[77];let we;t[78]===Ce?we=t[79]:(we=(0,$.jsx)(`div`,{className:`min-h-6 max-w-full`,children:Ce}),t[78]=Ce,t[79]=we),t[80]!==xe||t[81]!==Se||t[82]!==we?(ie=(0,$.jsxs)(`header`,{"data-personal-task-identity":!0,className:`flex shrink-0 flex-col items-center px-4 pb-7 pt-1 text-center sm:px-6`,children:[xe,Se,we]}),t[80]=xe,t[81]=Se,t[82]=we,t[83]=ie):ie=t[83];let Te=r?`任务与交付物`:`Tasks and deliverables`,Ee;t[84]!==E||t[85]!==p||t[86]!==l||t[87]!==fe||t[88]!==r?(Ee=fe.map(e=>{let{id:t,label:n,Icon:i}=e;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,id:`${p}-${t}-tab`,"aria-controls":`${p}-${t}`,"aria-selected":l===t,tabIndex:l===t?0:-1,onClick:()=>{u(t),t===`deliverables`&&f(!0)},className:Y(`flex min-h-9 min-w-0 items-center justify-center gap-1.5 rounded-full px-1 text-xs font-medium whitespace-nowrap text-fg-muted transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,l===t&&`text-fg`),children:[(0,$.jsx)(i,{className:`size-4 shrink-0`,strokeWidth:1.7,"aria-hidden":!0}),n,t===`tasks`&&E>0?(0,$.jsx)(`span`,{className:`text-fg-muted`,"aria-label":r?`${E} 项待处理`:`${E} need attention`,children:E}):null]},t)}),t[84]=E,t[85]=p,t[86]=l,t[87]=fe,t[88]=r,t[89]=Ee):Ee=t[89],t[90]!==Te||t[91]!==Ee?(G=(0,$.jsx)(nd,{role:`tablist`,"aria-label":Te,className:`mx-4 mb-3 grid shrink-0 grid-cols-2 gap-1 rounded-full bg-surface-inset p-1 sm:mx-6`,indicatorClassName:`rounded-full bg-surface-base shadow-sm dark:bg-surface-active dark:shadow-none`,children:Ee}),t[90]=Te,t[91]=Ee,t[92]=G):G=t[92],ce=P,z=!D,B=`tabpanel`,V=`${p}-tasks`,H=`${p}-tasks-tab`,ee=`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6 pt-3 [scrollbar-gutter:stable] sm:px-6`,t[93]!==y||t[94]!==x||t[95]!==A||t[96]!==r?(te=!y&&!x&&!A?(0,$.jsx)(`div`,{className:`space-y-2`,"aria-label":r?`正在读取任务`:`Loading tasks`,children:[0,1,2].map(jG)}):null,t[93]=y,t[94]=x,t[95]=A,t[96]=r,t[97]=te):te=t[97],t[98]!==x||t[99]!==C||t[100]!==r?(ne=x?(0,$.jsxs)(`p`,{role:`alert`,className:`px-3 pb-3 text-sm text-fg-muted`,children:[r?`暂时无法更新任务。`:`Could not update tasks.`,` `,(0,$.jsx)(`button`,{type:`button`,className:`text-accent-fg underline`,onClick:()=>void C(),children:r?`重试`:`Try again`})]}):null,t[98]=x,t[99]=C,t[100]=r,t[101]=ne):ne=t[101],t[102]!==y||t[103]!==pe||t[104]!==r?(U=y&&pe?(0,$.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-fg-muted`,children:r?`可以在对话里交代你想推进的事。`:`Delegate work from the conversation.`}):null,t[102]=y,t[103]=pe,t[104]=r,t[105]=U):U=t[105],K=`space-y-5`,ae=A||a.length?(0,$.jsxs)(kG,{title:r?`待你处理`:`Needs your attention`,children:[A?(0,$.jsx)(`li`,{children:(0,$.jsxs)(b,{to:v,state:{focusClarification:A.id},className:TG,onClick:R,children:[(0,$.jsx)(`span`,{className:EG,"aria-hidden":!0,children:(0,$.jsx)(Lo,{className:`size-[1.125rem]`,strokeWidth:1.7})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium`,title:A.question,children:A.question}),(0,$.jsx)(`span`,{className:`block text-xs leading-5 text-fg-muted`,children:A.kind===`approval`?r?`待确认`:`Needs approval`:r?`待回复`:`Needs a reply`})]})]})}):null,a.map(e=>N(e))]}):null,q=_.length?(0,$.jsx)(kG,{title:r?`当前任务`:`Current tasks`,children:_.map(e=>N(e))}):null;let De=c&&D;t[106]!==n||t[107]!==De||t[108]!==r?(oe=(0,$.jsx)(CG,{scope:n,visible:De,zh:r}),t[106]=n,t[107]=De,t[108]=r,t[109]=oe):oe=t[109];let Oe;t[110]===N?Oe=t[111]:(Oe=e=>{let{title:t,items:n,dateInHeading:r}=e;return(0,$.jsx)(kG,{title:t,children:n.map(e=>N(e,r))},t)},t[110]=N,t[111]=Oe),se=k.map(Oe),t[3]=E,t[4]=w,t[5]=s,t[6]=y,t[7]=L,t[8]=x,t[9]=O,t[10]=P,t[11]=C,t[12]=o,t[13]=p,t[14]=v,t[15]=I?.agentId,t[16]=I?.appearance,t[17]=S,t[18]=n,t[19]=T,t[20]=l,t[21]=D,t[22]=c,t[23]=r,t[24]=R,t[25]=z,t[26]=B,t[27]=V,t[28]=H,t[29]=ee,t[30]=te,t[31]=ne,t[32]=U,t[33]=re,t[34]=W,t[35]=ie,t[36]=G,t[37]=K,t[38]=ae,t[39]=q,t[40]=oe,t[41]=se,t[42]=ce}else R=t[24],z=t[25],B=t[26],V=t[27],H=t[28],ee=t[29],te=t[30],ne=t[31],U=t[32],re=t[33],W=t[34],ie=t[35],G=t[36],K=t[37],ae=t[38],q=t[39],oe=t[40],se=t[41],ce=t[42];let le;t[112]!==k||t[113]!==N||t[114]!==r?(le=k?(0,$.jsx)(`p`,{role:`alert`,className:`px-2 text-sm text-fg-muted`,children:(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 text-accent-fg underline`,onClick:N,children:r?`加载失败,重试`:`Loading failed. Try again`})}):null,t[112]=k,t[113]=N,t[114]=r,t[115]=le):le=t[115];let ue;t[116]!==A||t[117]!==r?(ue=A?(0,$.jsx)(`div`,{role:`status`,"aria-label":r?`正在加载更多任务`:`Loading more tasks`,children:(0,$.jsx)(ps,{className:`h-14 rounded-xl`})}):null,t[116]=A,t[117]=r,t[118]=ue):ue=t[118];let de;t[119]!==le||t[120]!==ue||t[121]!==K||t[122]!==ae||t[123]!==q||t[124]!==oe||t[125]!==se?(de=(0,$.jsxs)(`div`,{className:K,children:[ae,q,oe,se,le,ue]}),t[119]=le,t[120]=ue,t[121]=K,t[122]=ae,t[123]=q,t[124]=oe,t[125]=se,t[126]=de):de=t[126];let J;t[127]!==j||t[128]!==F?(J=j?(0,$.jsx)(`div`,{ref:F,className:`h-px`,"aria-hidden":!0}):null,t[127]=j,t[128]=F,t[129]=J):J=t[129];let fe;t[130]!==z||t[131]!==B||t[132]!==V||t[133]!==H||t[134]!==ee||t[135]!==te||t[136]!==ne||t[137]!==U||t[138]!==de||t[139]!==J||t[140]!==ce?(fe=(0,$.jsxs)(`div`,{ref:ce,hidden:z,role:B,id:V,"aria-labelledby":H,className:ee,children:[te,ne,U,de,J]}),t[130]=z,t[131]=B,t[132]=V,t[133]=H,t[134]=ee,t[135]=te,t[136]=ne,t[137]=U,t[138]=de,t[139]=J,t[140]=ce,t[141]=fe):fe=t[141];let pe=c&&!D,me=`${p}-deliverables`,he=`${p}-deliverables-tab`,ge;t[142]!==R||t[143]!==d||t[144]!==v||t[145]!==n||t[146]!==pe||t[147]!==me||t[148]!==he||t[149]!==r?(ge=(0,$.jsx)(dG,{scope:n,zh:r,enabled:d,active:pe,id:me,labelledBy:he,sourceHref:v,onSource:R}),t[142]=R,t[143]=d,t[144]=v,t[145]=n,t[146]=pe,t[147]=me,t[148]=he,t[149]=r,t[150]=ge):ge=t[150];let _e;return t[151]!==re||t[152]!==W||t[153]!==ie||t[154]!==G||t[155]!==fe||t[156]!==ge?(_e=(0,$.jsxs)(`div`,{className:re,"aria-label":W,children:[ie,G,fe,ge]}),t[151]=re,t[152]=W,t[153]=ie,t[154]=G,t[155]=fe,t[156]=ge,t[157]=_e):_e=t[157],_e}function jG(e){return(0,$.jsx)(ps,{className:`h-14 rounded-xl`},e)}function MG(e){return e.phase===`closed`||e.operationalState===`failed`||e.operationalState===`cancelled`}function NG(e){return e.id}function PG(e){return e.id}function FG({resolution:e,conversationId:t,onClose:n}){let r=D(e=>e.language),i=F(r).chat.fileReference,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=tu()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,h=p?.absolutePath??p?.workspaceRelativePath??f,g=(0,Z.useCallback)(()=>{pl(h).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[h]),_=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await ld(p.fileRefId,e,{conversationId:t?.trim()||void 0});if(e===`openExternal`){let e=await n.openPath(r.absolutePath);e.ok||c(e.error)}else(await n.showItemInFolder(r.absolutePath)).success||c(i.resolveFailedDescription)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return e.status===`loading`?(0,$.jsxs)(`div`,{"aria-label":i.resolvingDescription,"aria-busy":`true`,className:`flex flex-1 flex-col gap-4 bg-surface-panel p-4`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:m}),(0,$.jsx)(ps,{className:`h-5 w-1/3`}),(0,$.jsx)(ps,{className:`h-32 w-full rounded-xl`}),(0,$.jsx)(ps,{className:`h-4 w-2/3`})]}):(0,$.jsxs)(`div`,{className:Y(`m-4 flex min-w-0 flex-col gap-1.5 rounded-lg border px-2.5 py-2 text-xs`,e.status===`ready`&&e.ref.exists&&e.ref.scope!==`missing`?`border-edge-subtle bg-surface-panel`:`border-warning/30 bg-warning/5`),children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.status===`error`||p?.scope===`missing`||p?.scope===`invalid`?(0,$.jsx)(Ar,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Fi,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:m}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:Y(`ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,gl.focusRingPanel),"aria-label":i.closeActions,children:(0,$.jsx)(ds,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`line-clamp-2 break-all text-[11px] leading-snug text-fg-muted`,children:e.status===`error`?e.message:p?.scope===`missing`?i.missingDescription:p?.scope===`invalid`?i.invalidDescription:d?i.externalDescription:i.browserExternalDescription}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-0.5`,children:[e.retry?(0,$.jsxs)(`button`,{type:`button`,className:IG,onClick:e.retry,children:[(0,$.jsx)(Oo,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r===`zh`?`重试`:`Retry`})]}):null,d&&p?.capabilities.includes(`openExternal`)?(0,$.jsxs)(`button`,{type:`button`,className:IG,disabled:l,onClick:()=>void _(`openExternal`),children:[(0,$.jsx)(hi,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i.openExternal})]}):null,d&&p?.capabilities.includes(`revealInFolder`)?(0,$.jsxs)(`button`,{type:`button`,className:IG,disabled:l,onClick:()=>void _(`revealInFolder`),children:[(0,$.jsx)(Vi,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,$.jsxs)(`a`,{className:IG,href:`#${p.manageRoute}`,children:[(0,$.jsx)(Io,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:F(r).nav.settings})]}):null,(0,$.jsxs)(`button`,{type:`button`,className:IG,onClick:g,children:[(0,$.jsx)(ui,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a?F(r).chat.messageCopied:i.copyPath})]})]}),s?(0,$.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var IG=Y(`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`,gl.focusRingPanel,gl.press);function LG(e,t,n){let r=(0,Q.c)(16),{pathname:i,search:a}=m(),o=x(),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(!1),u,d;r[0]!==t.activeId||r[1]!==t.open||r[2]!==t.tabs||r[3]!==i||r[4]!==e||r[5]!==a?(u=()=>{let n=new URLSearchParams(a).toString(),r=s.current;if(s.current={pathname:i,search:a,scope:e},r?.pathname===i&&r.scope===e&&r.search===a)return;if(c.current===`${i}?${n}`){c.current=null;return}let o=new URLSearchParams(a).get(`workspaceTab`),u=r?.pathname===i&&r.scope===e&&new URLSearchParams(r.search).get(`workspaceTab`)!==o;if(o&&t.tabs.some(e=>e.id===o)&&(o!==t.activeId||!t.open)||u){l.current=!0;let n=tl.getState();o&&t.tabs.some(e=>e.id===o)?n.activate(o,e):t.activeId!==null&&n.activate(null,e)}},d=[t.activeId,t.open,t.tabs,i,e,a],r[0]=t.activeId,r[1]=t.open,r[2]=t.tabs,r[3]=i,r[4]=e,r[5]=a,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Z.useEffect)(u,d);let f,p;r[8]!==n||r[9]!==o||r[10]!==t.activeId||r[11]!==t.open||r[12]!==i||r[13]!==a?(f=()=>{if(!n)return;if(l.current){l.current=!1;return}if(window.location.hash.startsWith(`#/`)&&window.location.hash.slice(1)!==`${i}${a}`)return;let e=new URLSearchParams(a);t.open&&t.activeId?e.set(`workspaceTab`,t.activeId):e.delete(`workspaceTab`);let r=e.toString();r!==new URLSearchParams(a).toString()&&(c.current=`${i}?${r}`,o({pathname:i,search:r?`?${r}`:``}))},p=[n,o,t.activeId,t.open,i,a],r[8]=n,r[9]=o,r[10]=t.activeId,r[11]=t.open,r[12]=i,r[13]=a,r[14]=f,r[15]=p):(f=r[14],p=r[15]),(0,Z.useEffect)(f,p)}function RG(e,t){let n=(0,Q.c)(5),[r,i]=(0,Z.useState)(t),a=(0,Z.useRef)(!1),o=(0,Z.useRef)(null),s,c;return n[0]!==t||n[1]!==r||n[2]!==e?(s=()=>{let n=e.current;if(!n)return;if(t&&!r){i(!0);return}let s=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(s?.matches||typeof n.animate!=`function`){a.current=t,r!==t&&i(t);return}let c=a.current!==t;a.current=t;let l,u=!1;if((c||!t)&&r){let e=o.current??(t?{opacity:0,transform:`translateX(16px)`}:{opacity:1,transform:`translateX(0)`});o.current=null,l=n.animate([e,t?{opacity:1,transform:`translateX(0)`}:{opacity:0,transform:`translateX(16px)`}],{duration:t?220:150,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`}),t||l.finished.then(()=>{u||i(!1)}).catch(zG)}let d=()=>{s?.matches&&(l?.cancel(),t||i(!1))};return s?.addEventListener(`change`,d),()=>{if(u=!0,(c||!t)&&l?.playState===`running`){let e=window.getComputedStyle(n);o.current={opacity:e.opacity,transform:e.transform}}l?.cancel(),s?.removeEventListener(`change`,d)}},c=[t,r,e],n[0]=t,n[1]=r,n[2]=e,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,Z.useLayoutEffect)(s,c),r}function zG(){}function BG(e,t,n){let r=(0,Q.c)(7),[i,a]=(0,Z.useState)(0),o;r[0]!==t||r[1]!==e?(o=()=>{let n=e.current?.querySelector(`#workspace-content`),r=n&&[...n.querySelectorAll(`[data-workspace-toolbar]`)].find(VG);if(!t||!n||!r){a(0);return}let i=()=>a(Math.max(0,r.getBoundingClientRect().bottom-n.getBoundingClientRect().top));i();let o=typeof ResizeObserver<`u`?new ResizeObserver(i):null;return o?.observe(r),o?.observe(n),()=>o?.disconnect()},r[0]=t,r[1]=e,r[2]=o):o=r[2];let s;return r[3]!==n||r[4]!==t||r[5]!==e?(s=[n,t,e],r[3]=n,r[4]=t,r[5]=e,r[6]=s):s=r[6],(0,Z.useLayoutEffect)(o,s),i}function VG(e){return e.getClientRects().length>0}function HG(e){let t=(0,Q.c)(59),{tabs:n,canCreateSideChat:r,creating:i,onFiles:a,onSideChat:o,onActivate:s,onTerminal:c,onBrowser:l}=e,u=D(GG)===`zh`,d,f,p,m,h,g,_;if(t[0]!==r||t[1]!==i||t[2]!==s||t[3]!==l||t[4]!==a||t[5]!==o||t[6]!==c||t[7]!==n||t[8]!==u){let e=n.filter(WG).sort(UG).slice(0,4);g=`min-h-0 flex-1 overflow-y-auto bg-surface-base/70 px-6 py-10 sm:px-8`,_=!0,d=`mx-auto max-w-3xl`;let v=u?`工具`:`Tools`;t[16]===v?f=t[17]:(f=(0,$.jsx)(`h2`,{className:`mb-5 text-sm font-medium text-fg`,children:v}),t[16]=v,t[17]=f);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Vi,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[18]=y):y=t[18];let b=u?`文件`:`Files`,x;t[19]===b?x=t[20]:(x=(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:b}),t[19]=b,t[20]=x);let S;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Lt,{className:`size-4 text-fg-subtle opacity-0 group-hover:opacity-100`,"aria-hidden":!0}),t[21]=S):S=t[21];let C;t[22]!==a||t[23]!==x?(C=(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:a,children:[y,x,S]}),t[22]=a,t[23]=x,t[24]=C):C=t[24];let w=!r||i,T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Fa,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[25]=T):T=t[25];let E=u?`侧聊`:`Side chat`,D;t[26]===E?D=t[27]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:E}),t[26]=E,t[27]=D);let O;t[28]===i?O=t[29]:(O=i?(0,$.jsx)(`span`,{className:`h-3 w-10 animate-pulse rounded bg-surface-active`}):(0,$.jsx)(Lt,{className:`size-4 text-fg-subtle opacity-0 group-hover:opacity-100`,"aria-hidden":!0}),t[28]=i,t[29]=O);let k;t[30]!==o||t[31]!==w||t[32]!==D||t[33]!==O?(k=(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,disabled:w,onClick:o,children:[T,D,O]}),t[30]=o,t[31]=w,t[32]=D,t[33]=O,t[34]=k):k=t[34];let A;t[35]!==l||t[36]!==u?(A=l?(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:l,children:[(0,$.jsx)(Xi,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:u?`浏览器`:`Browser`}),(0,$.jsx)(Lt,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})]}):null,t[35]=l,t[36]=u,t[37]=A):A=t[37];let j;t[38]!==c||t[39]!==u?(j=c?(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:c,title:u?`打开主聊天的终端面板`:`Open the main chat terminal panel`,children:[(0,$.jsx)($o,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:u?`终端`:`Terminal`}),(0,$.jsx)(Lt,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})]}):null,t[38]=c,t[39]=u,t[40]=j):j=t[40],t[41]!==C||t[42]!==k||t[43]!==A||t[44]!==j?(p=(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,13rem),1fr))] gap-3`,children:[C,k,A,j]}),t[41]=C,t[42]=k,t[43]=A,t[44]=j,t[45]=p):p=t[45],t[46]!==r||t[47]!==u?(m=r?null:(0,$.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:u?`开始主聊天后,可以在这里新建临时侧聊。`:`Start a main conversation to create a temporary side chat here.`}),t[46]=r,t[47]=u,t[48]=m):m=t[48],h=e.length?(0,$.jsxs)(`section`,{className:`mt-12`,children:[(0,$.jsx)(`h2`,{className:`mb-5 text-sm font-medium text-fg`,children:u?`继续查看`:`Continue with`}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,$.jsxs)(`button`,{onClick:()=>s(e.id),title:e.kind===`file`&&e.path||e.title,className:`flex min-w-0 flex-col items-center gap-3 rounded-xl px-2 py-4 text-sm text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl border border-edge-subtle bg-surface-panel`,children:e.kind===`file`?(0,$.jsx)(Pi,{className:`size-5 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(Fa,{className:`size-5 text-fg-muted`,"aria-hidden":!0})}),(0,$.jsx)(`span`,{className:`w-full truncate text-center`,children:e.title===`Side chat`?u?`侧聊`:`Side chat`:e.title})]},e.id))})]}):null,t[0]=r,t[1]=i,t[2]=s,t[3]=l,t[4]=a,t[5]=o,t[6]=c,t[7]=n,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[49]!==d||t[50]!==f||t[51]!==p||t[52]!==m||t[53]!==h?(v=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[49]=d,t[50]=f,t[51]=p,t[52]=m,t[53]=h,t[54]=v):v=t[54];let y;return t[55]!==g||t[56]!==_||t[57]!==v?(y=(0,$.jsx)(`div`,{className:g,"data-workspace-start":_,children:v}),t[55]=g,t[56]=_,t[57]=v,t[58]=y):y=t[58],y}function UG(e,t){return t.visitedAt-e.visitedAt}function WG(e){return e.kind===`file`||e.kind===`sidechat`}function GG(e){return e.language}var KG=`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function qG({scope:e,enabled:t=!0,elevated:n=!1,onDockedWidthChange:r}){let i=D(e=>e.language)===`zh`,a=tl(e=>e.panes),o=a[e]??nl,s=o.tabs.find(e=>e.id===o.activeId),c=tl(e=>e.width),l=tl(e=>e.personalTasksWidth),u=tl(e=>e.personalPreviewChatWidth),d=tl(e=>e.treeWidth),f=tl(e=>e.fileTreeOpen),p=tl(e=>e.sideTreeOpen),h=tl(t=>t.notices[e]),g=tl(e=>e.fileStatus),_=Qe(e=>e.tabs),v=Qe(e=>e.pendingCreate),y=Qe(t=>t.creatingRequests[e]),b=!!(y||v?.parentConversationId===e),x=E(e=>e.conversationId),{pathname:S,search:C}=m(),w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),[O,k]=(0,Z.useState)(1200),A=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>A.current?.(),[]);let[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F=BG(w,N,o.activeId),[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(null),[H,ee]=(0,Z.useState)(``),[te,ne]=(0,Z.useState)(null),[U,re]=(0,Z.useState)(!1),W=tl.getState(),ie=t&&o.open,G=S===`/personal`&&s?.kind===`personal-tasks`,K=S===`/personal`&&o.tabs.some(e=>e.kind===`personal-tasks`),ae=S===`/personal`&&(s?.kind===`file`||s?.kind===`browser`),q=ie&&ae&&o.personalDetailsOpen===!0,oe=ae?o.tabs.filter(e=>e.kind!==`personal-tasks`):o.tabs,se=ae&&s?.kind===`file`&&oe.length===1,ce=!se&&(!G||oe.length>1),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),J=(0,Z.useRef)(new WeakMap),[fe]=(0,Z.useState)(()=>{let e=document.createElement(`div`);return e.className=`flex min-h-0 flex-1 flex-col`,e});(0,Z.useLayoutEffect)(()=>{let e=e=>{let t=e.target;t instanceof HTMLElement&&t.matches(`[role="tabpanel"]`)&&t.getClientRects().length&&J.current.set(t,t.scrollTop)};return fe.addEventListener(`scroll`,e,!0),()=>fe.removeEventListener(`scroll`,e,!0)},[fe]),(0,Z.useLayoutEffect)(()=>{let e=q?ue.current:le.current;e&&(fe.parentElement!==e&&e.appendChild(fe),!(!G&&!q)&&fe.querySelectorAll(`[role="tabpanel"]:not([hidden])`).forEach(e=>{e.scrollTop=J.current.get(e)??0}))},[q,K,G,fe,ie]),(0,Z.useLayoutEffect)(()=>{q&&de.current?.focus({preventScroll:!0})},[q]);let pe=RG(w,ie);(0,Z.useLayoutEffect)(()=>{if(!ie&&w.current?.contains(document.activeElement)){let e=G?`[data-personal-tasks-trigger]`:`[data-workspace-trigger]`,t=document.querySelector(e);if(t)t.focus();else{let t=requestAnimationFrame(()=>{(document.activeElement===document.body||w.current?.contains(document.activeElement))&&document.querySelector(e)?.focus()});return()=>cancelAnimationFrame(t)}}},[G,ie]);let me=Je(e,t);(0,Z.useEffect)(()=>{if(!t||me.isLoading||me.error)return;let n=me.data?.report,r=n&&!bt(n.status)?n.deviceId??n.sessionId:void 0,i=tl.getState();for(let t of i.panes[e]?.tabs??[])t.kind===`phone`&&t.phoneSessionId!==r&&i.remove(t.id,e);n&&r&&i.openPhone(r,n.deviceName,e,!1,!1)},[me.data,me.isLoading,me.error,e,t]);let he=s?.kind===`phone`,ge=R&&!G,_e=Math.min(420,Math.round(O*.3)),ve=G?300:he?360:ae?Math.max(460,Math.round(O*.4)):460,ye=Math.max(ve,O-(ae?280:he?420:380)),be=O<(G?760:he?900:840),xe=G&&be,Se=s?.kind===`browser`?I:s?.kind===`sidechat`?p:f,Ce=e=>Math.max(ve,Math.min(ye,e)),we=G?l||396:ae?O-(u||_e):c||(he?420:O*.6),Te=s?Ce(we):320,Ee=G?W.setPersonalTasksWidth:ae?e=>W.setPersonalPreviewChatWidth(e===0?0:O-e):W.setWidth;(0,Z.useLayoutEffect)(()=>{r?.(ie&&!be&&!ge?Te:0)},[r,Te,be,ie,ge]),(0,Z.useLayoutEffect)(()=>{if(ie&&pe&&G){let e=xe&&ce?`[role="tab"][aria-selected="true"]`:`[data-personal-task-close]`;w.current?.querySelector(e)?.focus()}},[G,pe,ce,xe,ie]);let De=s?.kind===`files`,Oe=De||s?.kind===`file`,ke=be||ge?O:Te,Ae=Oe?240:460,je=Math.min(d,Math.max(200,ke-Ae-8)),Me=ke>=Ae+je+8,Ne=De||(s?.kind===`file`||s?.kind===`sidechat`||s?.kind===`browser`)&&Se&&Me,Pe=De&&!Me,Fe=Ne||N,Ie=s?.kind===`file`?s:void 0,Le=(0,Z.useMemo)(()=>({conversationId:Ie?.path?Ie.conversationId:e===`new`?void 0:e,projectId:Ie?.path?Ie.projectId:new URLSearchParams(C).get(`projectId`)??void 0,agentId:Ie?.agentId}),[Ie?.agentId,Ie?.conversationId,Ie?.path,Ie?.projectId,e,C]),Re=JSON.stringify(Le),[ze,Be]=(0,Z.useState)({});(0,Z.useLayoutEffect)(()=>{W.setScope(e)},[e,W]),(0,Z.useEffect)(()=>{ie&&Be(e=>e[Re]?e:{...e,[Re]:Le})},[Re,Le,ie]),(0,Z.useLayoutEffect)(()=>{let e=w.current?.parentElement;if(!e)return;let t=()=>k(e.clientWidth||window.innerWidth);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,Z.useEffect)(()=>{for(let e of _)tl.getState().panes[e.parentConversationId]?.tabs.some(t=>t.id===`side:${e.id}`)||W.addSideChat(e.id,e.title,e.parentConversationId,!1)},[_,W]),(0,Z.useEffect)(()=>{P(!1)},[o.activeId,e]),(0,Z.useEffect)(()=>{Me&&P(!1)},[Me]),(0,Z.useEffect)(()=>{ne(null),re(!1),ee(``)},[e]),(0,Z.useEffect)(()=>{(T.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[O,R,o.activeId]),(0,Z.useEffect)(()=>{yc.setState({path:Ie?.path??null,projectId:Ie?.projectId??null,conversationId:Ie?.conversationId??null,line:Ie?.line??null})},[Ie]),(0,Z.useEffect)(()=>{let t=t=>{if(!(t.key!==`Escape`||t.defaultPrevented)){if(U){t.preventDefault(),re(!1);return}if(q&&ue.current?.contains(document.activeElement)){t.preventDefault(),Ge(!0);return}if(ge||N){t.preventDefault(),z(!1),P(!1);return}ie&&G&&w.current?.contains(document.activeElement)&&(t.preventDefault(),W.setOpen(!1,e))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[U,q,G,e,W,N,ie,ge]),LG(e,o,t),MW();async function Ve(t){if(!B){V(t),ee(``);try{await SW(t)&&W.remove(t,e)}catch(e){ee(e instanceof Error?e.message:String(e))}finally{V(null)}}}async function He(t,n=!1){if(!B){V(t);try{if(!n&&!await yd(t)){ne(t);return}W.remove(t,e),ne(null),re(!1)}finally{V(null)}}}function Ue(e){return e.kind===`home`?i?`新标签页`:`New tab`:e.kind===`browser`&&e.title===`Browser`?i?`浏览器`:`Browser`:e.kind===`files`?i?`文件`:`Files`:e.kind===`personal-tasks`?i?`任务`:`Tasks`:e.title===`Side chat`?i?`侧聊`:`Side chat`:e.title}function We(t){W.activate(t,e)}function Ge(t){W.closePersonalTasks(e),t&&requestAnimationFrame(()=>{(w.current?.querySelector(`[data-personal-preview-tasks]`)??document.querySelector(`[data-personal-tasks-trigger]`))?.focus({preventScroll:!0})})}function Ke(){s&&(N?P(!1):!Ne&&!Me?P(!0):s.kind===`browser`?L(!I):W.setTreeOpen(s.kind===`sidechat`?`sidechat`:`file`,!Se))}let qe=s&&!De&&s.kind!==`home`&&s.kind!==`phone`&&!G?(0,$.jsx)(`button`,{type:`button`,className:Y(KG,`rounded-full border border-edge-subtle`,Fe&&`border-accent/20 bg-accent-soft text-accent-fg`),"aria-label":i?`切换文件树`:`Toggle file tree`,"aria-pressed":Fe,onClick:Ke,children:(0,$.jsx)(Ki,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null;function Ye(e,t=!1){if(e.button!==0||A.current)return;e.preventDefault();let n=e.clientX,r=t?je:Te;e.currentTarget.setPointerCapture?.(e.pointerId),M(!0);let i=r,a=a=>{if(a.pointerId!==e.pointerId)return;let o=r+n-a.clientX;i=t?Math.max(200,Math.min(320,ke-Ae-8,o)):Ce(o);let s=t?w.current?.querySelector(`[data-workspace-tree]`):w.current;s&&(s.style.width=`${i}px`),!t&&q&&ue.current?.parentElement&&(ue.current.parentElement.style.right=`${i+8}px`)},o=n=>{n&&n.pointerId!==e.pointerId||(t?W.setTreeWidth(i):Ee(i),A.current=null,M(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o))};A.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)}let Xe=[...new Set([..._.map(e=>e.parentConversationId),...v?[v.parentConversationId]:[],...e===`new`?[]:[e]])],Ze=Object.entries(a).flatMap(([e,t])=>t.tabs.filter(e=>e.kind===`file`).map(t=>({owner:e,tab:t}))),$e=new Set([...Ze].sort((e,t)=>t.tab.visitedAt-e.tab.visitedAt).slice(0,8).map(({tab:e})=>e.id));return(0,$.jsxs)($.Fragment,{children:[ie&&xe?(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":!0,className:`absolute inset-0 z-[39] bg-scrim`,onClick:()=>W.setOpen(!1,e)}):null,q?(0,$.jsxs)(`aside`,{id:`personal-preview-details`,"aria-label":i?`助手详情`:`Assistant details`,"data-personal-preview-details":!0,className:Y(`file-preview-surface absolute inset-y-2 left-2 z-[45] flex min-w-0 flex-col overflow-hidden rounded-2xl shadow-popover`,(be||ge)&&`w-[min(92%,24rem)]`),style:be||ge?void 0:{right:Te+8},onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),Ge(!0))},children:[(0,$.jsx)(`button`,{ref:de,type:`button`,"aria-label":i?`收起助手详情`:`Close assistant details`,className:Y(KG,`mr-2 mt-2 self-end`),onClick:()=>Ge(!0),children:(0,$.jsx)(ds,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{ref:ue,className:`flex min-h-0 flex-1 flex-col`})]}):null,(0,$.jsxs)(`aside`,{id:`app-workspace-panel`,ref:w,"aria-label":G?i?`派发的任务`:`Delegated tasks`:i?`文件与侧聊工作区`:`Files and side chats`,role:xe?`dialog`:void 0,"aria-modal":xe||void 0,"data-right-workspace":!0,"aria-hidden":!ie,inert:!ie,onKeyDown:e=>{if(!xe||e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not(:disabled), a[href], [tabindex="0"]`)).filter(e=>e.tabIndex>=0&&e.getClientRects().length>0),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},className:Y(`relative min-h-0 shrink-0 flex-col overflow-hidden bg-surface-base`,pe?`flex`:`hidden`,pe&&(be||ge)&&(xe?`absolute inset-y-0 right-0 w-[min(92%,24rem)] shadow-popover`:`absolute inset-0`),n?`z-[110]`:`z-40`),style:{width:be||ge?void 0:Te},children:[!be&&!ge&&s?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":G?i?`调整任务栏宽度`:`Resize task panel`:i?`调整工作区宽度`:`Resize workspace`,"aria-valuemin":ve,"aria-valuemax":ye,"aria-valuenow":Math.round(Te),className:Y(`absolute left-0 top-0 z-20 h-full cursor-col-resize touch-none focus-visible:bg-accent/30`,G?`w-3`:`w-2 -translate-x-1/2`),onPointerDown:Ye,onKeyDown:e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),Ee(Ce(Te+(e.key===`ArrowLeft`?20:-20)))):e.key===`Home`&&(e.preventDefault(),Ee(0))}}):null,j?(0,$.jsx)(`div`,{"data-browser-occluder":!0,className:`fixed inset-0 z-[120] cursor-col-resize`}):null,!se||be||ge?(0,$.jsxs)(`div`,{"data-workspace-tab-bar":!0,className:Y(`flex shrink-0 items-center justify-end gap-1 bg-surface-base px-2`,G||se?`h-12 px-3`:`h-14`),children:[ae&&(be||ge)?(0,$.jsxs)(`button`,{type:`button`,"data-personal-preview-tasks":!0,className:Y(KG,`mr-auto w-auto gap-1 px-2 text-sm`),"aria-expanded":q,"aria-controls":`personal-preview-details`,onClick:()=>q?Ge(!0):W.openPersonalTasks(e),children:[(0,$.jsx)(ga,{className:`size-4`,"aria-hidden":!0}),i?`助手详情`:`Assistant details`]}):null,ce?(0,$.jsx)(nd,{ref:T,role:`tablist`,"aria-label":i?`工作区标签`:`Workspace tabs`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`[role="tab"]`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowRight`?(n+1)%t.length:e.key===`ArrowLeft`?(n-1+t.length)%t.length:e.key===`Home`?0:e.key===`End`?t.length-1:-1;r>=0&&(e.preventDefault(),t[r]?.focus())},indicatorClassName:`rounded-md bg-surface-panel`,children:oe.map(t=>{let n=t.kind===`sidechat`?_.find(e=>e.id===t.sideChatId):void 0,r=Ue(t),a=n?.waiting?i?`待处理`:`Needs attention`:n?.disconnected?i?`连接中断`:`Disconnected`:n?.ended?i?`已结束`:`Ended`:n?.runId?i?`运行中`:`Running`:n?.unread?i?`未读`:`Unread`:g[t.id]?i?`未保存`:`Unsaved`:``;return(0,$.jsxs)(`div`,{"data-sliding-active":t.id===o.activeId,className:Y(`group flex h-9 shrink-0 items-center rounded-md transition-colors`,t.id===o.activeId?`bg-surface-panel text-fg`:`text-fg-muted hover:bg-surface-hover`),children:[(0,$.jsxs)(`button`,{role:`tab`,id:`workspace-tab-${t.id}`,"aria-controls":`workspace-content`,"aria-selected":t.id===o.activeId,tabIndex:t.id===o.activeId?0:-1,title:t.kind===`file`&&t.path||r,className:`flex max-w-56 items-center gap-1.5 rounded-md px-2 py-1 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>We(t.id),onDoubleClick:()=>{t.kind===`file`&&W.keepFileOpen(t.id)},children:[t.kind===`phone`?(0,$.jsx)(Bo,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`browser`?(0,$.jsx)(Xi,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`sidechat`?(0,$.jsx)(Ia,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`files`?(0,$.jsx)(Vi,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`personal-tasks`?(0,$.jsx)(ga,{className:`size-4 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(Si,{name:t.title}),(0,$.jsx)(`span`,{className:Y(`truncate`,t.kind===`file`&&t.preview&&`italic`),children:r}),a?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:a}):null]}),(0,$.jsx)(`button`,{className:Y(KG,`size-7`),tabIndex:t.id===o.activeId?0:-1,"aria-label":`${i?`关闭`:`Close`} ${r}`,disabled:B===t.id,onClick:()=>{t.kind===`file`?He(t.id):t.kind===`browser`?Ve(t.id):t.kind===`sidechat`?window.dispatchEvent(new CustomEvent(`workspace-close-sidechat`,{detail:t.sideChatId})):W.remove(t.id,e)},children:(0,$.jsx)(ds,{className:`size-3.5`,"aria-hidden":!0})})]},t.id)})}):null,!G&&!se?(0,$.jsx)(`button`,{className:KG,"aria-label":i?`新建标签`:`New tab`,title:i?`新建标签`:`New tab`,onClick:()=>W.openTools(e),children:(0,$.jsx)(yo,{className:`size-5`,"aria-hidden":!0})}):null,!G&&!se?(0,$.jsx)(`button`,{className:KG,"aria-label":R?i?`还原工作区`:`Restore workspace`:i?`放大工作区`:`Expand workspace`,onClick:()=>z(!R),children:R?(0,$.jsx)(za,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ja,{className:`size-4`,"aria-hidden":!0})}):null,se?null:(0,$.jsx)(`button`,{className:KG,"data-personal-task-close":G||void 0,title:G?i?`收起任务`:`Close tasks`:i?`收起工作区 · ${o.tabs.length} 个标签`:`Collapse workspace · ${o.tabs.length} tabs`,"aria-label":G?i?`收起任务`:`Close tasks`:be?i?`返回聊天`:`Back to chat`:i?`收起工作区`:`Collapse workspace`,onClick:()=>W.setOpen(!1,e),children:G?(0,$.jsx)(ds,{className:`size-5`,"aria-hidden":!0}):(0,$.jsx)(Qa,{className:`size-5`,"aria-hidden":!0})})]}):null,h?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:[h,` `,(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>Qe.getState().requestCreate(e),children:i?`重试新建侧聊`:`Retry new side chat`})]}):null,H?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:[H,` `,(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>ee(``),children:i?`关闭提示`:`Dismiss`})]}):null,y?(0,$.jsx)(`div`,{role:`status`,className:`h-1 shrink-0 animate-pulse bg-surface-active`,"aria-label":i?`正在创建侧聊`:`Creating side chat`}):null,te?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{children:i?`文件未保存,可能已被外部修改。编辑内容已保留。`:`File could not be saved; it may have changed externally. Your edits are retained.`}),(0,$.jsx)(`button`,{className:`mr-3 text-accent`,onClick:()=>void He(te),children:i?`重试保存并关闭`:`Retry save and close`}),(0,$.jsx)(`button`,{className:`mr-3`,onClick:()=>{ne(null),re(!1)},children:i?`继续编辑`:`Keep editing`}),(0,$.jsx)(`button`,{className:`text-red-600`,onClick:()=>re(!0),children:i?`放弃修改`:`Discard edits`}),U?(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":i?`确认放弃修改`:`Confirm discard edits`,className:`mt-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`p`,{children:i?`放弃此文件未保存的修改?`:`Discard unsaved edits to this file?`}),(0,$.jsxs)(`div`,{className:`mt-2 flex gap-3`,children:[(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>re(!1),children:i?`保留草稿`:`Keep draft`}),(0,$.jsx)(`button`,{onClick:()=>void He(te,!0),children:i?`确认放弃`:`Confirm discard`})]})]}):null]}):null,(0,$.jsx)(qi.Provider,{value:qe?{button:qe,label:i?Fe?`隐藏文件树`:`显示文件树`:Fe?`Hide file tree`:`Show file tree`,active:Fe,onToggle:Ke}:null,children:(0,$.jsxs)(`div`,{id:`workspace-content`,role:ce?`tabpanel`:void 0,"aria-labelledby":ce&&s?`workspace-tab-${s.id}`:void 0,className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:Y(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,Pe?`hidden`:`flex`),children:[ie&&K?(0,$.jsx)(`div`,{ref:le,hidden:!G,className:Y(G&&`flex`,`min-h-0 flex-1 flex-col`),children:(0,Sf.createPortal)((0,$.jsx)(AG,{scope:e,zh:i,closeOnNavigate:xe,visible:G||q,onNavigate:q?()=>Ge(!1):void 0},e),fe)}):null,ie&&he?(0,$.jsx)(`div`,{id:`phone-workspace-slot`,"data-phone-conversation-id":e,className:`flex min-h-0 flex-1 flex-col overflow-hidden`}):null,De&&!Pe?(0,$.jsxs)(`div`,{"data-workspace-file-placeholder":!0,className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(Pi,{className:`size-9 text-fg-muted`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i?`选择文件预览`:`Select a file to preview`}),(0,$.jsx)(`p`,{className:`max-w-64 text-sm text-fg-muted`,children:i?`从右侧文件列表打开文件,在这里查看内容。`:`Open a file from the list on the right to view its contents here.`})]}):null,s?.kind===`home`&&!b?(0,$.jsx)(HG,{tabs:o.tabs,canCreateSideChat:e!==`new`,creating:!!y,onBrowser:window.electronAPI?.browser?()=>W.openBrowser(void 0,e):void 0,onFiles:()=>W.openFiles(e),onSideChat:()=>Qe.getState().requestCreate(e),onActivate:We,onTerminal:window.electronAPI?.terminal?()=>e===`new`?window.dispatchEvent(new Event(`workspace-open-terminal`)):af.getState().open(e):void 0}):null,Object.entries(a).flatMap(([t,n])=>n.tabs.filter(e=>e.kind===`browser`).map(n=>(0,$.jsx)(kW,{tab:n,scope:t,active:ie&&t===e&&s?.id===n.id},n.id))),(0,$.jsx)(Gi.Provider,{value:[{id:e,label:i?`引用到主聊天`:`Reference in main chat`},...Ie?.returnTo?.startsWith(`side:`)?[{id:Ie.returnTo.slice(5),label:i?`引用到来源侧聊`:`Reference in source side chat`}]:[]],children:Ze.map(({owner:t,tab:n})=>{let r=pe&&t===e&&s?.id===n.id;if(n.reference)return r?(0,$.jsx)(FG,{resolution:n.reference,conversationId:n.conversationId,onClose:()=>void He(n.id)},n.id):null;if(n.attachment)return r?(0,$.jsx)(Ad,{tabId:n.id,embedded:!0,showEmbeddedClose:se,open:!0,attachment:n.attachment,images:n.images,onAttachmentChange:e=>W.openFile({attachment:e,images:n.images,conversationId:n.conversationId},t),authToken:x,conversationId:n.conversationId,onClose:()=>void He(n.id)},n.id):null;let i=[`code`,`text`,`markdown`,`html`].includes(qo(n.title));return!r&&(!i||!$e.has(n.id)&&!g[n.id])?null:(0,$.jsx)(bd,{tabId:n.id,active:r,showEmbeddedClose:se,filePath:n.path??null,projectId:n.projectId,conversationId:n.conversationId,agentId:n.agentId,targetLine:n.line,resultRevision:n.resultRevision,resolvedFile:n.resolvedFile,onClose:()=>void He(n.id)},n.id)})}),Xe.map(t=>(0,$.jsx)(Ui.Provider,{value:t,children:(0,$.jsx)(sG,{parentConversationId:t,embedded:!0,visible:pe&&e===t&&(s?.kind===`sidechat`||(!s||s.kind===`home`)&&b)})},t))]}),Ne&&!Pe&&!N?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":i?`调整文件树宽度`:`Resize file tree`,"aria-valuemin":200,"aria-valuemax":Math.min(320,ke-Ae-8),"aria-valuenow":je,className:`z-10 w-2 shrink-0 cursor-col-resize touch-none bg-surface-base transition-colors duration-150 hover:bg-accent/20 focus-visible:bg-accent/30`,onPointerDown:e=>Ye(e,!0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),W.setTreeWidth(Math.min(ke-Ae-8,je+(e.key===`ArrowLeft`?20:-20))))}}):null,N?(0,$.jsx)(`button`,{"data-browser-occluder":!0,style:{top:F},className:`absolute inset-0 z-20 bg-scrim`,"aria-label":i?`关闭文件树`:`Close file tree`,onClick:()=>P(!1)}):null,(0,$.jsx)(`div`,{"data-workspace-tree":!0,className:Y(`min-h-0 min-w-0 flex-col overflow-hidden border-l border-edge-subtle bg-surface-base`,Fe?`flex`:`hidden`,Pe&&`flex-1`,N&&`absolute inset-y-0 right-0 z-30 bg-surface-base shadow-popover`),style:Pe?void 0:{width:N?d:je,...N?{top:F}:{}},children:Object.entries(ze).map(([t,n])=>(0,$.jsx)(`div`,{className:Y(`h-full min-h-0 flex-col`,t===Re?`flex`:`hidden`),children:(0,$.jsx)(LW,{embedded:!0,scope:n,onCloseTree:()=>N?P(!1):De?s&&W.remove(s.id,e):s?.kind===`browser`?L(!1):W.setTreeOpen(s?.kind===`sidechat`?`sidechat`:`file`,!1)})},t))})]})})]})]})}function JG(e){Oe(e)}var YG=32e3,XG=264,ZG=10;function QG(e){let t=(0,Q.c)(36),{conversationId:n}=e,{pathname:r}=m(),i=D(nK),a;t[0]===i?a=t[1]:(a=F(i),t[0]=i,t[1]=a);let o=a.sideChat,s=Qe(tK),c=Qe(eK),[l,u]=(0,Z.useState)(null),d;t[2]!==n||t[3]!==c?(d=()=>{if(!n||n===`new`||c){u(null);return}let e=window.getSelection(),t=e?.toString().trim()??``;if(!e||e.rangeCount===0||!t||t.length>YG){u(null);return}let r=e.getRangeAt(0),i=rK(e.anchorNode),a=rK(e.focusNode),o=document.getElementById(`app-main-content`),s=document.getElementById(`app-side-chat-panel`),l=!!(s?.contains(i)&&s?.contains(a));if(!i||!a||!l&&(!o?.contains(i)||!o.contains(a))||!i.closest(`[data-chat-message-index]`)||!a.closest(`[data-chat-message-index]`)){u(null);return}let d=r.getBoundingClientRect();if(d.width===0&&d.height===0){u(null);return}let f=Math.min(window.innerWidth-XG-ZG,Math.max(ZG,d.left+d.width/2-XG/2)),p=d.bottom+8,m=p+38<window.innerHeight?p:Math.max(ZG,d.top-42);u({text:t,left:f,top:m,fromSide:l})},t[2]=n,t[3]=c,t[4]=d):d=t[4];let f=d,p;t[5]!==n||t[6]!==f?(p=()=>{if(u(null),!n)return;let e=()=>window.requestAnimationFrame(f),t=()=>u(null);return document.addEventListener(`pointerup`,e),document.addEventListener(`keyup`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`pointerup`,e),document.removeEventListener(`keyup`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},t[5]=n,t[6]=f,t[7]=p):p=t[7];let h;if(t[8]!==n||t[9]!==f||t[10]!==r?(h=[n,f,r],t[8]=n,t[9]=f,t[10]=r,t[11]=h):h=t[11],(0,Z.useEffect)(p,h),!l||!n||n===`new`)return null;let g=l.fromSide?XG/2:XG,_;t[12]!==l.left||t[13]!==l.top||t[14]!==g?(_={left:l.left,top:l.top,width:g},t[12]=l.left,t[13]=l.top,t[14]=g,t[15]=_):_=t[15];let v;t[16]===l.text?v=t[17]:(v=()=>{JG(l.text),window.getSelection()?.removeAllRanges(),u(null)},t[16]=l.text,t[17]=v);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(yo,{className:`size-3.5 shrink-0`}),t[18]=y):y=t[18];let b;t[19]===o.addToChat?b=t[20]:(b=(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.addToChat}),t[19]=o.addToChat,t[20]=b);let x;t[21]!==v||t[22]!==b?(x=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:v,children:[y,b]}),t[21]=v,t[22]=b,t[23]=x):x=t[23];let S;t[24]!==n||t[25]!==o.askInSideChat||t[26]!==o.selectedText||t[27]!==l.fromSide||t[28]!==l.text||t[29]!==s?(S=l.fromSide?null:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 border-l border-edge px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>{s(n,[{id:crypto.randomUUID(),type:`text`,text:l.text,label:o.selectedText}]),window.getSelection()?.removeAllRanges(),u(null)},children:[(0,$.jsx)(Fa,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.askInSideChat})]}),t[24]=n,t[25]=o.askInSideChat,t[26]=o.selectedText,t[27]=l.fromSide,t[28]=l.text,t[29]=s,t[30]=S):S=t[30];let C;return t[31]!==o.selectedTextActionsAria||t[32]!==x||t[33]!==S||t[34]!==_?(C=(0,$.jsxs)(`div`,{role:`group`,"aria-label":o.selectedTextActionsAria,className:`fixed z-[70] flex h-9 overflow-hidden rounded-lg border border-edge bg-surface-overlay text-xs font-medium text-fg shadow-popover`,style:_,onPointerDown:$G,children:[x,S]}),t[31]=o.selectedTextActionsAria,t[32]=x,t[33]=S,t[34]=_,t[35]=C):C=t[35],C}function $G(e){return e.preventDefault()}function eK(e){return e.pendingCreate}function tK(e){return e.requestCreate}function nK(e){return e.language}function rK(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function iK(){let e=(0,Q.c)(28),t=(0,Z.useRef)(null),n=E(dK),r=E(uK),i=E(lK),a=E(cK),o=E(sK),s=E(oK),c=D(aK),l;e[0]===c?l=e[1]:(l=F(c),e[0]=c,e[1]=l);let u=l.token,d=!!s&&!i,f;e[2]!==d||e[3]!==o?(f=e=>{!e&&!d||e||o()},e[2]=d,e[3]=o,e[4]=f):f=e[4];let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(R,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[2px]`,ul)}),e[5]=p):p=e[5];let m,h;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4`,cl,`dark:border-edge`),h=e=>{e.preventDefault(),t.current?.focus()},e[6]=m,e[7]=h):(m=e[6],h=e[7]);let g;e[8]===u.title?g=e[9]:(g=(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:u.title}),e[8]=u.title,e[9]=g);let _;e[10]===u.description?_=e[11]:(_=(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:u.description}),e[10]=u.description,e[11]=_);let v;e[12]!==d||e[13]!==o||e[14]!==c?(v=d?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=d,e[13]=o,e[14]=c,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==a||e[18]!==v?(y=(0,$.jsx)(vV,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:v}),e[16]=r,e[17]=a,e[18]=v,e[19]=y):y=e[19];let b;e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,$.jsxs)(H,{children:[p,(0,$.jsxs)(ee,{className:m,onOpenAutoFocus:h,children:[g,_,y]})]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23];let x;return e[24]!==n||e[25]!==f||e[26]!==b?(x=(0,$.jsx)(ne,{open:n,onOpenChange:f,children:b}),e[24]=n,e[25]=f,e[26]=b,e[27]=x):x=e[27],x}function aK(e){return e.language}function oK(e){return e.conversationId}function sK(e){return e.closeTokenDialog}function cK(e){return e.setBrowserSession}function lK(e){return e.tokenExpired}function uK(e){return e.baseUrl}function dK(e){return e.tokenDialogOpen}function fK(e){return e?e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `):null}function pK(e){let t=(0,Q.c)(15),{item:n,onInvoke:r}=e;if(n.type===`separator`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Od,{className:`my-1 h-px bg-edge-subtle`}),t[0]=e):e=t[0],e}let i;t[1]===n.accelerator?i=t[2]:(i=fK(n.accelerator),t[1]=n.accelerator,t[2]=i);let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=Y(`flex min-h-7 cursor-default select-none items-center gap-6 rounded-md px-2 py-1.5 text-xs text-fg outline-none`,`data-[highlighted]:bg-surface-hover data-[highlighted]:text-fg`),t[3]=o):o=t[3];let s;t[4]!==n.id||t[5]!==r?(s=()=>r(n.id),t[4]=n.id,t[5]=r,t[6]=s):s=t[6];let c;t[7]===n.label?c=t[8]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),t[7]=n.label,t[8]=c);let l;t[9]===a?l=t[10]:(l=a?(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-fg-subtle`,children:a}):null,t[9]=a,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,$.jsxs)(Ed,{className:o,onSelect:s,children:[c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function mK(e){let t=(0,Q.c)(6),{groups:n}=e,r=hK,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Y(`windows-titlebar-interactive flex min-w-0 items-center gap-1`,Fl),t[0]=i):i=t[0];let a;if(t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>(0,$.jsxs)(Cd,{modal:!1,children:[(0,$.jsx)(wd,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 shrink-0 items-center rounded-md px-3 text-sm font-normal text-fg-muted`,`outline-none transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent/60 data-[state=open]:bg-surface-hover data-[state=open]:text-fg`,Fl),role:`menuitem`,children:e.label})}),(0,$.jsx)(Td,{children:(0,$.jsx)(Dd,{align:`start`,sideOffset:4,className:Y(`windows-titlebar-interactive z-[90] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,Fl),children:e.items.map((t,n)=>(0,$.jsx)(pK,{item:t,onInvoke:r},t.type===`item`?t.id:`${e.id}-separator-${n}`))})})]},e.id),t[3]=e):e=t[3],a=n.map(e),t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:i,role:`menubar`,children:a}),t[4]=a,t[5]=o),o}function hK(e){window.electronAPI?.menu?.invoke(e)}var gK=(0,Z.memo)(function(){let e=(0,Q.c)(11),t=D(_K),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0];let[r,i]=(0,Z.useState)(n),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{if(!gd())return;let e=!1;return window.electronAPI?.menu?.getModel().then(t=>{e||i(t)}).catch(()=>{e||i([])}),()=>{e=!0}},e[1]=a):a=e[1];let o;if(e[2]===t?o=e[3]:(o=[t],e[2]=t,e[3]=o),(0,Z.useEffect)(a,o),!gd())return null;let s,c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y(`windows-titlebar flex h-9 min-w-0 shrink-0 items-center gap-2 border-b border-edge-subtle`),c=(0,$.jsx)(`div`,{className:Y(`windows-titlebar-interactive flex shrink-0 items-center gap-0.5`,Fl),children:(0,$.jsx)(zV,{sidebarToggleVariant:`main`})}),e[4]=s,e[5]=c):(s=e[4],c=e[5]);let l;e[6]===r?l=e[7]:(l=(0,$.jsx)(mK,{groups:r}),e[6]=r,e[7]=l);let u;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:Y(`min-w-8 flex-1 self-stretch`,Pl),"aria-hidden":!0}),e[8]=u):u=e[8];let d;return e[9]===l?d=e[10]:(d=(0,$.jsxs)(`header`,{className:s,children:[c,l,u]}),e[9]=l,e[10]=d),d});function _K(e){return e.language}function vK(){let e=(0,Q.c)(16),t=D(yK),n;e[0]===t?n=e[1]:(n=F(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,Z.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!tu())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Z.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,$.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let u;e[7]===r.gatewayExitBody?u=e[8]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=u);let d=i.code??`—`,f=i.signal??`—`,p;e[9]!==d||e[10]!==f?(p=(0,$.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,d,` · signal `,f]}),e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==p?(m=(0,$.jsxs)(`div`,{className:c,role:`alert`,children:[l,u,p]}),e[12]=l,e[13]=u,e[14]=p,e[15]=m):m=e[15],m}function yK(e){return e.language}function bK(e){return{content:[{type:`text`,text:e}]}}function xK(e,t,n){if(Object.keys(e).length!==1||typeof e[t]!=`string`)throw TypeError(`Expected exactly one string argument: ${t}`);let r=e[t];if(!r||r.length>n)throw TypeError(`Invalid ${t}`);return r}function SK(e){let t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function CK(e){return[{descriptor:Wc(`desktop`,`state`),async execute(t){if(Object.keys(t).length)throw TypeError(`Expected no arguments`);let n=e().device;if(!n)throw Error(`Device environment is unavailable`);return{content:[{type:`json`,value:{...await n.readState(),capturedAt:Date.now()}}]}}},{descriptor:{name:`desktop.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one local file and make it available to the agent.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:Oc,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(t,n){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let r=await e().file.pickEndpointFile();if(!r)throw new DOMException(`File selection cancelled`,`AbortError`);let i=SK(r.dataBase64);if(i.byteLength!==r.size||i.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await n.uploadFile({name:r.name,mimeType:r.mimeType,bytes:i})]}}},{descriptor:{name:`desktop.file.save`,title:`Save a text file`,description:`Ask the user where to save UTF-8 text generated by the agent.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`suggestedName`,`content`],properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}}},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-write`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.suggestedName,r=t.content;if(Object.keys(t).length!==2||typeof n!=`string`||!n||n.length>255||typeof r!=`string`||r.length>2e5||new TextEncoder().encode(r).byteLength>200*1024)throw TypeError(`Invalid file save arguments`);let i=await e().file.saveEndpointText({suggestedName:n,content:r});if(!i.saved)throw new DOMException(`File save cancelled`,`AbortError`);return bK(`Saved ${i.name}`)}},{descriptor:{name:`desktop.notification.show`,title:`Show a notification`,description:`Show a bounded native desktop notification after user confirmation.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`title`,`body`],properties:{title:{type:`string`,minLength:1,maxLength:120},body:{type:`string`,minLength:1,maxLength:500}}},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`notifications`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.title,r=t.body;if(Object.keys(t).length!==2||typeof n!=`string`||!n.trim()||n.length>120||typeof r!=`string`||!r.trim()||r.length>500)throw TypeError(`Invalid notification arguments`);let i=e().system;if(!i)throw Error(`Desktop notifications are unavailable`);let a=await i.showEndpointNotification({title:n,body:r});if(a.ok===!1)throw a.error===`PERMISSION_DENIED`||a.error===`NOTIFICATIONS_DISABLED`?new DOMException(`Desktop notification permission is not granted`,`NotAllowedError`):Error(`Desktop notification failed: ${a.error}`);return bK(`Notification shown.`)}},{descriptor:{name:`desktop.clipboard.read`,title:`Read the clipboard`,description:`Read plain text from the desktop clipboard.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:Ac,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-read`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let n=e().clipboard;if(!n?.readText)throw Error(`Clipboard read is unavailable`);return bK(await n.readText())}},{descriptor:{name:`desktop.clipboard.write`,title:`Write to the clipboard`,description:`Replace the desktop clipboard with plain text.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`text`],properties:{text:{type:`string`,minLength:1,maxLength:1e5}}},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){let n=xK(t,`text`,1e5),r=e().clipboard;if(!r?.writeText||!await r.writeText(n))throw Error(`Clipboard write failed`);return bK(`Clipboard updated.`)}},{descriptor:{name:`desktop.app.open_external`,title:`Open an external URL`,description:`Open an HTTP or HTTPS URL in the default desktop application.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,maxLength:2048}}},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`open-external-url`],timeoutMs:15e3,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=xK(t,`url`,2048),r=new URL(n);if(r.protocol!==`http:`&&r.protocol!==`https:`)throw TypeError(`Only HTTP and HTTPS URLs are allowed`);let i=e().shell;if(!i?.openExternalUrl)throw Error(`External URL opening is unavailable`);let a=await i.openExternalUrl(r.href);if(a.ok===!1)throw Error(a.error);return bK(`Opened ${r.href}`)}}]}var wK=CK(()=>{if(!window.electronAPI)throw Error(`Desktop bridge is unavailable`);return{...window.electronAPI,device:{readState:async()=>({platform:window.electronAPI.platform,systemVersion:``,locale:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}}}),TK=600,EK=[],DK=new Set;function OK(){for(let e of DK)e()}function kK(){return EK[0]}function AK(e){return DK.add(e),()=>DK.delete(e)}function jK(e){let t=JSON.stringify(e,null,2);return t.length<=TK?t:`${t.slice(0,TK)}\n…`}function MK(e){return e.deadlineAt<=Date.now()?Promise.resolve(!1):new Promise(t=>{let n=window.setTimeout(()=>NK(e.invocationId,!1),e.deadlineAt-Date.now());EK.push({invocationId:e.invocationId,title:e.title,toolName:e.toolName,argumentsPreview:jK(e.args),resolve:t,timeout:n}),OK()})}function NK(e,t){let n=EK.findIndex(t=>t.invocationId===e);if(n<0)return;let[r]=EK.splice(n,1);window.clearTimeout(r.timeout),r.resolve(t),OK()}function PK(){let e=EK;EK=[];for(let t of e)window.clearTimeout(t.timeout),t.resolve(!1);OK()}function FK(){return(0,Z.useSyncExternalStore)(AK,kK,kK)}function IK(){let e=(0,Q.c)(42),t=FK(),n=D(LK)===`zh`,r;e[0]===t?.toolName?r=e[1]:(r=t?.toolName?.endsWith(`.device.get_location`),e[0]=t?.toolName,e[1]=r);let i=r,a;e[2]!==i||e[3]!==t?(a=i?JSON.parse(t.argumentsPreview):void 0,e[2]=i,e[3]=t,e[4]=a):a=e[4];let o=a,s=!!t,c;e[5]===t?c=e[6]:(c=e=>{!e&&t&&NK(t.invocationId,!1)},e[5]=t,e[6]=c);let l;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[7]=l):l=e[7];let u=i?n?`允许本次使用位置?`:`Use location once?`:n?`允许端侧工具执行?`:`Allow endpoint tool?`,d;e[8]===u?d=e[9]:(d=(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:u}),e[8]=u,e[9]=d);let f=t?.title??``,p;e[10]===f?p=e[11]:(p=(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:f}),e[10]=f,e[11]=p);let m;e[12]!==d||e[13]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-5 py-4`,children:[d,p]}),e[12]=d,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==o?.precision||e[16]!==o?.purpose||e[17]!==i||e[18]!==t?.argumentsPreview||e[19]!==n?(h=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:i?(0,$.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[n?`用途:`:`Purpose: `,o?.purpose===`weather`?n?`查询天气`:`Weather`:n?`查询附近地点`:`Nearby places`]}),(0,$.jsxs)(`p`,{children:[n?`精度:`:`Precision: `,o?.precision===`precise`?n?`精确位置`:`Precise`:n?`大致位置`:`Approximate`]}),(0,$.jsxs)(`p`,{children:[n?`此浏览器的位置仅用于本次查询。坐标将发送给 `:`This browser’s location is used only for this query. Coordinates are sent to `,o?.purpose===`weather`?`Open-Meteo`:`OpenStreetMap`,n?`,原始坐标不进入聊天历史。系统权限开启后,每次调用仍需确认。`:`; raw coordinates are excluded from chat history. Each call requires consent even when OS permission is enabled.`]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n?`实际参数`:`Arguments`}),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-lg border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg`,children:t?.argumentsPreview??`{}`})]})}),e[15]=o?.precision,e[16]=o?.purpose,e[17]=i,e[18]=t?.argumentsPreview,e[19]=n,e[20]=h):h=e[20];let g;e[21]===t?g=e[22]:(g=()=>t&&NK(t.invocationId,!1),e[21]=t,e[22]=g);let _=n?`拒绝`:`Deny`,v;e[23]!==g||e[24]!==_?(v=(0,$.jsx)(X,{onClick:g,children:_}),e[23]=g,e[24]=_,e[25]=v):v=e[25];let y;e[26]===t?y=e[27]:(y=()=>t&&NK(t.invocationId,!0),e[26]=t,e[27]=y);let b=n?`允许一次`:`Allow once`,x;e[28]!==y||e[29]!==b?(x=(0,$.jsx)(X,{variant:`primary`,onClick:y,children:b}),e[28]=y,e[29]=b,e[30]=x):x=e[30];let S;e[31]!==v||e[32]!==x?(S=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[v,x]}),e[31]=v,e[32]=x,e[33]=S):S=e[33];let C;e[34]!==h||e[35]!==S||e[36]!==m?(C=(0,$.jsxs)(H,{children:[l,(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(26rem,calc(100vh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[m,h,S]})]}),e[34]=h,e[35]=S,e[36]=m,e[37]=C):C=e[37];let w;return e[38]!==C||e[39]!==s||e[40]!==c?(w=(0,$.jsx)(ne,{open:s,onOpenChange:c,children:C}),e[38]=C,e[39]=s,e[40]=c,e[41]=w):w=e[41],w}function LK(e){return e.language}var RK=`xopc-endpoint-tools`,zK=`identity`,BK=`xopc.endpoint-tools.endpoint-id`,VK;function HK(e){if(VK?.startsWith(`${e}:`))return VK;let t=sessionStorage.getItem(BK);return t?.startsWith(`${e}:`)?(VK=t,t):(VK=`${e}:${crypto.randomUUID()}`,sessionStorage.setItem(BK,VK),VK)}function UK(e){let t=String.fromCharCode(...new Uint8Array(e));return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}function WK(){return new Promise((e,t)=>{let n=indexedDB.open(RK,1);n.onupgradeneeded=()=>n.result.createObjectStore(zK),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Endpoint identity database failed`))})}async function GK(e){let t=await WK();try{return await new Promise((n,r)=>{let i=t.transaction(zK).objectStore(zK).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error??Error(`Endpoint identity read failed`))})}finally{t.close()}}async function KK(e,t){let n=await WK();try{await new Promise((r,i)=>{let a=n.transaction(zK,`readwrite`);a.objectStore(zK).put(t,e),a.oncomplete=()=>r(),a.onerror=()=>i(a.error??Error(`Endpoint identity write failed`))})}finally{n.close()}}async function qK(e){let t=await WK();try{await new Promise((n,r)=>{let i=t.transaction(zK,`readwrite`);i.objectStore(zK).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error??Error(`Endpoint identity deletion failed`))})}finally{t.close()}}async function JK(e){let t=await GK(e);if(t)return t;let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=UK(await crypto.subtle.exportKey(`spki`,n.publicKey)),i=await crypto.subtle.importKey(`pkcs8`,await crypto.subtle.exportKey(`pkcs8`,n.privateKey),{name:`ECDSA`,namedCurve:`P-256`},!1,[`sign`]),a={principalId:crypto.randomUUID(),publicKey:r,privateKey:i};return await KK(e,a),a}async function YK(e){return await qK(e),VK=void 0,sessionStorage.removeItem(BK),JK(e)}async function XK(e,t){return UK(await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},e,new TextEncoder().encode(t)))}var ZK=2e3;function QK(){return document.visibilityState===`visible`&&document.hasFocus()?`foreground`:`background`}async function $K(e){if(e.signal.aborted)return!1;let t=()=>NK(e.invocationId,!1);e.signal.addEventListener(`abort`,t,{once:!0});try{return await MK({invocationId:e.invocationId,title:e.descriptor.title,toolName:e.descriptor.name,args:e.arguments,deadlineAt:e.deadlineAt})}finally{e.signal.removeEventListener(`abort`,t)}}var eq=class{config;reconnectTimer;connectPromise;detachRealtime;stopped=!1;registrationBlocked=!1;endpointId;supportsDeviceState=!1;supportsEnvironment=!1;contextPublisher=tV();supportsLocationTasks=!1;turnToken;registry;controller;constructor(e){this.config=e,this.registry=new ZB(e.definitions),this.controller=new QB({registry:this.registry,getAvailability:QK,confirm:$K,uploadFile:(e,t)=>this.uploadFile(e,t),createMessageId:()=>crypto.randomUUID()})}async start(){this.stopped=!1,this.registrationBlocked=!1,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`focus`,this.onVisibilityChange),window.addEventListener(`blur`,this.onVisibilityChange),window.addEventListener(`gateway-authenticated`,this.onTokenSaved),await this.connect()}stop(){this.stopped=!0,this.contextPublisher.stop(),Ys(!1),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`focus`,this.onVisibilityChange),window.removeEventListener(`blur`,this.onVisibilityChange),window.removeEventListener(`gateway-authenticated`,this.onTokenSaved),window.clearTimeout(this.reconnectTimer),this.detachRealtime?.(),this.detachRealtime=void 0,this.controller.disconnect(),nc(this.turnToken),this.turnToken=void 0,this.endpointId=void 0,PK()}onTokenSaved=()=>{this.registrationBlocked=!1,this.connect()};onVisibilityChange=()=>{this.controller.publishAvailability(),this.contextPublisher.refresh()};connect(e=!0){if(this.connectPromise)return this.connectPromise;let t=this.connectOnce(e).finally(()=>{this.connectPromise===t&&(this.connectPromise=void 0)});return this.connectPromise=t,t}async connectOnce(e){if(!(this.stopped||this.registrationBlocked)){window.clearTimeout(this.reconnectTimer);try{let t=await S(T(`/api/endpoint-tools/compatibility`)),n=await t.json().catch(()=>null);this.supportsEnvironment=t.ok&&n?.payload?.endpointEnvironmentV1===!0,Ys(t.ok&&n?.payload?.turnDeviceContextV1===!0),this.supportsLocationTasks=t.ok&&n?.payload?.deviceLocationTasksV1===!0,this.supportsDeviceState=t.ok&&n?.payload?.deviceStateToolsV1===!0;let r=await JK(this.config.kind);if(this.stopped)return;let i=await S(T(`/api/endpoint-tools/principals`),{method:`POST`,body:JSON.stringify({principalId:r.principalId,displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,publicKey:r.publicKey})});if(!i.ok){if((await i.json().catch(()=>null))?.error?.code===`PRINCIPAL_REVOKED`){if(!e){this.registrationBlocked=!0;return}let t=await this.config.confirmReenrollment();if(this.stopped)return;if(!t){this.registrationBlocked=!0;return}await YK(this.config.kind),this.stopped||await this.connectOnce(!1);return}if(i.status>=400&&i.status<500){this.registrationBlocked=!0;return}throw Error(`Endpoint registration failed: ${i.status}`)}if(this.stopped)return;let a={createHello:()=>this.createHello(r),onReady:({endpointId:e,turnToken:t})=>{this.endpointId=e,this.turnToken=t,$s(e,t),this.controller.connect(Vc),this.supportsEnvironment&&this.contextPublisher.start({endpointId:e,token:t})},onMessage:e=>{this.controller.handleMessage(e)},onDisconnected:()=>{this.contextPublisher.stop(),this.controller.disconnect(),nc(this.turnToken),this.turnToken=void 0,PK()}};this.detachRealtime?.(),this.detachRealtime=Uc(a)}catch{this.scheduleReconnect()}}}scheduleReconnect(){this.stopped||this.reconnectTimer!==void 0||(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=void 0,this.connect()},ZK))}async createHello(e){let t=HK(e.principalId);this.endpointId=t;let n={principalId:e.principalId,endpointId:t,connectionInstanceId:crypto.randomUUID(),displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,appVersion:this.config.appVersion,availability:QK(),nonce:crypto.randomUUID(),signedAt:Date.now(),signature:`pending`,tools:this.registry.descriptors().filter(e=>e.name.endsWith(`.device.get_location`)?this.supportsLocationTasks:this.supportsDeviceState||!e.name.includes(`.device.get_`))},r=await XK(e.privateKey,jc(n));return{...n,signature:r}}async uploadFile(e,t){if(!e||!this.endpointId)throw Error(`Endpoint file upload grant is unavailable`);if(!t.name||t.name.length>255||!t.mimeType||t.mimeType.length>255||t.bytes.byteLength>e.maxBytes||e.expiresAt<=Date.now())throw TypeError(`Endpoint file is invalid`);let n=new URL(T(e.path),window.location.href);n.searchParams.set(`name`,t.name);let r=t.bytes.buffer.slice(t.bytes.byteOffset,t.bytes.byteOffset+t.bytes.byteLength),i=await S(n,{method:`POST`,headers:{"Content-Type":t.mimeType,"x-endpoint-id":this.endpointId,"x-endpoint-upload-token":e.token},body:r}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error?.message??`Endpoint file upload failed: ${i.status}`);let o=Mc.safeParse(a?.payload);if(!o.success||o.data.type!==`file`)throw Error(`Endpoint file upload returned an invalid response`);return o.data}},tq,nq=new Set;function rq(){for(let e of nq)e()}function iq(e){return nq.add(e),()=>nq.delete(e)}function aq(){return!!tq}function oq(){return tq?Promise.resolve(!1):new Promise(e=>{tq={resolve:e},rq()})}function sq(e){let t=tq;t&&(tq=void 0,t.resolve(e),rq())}function cq(){return(0,Z.useSyncExternalStore)(iq,aq,aq)}function lq(){let e=(0,Q.c)(21),t=cq(),n=D(pq)===`zh`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[0]=r):r=e[0];let i=n?`重新注册此端?`:`Re-enroll this endpoint?`,a;e[1]===i?a=e[2]:(a=(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:i}),e[1]=i,e[2]=a);let o=n?`此端身份已被撤销。继续会删除旧密钥并生成一个新的端身份,然后重新连接 Gateway。`:`This endpoint identity was revoked. Continuing deletes the old key, creates a new endpoint identity, and reconnects to the Gateway.`,s;e[3]===o?s=e[4]:(s=(0,$.jsx)(B,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:o}),e[3]=o,e[4]=s);let c;e[5]!==a||e[6]!==s?(c=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:[a,s]}),e[5]=a,e[6]=s,e[7]=c):c=e[7];let l=n?`取消`:`Cancel`,u;e[8]===l?u=e[9]:(u=(0,$.jsx)(X,{onClick:dq,children:l}),e[8]=l,e[9]=u);let d=n?`生成新身份`:`Create new identity`,f;e[10]===d?f=e[11]:(f=(0,$.jsx)(X,{variant:`primary`,onClick:uq,children:d}),e[10]=d,e[11]=f);let p;e[12]!==u||e[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[u,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14];let m;e[15]!==p||e[16]!==c?(m=(0,$.jsxs)(H,{children:[r,(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(22rem,calc(100vh-2rem))] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[c,p]})]}),e[15]=p,e[16]=c,e[17]=m):m=e[17];let h;return e[18]!==t||e[19]!==m?(h=(0,$.jsx)(ne,{open:t,onOpenChange:fq,children:m}),e[18]=t,e[19]=m,e[20]=h):h=e[20],h}function uq(){return sq(!0)}function dq(){return sq(!1)}function fq(e){return!e&&sq(!1)}function pq(e){return e.language}var mq={descriptor:uB(`web`),async execute(e,t){let n=sB.parse(e);if(!navigator.geolocation)throw new JB(`PERMISSION_DENIED`,`Location is unavailable in this browser`);return{content:[{type:`json`,value:await new Promise((e,r)=>{let i=!1,a=(a,s)=>{if(i)return;if(i=!0,t.signal.removeEventListener(`abort`,o),s){r(s);return}let c=n.precision===`approximate`||a.coords.accuracy>1e3;e({capturedAt:a.timestamp,latitude:c?Math.round(a.coords.latitude*50)/50:a.coords.latitude,longitude:c?Math.round(a.coords.longitude*50)/50:a.coords.longitude,accuracyMeters:c?Math.max(3e3,a.coords.accuracy):a.coords.accuracy,coordinateSystem:`WGS84`,precision:c?`approximate`:`precise`})},o=()=>a(void 0,new JB(`TOOL_CANCELLED`,`Location request cancelled`));if(t.signal.addEventListener(`abort`,o,{once:!0}),t.signal.aborted){o();return}navigator.geolocation.getCurrentPosition(e=>a(e),e=>a(void 0,new JB(e.code===1?`PERMISSION_DENIED`:e.code===3?`TOOL_TIMEOUT`:`PROTOCOL_ERROR`,e.code===1?`Location permission denied`:`Location is unavailable`)),{maximumAge:0,timeout:2e4,enableHighAccuracy:n.precision===`precise`})})}]}}};function hq(e){return{content:[{type:`text`,text:e}]}}function gq(){if(!navigator.userActivation?.isActive)throw new DOMException(`A current user gesture is required`,`NotAllowedError`)}function _q(e){return new DOMException(e,`AbortError`)}function vq(e){let t=e.suggestedName,n=e.content;if(Object.keys(e).length!==2||typeof t!=`string`||!t||t===`.`||t===`..`||t.length>255||t.includes(`/`)||t.includes(`\\`)||typeof n!=`string`||n.length>2e5||new TextEncoder().encode(n).byteLength>200*1024)throw TypeError(`Invalid file download arguments`);return{suggestedName:t,content:n}}function yq(){return gq(),new Promise((e,t)=>{let n=document.createElement(`input`);n.type=`file`,n.multiple=!1,n.onchange=()=>{let r=n.files?.[0];r?e(r):t(_q(`File selection cancelled`))},n.oncancel=()=>t(_q(`File selection cancelled`)),n.click()})}function bq(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw TypeError(`${t} must be a non-empty string`);return n}function xq(e,t){let n=Object.keys(e).toSorted(),r=t.toSorted();if(n.length!==r.length||n.some((e,t)=>e!==r[t]))throw TypeError(`arguments must contain exactly: ${r.join(`, `)||`no fields`}`)}var Sq=[mq,{descriptor:Wc(`web`,`state`),async execute(e){if(Object.keys(e).length)throw TypeError(`Expected no arguments`);return{content:[{type:`json`,value:{capturedAt:Date.now(),platform:`web`,systemVersion:``,locale:navigator.language.slice(0,80),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,online:navigator.onLine}}]}}},{descriptor:{name:`web.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one browser-accessible file and make it available to the agent.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:Oc,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(e,t){xq(e,[]);let n=await yq();if(n.size>26214400)throw TypeError(`Selected file exceeds ${Hc} bytes`);let r=new Uint8Array(await n.arrayBuffer());if(r.byteLength!==n.size||r.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await t.uploadFile({name:n.name,mimeType:n.type||`application/octet-stream`,bytes:r})]}}},{descriptor:{name:`web.file.download`,title:`Download a text file`,description:`Download bounded UTF-8 text generated by the agent through this browser.`,inputSchema:{type:`object`,properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}},required:[`suggestedName`,`content`],additionalProperties:!1},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-download`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){let{suggestedName:t,content:n}=vq(e);gq();let r=URL.createObjectURL(new Blob([n],{type:`text/plain;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=r,e.download=t,e.click()}finally{URL.revokeObjectURL(r)}return hq(`Download started: ${t}`)}},{descriptor:{name:`web.page.get_selection`,title:`Read selected text`,description:`Read the text currently selected in this browser tab.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:Ac,policyId:`public.foreground-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!0,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){return xq(e,[]),hq(window.getSelection()?.toString()??``)}},{descriptor:{name:`web.clipboard.write`,title:`Write clipboard`,description:`Write text to the clipboard from this browser tab.`,inputSchema:{type:`object`,properties:{text:{type:`string`,maxLength:1e5}},required:[`text`],additionalProperties:!1},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){if(xq(e,[`text`]),!navigator.clipboard||!document.hasFocus())throw new DOMException(`Clipboard access requires a focused browser tab`,`NotAllowedError`);let t=bq(e,`text`);if(t.length>1e5)throw TypeError(`text exceeds 100000 characters`);return await navigator.clipboard.writeText(t),hq(`Clipboard updated.`)}},{descriptor:{name:`web.page.navigate`,title:`Navigate page`,description:`Navigate this browser tab to an HTTP or HTTPS URL.`,inputSchema:{type:`object`,properties:{url:{type:`string`,maxLength:4096}},required:[`url`],additionalProperties:!1},outputSchema:Ac,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`destructive`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`navigation`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){xq(e,[`url`]);let t=bq(e,`url`);if(t.length>4096)throw TypeError(`url exceeds 4096 characters`);let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw TypeError(`url must use HTTP or HTTPS`);return{content:[{type:`text`,text:`Navigating to ${n.href}`}],afterSend:()=>window.location.assign(n.href)}}}];function Cq(){return(0,Z.useEffect)(()=>{let e=tu();if(e&&window.electronAPI?.computer){let e=!1,t=!1,n,r=tV(),i=()=>{r.refresh()};document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),window.addEventListener(`blur`,i),S(T(`/api/endpoint-tools/compatibility`)).then(async n=>{let r=await n.json();t=n.ok&&r?.payload?.endpointEnvironmentV1===!0,e||Ys(n.ok&&r?.payload?.turnDeviceContextV1===!0)}).catch(()=>{e||Ys(!1)});let a=async()=>{try{let i=await window.electronAPI.computer.status();if(e)return;i.claim?($s(i.claim.endpointId,i.claim.token),t&&n!==i.claim.token&&(n=i.claim.token,r.start(i.claim))):(n=void 0,r.stop(),nc())}catch{e||(n=void 0,r.stop(),nc())}};a();let o=window.setInterval(()=>{a()},1e3);return()=>{e=!0,r.stop(),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i),window.removeEventListener(`blur`,i),Ys(!1),window.clearInterval(o),nc()}}let t=new eq(e?{kind:`desktop`,platform:window.electronAPI?.platform??`desktop`,displayName:`xopc Desktop`,appVersion:`1`,definitions:wK,confirmReenrollment:oq}:{kind:`web`,platform:`web`,displayName:`Web browser`,appVersion:`1`,definitions:Sq,confirmReenrollment:oq});return t.start(),()=>{sq(!1),t.stop()}},[]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(IK,{}),(0,$.jsx)(lq,{})]})}function wq(){let e=(0,Q.c)(3),t=x(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!tu())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(Dq),i=e.menu.onQuickCapture(Eq),a=e.menu.onToggleSidebar(Tq),o=e.menu.onHistoryNavigate(e=>{t(e)});return()=>{n(),r(),i(),a(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function Tq(){_e.getState().toggleCollapsed()}function Eq(){wn()}function Dq(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var Oq=1500,kq=9e4;function Aq(){let e=(0,Q.c)(16),t=D(Nq),n;e[0]===t?n=e[1]:(n=F(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(Mq);let t=Date.now()+kq;for(;e===c.current&&Date.now()<t;){try{if((await fetch(T(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(jq)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let u=l,d,f;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=()=>u();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},f=[u],e[3]=d,e[4]=f):(d=e[3],f=e[4]),(0,Z.useEffect)(d,f);let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{u()},e[5]=p):p=e[5];let m=p;if(!i)return null;let h=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,g;e[6]===h?g=e[7]:(g=Y(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,h),e[6]=h,e[7]=g);let _;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(_=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:r.restartPollTimeout}),(0,$.jsx)(`button`,{type:`button`,onClick:m,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-on-accent hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=_):_=e[12];let v;return e[13]!==g||e[14]!==_?(v=(0,$.jsx)(`div`,{className:g,children:_}),e[13]=g,e[14]=_,e[15]=v):v=e[15],v}function jq(e){return setTimeout(e,Oq)}function Mq(e){return setTimeout(e,2e3)}function Nq(e){return e.language}function Pq({reminder:e,compact:t}){let n=D(e=>e.language),r=F(n).updatePanel,{show:i,dismiss:a,electronCheck:o,electronQuitAndInstall:s,runNpmUpdate:c,npmUpdateRunning:l}=e,[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useCallback)(async()=>{d(!0),p(null);try{let e=await jo();if(e.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}p(e.message??`Gateway restart failed`)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[]),h=(0,Z.useCallback)(async()=>{let e=F(n).updatePanel;p(null);let t=await c();if(t.ok){jl({tone:`success`,title:e.updateSuccess,message:sH(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;p(`${r}: ${t.message}`)},[c,n]);if(i.kind===`none`)return null;let g=Y(`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`,Fl);return i.kind===`electron-ready`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,Pl,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(pi,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,$.jsxs)(`div`,{className:g,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90`,children:[(0,$.jsx)(Eo,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ds,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-edge bg-surface-panel px-10 py-2 text-sm text-fg-muted sm:px-12`,Pl,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex w-full max-w-[52rem] min-w-0 flex-wrap items-center justify-center gap-x-3 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-center gap-2`,role:`status`,children:[(0,$.jsx)(ca,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:/(?:ERR_(?:CONNECTION_\w+|INTERNET_DISCONNECTED|NAME_NOT_RESOLVED|NETWORK_CHANGED|TIMED_OUT)|ECONN|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|ERR_NETWORK|network|timed?\s*out|socket hang up)/i.test(i.message)?r.reminderElectronUpdateNetworkError:r.reminderElectronUpdateError})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:Y(`inline-flex shrink-0 items-center gap-1 rounded px-2 py-1 text-xs font-medium text-accent-fg hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent`,Fl),children:[(0,$.jsx)(Eo,{className:`size-3`,"aria-hidden":!0}),r.reminderElectronUpdateRetry]}),i.message&&(0,$.jsxs)(`details`,{className:Y(`basis-full min-w-0 text-xs`,`[-webkit-app-region:no-drag]`),children:[(0,$.jsx)(`summary`,{className:`mx-auto w-fit cursor-pointer rounded text-fg-subtle hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,children:r.reminderElectronUpdateDetails}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded border border-edge bg-surface-inset p-2 text-fg-muted select-text`,children:i.message})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:Y(g,`rounded p-1 hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent`),"aria-label":r.dismissAria,title:r.dismissAria,children:(0,$.jsx)(ds,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-panel px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,Pl,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(pi,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,$.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-inset sm:max-w-[12rem]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:Y(g,`sm:right-2`),"aria-label":r.dismissAria,children:(0,$.jsx)(ds,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,Pl,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,$.jsxs)(`button`,{type:`button`,onClick:m,disabled:u,className:Y(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,Fl),children:[u?(0,$.jsx)(_a,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Eo,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]}),f?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:f}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:g,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ds,{className:`size-4`})})]}):i.kind===`npm-restarting`?(0,$.jsx)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,Pl,t&&`text-xs`),children:(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] items-center justify-center gap-2 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(_a,{className:`size-4 shrink-0 animate-spin text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartingAutomatically.replace(`{{version}}`,i.version)})]})}):i.kind===`npm`?(0,$.jsxs)(`div`,{className:Y(`relative hidden min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm md:flex`,Pl,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:Y(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,$.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:l,className:Y(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,Fl),children:[l?(0,$.jsx)(_a,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Eo,{className:`size-3 shrink-0`,"aria-hidden":!0}),l?r.updateRunning:r.updateNow]}),f?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:f}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:g,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ds,{className:`size-4`})})]}):null}function Fq(e,t,n){let r=F(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:local-app:create`,title:i.createLocalApp,subtitle:i.createLocalAppSubtitle,groupLabel:a,keywords:[`app`,`local app`,`create app`,`tool`,`workshop`,`coder`,`应用`,`创建应用`,`工具`,`工坊`],run:()=>{n(),t(`/local-apps/new`)}},{kind:`action`,id:`action:automation:create`,title:`Create automation`,subtitle:`Open automations to create a trigger and action`,groupLabel:a,keywords:[`automation`,`schedule`,`trigger`,`action`,`timer`],run:()=>{n(),t(`/automations?action=create`)}},{kind:`action`,id:`action:automation:manage`,title:`Manage automations`,subtitle:`View automations and run history`,groupLabel:a,keywords:[`automation`,`schedule`,`tasks`,`runs`],run:()=>{n(),t(`/automations`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/capabilities/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),c(async()=>{let{reloadSkills:e}=await import(`./skill-reload-api-Bm-8vhsQ.js`).then(e=>e.n);return{reloadSkills:e}},__vite__mapDeps([170,1,5,2,6,171])).then(({reloadSkills:e})=>e())}}]}function Iq(e){if(e)return e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `)}async function Lq(e,t){let n=window.electronAPI?.menu;if(!n)return[];try{let r=await n.getModel(),i=F(e).commandPalette.groups.actions;return r.flatMap(e=>e.items.flatMap(r=>{if(r.type!==`item`||r.id.startsWith(`role.`))return[];let a=Iq(r.accelerator);return[{kind:`action`,id:`desktop-menu:${r.id}`,title:r.label,subtitle:[e.label,a].filter(Boolean).join(` · `)||void 0,groupLabel:i,keywords:[r.id,e.id,e.label,r.accelerator??``],run:()=>{t(),n.invoke(r.id)}}]}))}catch{return[]}}function Rq(e){return F(e).commandPalette.groups}function zq(e){let t=Rq(e);return{[t.navigate]:0,[t.projects]:1,[t.connectors]:2,[t.quickSettings]:3,[t.extensions]:4,[t.sessions]:5,[t.files]:6,[t.commands]:7,[t.skills]:8,[t.actions]:9}}function Bq(e){let t=Rq(e);return{[t.navigate]:12,[t.projects]:8,[t.connectors]:6,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function Vq(e,t){return zq(e)[t]??10}var Hq=null;function Uq(){Hq=null}function Wq(){return Hq||(Hq=Promise.allSettled([xl(),yl()]).then(([e,t])=>{if(e.status===`rejected`&&t.status===`rejected`)throw e.reason;let n={catalog:e.status===`fulfilled`?e.value:[],instances:t.status===`fulfilled`?t.value:[]};return(e.status===`rejected`||t.status===`rejected`)&&(Hq=null),n}).catch(e=>{throw Hq=null,e}),Hq)}function Gq(e,t){return!e.enabled||e.status===`disabled`?t.disabled:e.status===`failed`||e.status===`degraded`||e.status===`not_configured`||e.status===`unauthorized`||e.connectionStatus===`error`||e.connectionStatus===`unauthorized`?t.needsSetup:e.status===`connected`||e.connectionStatus===`connected`?t.connected:t.installed}function Kq(e){return e?[e.id,e.description,e.category,e.kind,...e.tags??[],...e.capabilities,...e.benefits??[]]:[]}function qq(e,t){return t?`${e} · ${t}`:e}function Jq(e){if(!e.query.trim())return[];let t=new Map(e.catalog.map(e=>[e.id,e])),n=new Set(e.instances.map(e=>e.connectorId)),r=e.instances.map(n=>{let r=t.get(n.connectorId);return{kind:`connector`,id:`connector-instance:${n.instanceId}`,title:n.displayName,subtitle:qq(Gq(n,e.labels),r?.description),groupLabel:e.labels.group,keywords:[n.connectorId,n.instanceId,n.materialized.type,...Kq(r)],run:()=>{e.close(),e.navigate(`/capabilities/connectors?instance=${encodeURIComponent(n.instanceId)}&tab=connected`)}}}),i=e.catalog.flatMap(t=>t.source!==`builtin`||t.integrationStrategy?.preferred===!1||!Jr(t)||n.has(t.id)?[]:[{kind:`connector`,id:`connector:${t.id}`,title:t.displayName,subtitle:qq(e.labels.builtin,t.description),groupLabel:e.labels.group,keywords:Kq(t),run:()=>{e.close(),e.navigate(`/capabilities/connectors?connector=${encodeURIComponent(t.id)}&tab=discover`)}}]);return[...r,...i]}function Yq(e){return e.trim().toLowerCase()}function Xq(e,t){let n=Yq(e),r=Yq(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function Zq(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=Xq(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`project`?-.12:e.kind===`connector`||e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function Qq(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var $q=new Set([`logs`,`tracing`,`settingsRuntimes`]),eJ=[`/settings/logs`,`/settings/tracing`,`/settings/runtimes`,`/settings/extensions/debug`];function tJ(e,t){return t===`advanced`||!$q.has(e)}function nJ(e,t){return t===`advanced`||!eJ.some(t=>e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`))}var rJ=[`settingsAgentBrowser`,`settingsComputerUse`,`settingsPhoneUse`],iJ={settingsAgentBrowser:[`browser`,`playwright`,`automation`],settingsPhoneUse:[`phone use`,`Android`,`ADB`,`AutoGLM`,`手机控制`,`模拟器`],settingsComputerUse:[`computer use`,`compute use`,`desktop`,`电脑控制`,`电脑操作`,`桌面控制`,`GUI`,`BYOK`]};function aJ(e,t){let n=F(e).commandPalette.routes.agentsSubtitle;return rJ.filter(e=>tJ(e,t)&&(e!==`settingsComputerUse`||nu())).map(t=>({id:`route:settings:agent:${t}`,title:P(e,t),subtitle:n,path:Yl(t),keywords:[`agent`,`manifest`,`preset`,`config`,...iJ[t]??[]]}))}function oJ(e,t){return e.filter(e=>nJ(e.path.split(`?`)[0]??e.path,t))}function sJ(e){let t=F(e),n=t.commandPalette.routes,r=t.channelsSettings,i=sf.getState().mode;return oJ([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:of,keywords:[`agent`,`persona`,`switch`]},{id:`route:extensions`,title:t.nav.extensions,subtitle:n.extensionsSubtitle,path:Qc(`extensions`),keywords:[`extension`,`plugin`,`addon`]},{id:`route:local-apps`,title:t.nav.localApps,subtitle:n.localAppsSubtitle,path:`/local-apps`,keywords:[`app`,`apps`,`local app`,`tool`,`workshop`,`coder`,`应用`,`本地应用`,`工具`,`工坊`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:usage`,title:t.nav.usage,subtitle:n.usageSubtitle,path:`/settings/usage`,keywords:[`usage`,`cost`,`tokens`,`model`,`用量`,`费用`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:Qc(`skills`),keywords:[`tools`,`catalog`]},{id:`route:connectors`,title:t.nav.connectors,subtitle:n.connectorsSubtitle,path:Qc(`connectors`),keywords:[`connector`,`mcp`,`registry`,`integration`,`tools`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:To,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:`Telegram`,subtitle:n.channelsSubtitle,path:wo(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:`Weixin`,subtitle:n.channelsSubtitle,path:wo(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:`Feishu/Lark`,subtitle:n.channelsSubtitle,path:wo(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`Telegram — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:wo(`telegram`),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:automations`,title:`Automations`,subtitle:`Triggers, actions, and run history`,path:`/automations`,keywords:[`automation`,`automations`,`schedule`,`tasks`,`history`,`scheduler`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:capabilities:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:Ql(`models`),keywords:[`api`,`key`,`provider`,`openai`,`anthropic`,`google`,`gpt`,`claude`,`gemini`,`llm`,`模型`,`模型服务`,`语音`,`音色`,`听写`,`voice`,`stt`,`tts`,`image`,`服务商`,`密钥`]},{id:`route:settings:capabilities:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:Ql(`search`),keywords:[`search`,`web`,`tavily`,`serper`,`brave`,`搜索`,`网络搜索`,`联网搜索`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...aJ(e,i)],i)}async function cJ(e,t={}){let n=new URLSearchParams;return n.set(`q`,e.trim()),t.types?.length&&n.set(`types`,t.types.join(`,`)),t.limit&&n.set(`limit`,String(t.limit)),(await O(T(`/api/search?${n.toString()}`))).hits}function lJ(e){Wl.getState().setPreference(e)}function uJ(e){D.getState().setLanguage(e)}function dJ(e,t){let n=F(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`default model`,`默认模型`,`gpt`,`claude`,`gemini`,`llm`,`模型`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{lJ(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{lJ(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{lJ(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{uJ(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{uJ(`zh`),t.closePalette()}}]}function fJ(e){let t=e===`zh`;return[{advanced:!0,id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway?tab=network`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{advanced:!0,id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway?tab=network`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway?tab=access`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent-defaults:models`,title:t?`Agent 全局模型`:`Global agent models`,subtitle:t?`设置所有 Agent 继承的模型与回退`:`Set inherited models and fallbacks`,path:`/settings/capabilities/models`,keywords:[`agent defaults`,`model intents`,`fallbacks`,`llm`,`全局默认`,`模型意图`]},{id:`field:agent-defaults:skills`,title:t?`Agent 全局技能`:`Global agent skills`,subtitle:t?`设置所有 Agent 默认可用或排除的技能`:`Set skills enabled or excluded for every agent`,path:`/settings/agent-defaults?panel=skills`,keywords:[`agent defaults`,`skills`,`inherit`,`全局默认`,`技能`,`继承`]},{id:`field:agent-defaults:tools`,title:t?`Agent 全局工具权限`:`Global agent tool permissions`,subtitle:t?`设置所有 Agent 继承的 allow、ask 或 deny 策略`:`Set inherited allow, ask, or deny policies`,path:`/settings/agent-defaults?panel=tools`,keywords:[`agent defaults`,`tools`,`permissions`,`allow`,`ask`,`deny`,`工具权限`]},{advanced:!0,id:`field:agent-defaults:runtime`,title:t?`Agent 全局运行限制`:`Global agent runtime limits`,subtitle:t?`设置继承的轮次和超时`:`Set inherited turn and timeout limits`,path:`/settings/agent-defaults?panel=runtime`,keywords:[`agent defaults`,`runtime`,`turns`,`timeout`,`运行限制`]},{id:`field:agent:profile`,title:t?`Agent 个性`:`Agent personality`,subtitle:t?`设置名称、个性指令和可选覆盖`:`Set the name, personality, and optional overrides`,path:of,keywords:[`agent`,`profile`,`personality`,`instructions`,`agent 个性`,`指令`]},{id:`field:agent:workspace`,title:t?`Agent 工作目录`:`Agent workspace`,subtitle:t?`按需覆盖该 Agent 的自动工作目录`:`Optionally override the automatic workspace`,path:of,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/settings/agent-browser`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/settings/agent-browser`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/settings/agent-browser`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/settings/agent-browser`,keywords:[`headless`,`window`,`visible`,`无头`]},{advanced:!0,id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/settings/agent-browser`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/capabilities/models?configure=transcription`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/capabilities/models?configure=speech`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/capabilities/search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:automations:enabled`,title:t?`自动化`:`Automations`,subtitle:t?`创建和管理自动化`:`Create and manage automations`,path:`/automations`,keywords:[`automation`,`automations`,`scheduler`,`timer`,`自动化`,`调度`]},{id:`field:automations:runs`,title:t?`自动化运行记录`:`Automation Runs`,subtitle:t?`查看自动化执行历史`:`Review automation run history`,path:`/automations`,keywords:[`automation`,`runs`,`history`,`自动化`,`历史`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:To,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:To,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/capabilities/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function pJ(e,t,n,r){return fJ(e).map(i=>({kind:`setting`,id:i.id,title:i.title,subtitle:i.advanced?`${e===`zh`?`高级设置`:`Advanced settings`} · ${i.subtitle}`:i.subtitle,groupLabel:r,keywords:i.keywords,run:()=>{i.advanced&&sf.getState().setMode(`advanced`),n(),t(i.path)}}))}function mJ(){let{pathname:e}=m(),{conversationId:t}=f();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}async function hJ(e){let{defaults:t}=await lf();await cf({...t,models:{...t.models,chat:{primary:e,fallbacks:[]}}})}function gJ(e,t,n,r){let i=e.trim().toLowerCase();i&&(dc(i),t.startsWith(`/chat`)?window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:i}})):n(`/chat/new?projectScope=none`,{state:{agentId:i}}),r())}function _J(e){switch(e.kind){case`connector`:return(0,$.jsx)(cr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`extension`:return(0,$.jsx)(So,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,$.jsx)(Vi,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`project`:return(0,$.jsx)(Bi,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,$.jsx)(Vi,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,$.jsx)(Fi,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,$.jsx)($o,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,$.jsx)(Vo,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,$.jsx)(Io,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,$.jsx)(fs,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function vJ(e,t,n,r){if(r(),t.startsWith(`/chat`)){Oe(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Oe(e)})}))}function yJ(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/extensions/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function bJ(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var xJ={query:``,selectedIndex:0,paletteLayer:`main`};async function SJ(){let e=await O(T(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function CJ(e){let t=await qc(),n=F(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:qu(e,n),subtitle:e.id}))}function wJ({onClose:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=x(),{pathname:i}=m(),a=D(e=>e.language),o=Fu(),s=mJ(),c=Sd(e=>e.agentId),l=yc(e=>e.setPath),[u,d]=(0,Z.useReducer)(bJ,xJ),[f,p]=(0,Z.useState)(0),[h,g]=(0,Z.useState)(0),{query:_,selectedIndex:v,paletteLayer:y}=u,b=(0,Z.useMemo)(()=>sJ(a),[a]),[S]=md(_,120);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&p(e=>e+1),g(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let C=Nu(Wq,[h],{enabled:y===`main`&&!!S.trim(),initial:{catalog:[],instances:[]},errorData:{catalog:[],instances:[]}}),w=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),T=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),E=Nu(async()=>y===`models`?SJ():y===`agents`?CJ(a):[],[y,a],{enabled:y===`models`||y===`agents`,initial:[],errorData:[]}),O=Nu(async()=>{let t=S.trim(),n=e,u=F(a).commandPalette.groups,d=b.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=dJ(a,{closePalette:n,openModelPalette:w,openAgentPalette:T}),p=Fq(a,r,n),m=Jq({query:t,...C.data,labels:{group:u.connectors,...F(a).commandPalette.connectors},navigate:r,close:n}),h=yJ({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,_,v,y,x,E]=await Promise.all([Md(),Pd(),t?cJ(t,{types:[`project`],limit:8}).catch(()=>[]):[],zs({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await Tt(t,{conversationId:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})(),Lq(a,n)]),D=v.map(e=>({kind:`project`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.projects,keywords:[e.payload.project.slug,e.payload.project.workspaceRoot??``,e.payload.project.defaultAgentId??``,e.payload.project.brief??``],run:()=>{n(),r(e.href)}})),O=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{vJ(Ye(e),i,r,n)}})),k=_.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{vJ(`/skill:${e.name} `,i,r,n)}}]),A=(y.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),j=x.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),M=pJ(a,r,n,u.navigate),N=[...d,...f,...p,...E,...h,...M,...D,...m,...A,...j,...O,...k],P=[];for(let e of N){let n=Zq(e,t);n!==null&&P.push({...e,rank:n})}let I=Bq(a),L=Qq(P),R=[],z={};for(let e of L){let t=(z[e.groupLabel]??0)+1;if(!(t>(I[e.groupLabel]??6))&&(z[e.groupLabel]=t,R.push(e),R.length>=36))break}return R.sort((e,t)=>Vq(a,e.groupLabel)-Vq(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),R},[S,b,o,r,s,c,i,l,a,w,T,e,f,C.data],{enabled:y===`main`,initial:[],errorData:[]}),k=O.data,A=O.loading,j=O.error,M=(0,Z.useMemo)(()=>{let e=_.trim().toLowerCase(),t=E.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[E.data,_]),N=`${y}|${_}|${String(M.length)}|${String(k.length)}`,P=(0,Z.useRef)(N);if(P.current!==N){P.current=N;let e=y===`main`?Math.max(0,k.length-1):Math.max(0,M.length);v>e&&d({type:`setSelectedIndex`,value:e})}(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let I=(0,Z.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),y!==`main`){d({type:`resetMain`});return}e();return}let n=y===`main`?Math.max(0,k.length-1):Math.max(0,M.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),y===`models`){if(v===0){d({type:`resetMain`});return}let t=M[v-1];if(!t)return;(async()=>{await hJ(t.id),xc(),zc(),e(),d({type:`resetMain`})})();return}if(y===`agents`){if(v===0){d({type:`resetMain`});return}let t=M[v-1];if(!t)return;gJ(t.id,i,r,e),d({type:`resetMain`});return}let n=k[v];n&&n.run()}});(0,Z.useEffect)(()=>{let e=e=>{I(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Z.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(v)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[v,k,y,M.length]);let L=a===`zh`?`返回`:`Back`;if(y===`models`||y===`agents`){let o=M,s=E.loading;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:y===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,v===0?`bg-surface-hover`:`hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,L]})}),s?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):o.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):o.map((t,n)=>{let a=n+1;return(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,"data-global-palette-index":a,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,v===a?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:a}),onClick:()=>{y===`models`?(async()=>{await hJ(t.id),xc(),zc(),e(),d({type:`resetMain`})})():(gJ(t.id,i,r,e),d({type:`resetMain`}))},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let R=``;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 连接 / 设置 / 命令)`:`Search… (sessions, files, connectors, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":k[v]?`global-hit-${k[v].id}`:void 0,children:k.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:A?a===`zh`?`搜索中…`:`Searching…`:j?j instanceof Error?j.message:String(j):a===`zh`?`无结果`:`No results`}):k.map((e,t)=>{let n=e.groupLabel===R?``:e.groupLabel;return R=e.groupLabel,(0,$.jsxs)(`li`,{children:[n?(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,$.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===v?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,$.jsx)(`span`,{className:`mt-0.5`,children:_J(e)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function TJ(){let e=(0,Q.c)(7),[t,n]=(0,Z.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(DJ))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(EJ);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,Z.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(wJ,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function EJ(e){return!e}function DJ(e){return!e}function OJ(e){let t=(0,Q.c)(47),{noteId:n,backgroundPath:r,onClose:i}=e,a=D(AJ),o=E(kJ),s;t[0]!==n||t[1]!==o?(s=[`note-preview`,n,o],t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=()=>ra(n),t[3]=n,t[4]=c);let{data:l,error:u,isLoading:d}=gc(s,c),f=a===`zh`,p;t[5]!==l?.title||t[6]!==f?(p=l?.title?.trim()||(f?`笔记预览`:`Note preview`),t[5]=l?.title,t[6]=f,t[7]=p):p=t[7];let m=p,h=f?`关闭笔记预览`:`Close note preview`,g;t[8]===i?g=t[9]:(g=e=>{e||i()},t[8]=i,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(R,{className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`}),t[10]=_):_=t[10];let v;t[11]===m?v=t[12]:(v=(0,$.jsx)(te,{className:`min-w-0 flex-1 truncate font-medium text-fg`,title:m,children:m}),t[11]=m,t[12]=v);let y=f?`预览笔记内容,或打开独立页面。`:`Preview the note or open its full page.`,x;t[13]===y?x=t[14]:(x=(0,$.jsx)(B,{className:`sr-only`,children:y}),t[13]=y,t[14]=x);let S=`/notes/${encodeURIComponent(n)}`,C;t[15]!==r||t[16]!==S?(C=Oa(S,r),t[15]=r,t[16]=S,t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(hi,{className:`size-4`,"aria-hidden":!0}),t[18]=w):w=t[18];let T=f?`打开独立页面`:`Open full page`,O;t[19]===T?O=t[20]:(O=(0,$.jsx)(`span`,{children:T}),t[19]=T,t[20]=O);let k;t[21]!==C||t[22]!==O?(k=(0,$.jsxs)(b,{to:C,className:`flex shrink-0 items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm text-accent hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[w,O]}),t[21]=C,t[22]=O,t[23]=k):k=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0}),t[24]=A):A=t[24];let j;t[25]===h?j=t[26]:(j=(0,$.jsx)(V,{title:h,"aria-label":h,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:A}),t[25]=h,t[26]=j);let M;t[27]!==k||t[28]!==j||t[29]!==v||t[30]!==x?(M=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge bg-surface-panel px-5 py-3.5`,children:[v,x,k,j]}),t[27]=k,t[28]=j,t[29]=v,t[30]=x,t[31]=M):M=t[31];let N;t[32]!==u||t[33]!==d||t[34]!==l||t[35]!==n||t[36]!==f?(N=d?(0,$.jsxs)(`div`,{className:`space-y-4`,role:`status`,"aria-label":f?`正在加载笔记`:`Loading note`,children:[(0,$.jsx)(ps,{className:`h-7 w-2/3`}),(0,$.jsx)(ps,{className:`h-4 w-full`}),(0,$.jsx)(ps,{className:`h-4 w-full`}),(0,$.jsx)(ps,{className:`h-4 w-4/5`}),(0,$.jsx)(ps,{className:`mt-8 h-32 w-full`})]}):u?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:f?`笔记加载失败,请重新打开预览。`:`Unable to load the note. Please reopen the preview.`}):l?l.markdown.trim()?(0,$.jsx)(ta,{noteId:n,content:l.markdown,mermaidActions:!1},n):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无笔记内容。`:`This note has no content yet.`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`笔记不存在或已删除。`:`This note is unavailable or has been deleted.`}),t[32]=u,t[33]=d,t[34]=l,t[35]=n,t[36]=f,t[37]=N):N=t[37];let P;t[38]!==d||t[39]!==N?(P=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-8`,"aria-busy":d,children:N}),t[38]=d,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==M||t[42]!==P?(F=(0,$.jsxs)(H,{children:[_,(0,$.jsxs)(ee,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(48rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,children:[M,P]})]}),t[41]=M,t[42]=P,t[43]=F):F=t[43];let I;return t[44]!==F||t[45]!==g?(I=(0,$.jsx)(ne,{open:!0,onOpenChange:g,children:F}),t[44]=F,t[45]=g,t[46]=I):I=t[46],I}function kJ(e){return e.conversationId}function AJ(e){return e.language}function jJ(e){let t=(0,Q.c)(100),{onClose:n}=e,r=x(),i=D(NJ),a;t[0]===i?a=t[1]:(a=F(i),t[0]=i,t[1]=a);let o=a.notes,s;t[2]===i?s=t[3]:(s=F(i),t[2]=i,t[3]=s);let c=s.chat,l=Bd(MJ),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(null),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>{d(t=>ml(t,e)),window.setTimeout(()=>m.current?.focus(),0)},t[4]=h):h=t[4];let g;t[5]!==c||t[6]!==f?(g={disabled:f,chat:c,onTranscript:h},t[5]=c,t[6]=f,t[7]=g):g=t[7];let _=kl(g),{phase:v,voiceActive:y,startVoiceInput:b,cancelVoiceInput:S,confirmVoiceInput:C}=_,w,T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=window.setTimeout(()=>m.current?.focus(),50);return()=>window.clearTimeout(e)},T=[],t[8]=w,t[9]=T):(w=t[8],T=t[9]),(0,Z.useEffect)(w,T);let E,O;t[10]!==S||t[11]!==C||t[12]!==f||t[13]!==b||t[14]!==y||t[15]!==v?(E=()=>{let e=e=>{e.detail?.target===`note`&&(e.preventDefault(),!f&&(v===`recording`?C():(v===`idle`||v===`error`)&&b()))},t=e=>{e.detail?.target!==`note`||!y||(e.preventDefault(),S(),m.current?.focus())};return window.addEventListener(Wd,e),window.addEventListener(Vd,t),()=>{window.removeEventListener(Wd,e),window.removeEventListener(Vd,t)}},O=[S,C,f,b,y,v],t[10]=S,t[11]=C,t[12]=f,t[13]=b,t[14]=y,t[15]=v,t[16]=E,t[17]=O):(E=t[16],O=t[17]),(0,Z.useEffect)(E,O);let k;t[18]!==r||t[19]!==n||t[20]!==f||t[21]!==u?(k=async e=>{let t=u.trim();if(!(!t||f)){p(!0);try{let i=await ia(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{p(!1)}}},t[18]=r,t[19]=n,t[20]=f,t[21]=u,t[22]=k):k=t[22];let A=k,j;t[23]!==A||t[24]!==n?(j=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),A(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),A(!1))},t[23]=A,t[24]=n,t[25]=j):j=t[25];let M=j,N=o.quickCapturePlaceholder,P;t[26]===n?P=t[27]:(P=e=>{e.target===e.currentTarget&&n()},t[26]=n,t[27]=P);let I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Zo,{className:`size-4 text-accent`}),t[28]=I):I=t[28];let L;t[29]===o.quickCapturePlaceholder?L=t[30]:(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[I,(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[29]=o.quickCapturePlaceholder,t[30]=L);let R;t[31]!==c||t[32]!==M||t[33]!==o.quickCapturePlaceholder||t[34]!==f||t[35]!==u||t[36]!==_.audioLevel||t[37]!==_.cancelVoiceInput||t[38]!==_.confirmVoiceInput||t[39]!==_.elapsedLabel||t[40]!==_.error||t[41]!==_.finalTranscript||t[42]!==_.partialTranscript||t[43]!==_.phase||t[44]!==_.retryVoiceInput||t[45]!==_.settingsRequired||t[46]!==_.voiceActive?(R=_.voiceActive?(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(hl,{phase:_.phase,elapsedLabel:_.elapsedLabel,audioLevel:_.audioLevel,partialTranscript:_.partialTranscript,finalTranscript:_.finalTranscript,error:_.error,settingsRequired:_.settingsRequired,disabled:f,chat:c,onCancel:_.cancelVoiceInput,onConfirm:_.confirmVoiceInput,onRetry:_.retryVoiceInput})}):(0,$.jsx)(`textarea`,{ref:m,value:u,onChange:e=>d(e.target.value),onKeyDown:M,placeholder:o.quickCapturePlaceholder,disabled:f,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`}}),t[31]=c,t[32]=M,t[33]=o.quickCapturePlaceholder,t[34]=f,t[35]=u,t[36]=_.audioLevel,t[37]=_.cancelVoiceInput,t[38]=_.confirmVoiceInput,t[39]=_.elapsedLabel,t[40]=_.error,t[41]=_.finalTranscript,t[42]=_.partialTranscript,t[43]=_.phase,t[44]=_.retryVoiceInput,t[45]=_.settingsRequired,t[46]=_.voiceActive,t[47]=R):R=t[47];let z=f||_.voiceActive,B;t[48]===n?B=t[49]:(B=()=>{n(),wn()},t[48]=n,t[49]=B);let V;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Bt,{className:`size-3.5`,"aria-hidden":!0}),t[50]=V):V=t[50];let H;t[51]===o.discussionCapture.title?H=t[52]:(H=(0,$.jsx)(`span`,{children:o.discussionCapture.title}),t[51]=o.discussionCapture.title,t[52]=H);let ee;t[53]!==z||t[54]!==B||t[55]!==H?(ee=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:z,onClick:B,children:[V,H]}),t[53]=z,t[54]=B,t[55]=H,t[56]=ee):ee=t[56];let te=f||_.voiceActive,ne=c.voiceInput,U;t[57]===l?U=t[58]:(U=Ud(l).join(`+`),t[57]=l,t[58]=U);let re=`${ne} (${U})`,W=c.voiceInput,ie;t[59]===l?ie=t[60]:(ie=Ud(l).join(`+`),t[59]=l,t[60]=ie);let G=`${W} (${ie})`,K;t[61]===_?K=t[62]:(K=()=>void _.startVoiceInput(),t[61]=_,t[62]=K);let ae;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Ra,{className:`size-3.5`,"aria-hidden":!0}),t[63]=ae):ae=t[63];let q;t[64]===c.voiceInput?q=t[65]:(q=(0,$.jsx)(`span`,{children:c.voiceInput}),t[64]=c.voiceInput,t[65]=q);let oe;t[66]!==te||t[67]!==re||t[68]!==G||t[69]!==K||t[70]!==q?(oe=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:te,title:re,"aria-label":G,onClick:K,children:[ae,q]}),t[66]=te,t[67]=re,t[68]=G,t[69]=K,t[70]=q,t[71]=oe):oe=t[71];let se;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[72]=se):se=t[72];let ce;t[73]===o.quickCaptureHintEnter?ce=t[74]:(ce=(0,$.jsxs)(`span`,{children:[se,` `,o.quickCaptureHintEnter]}),t[73]=o.quickCaptureHintEnter,t[74]=ce);let le;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[75]=le):le=t[75];let ue;t[76]===o.quickCaptureHintShift?ue=t[77]:(ue=(0,$.jsxs)(`span`,{children:[le,` `,o.quickCaptureHintShift]}),t[76]=o.quickCaptureHintShift,t[77]=ue);let de;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[78]=de):de=t[78];let J;t[79]===o.quickCaptureHintEsc?J=t[80]:(J=(0,$.jsxs)(`span`,{children:[de,` `,o.quickCaptureHintEsc]}),t[79]=o.quickCaptureHintEsc,t[80]=J);let fe;t[81]!==ee||t[82]!==oe||t[83]!==ce||t[84]!==ue||t[85]!==J?(fe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-fg-muted`,children:[ee,oe,ce,ue,J]}),t[81]=ee,t[82]=oe,t[83]=ce,t[84]=ue,t[85]=J,t[86]=fe):fe=t[86];let pe;t[87]===f?pe=t[88]:(pe=f&&(0,$.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[87]=f,t[88]=pe);let me;t[89]!==fe||t[90]!==pe?(me=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[fe,pe]}),t[89]=fe,t[90]=pe,t[91]=me):me=t[91];let he;t[92]!==L||t[93]!==R||t[94]!==me?(he=(0,$.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[L,R,me]}),t[92]=L,t[93]=R,t[94]=me,t[95]=he):he=t[95];let ge;return t[96]!==o.quickCapturePlaceholder||t[97]!==P||t[98]!==he?(ge=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"data-voice-input-scope":`note`,"aria-label":N,onMouseDown:P,children:he}),t[96]=o.quickCapturePlaceholder,t[97]=P,t[98]=he,t[99]=ge):ge=t[99],ge}function MJ(e){return e.shortcut}function NJ(e){return e.language}function PJ(){let e=(0,Q.c)(11),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),a=E(LJ),o=Rd(IJ),s,c;e[0]!==r||e[1]!==o||e[2]!==a?(s=()=>{let e=e=>{r||Ld(e,o)&&(e.preventDefault(),a&&n(FJ))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},c=[r,o,a],e[0]=r,e[1]=o,e[2]=a,e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l,u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=e=>{i(!!e.detail?.active)};return window.addEventListener(`quick-capture-shortcut-recording`,e),window.addEventListener(Gd,e),()=>{window.removeEventListener(`quick-capture-shortcut-recording`,e),window.removeEventListener(Gd,e)}},u=[],e[5]=l,e[6]=u):(l=e[5],u=e[6]),(0,Z.useEffect)(l,u);let d,f;if(e[7]===a?(d=e[8],f=e[9]):(d=()=>{let e=()=>{a&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},f=[a],e[7]=a,e[8]=d,e[9]=f),(0,Z.useEffect)(d,f),!t)return null;let p;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(jJ,{onClose:()=>n(!1)}),e[10]=p):p=e[10],p}function FJ(e){return!e}function IJ(e){return e.shortcut}function LJ(e){return e.conversationId}var RJ=(0,Z.lazy)(()=>c(()=>import(`./capabilities-settings-panel-DfyND0IO.js`).then(e=>({default:e.CapabilitiesSettingsPanel})),__vite__mapDeps([172,1,2,4,3,5,6,7,8,9,173,11,174,10,66,34,20,21,22,25,26,27,28,12,175,118,176,35,128,42,36,49,45,177,41,75,76,62,19,23,44,82,80,24,178,90,84,93,179,180,181,182,183,38,37,15,184,185,48,61,111,137,186,78,187,188,189,31,190,92,191,192,136,193,194,195,144,130,141,30,79,145,146,147,112,113,148,96,196,162,197,91,198,199,97,101,102,200,201,46,89,202,203,204,94,95,39,98,99,100,47,205,206]))),zJ=`[role="dialog"]:not([aria-modal="false"])`;function BJ(){let e=(0,Z.useId)(),t=(0,Z.useRef)(null),n=(0,Z.useRef)(!1),r=(0,Z.useRef)(null),i=(0,Z.useRef)(new Map),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(),[p,m]=(0,Z.useState)(`settings`),[h,g]=(0,Z.useState)(!1);n.current=s;let _=D(e=>e.language)===`zh`;(0,Z.useEffect)(()=>{let e=e=>{let r=e.detail,i=ff(r?.use??null);if(i&&!h){if(!n.current){t.current=document.activeElement instanceof HTMLElement?document.activeElement:null;let e=t.current?.closest(zJ);e?.closest(`[data-capability-settings-sheet]`)||o(e?.parentElement?.closest(zJ)??e??null)}u(i),f(r?.purpose===`phone`||r?.purpose===`automation`?r.purpose:void 0),c(!0),m(r?.view===`services`?`services`:`settings`)}},r=()=>{h||(t.current=null,c(!1))};return window.addEventListener(`open-capability-settings`,e),window.addEventListener(`close-capability-settings`,r),()=>{window.removeEventListener(`open-capability-settings`,e),window.removeEventListener(`close-capability-settings`,r)}},[h]),(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=`${l}:${p}`;return e.scrollTop=i.current.get(t)??0,()=>{i.current.set(t,e.scrollTop)}},[p,l]);let v=e=>{h||m(e)};return(0,$.jsx)(ne,{open:s,onOpenChange:e=>{h||c(e)},children:(0,$.jsx)(H,{forceMount:!0,container:a??void 0,children:(0,$.jsx)(`div`,{className:`contents`,children:(0,$.jsxs)(Z.Activity,{mode:s?`visible`:`hidden`,children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[150] bg-scrim`}),(0,$.jsxs)(ee,{"data-capability-settings-sheet":!0,"aria-describedby":void 0,forceMount:!0,onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>t.current?.focus())},className:`xopc-dialog-content fixed inset-x-3 top-1/2 z-[151] mx-auto flex h-[min(48rem,calc(100dvh-2rem))] w-[calc(100%-1.5rem)] max-w-3xl -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onEscapeKeyDown:e=>{h&&e.preventDefault()},onInteractOutside:e=>{h&&e.preventDefault()},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:d===`phone`?_?`手机模型服务`:`Phone model services`:d===`automation`?_?`自动化模型`:`Automation models`:l?pf[l][+!_]:``})}),(0,$.jsx)(X,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":_?`关闭设置`:`Close settings`,disabled:h,onClick:()=>c(!1),children:(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge px-5 py-3`,children:(0,$.jsx)(nd,{role:`tablist`,"aria-label":_?`能力配置`:`Capability configuration`,className:`inline-flex gap-1 rounded-xl bg-surface-inset p-1`,indicatorClassName:`rounded-md bg-surface-panel shadow-sm`,children:[`settings`,`services`].map(t=>(0,$.jsx)(X,{id:`${e}-${t}`,role:`tab`,"aria-selected":p===t,"aria-controls":`${e}-panel`,tabIndex:p===t?0:-1,variant:`ghost`,className:p===t?`bg-surface-panel text-fg shadow-sm hover:bg-surface-panel`:``,disabled:h,onClick:()=>v(t),onKeyDown:n=>{if(h||![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(n.key))return;n.preventDefault();let r=n.key===`Home`?`settings`:n.key===`End`||t===`settings`?`services`:`settings`;v(r),document.getElementById(`${e}-${r}`)?.focus()},children:t===`settings`?_?`模型与参数`:`Model and parameters`:_?`管理服务`:`Manage services`},t))})}),(0,$.jsx)(`div`,{ref:r,id:`${e}-panel`,role:`tabpanel`,"aria-labelledby":`${e}-${p}`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:l?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(df,{}),children:(0,$.jsx)(RJ,{inlineUse:l,inlineView:p,onViewChange:m,onPendingChange:g},l)}):null}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-4 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:h?_?`正在保存…`:`Saving…`:p===`settings`?_?`自动保存`:`Saves automatically`:null}),(0,$.jsx)(X,{variant:`secondary`,disabled:h,onClick:()=>c(!1),children:d===`phone`?_?`返回手机设置`:`Back to phone settings`:d===`automation`?_?`返回自动化`:`Back to automation`:_?`完成`:`Done`})]})]})]})})})})}function VJ(e){let t=(0,Q.c)(25),{text:n,placeholder:r,zh:i}=e,a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(!0),[c,l]=(0,Z.useState)(n),u=o?n:c,d=!o&&n!==c,f;t[0]===o?f=t[1]:(f=()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},t[0]=o,t[1]=f);let p;t[2]!==u||t[3]!==o?(p=[u,o],t[2]=u,t[3]=o,t[4]=p):p=t[4],(0,Z.useLayoutEffect)(f,p);let m;t[5]===u?m=t[6]:(m=function(){l(u),s(!1)},t[5]=u,t[6]=m);let h=m,g=i?`实时文字`:`Live transcript`,_;t[7]!==o||t[8]!==h?(_=e=>{let t=e.currentTarget;o&&t.scrollHeight-t.scrollTop-t.clientHeight>24&&h()},t[7]=o,t[8]=h,t[9]=_):_=t[9];let v;t[10]===h?v=t[11]:(v=e=>{e.key!==`Tab`&&h()},t[10]=h,t[11]=v);let y=u||r,b;t[12]!==h||t[13]!==g||t[14]!==_||t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`div`,{ref:a,tabIndex:0,"aria-label":g,className:`h-32 overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,onScroll:_,onPointerDown:h,onKeyDown:v,children:y}),t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==o||t[19]!==d||t[20]!==i?(x=(0,$.jsx)(`div`,{className:`flex h-9 items-center justify-end text-xs text-fg-muted`,children:o?(0,$.jsx)(`span`,{children:i?`跟随最新文字`:`Following live text`}):(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-lg px-2 text-accent-fg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>s(!0),children:d?i?`有新文字 · 回到最新`:`New text · Back to latest`:i?`回到最新`:`Back to latest`})}),t[18]=o,t[19]=d,t[20]=i,t[21]=x):x=t[21];let S;return t[22]!==b||t[23]!==x?(S=(0,$.jsxs)(`div`,{className:`mt-2`,children:[b,x]}),t[22]=b,t[23]=x,t[24]=S):S=t[24],S}var HJ=()=>`xopc-recording-consent:${E.getState().baseUrl}`;function UJ(e){if(e.consentAcknowledgedAt==null){GJ();return}try{localStorage.setItem(HJ(),JSON.stringify(e))}catch{}}function WJ(){try{let e=JSON.parse(localStorage.getItem(HJ())??`null`);return e&&Number.isSafeInteger(e.consentPolicyVersion)&&e.consentPolicyVersion>0&&typeof e.consentAcknowledgedAt==`number`&&Number.isFinite(e.consentAcknowledgedAt)&&e.consentAcknowledgedAt>0?e:null}catch{return null}}function GJ(){try{localStorage.removeItem(HJ())}catch{}}var KJ=3e4;function qJ(e,t){let n=e?.retryAfterMs;return typeof n==`number`&&Number.isFinite(n)?Math.min(KJ,Math.max(0,n)):Math.min(KJ,1e3*2**Math.min(t,5))}function JJ(e){let t=e?.status;return typeof t!=`number`||t===408||t===429||t>=500}function YJ(e,t){return t.throwIfAborted(),new Promise((n,r)=>{let i=()=>{globalThis.clearTimeout(a),r(t.reason??new DOMException(`Aborted`,`AbortError`))},a=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}async function XJ(e,t,n){let r=0;for(;!n.aborted;){let i=await t.list(e.draftId);t.onPendingCount?.(i.length);let a=i[0];if(!a)return;try{let n=await t.upload(e.discussionId,a);await t.remove(e.draftId,a),t.onTranscript?.(n),r=0}catch(e){if(n.aborted)throw n.reason??e;if(!JJ(e))throw e;await YJ(qJ(e,r),n),r+=1}}}var ZJ=`[data-chat-composer-frame]`,QJ=12;function $J(e,t,n){return{x:Math.max(n.left,Math.min(e.x,n.right-t.width)),y:Math.max(n.top,Math.min(e.y,n.bottom-t.height))}}function eY(e,t){let n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.right>t.left&&n.left<t.right&&n.bottom>t.top&&n.top<t.bottom?n:null}function tY(e,t){let n=window.visualViewport,r=n?.offsetLeft??0,i=n?.offsetTop??0,a={left:r+QJ,top:i+QJ,right:r+(n?.width??window.innerWidth)-QJ,bottom:i+(n?.height??window.innerHeight)-QJ};for(let e of document.querySelectorAll(ZJ)){let t=eY(e,a);t&&(a.bottom=Math.max(a.top,Math.min(a.bottom,t.top-QJ)))}let o=e?.getBoundingClientRect(),s=Math.min(o?.width??0,a.right-a.left),c=Math.min(o?.height??0,a.bottom-a.top),l=a.bottom,u=t?document.querySelector(t):null,d=u&&eY(u,a);return d&&d.right>a.right-s&&d.bottom>a.bottom-c&&d.top-QJ-c>=a.top&&(l=d.top-QJ),{...a,dockBottom:l,width:s,height:c,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function nY(e,t,n,r){let i=(0,Q.c)(24),[a,o]=(0,Z.useState)(rY),s,c;i[0]!==e||i[1]!==r||i[2]!==t?(s=()=>{if(!t||!e.current)return;let n=e.current,i=r?`${ZJ}, ${r}`:ZJ,a=()=>{let e=tY(n,r);o(t=>Object.keys(e).every(n=>e[n]===t[n])?t:e)},s=0,c=()=>{s||=requestAnimationFrame(()=>{s=0,a()})},l=typeof ResizeObserver>`u`?null:new ResizeObserver(a),u=new MutationObserver(c),d=()=>{l?.disconnect(),u.disconnect(),l?.observe(n);for(let e of document.querySelectorAll(i))l?.observe(e),e.parentElement&&l?.observe(e.parentElement),r&&e.matches(r)&&u.observe(e,{attributes:!0,attributeFilter:[`style`]});a()},f=e=>e instanceof Element&&(e.matches(i)||!!e.querySelector(i)),p=new MutationObserver(e=>{e.some(e=>[...e.addedNodes,...e.removedNodes].some(f))&&d()});p.observe(document.body,{childList:!0,subtree:!0}),d();let m=window.visualViewport;return window.addEventListener(`resize`,a),window.addEventListener(`scroll`,c,!0),m?.addEventListener(`resize`,a),m?.addEventListener(`scroll`,c),()=>{cancelAnimationFrame(s),l?.disconnect(),p.disconnect(),u.disconnect(),window.removeEventListener(`resize`,a),window.removeEventListener(`scroll`,c,!0),m?.removeEventListener(`resize`,a),m?.removeEventListener(`scroll`,c)}},c=[e,t,r],i[0]=e,i[1]=r,i[2]=t,i[3]=s,i[4]=c):(s=i[3],c=i[4]),(0,Z.useLayoutEffect)(s,c);let l;i[5]===a?l=i[6]:(l=e=>$J(e,a,a),i[5]=a,i[6]=l);let u=l,d;i[7]!==u||i[8]!==n?(d=n&&u(n),i[7]=u,i[8]=n,i[9]=d):d=i[9];let f=d,p=Math.max(0,a.right-a.left),m=Math.max(0,a.bottom-a.top),h;i[10]!==f||i[11]!==a.dockBottom||i[12]!==a.right||i[13]!==a.viewportHeight||i[14]!==a.viewportWidth?(h=f?{left:f.x,top:f.y,right:`auto`,bottom:`auto`}:{right:a.viewportWidth-a.right,bottom:`max(${a.viewportHeight-a.dockBottom}px, env(safe-area-inset-bottom))`},i[10]=f,i[11]=a.dockBottom,i[12]=a.right,i[13]=a.viewportHeight,i[14]=a.viewportWidth,i[15]=h):h=i[15];let g;i[16]!==p||i[17]!==m||i[18]!==h?(g={maxWidth:p,maxHeight:m,...h},i[16]=p,i[17]=m,i[18]=h,i[19]=g):g=i[19];let _=g,v;return i[20]!==u||i[21]!==a||i[22]!==_?(v={area:a,clamp:u,style:_},i[20]=u,i[21]=a,i[22]=_,i[23]=v):v=i[23],v}function rY(){return tY(null)}var iY=`xopc:recording-window-position:v1`;function aY(){try{let e=JSON.parse(sessionStorage.getItem(iY)??`null`);return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e:null}catch{return null}}function oY(e){let t=(0,Q.c)(61),{compact:n,onCompactChange:r,title:i,subtitle:a,compactActions:o,children:s,language:c}=e,l=c===`zh`,u=(0,Z.useRef)(null),[d,f]=(0,Z.useState)(aY),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),_=nY(u,!0,d),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1),b;t[0]===_?b=t[1]:(b=function(e){let t=_.clamp(e);f(t);try{sessionStorage.setItem(iY,JSON.stringify(t))}catch{}},t[0]=_,t[1]=b);let x=b,S=l?`录音浮窗`:`Recording window`,C=n?`compact`:`expanded`,w=n?340:400,T=p?`grabbing`:void 0,E;t[2]!==_.style||t[3]!==w||t[4]!==T?(E={..._.style,width:w,cursor:T},t[2]=_.style,t[3]=w,t[4]=T,t[5]=E):E=t[5];let D=`flex shrink-0 items-center gap-1 ${n?`p-2`:`border-b border-edge-subtle px-3 py-2`}`,O=l?`移动录音窗`:`Move recording window`,k=l?`拖动移动,也可使用方向键或点击选择位置`:`Drag, use arrow keys, or click to choose a position`,A;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{if(e.button!==0||!e.isPrimary)return;let t=u.current?.getBoundingClientRect();t&&(v.current={id:e.pointerId,start:{x:e.clientX,y:e.clientY},origin:{x:t.left,y:t.top},moved:!1},e.currentTarget.setPointerCapture(e.pointerId))},t[6]=A):A=t[6];let j;t[7]===x?j=t[8]:(j=e=>{let t=v.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.start.x,r=e.clientY-t.start.y;!t.moved&&Math.hypot(n,r)<4||(t.moved=!0,g(!1),m(!0),x({x:t.origin.x+n,y:t.origin.y+r}))},t[7]=x,t[8]=j);let M,N,P,F;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{let t=v.current;!t||t.id!==e.pointerId||(y.current=t.moved,v.current=null,m(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},N=()=>{v.current=null,y.current=!0,m(!1)},P=()=>{v.current=null,m(!1)},F=()=>{if(y.current){y.current=!1;return}g(sY)},t[9]=M,t[10]=N,t[11]=P,t[12]=F):(M=t[9],N=t[10],P=t[11],F=t[12]);let I;t[13]!==_.area||t[14]!==x?(I=e=>{let t=e.shiftKey?48:16,n=u.current?.getBoundingClientRect();if(!n)return;let r={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];r&&(e.preventDefault(),x({x:n.left+r[0],y:n.top+r[1]})),e.key===`Escape`&&g(!1),e.key===`Home`&&(e.preventDefault(),x({x:_.area.right,y:_.area.bottom}))},t[13]=_.area,t[14]=x,t[15]=I):I=t[15];let L;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0}),t[16]=L):L=t[16];let R;t[17]!==h||t[18]!==j||t[19]!==I||t[20]!==O||t[21]!==k?(R=(0,$.jsx)(`button`,{type:`button`,"aria-label":O,title:k,"aria-expanded":h,className:`flex size-10 shrink-0 touch-none items-center justify-center rounded-lg text-fg-muted outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent active:cursor-grabbing`,onPointerDown:A,onPointerMove:j,onPointerUp:M,onPointerCancel:N,onLostPointerCapture:P,onClick:F,onKeyDown:I,children:L}),t[17]=h,t[18]=j,t[19]=I,t[20]=O,t[21]=k,t[22]=R):R=t[22];let z=`${n?`text-lg`:`text-sm`} font-medium tabular-nums`,B;t[23]!==z||t[24]!==i?(B=(0,$.jsx)(`div`,{className:z,children:i}),t[23]=z,t[24]=i,t[25]=B):B=t[25];let V;t[26]===a?V=t[27]:(V=a?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:a}):null,t[26]=a,t[27]=V);let H;t[28]!==B||t[29]!==V?(H=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[28]=B,t[29]=V,t[30]=H):H=t[30];let ee=n?o:null,te=n?l?`展开录音窗`:`Expand recording window`:l?`缩小录音窗`:`Minimize recording window`,ne=!n,U;t[31]!==n||t[32]!==r?(U=()=>{r(!n),g(!1)},t[31]=n,t[32]=r,t[33]=U):U=t[33];let re;t[34]===n?re=t[35]:(re=n?(0,$.jsx)(ja,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(za,{className:`size-4`,"aria-hidden":!0}),t[34]=n,t[35]=re);let W;t[36]!==te||t[37]!==ne||t[38]!==U||t[39]!==re?(W=(0,$.jsx)(`button`,{type:`button`,"aria-label":te,"aria-expanded":ne,className:`flex size-10 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:U,children:re}),t[36]=te,t[37]=ne,t[38]=U,t[39]=re,t[40]=W):W=t[40];let ie;t[41]!==R||t[42]!==H||t[43]!==ee||t[44]!==W||t[45]!==D?(ie=(0,$.jsxs)(`header`,{className:D,children:[R,H,ee,W]}),t[41]=R,t[42]=H,t[43]=ee,t[44]=W,t[45]=D,t[46]=ie):ie=t[46];let G;t[47]!==_.area||t[48]!==h||t[49]!==x||t[50]!==l?(G=h?(0,$.jsx)(`div`,{className:`grid shrink-0 grid-cols-2 gap-1 border-b border-edge-subtle p-2`,"aria-label":l?`选择浮窗位置`:`Choose window position`,children:[[!1,!1],[!0,!1],[!1,!0],[!0,!0]].map((e,t)=>{let[n,r]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 rounded-lg px-3 text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{x({x:n?_.area.right:_.area.left,y:r?_.area.bottom:_.area.top}),g(!1)},children:(l?[`左上角`,`右上角`,`左下角`,`右下角`]:[`Top left`,`Top right`,`Bottom left`,`Bottom right`])[t]},t)})}):null,t[47]=_.area,t[48]=h,t[49]=x,t[50]=l,t[51]=G):G=t[51];let K;t[52]===s?K=t[53]:(K=(0,$.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain`,children:s}),t[52]=s,t[53]=K);let ae;return t[54]!==S||t[55]!==ie||t[56]!==C||t[57]!==G||t[58]!==K||t[59]!==E?(ae=(0,$.jsxs)(`aside`,{ref:u,"aria-label":S,"data-recording-window":C,className:`fixed z-[125] flex flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay text-fg shadow-elevated`,style:E,children:[ie,G,K]}),t[54]=S,t[55]=ie,t[56]=C,t[57]=G,t[58]=K,t[59]=E,t[60]=ae):ae=t[60],ae}function sY(e){return!e}function cY(e,t){let n=t===`zh`,r=F(t).notes.discussionCapture.status;return e.save===`saveFailed`?e.savedThroughMs?`${n?`保存遇到问题,已保留至`:`Save interrupted; retained through`} ${lY(e.savedThroughMs)}`:r.saveFailed:e.localComplete?r.localComplete:e.savedThroughMs!==null&&e.savedThroughMs>0?r.savedThrough.replace(`{{time}}`,lY(e.savedThroughMs)):e.save===`savedUnknown`?n?`原音已暂存,保存时长确认中`:`Audio retained; checking saved duration`:n?`正在保存录音`:`Saving recording`}function lY(e){return`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`}function uY(e){let t=(0,Q.c)(66),{status:n,language:r,compact:i}=e,a=i!==void 0&&i,o;t[0]===r?o=t[1]:(o=F(r),t[0]=r,t[1]=o);let s=o.notes.discussionCapture.status,c=r===`zh`,l;t[2]!==r||t[3]!==n?(l=cY(n,r),t[2]=r,t[3]=n,t[4]=l):l=t[4];let u=l;if(a){let e=`px-3 pb-2 text-xs ${n.save===`saveFailed`?`text-danger`:`text-fg-muted`}`,r=n.sync===`offline`?c?`离线录音 · `:`Recording offline · `:``,i;return t[5]!==u||t[6]!==e||t[7]!==r?(i=(0,$.jsxs)(`p`,{className:e,children:[r,u]}),t[5]=u,t[6]=e,t[7]=r,t[8]=i):i=t[8],i}let d;t[9]!==s.localComplete||t[10]!==n.localComplete?(d=n.localComplete?(0,$.jsx)(`p`,{role:`status`,className:`font-medium leading-5 text-fg`,children:s.localComplete}):null,t[9]=s.localComplete,t[10]=n.localComplete,t[11]=d):d=t[11];let f;t[12]!==n.hasInterruptions||t[13]!==c?(f=n.hasInterruptions?(0,$.jsx)(`p`,{children:c?`包含中断与续录;中断期间没有录音。`:`Contains interruptions and resumed audio. Nothing was captured during the interruptions.`}):null,t[12]=n.hasInterruptions,t[13]=c,t[14]=f):f=t[14];let p=`flex cursor-pointer list-none items-center gap-2 py-1 outline-none focus-visible:rounded focus-visible:ring-2 focus-visible:ring-accent ${n.save===`saveFailed`?`text-danger`:``}`,m=n.localComplete?c?`查看保存与整理进度`:`View saving and summary progress`:u,h;t[15]===m?h=t[16]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 leading-5`,children:m}),t[15]=m,t[16]=h);let g=c?`详情`:`Details`,_;t[17]===g?_=t[18]:(_=(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:g}),t[17]=g,t[18]=_);let v;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(vr,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[19]=v):v=t[19];let y;t[20]!==_||t[21]!==p||t[22]!==h?(y=(0,$.jsxs)(`summary`,{className:p,children:[h,_,v]}),t[20]=_,t[21]=p,t[22]=h,t[23]=y):y=t[23];let b=c?`录音`:`Recording`,x;t[24]===b?x=t[25]:(x=(0,$.jsx)(`dt`,{children:b}),t[24]=b,t[25]=x);let S=s[n.capture],C;t[26]===S?C=t[27]:(C=(0,$.jsx)(`dd`,{children:S}),t[26]=S,t[27]=C);let w=c?`本机保存`:`On this device`,T;t[28]===w?T=t[29]:(T=(0,$.jsx)(`dt`,{children:w}),t[28]=w,t[29]=T);let E;t[30]===u?E=t[31]:(E=(0,$.jsx)(`dd`,{children:u}),t[30]=u,t[31]=E);let D=c?`云端备份`:`Cloud backup`,O;t[32]===D?O=t[33]:(O=(0,$.jsx)(`dt`,{children:D}),t[32]=D,t[33]=O);let k=n.sync===`pending`?c?`录音结束后自动备份`:`Backs up after recording`:s[n.sync],A;t[34]===k?A=t[35]:(A=(0,$.jsx)(`dd`,{children:k}),t[34]=k,t[35]=A);let j=c?`文字与笔记`:`Text and notes`,M;t[36]===j?M=t[37]:(M=(0,$.jsx)(`dt`,{children:j}),t[36]=j,t[37]=M);let N=n.ai===`waitingSource`?c?`录音保存后继续整理`:`Continues after the recording is saved`:s[n.ai],P;t[38]===N?P=t[39]:(P=(0,$.jsx)(`dd`,{children:N}),t[38]=N,t[39]=P);let I;t[40]!==x||t[41]!==C||t[42]!==T||t[43]!==E||t[44]!==O||t[45]!==A||t[46]!==M||t[47]!==P?(I=(0,$.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 rounded-lg bg-surface-inset p-3 leading-5`,children:[x,C,T,E,O,A,M,P]}),t[40]=x,t[41]=C,t[42]=T,t[43]=E,t[44]=O,t[45]=A,t[46]=M,t[47]=P,t[48]=I):I=t[48];let L;t[49]!==s.timingPending||t[50]!==n.timingUncertain?(L=n.timingUncertain?(0,$.jsx)(`p`,{className:`mt-2 leading-5`,children:s.timingPending}):null,t[49]=s.timingPending,t[50]=n.timingUncertain,t[51]=L):L=t[51];let R;t[52]!==s.leaveHint||t[53]!==n.localComplete||t[54]!==n.sync?(R=n.localComplete&&n.sync!==`available`?(0,$.jsx)(`p`,{className:`mt-2 leading-5`,children:s.leaveHint}):null,t[52]=s.leaveHint,t[53]=n.localComplete,t[54]=n.sync,t[55]=R):R=t[55];let z;t[56]!==y||t[57]!==I||t[58]!==L||t[59]!==R?(z=(0,$.jsxs)(`details`,{className:`group`,children:[y,I,L,R]}),t[56]=y,t[57]=I,t[58]=L,t[59]=R,t[60]=z):z=t[60];let B;return t[61]!==s.label||t[62]!==z||t[63]!==d||t[64]!==f?(B=(0,$.jsxs)(`section`,{"aria-label":s.label,className:`space-y-2 text-xs text-fg-muted`,children:[d,f,z]}),t[61]=s.label,t[62]=z,t[63]=d,t[64]=f,t[65]=B):B=t[65],B}async function dY(e){return navigator.locks?new Promise((t,n)=>{navigator.locks.request(`xopc-recording:${e}`,{ifAvailable:!0},async e=>{if(!e){n(Error(`This recording is open in another tab. Close it before recovery.`));return}await new Promise(e=>t(e))}).catch(n)}):()=>{}}function fY(e,t){let n=new Uint8Array(512),r=(e,t)=>n.set(new TextEncoder().encode(t),e);return r(0,e),r(100,`0000600\0`),r(108,`0000000\0`),r(116,`0000000\0`),r(124,t.toString(8).padStart(11,`0`)+`\0`),r(136,`00000000000\0`),n.fill(32,148,156),r(156,`0`),r(257,`ustar\0`),r(263,`00`),r(148,n.reduce((e,t)=>e+t,0).toString(8).padStart(6,`0`)+`\0 `),n}async function*pY(e){let t=[];for(let n=0;n<e.chunkCount;n++){let r=await Mn(e.id,n);if(!r){t.push({index:n,missing:!0});continue}let i=new Uint8Array(await r.blob.arrayBuffer()),a=await crypto.subtle.digest(`SHA-256`,i);t.push({index:n,bytes:i.length,sha256:[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}),yield fY(`chunks/${String(n).padStart(6,`0`)}.bin`,i.length),yield i,i.length%512&&(yield new Uint8Array(512-i.length%512))}let n,r=await kn(e.id).catch(e=>(n=String(e),[])),i=new TextEncoder().encode(JSON.stringify({version:1,draft:e,chunks:t,annotations:r,annotationReadError:n,reconstruction:`Concatenate chunk bytes in index order within each epoch only. Epochs are independent containers. Missing chunks must never be skipped when reconstructing media.`},null,2));yield fY(`manifest.json`,i.length),yield i,i.length%512&&(yield new Uint8Array(512-i.length%512)),yield new Uint8Array(1024)}function mY(e){return(e.epochs?.length??1)===1&&e.saveOutcome===`complete`&&e.mediaCoverage?.status===`verified`&&e.mediaCoverage.committedChunkCount===e.chunkCount&&e.mediaCoverage.verifiedThroughMs>0}async function*hY(e){for(let t=0;t<e.chunkCount;t++){let n=await Mn(e.id,t);if(!n)throw Error(`Original audio has missing chunks; export a recovery package instead.`);let r=n.blob.stream().getReader();try{for(;;){let e=await r.read();if(e.done)break;yield e.value}}finally{r.releaseLock()}}}async function gY(e){let t=window.showSaveFilePicker,n=await kn(e.id).catch(()=>null),r=mY(e)&&n!==null&&n.length===0,i=e.mimeType.includes(`mp4`)?`m4a`:e.mimeType.includes(`ogg`)?`ogg`:`webm`,a=`recording-${e.id}.${r?i:`tar`}`,o=()=>r?hY(e):pY(e);if(t){let e=await(await t.call(window,{suggestedName:a})).createWritable();try{for await(let t of o())await e.write(t);await e.close()}catch(t){throw await e.abort().catch(()=>void 0),t}return}let s=[],c=0;for await(let e of o()){if(c+=e.length,c>64*1024*1024)throw Error(`Use Chrome or Edge file saving to export recordings over 64 MB. Your original audio is retained.`);s.push(e)}let l=URL.createObjectURL(new Blob(s,{type:r?e.mimeType:`application/x-tar`})),u=document.createElement(`a`);u.href=l,u.download=a,u.click(),window.setTimeout(()=>URL.revokeObjectURL(l),6e4)}var _Y=class{now;accumulated=0;started=null;constructor(e=()=>performance.now()){this.now=e}get elapsedMs(){return this.accumulated+(this.started===null?0:Math.max(0,this.now()-this.started))}resume(){this.started===null&&(this.started=this.now())}pause(){this.accumulated=this.elapsedMs,this.started=null}reset(e=0){this.accumulated=e,this.started=null}},vY=4,yY=15,bY=.6,xY=.5,SY=.5,CY=.015;function wY(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function TY(e){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var EY=class{sampleRate;chunks=[];bufferedSamples=0;segmentStartSample=0;sequence=0;silenceSamples=0;hasSpeech=!1;constructor(e){this.sampleRate=e}add(e){if(e.length===0)return[];this.chunks.push(e),this.bufferedSamples+=e.length,Ol(e)>=CY?(this.hasSpeech=!0,this.silenceSamples=0):this.silenceSamples+=e.length;let t=this.sampleRate*yY;return this.bufferedSamples>=t?this.hasSpeech?[this.emit(`max`)]:(this.discardBuffered(),[]):this.hasSpeech&&this.bufferedSamples>=this.sampleRate*vY&&this.silenceSamples>=this.sampleRate*bY?[this.emit(`silence`)]:[]}finish(){return!this.hasSpeech||this.bufferedSamples<this.sampleRate*SY?(this.discardBuffered(),[]):[this.emit(`final`)]}cancel(){this.chunks=[],this.bufferedSamples=0}get lastSequence(){return this.sequence-1}emit(e){let t=wY(this.chunks),n=e===`max`?Math.min(t.length,this.sampleRate*yY):t.length,r=t.slice(0,n),i=e===`max`?Math.min(n,this.sampleRate*xY):0,a=t.slice(n-i),o=Math.round(this.segmentStartSample/this.sampleRate*1e3),s=Math.round((this.segmentStartSample+n)/this.sampleRate*1e3),c={sequence:this.sequence++,samples:r,startedAtMs:o,endedAtMs:s};return this.segmentStartSample+=n-i,this.chunks=a.length?[a]:[],this.bufferedSamples=a.length,this.hasSpeech=a.length>0&&Ol(a)>=CY,this.silenceSamples=this.hasSpeech?0:a.length,c}discardBuffered(){this.segmentStartSample+=this.bufferedSamples,this.chunks=[],this.bufferedSamples=0,this.silenceSamples=0,this.hasSpeech=!1}},DY=class e{capture;accumulator;emitState;onSegment;stopped=!1;constructor(e,t,n,r){this.capture=e,this.accumulator=t,this.emitState=n,this.onSegment=r}static async start(t,n,r){let i={pending:new Set},a,o=[],s=await Sl.start(t,{onSamples:e=>{if(e.length&&r?.(Ol(e)),!a){o.push(e);return}for(let t of a.accumulator.add(e))a.emit(t)}});a=new e(s,new EY(s.sampleRate),i,n);for(let e of o)for(let t of a.accumulator.add(e))a.emit(t);return a}pause(){this.capture.pause()}resume(){this.capture.resume()}async stop(){if(this.stopped)return this.accumulator.lastSequence;this.stopped=!0,await this.capture.stop();for(let e of this.accumulator.finish())this.emit(e);if(await Promise.all(this.emitState.pending),this.emitState.error)throw this.emitState.error;return this.accumulator.lastSequence}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.accumulator.cancel())}emit(e){let t=Tl(e.samples,this.capture.sampleRate),n=new Blob([Cl(t)],{type:`audio/wav`}),r=(async()=>{await this.onSegment({sequence:e.sequence,blob:n,startedAtMs:e.startedAtMs,endedAtMs:e.endedAtMs,sha256:await TY(n)})})().catch(e=>{this.emitState.error??=e});this.emitState.pending.add(r),r.then(()=>this.emitState.pending.delete(r))}},OY=xn,kY=100*1024*1024,AY=32*1024*1024;function jY(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/ogg;codecs=opus`,`audio/webm`].find(e=>MediaRecorder.isTypeSupported(e))}function MY(e){try{e?.cancel()}catch{}}function NY(){let e=(0,Z.useRef)(null),t=()=>{e.current?.(),e.current=null},n=(0,Z.useRef)([]),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=(0,Z.useRef)(Symbol(`meeting-capture`)),c=(0,Z.useRef)(0),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(`idle`),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!0),S=(0,Z.useRef)(null),C=(0,Z.useRef)(Promise.resolve()),w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useRef)(0),O=(0,Z.useRef)(new _Y),k=(0,Z.useRef)(Promise.resolve()),A=(0,Z.useRef)(0),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(!1),P=(0,Z.useRef)(!1),F=(0,Z.useRef)(0),[I,L]=(0,Z.useState)(null),R=(0,Z.useRef)(null),z=(0,Z.useRef)(null),B=(0,Z.useRef)(!1),V=(0,Z.useRef)(()=>Promise.resolve(null)),H=(0,Z.useCallback)(async()=>{try{h(await Nn())}catch{h([])}},[]);(0,Z.useEffect)(()=>{H()},[H]);let ee=(0,Z.useCallback)(()=>{R.current!=null&&window.clearInterval(R.current),R.current=null,z.current?.(),z.current=null,Dl(s.current),T.current?.getTracks().forEach(e=>e.stop()),T.current=null,S.current=null},[]);(0,Z.useEffect)(()=>()=>{c.current+=1,E.current||ee(),V.current().catch(()=>void 0)},[ee]);let te=(0,Z.useCallback)(e=>{j.current??=e instanceof Error?e:Error(`Local recording storage failed`),O.current.pause(),y(`Local recording storage failed. Only previously saved audio can be recovered.`),MY(w.current),V.current().catch(()=>void 0)},[]),ne=(0,Z.useCallback)(e=>{let t=E.current;if(!t||!P.current||j.current)return;if(e.size===0){let e=performance.now();k.current=k.current.then(()=>{let r=M.current?.packetClock();if(E.current?.id===t.id&&r?.verified)for(let t of n.current)t.at<=e&&(t.target??=r.durationMs)});return}if(A.current+e.size>AY){te(Error(`Local storage cannot keep up with recording`));return}let r=O.current.elapsedMs,i=performance.now();A.current+=e.size;let a=D.current;D.current+=Math.ceil(e.size/bn),k.current=k.current.then(async()=>{let s=M.current?.packetClock().durationMs??0;for(let c=0,l=a;c<e.size;c+=bn,l+=1){if(j.current)return;let a=E.current;if(!a||a.id!==t.id)return;let u=e.slice(c,c+bn),f=M.current?.snapshot().observedThroughMs??0,m=M.current?.append(new Uint8Array(await u.arrayBuffer()));m&&m.observedThroughMs>f&&(F.current=Math.max(F.current,i),performance.now()-i<15e3&&S.current?.state===`recording`&&d(e=>e===`waiting_for_audio`?`recording`:e));let h={...a,chunkCount:l+1,durationMs:c+8388608>=e.size?Math.max(a.durationMs,r):a.durationMs,updatedAt:Date.now(),...m?{mediaCoverage:{...m,committedChunkCount:l+1}}:{}};if(await Pn({draftId:t.id,index:l,blob:u,createdAt:Date.now()},h),E.current?.id!==t.id)return;E.current=h,p(h);let g=M.current?.packetClock();if(g?.verified&&c+8388608>=e.size){let e=n.current.filter(e=>e.at<=i);if(g.durationMs<=s)for(let t of e)t.target??=g.durationMs;else{let r=e.filter(e=>e.target===void 0||e.target<g.durationMs),i=new Set(r.map(e=>e.id));n.current=n.current.filter(e=>!i.has(e.id));for(let e of r){let n=e.target??Math.max(0,g.durationMs-1);e.saved.then(()=>Wn(t.id,e.id,n)).catch(e=>o(e instanceof Error?e.message:`Could not locate the saved highlight`))}}}}}).catch(e=>{te(e)}).finally(()=>{A.current-=e.size})},[te]),U=(0,Z.useCallback)(async()=>{let e=S.current;if(!E.current)return null;if(!e&&E.current.state!==`recording`)return E.current;++c.current,d(`stopping`),O.current.pause(),_(O.current.elapsedMs);let n=w.current;w.current=null,MY(n);let r;try{e&&await new Promise((t,n)=>{let r=window.setTimeout(()=>{n(Error(`Recording stopped responding. Previously saved audio is available for recovery.`))},5e3);C.current.then(()=>{window.clearTimeout(r),t()});try{e.state!==`inactive`&&e.stop()}catch(e){window.clearTimeout(r),n(e)}})}catch(e){r=e instanceof Error?e:Error(`Recording could not finish`)}finally{P.current=!1,ee(),L(null)}await k.current;let i=E.current;if(!i)return null;let a={...i,state:`stopped`,lastSequence:-1,durationMs:i.durationMs,updatedAt:Date.now(),endedAt:Date.now(),saveOutcome:j.current||r||!i.chunkCount?`incomplete`:N.current?`interrupted`:`complete`};try{if(await Fn(a),E.current=a,p(a),_(a.durationMs),j.current)throw j.current;if(r)throw r;if(!i.chunkCount)throw Error(`No audio was saved`);return d(`stopped`),a}catch(e){throw d(`error`),y(j.current?`Local storage failed. Recover the previously saved portion after freeing space.`:e instanceof Error?e.message:`Recording could not finish`),e}finally{t(),await H()}},[H,ee]),re=(0,Z.useCallback)(()=>{if(l.current)return l.current;let e=Promise.resolve().then(U).finally(()=>{l.current=null});return l.current=e,e},[U]);V.current=re;let W=(0,Z.useCallback)(async r=>{if(B.current||S.current||l.current)return null;if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`)return y(`Audio recording is not supported in this environment.`),d(`error`),null;if(!El(s.current))return y(`The microphone is being used by a voice call. End the call before recording.`),null;B.current=!0;let a=++c.current;y(null),d(`requesting_permission`);try{await k.current,j.current=null,N.current=!1,P.current=!1,L(null),A.current=0,n.current=[],i(null),o(null),r.continuation&&(e.current=await dY(r.continuation.id));let u=r.continuation?await zn(r.continuation.id):null;if(u?.sealRequested)throw Error(`Recording has already been submitted. Recover and sync it first.`);if(u&&u.gatewayUrl!==r.gatewayUrl)throw Error(`Return to the original Gateway before continuing this recording.`);let f=await navigator.storage?.estimate?.();if(f?.quota!=null&&f.usage!=null&&f.quota-f.usage<kY)throw Error(`Not enough local storage for a discussion recording.`);let m=await navigator.mediaDevices.getUserMedia({audio:!0});if(a!==c.current)return m.getTracks().forEach(e=>e.stop()),Dl(s.current),t(),null;T.current=m;let h=jY(),g=h?new MediaRecorder(m,{mimeType:h,audioBitsPerSecond:64e3}):new MediaRecorder(m,{audioBitsPerSecond:64e3}),v=Date.now(),b=g.mimeType||h||`audio/webm`,I=u?[...u.epochs??[{firstChunk:0,mimeType:u.mimeType,startedAt:u.startedAt}]]:[{firstChunk:0,mimeType:b,startedAt:v}];u&&(I[I.length-1]={...I[I.length-1],savedThroughMs:u.mediaCoverage?.committedChunkCount===u.chunkCount?u.mediaCoverage.verifiedThroughMs:void 0},I.push({firstChunk:u.chunkCount,mimeType:b,startedAt:v,previousEndedAt:u.endedAt??u.updatedAt}));let B={id:u?.id??crypto.randomUUID(),...u,gatewayUrl:r.gatewayUrl,epochs:I,mediaCoverage:void 0,endedAt:void 0,saveOutcome:void 0,consentPolicyVersion:r.consentPolicyVersion??u?.consentPolicyVersion,...r.projectId?{projectId:r.projectId}:{},mimeType:b,startedAt:u?.startedAt??v,updatedAt:v,durationMs:u?.durationMs??0,chunkCount:u?.chunkCount??0,lastSequence:-1,state:`recording`};if(e.current||=await dY(B.id),await Fn(B),navigator.storage?.persist?.().catch(()=>!1),a!==c.current)return ee(),t(),null;S.current=g,E.current=B,D.current=B.chunkCount,M.current=new Kn(B.mimeType),P.current=!0,F.current=performance.now(),O.current.reset(B.durationMs),O.current.resume(),k.current=Promise.resolve(),g.ondataavailable=e=>{E.current?.id===B.id&&S.current===g&&ne(e.data)};let V=()=>{E.current?.id!==B.id||S.current!==g||!P.current||(N.current=!0,O.current.pause(),d(`stopping`),y(`The microphone stopped unexpectedly. Recover the saved audio.`),re().catch(()=>void 0))};g.onerror=V,C.current=new Promise(e=>{g.onstop=()=>{e(),l.current||V()}});let H=m.getAudioTracks(),te=()=>{H.some(e=>e.muted||e.readyState===`ended`)&&V()};H.forEach(e=>{e.addEventListener(`ended`,V),e.addEventListener(`mute`,V)}),document.addEventListener(`freeze`,V),document.addEventListener(`visibilitychange`,te),window.addEventListener(`pageshow`,te),z.current=()=>{H.forEach(e=>{e.removeEventListener(`ended`,V),e.removeEventListener(`mute`,V)}),document.removeEventListener(`freeze`,V),document.removeEventListener(`visibilitychange`,te),window.removeEventListener(`pageshow`,te)},g.start(5e3);let U=-1/0;return DY.start(m,e=>{if(!u)return r.onLiveSegment(B.id,e)},e=>{a!==c.current||g.state!==`recording`||(F.current=performance.now(),d(e=>e===`waiting_for_audio`?`recording`:e),performance.now()-U>=200&&(U=performance.now(),L(e)))}).then(e=>{if(a!==c.current||g.state===`inactive`){MY(e);return}w.current=e,x(!u)}).catch(()=>x(!1)),p(B),_(B.durationMs),d(`waiting_for_audio`),te(),R.current=window.setInterval(()=>{if(g.state===`inactive`&&!l.current){V();return}g.state===`recording`&&performance.now()-F.current>=15e3&&(d(e=>e===`recording`?`waiting_for_audio`:e),L(null));let e=O.current.elapsedMs;_(e),e>=OY&&re().catch(()=>void 0)},1e3),B}catch(e){return MY(w.current),P.current=!1,w.current=null,ee(),t(),y(e instanceof Error?e.message:`Microphone permission was denied.`),d(`error`),null}finally{B.current=!1}},[ne,re,ee]),ie=(0,Z.useCallback)(async()=>{let e=E.current,t=S.current;if(!e||!t||t.state!==`recording`)return;let r=Vn({type:`time`,capturedAt:Date.now(),epoch:(e.epochs?.length??1)-1,coordinate:`pcm`});o(null);let a=jn(e.id,r);n.current.push({id:r.id,at:performance.now(),saved:a});try{t.requestData()}catch{}try{await a,i(`saved`)}catch(e){n.current=n.current.filter(e=>e.id!==r.id),o(e instanceof Error?e.message:`Highlight could not be saved`)}},[]),G=(0,Z.useCallback)(()=>{S.current?.state===`recording`&&(O.current.pause(),_(O.current.elapsedMs),S.current.pause(),w.current?.pause(),d(`paused`),L(null))},[]),K=(0,Z.useCallback)(()=>{S.current?.state===`paused`&&(O.current.resume(),S.current.resume(),w.current?.resume(),d(`waiting_for_audio`))},[]),ae=(0,Z.useCallback)(async e=>{k.current=k.current.then(async()=>{let t=E.current;if(!t)return;let n={...t,serverDiscussionId:e,updatedAt:Date.now()};await Fn(n),E.current=n,p(n)}).catch(te),await k.current},[te]);return{phase:u,draft:f,recoverableDrafts:m,elapsedMs:g,error:v,liveTranscriptionAvailable:b,inputLevel:I,mark:ie,markerMessage:r,markerError:a,start:W,pause:G,resume:K,stop:re,restore:(0,Z.useCallback)(async e=>{if(S.current||B.current||l.current)throw Error(`Stop the active recording before recovery.`);await k.current,j.current=null;let t=await zn(e.id),n={...t,endedAt:t.endedAt??t.updatedAt,state:`stopped`,updatedAt:Date.now()};return await Fn(n),E.current=n,O.current.reset(n.durationMs),p(n),_(n.durationMs),y(null),d(`stopped`),n},[]),discard:(0,Z.useCallback)(async e=>{if(S.current||B.current||l.current)throw Error(`Stop the active recording before discarding.`);await k.current,await Rn(e),E.current?.id===e&&(E.current=null,p(null),_(0),d(`idle`)),await H()},[H]),markUploadFailed:(0,Z.useCallback)(async e=>{let t=e??E.current?.id;if(!t)return;let n=(await Nn()).find(e=>e.id===t);if(!n||n.state===`recording`)return;let r={...n,state:`upload_failed`,updatedAt:Date.now()};await Fn(r),E.current?.id===t&&(E.current=r,p(r)),await H()},[H]),reset:(0,Z.useCallback)(()=>{E.current=null,O.current.reset(),p(null),_(0),y(null),d(`idle`)},[]),setServerDiscussionId:ae,refreshRecoverableDrafts:H}}function PY(e){return e instanceof Error&&/Recording consent (must be acknowledged first|policy changed)/.test(e.message)}function FY(e){let t=Math.max(0,Math.floor(e/1e3));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function IY(){let e=x(),{pathname:t}=m(),n=E(e=>e.conversationId),r=E(e=>e.baseUrl),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=D(e=>e.language),d=F(u).notes.discussionCapture,f=NY(),p=(0,Z.useRef)(!1),h=(0,Z.useRef)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(),[N,P]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(!1),[H,ee]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(0),[U,re]=(0,Z.useState)(0),[W,ie]=(0,Z.useState)(null),[G,K]=(0,Z.useState)(null),[ae,q]=(0,Z.useState)(`pending`),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(()=>navigator.onLine);(0,Z.useEffect)(()=>{let e=()=>de(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let J=Yn({phase:f.phase,draft:oe?null:f.draft,locallyFinalized:oe?null:ce,online:ue,syncStage:ae,detail:N,transcript:I,pendingText:U,liveAvailable:f.liveTranscriptionAvailable}),fe=[`recording`,`waiting_for_audio`,`requesting_permission`,`paused`,`stopping`].includes(f.phase),pe=(0,Z.useRef)(!1),me=(0,Z.useRef)(null),he=(0,Z.useRef)(!1),ge=(0,Z.useRef)(!1),_e=(0,Z.useRef)(null),ve=(0,Z.useRef)(null),ye=(0,Z.useRef)(null),be=(0,Z.useRef)(null),xe=(0,Z.useRef)(()=>{}),Se=(0,Z.useCallback)(()=>{let e=be.current;if(e)return e;let t=ve.current;if(!t)return Promise.resolve();let n=new AbortController;ye.current=n;let r=XJ(t,{list:Hn,upload:(e,t)=>Ln(e,t.sequence,t),remove:(e,t)=>Gn(e,t.sequence),onTranscript:L,onPendingCount:re},n.signal).finally(()=>{be.current===r&&(be.current=null,ye.current===n&&(ye.current=null))});return be.current=r,r.then(()=>{window.setTimeout(()=>xe.current(),0)}).catch(e=>{n.signal.aborted||ie(e instanceof Error?e.message:d.saveFailed)}),r},[]);xe.current=()=>{let e=ve.current;!e||be.current||Hn(e.draftId).then(e=>{re(e.length),e.length>0&&Se()})};let Ce=(0,Z.useCallback)((e,t)=>{let n=ve.current;return n&&(n.draftId!==e||n.discussionId!==t)&&(ye.current?.abort(),be.current=null),ve.current={draftId:e,discussionId:t},Se()},[Se]),we=(0,Z.useCallback)(async(e,t)=>{await On({draftId:e,...t,createdAt:Date.now()}),re(e=>e+1),Se()},[Se]),Te=(0,Z.useCallback)(async(e,t)=>{p.current=!1,ie(null),y(!1),w(null),M(void 0),S(!0),K(null),L(null),P(null),ne(0),se(!1),a(!1),le(null),q(`pending`);let n=await f.start({...e?{projectId:e}:{},consentPolicyVersion:t,gatewayUrl:r,onLiveSegment:we});if(!n)return;ge.current=!0;let i=Dn({clientRequestId:n.id,...e?{contextProjectId:e}:{},consentPolicyVersion:t,source:tu()?`electron`:`web`,recordedAt:n.startedAt});_e.current=i;try{let e=await i;P(e),await f.setServerDiscussionId(e.discussion.id),Ce(n.id,e.discussion.id)}catch(e){q(`failed`),PY(e)&&GJ(),ie(PY(e)?u===`zh`?`录音授权需要重新确认。结束录音后可确认并同步,本机录音会保留。`:`Recording consent needs confirmation. Stop recording to confirm and sync; local audio is retained.`:e instanceof Error?e.message:d.saveFailed)}},[Ce,d.saveFailed,f,we,r,u]);(0,Z.useEffect)(()=>()=>ye.current?.abort(),[]);let Ee=(0,Z.useCallback)(async e=>{if(!(!n||h.current||R)){if([`recording`,`waiting_for_audio`,`requesting_permission`,`paused`,`stopping`].includes(f.phase)){S(!0),y(!1);return}h.current=!0,_(!0),S(!0),K(null);try{let t=WJ()??await qn();if(UJ(t),t.consentAcknowledgedAt==null){M(e),w(t.consentPolicyVersion);return}await Te(e,t.consentPolicyVersion)}catch(e){K(e instanceof Error?e.message:d.saveFailed)}finally{h.current=!1,_(!1)}}},[Te,d.saveFailed,R,f.phase,n]);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.projectId;Ee(t)};return window.addEventListener(Cn,e),()=>window.removeEventListener(Cn,e)},[Ee]),(0,Z.useEffect)(()=>{let e=f.draft,t=N?.discussion.id;if(!e||!t||!e.chunkCount||R||me.current||![`recording`,`waiting_for_audio`,`paused`].includes(f.phase))return;let n=Bn(e,t,ne,!1,q).catch(e=>{q(`failed`),ie(e instanceof Error?e.message:d.saveFailed)}).finally(()=>{me.current=null});me.current=n},[f.draft,f.phase,N?.discussion.id,R,d.saveFailed]);let De=(0,Z.useCallback)(async()=>{let e=N?.discussion.id;if(!e)return;let[t,n]=await Promise.all([_n(e),yn(e)]);P(t),L(n)},[N?.discussion.id]);(0,Z.useEffect)(()=>{let e=()=>void De().catch(()=>void 0);return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,e),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,e)}},[De]),(0,Z.useEffect)(()=>{if(!N||![`stopping`,`sealing`,`organizing`].includes(N.discussion.status)&&![`queued`,`running`].includes(N.recordingJob?.state??``))return;let e=window.setInterval(()=>void De().catch(()=>void 0),3e3);return()=>window.clearInterval(e)},[N,De]);let Oe=async()=>{if(!(C==null||h.current)){h.current=!0,_(!0);try{if(UJ(await Jn(C)),w(null),k){let e={...k,consentPolicyVersion:C};A(null),await Me(e)}else await Te(j,C)}catch(e){K(e instanceof Error?e.message:d.saveFailed)}finally{h.current=!1,_(!1)}}},ke=async()=>{if(he.current)return;he.current=!0,ge.current=!1,z(!0),K(null);let e;try{let t=await f.stop();if(!t)throw Error(d.emptyRecording);se(!1),le(t),e=await dY(t.id);let n=await _e.current?.catch(()=>null);if(!n){let e=await qn();if(UJ(e),e.consentAcknowledgedAt==null||t.consentPolicyVersion!==e.consentPolicyVersion){A(t),w(e.consentPolicyVersion);return}n=await Dn({clientRequestId:t.id,...t.projectId?{contextProjectId:t.projectId}:{},consentPolicyVersion:e.consentPolicyVersion,source:tu()?`electron`:`web`,recordedAt:t.startedAt})}_e.current=Promise.resolve(n),P(n),await f.setServerDiscussionId(n.discussion.id),V(!0),await me.current;let r=await Bn(t,n.discussion.id,ne,!0,q);if(ye.current?.abort(),!r?.discussion.audioAttachmentId||r.discussion.audioDeletedAt)throw Error(`Original audio attachment is not confirmed`);P(r);try{await Un(t.id,n.discussion.id),a(!1),await f.discard(t.id),se(!0)}catch{a(!0)}ve.current=null,re(0)}catch(e){q(`failed`),await f.markUploadFailed().catch(()=>void 0),K(e instanceof Error?e.message:d.saveFailed),S(!0)}finally{e?.(),he.current=!1,z(!1),V(!1)}};(0,Z.useEffect)(()=>{f.phase===`stopped`&&f.draft?.saveOutcome===`complete`&&ge.current&&ke()}),(0,Z.useEffect)(()=>{(p.current||t===`/notes/${encodeURIComponent(N?.note.id??``)}`)&&!i&&N?.discussion.audioAttachmentId&&!N.discussion.audioDeletedAt&&![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase)&&S(!1)},[N,f.phase,i,t]);let Ae=()=>{N&&(p.current=![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase),y(!0),p.current&&N.discussion.audioAttachmentId&&!N.discussion.audioDeletedAt&&!i&&S(!1),e(`/notes/${encodeURIComponent(N.note.id)}`))},je=async()=>{if(N)try{P(await Tn(N.discussion.id))}catch(e){K(e instanceof Error?e.message:d.saveFailed)}},Me=async e=>{let t=e??f.recoverableDrafts[0];if(!t||H||pe.current||he.current||fe)return;pe.current=!0,ge.current=!1,ee(!0),S(!0),K(null),ie(null),ne(0);let n;try{if(n=await dY(t.id),t.gatewayUrl!==r)throw Error(u===`zh`?`请切回录制时的 Gateway 后恢复`:`Return to the original Gateway to recover`);let e=t.consentPolicyVersion;t={...await f.restore(t),consentPolicyVersion:e},se(!1),le(t);let i=await qn();if(UJ(i),i.consentAcknowledgedAt==null||t.consentPolicyVersion!==i.consentPolicyVersion){A(t),w(i.consentPolicyVersion);return}let o=t.serverDiscussionId?await _n(t.serverDiscussionId):null;o||=await Dn({clientRequestId:t.id,...t.projectId?{contextProjectId:t.projectId}:{},consentPolicyVersion:i.consentPolicyVersion,source:tu()?`electron`:`web`,recordedAt:t.startedAt}),_e.current=Promise.resolve(o),P(o),await f.setServerDiscussionId(o.discussion.id);let s=!1;try{await Un(t.id,o.discussion.id),s=!0,a(!1)}catch{a(!0)}if(o.discussion.audioDeletedAt)throw Error(`Original recording was deleted`);if(o.discussion.audioAttachmentId&&[`sealing`,`organizing`,`completed`].includes(o.discussion.status)){s&&(await f.discard(t.id),se(!0));return}if(o.discussion.status===`cancelled`)throw Error(`This recording was cancelled`);o.discussion.audioAttachmentId||await Bn(t,o.discussion.id,ne,!0,q),ye.current?.abort();let c=await _n(o.discussion.id);if(!c.discussion.audioAttachmentId||c.discussion.audioDeletedAt)throw Error(`Original audio attachment is not confirmed`);c.discussion.status===`needs_attention`?P(await vn(o.discussion.id)):P(c),s&&(await f.discard(t.id),se(!0))}catch(e){await f.markUploadFailed(t.id).catch(()=>void 0),q(`failed`),K(e instanceof Error?e.message:d.saveFailed)}finally{n?.(),pe.current=!1,ee(!1)}},Ne=async e=>{if(!(pe.current||he.current||[`recording`,`waiting_for_audio`,`paused`,`requesting_permission`,`stopping`].includes(f.phase))){pe.current=!0,ee(!0),K(null);try{if(e.gatewayUrl!==r)throw Error(`Return to the original Gateway before continuing.`);if(e.sealRequested)throw Error(`Recover and sync this submitted recording first.`);let t=e.serverDiscussionId?await _n(e.serverDiscussionId):null;if(t&&(t.discussion.audioAttachmentId||t.recordingJob||![`recording`,`needs_attention`].includes(t.discussion.status)))throw Error(`Recover and sync this submitted recording first.`);if(!await f.start({continuation:e,gatewayUrl:r,onLiveSegment:we}))return;_e.current=t?Promise.resolve(t):null,P(t),L(null),se(!1),a(!1),le(null),q(`pending`),l(!1),S(!0),ge.current=!0}catch(e){K(e instanceof Error?e.message:d.saveFailed)}finally{pe.current=!1,ee(!1)}}},Pe=async e=>{if(he.current||H||fe)return;let t=e??f.recoverableDrafts[0];if(!t)return;let n;try{n=await dY(t.id),await f.discard(t.id)}catch(e){K(e instanceof Error?e.message:d.saveFailed)}finally{n?.()}},Fe=async e=>{if(pe.current||he.current||fe)return;pe.current=!0,ee(!0),K(null);let t;try{t=await dY(e.id);let n=(await Nn()).find(t=>t.id===e.id);if(!n)throw Error(`Recording is no longer available on this device.`);await gY(n)}catch(e){e instanceof DOMException&&e.name===`AbortError`||K(e instanceof Error?e.message:d.saveFailed)}finally{t?.(),pe.current=!1,ee(!1)}};if((0,Z.useEffect)(()=>{let e=()=>{f.refreshRecoverableDrafts(),l(!0)};return window.addEventListener(`open-recording-recoveries`,e),()=>window.removeEventListener(`open-recording-recoveries`,e)},[f.refreshRecoverableDrafts]),c)return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[135] flex items-center justify-center bg-black/45 p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":d.recoveredTitle,children:(0,$.jsxs)(`section`,{className:`flex h-[min(40rem,85vh)] w-[min(40rem,95vw)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(`h2`,{children:d.recoveredTitle}),(0,$.jsx)(X,{onClick:()=>l(!1),children:d.close})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[G?(0,$.jsx)(`p`,{role:`alert`,className:`mb-3 text-danger`,children:G}):null,f.recoverableDrafts.length?null:(0,$.jsx)(`p`,{children:u===`zh`?`没有待恢复录音`:`No recordings to recover`}),f.recoverableDrafts.map(e=>(0,$.jsxs)(`article`,{className:`mb-3 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{children:[new Date(e.startedAt).toLocaleString(),` · `,e.id.slice(0,8)]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.gatewayUrl,` · `,e.state===`upload_failed`?d.status.failed:e.sealRequested?d.status.verifying:d.status.pending]}),(0,$.jsxs)(`p`,{className:`text-sm`,children:[u===`zh`?`本机已保存`:`Saved locally`,` · `,An(e)===null?u===`zh`?`时长待核实`:`duration unverified`:FY(An(e)),` · `,FY(e.durationMs),` `,u===`zh`?`录制时长(中断处可能缺失)`:`capture duration (may contain interruptions)`]}),e.epochs?.slice(1).map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u===`zh`?`中断后续录`:`Resumed after interruption`,` · `,new Date(e.previousEndedAt??e.startedAt).toLocaleString(),` → `,new Date(e.startedAt).toLocaleString()]},e.firstChunk)),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{disabled:H||R||fe,onClick:()=>void Me(e).then(()=>l(!1)),children:d.recover}),(0,$.jsx)(X,{disabled:H||R||fe||e.sealRequested,onClick:()=>void Ne(e),children:u===`zh`?`继续录制`:`Continue recording`}),(0,$.jsx)(X,{disabled:H||R||fe,onClick:()=>void Fe(e),children:u===`zh`?`导出原音包`:`Export originals`}),(0,$.jsx)(X,{disabled:H||R||fe,onClick:()=>void Pe(e),children:u===`zh`?`丢弃本机副本`:`Discard local copy`})]})]},e.id))]})]})});if(!b)return B||ce||!f.recoverableDrafts[0]?null:(0,$.jsxs)(`aside`,{className:`fixed bottom-5 right-5 z-[125] w-[min(24rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-4 shadow-elevated`,children:[(0,$.jsxs)(`button`,{className:`text-sm font-medium text-fg`,onClick:()=>l(!0),children:[d.recoveredTitle,` (`,f.recoverableDrafts.length,`)`]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.recoveredDescription}),(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(X,{variant:`ghost`,disabled:H||R||fe,onClick:()=>void Pe(),children:d.discard}),(0,$.jsx)(X,{variant:`primary`,disabled:H||R||fe,onClick:()=>void Me(),children:H?d.recovering:d.recover})]})]});if(C!=null)return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[130] flex items-center justify-center bg-black/45 p-4`,role:`dialog`,"aria-modal":`true`,children:(0,$.jsxs)(`div`,{className:`w-[min(28rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-5 shadow-elevated`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:d.consentTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:d.consent})]}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,onClick:()=>{w(null),A(null),S(!1)},children:(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})]}),G?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:G}):null,(0,$.jsxs)(X,{variant:`primary`,className:`mt-5 w-full`,disabled:g,onClick:()=>void Oe(),children:[(0,$.jsx)(Ra,{className:`size-4`,"aria-hidden":!0}),k?u===`zh`?`确认并同步已有录音`:`Confirm and sync recording`:d.consentAction]})]})});if(g&&![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase))return(0,$.jsx)(oY,{compact:v,onCompactChange:y,language:u,title:u===`zh`?`准备录音`:`Preparing to record`,children:(0,$.jsxs)(`div`,{className:`space-y-3 p-4`,role:`status`,children:[(0,$.jsx)(ps,{className:`h-7 w-24`}),(0,$.jsx)(ps,{className:`h-3 w-3/4`})]})});let Ie=[`recording`,`paused`,`requesting_permission`,`waiting_for_audio`].includes(f.phase);if(!Ie&&(R||ce||f.phase===`stopping`||f.phase===`error`)){let e=In(N,J.localComplete?`complete`:oe?`unknown`:f.phase===`stopping`?`saving`:(f.draft??ce)?.chunkCount?`partial`:`failed`,J.sync),t=async e=>{if(!(o||R||H)){s(!0),K(null);try{e===`sync`||e===`recover`?await Me(f.draft??ce??void 0):N&&P(e===`analyze`?await O(T(`/api/discussions/${encodeURIComponent(N.discussion.id)}/organize`),{method:`POST`,body:`{}`}):await vn(N.discussion.id,e===`regenerate`?`from_audio`:`resume`))}catch(e){K(String(e))}finally{s(!1)}}};return(0,$.jsx)(oY,{compact:v,onCompactChange:y,language:u,title:u===`zh`?`录音已结束`:`Recording ended`,subtitle:FY(N?.discussion.durationMs??ce?.durationMs??f.elapsedMs),children:(0,$.jsx)(`div`,{className:`p-3`,children:(0,$.jsxs)(gn,{input:e,zh:u===`zh`,compact:v,busy:o||R||H,onRetry:e=>void t(e),children:[i?(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:u===`zh`?`重点同步未完成,原音和笔记处理不受影响。`:`Highlights are not synced yet. Audio and note processing are unaffected.`}),(0,$.jsx)(X,{disabled:o||R||H,onClick:()=>void(async()=>{if(!(!N||!ce||o)){s(!0);try{await Un(ce.id,N.discussion.id),a(!1),N.discussion.audioAttachmentId&&!N.discussion.audioDeletedAt&&(await f.discard(ce.id),se(!0))}catch(e){K(String(e))}finally{s(!1)}}})(),children:u===`zh`?`重试重点同步`:`Retry highlights`})]}):null,G?(0,$.jsxs)(`details`,{className:`text-xs text-danger`,children:[(0,$.jsx)(`summary`,{children:u===`zh`?`操作未完成,查看详情`:`Action incomplete. View details`}),G]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!oe&&f.draft&&f.draft.saveOutcome!==`complete`&&!f.draft.sealRequested&&!R?(0,$.jsx)(X,{disabled:H||o,onClick:()=>void Ne(f.draft),children:u===`zh`?`继续录制`:`Continue recording`}):null,N?(0,$.jsx)(X,{onClick:Ae,children:d.openNote}):null,!oe&&f.draft?.chunkCount&&!R?(0,$.jsx)(X,{onClick:()=>void Fe(f.draft),children:u===`zh`?`导出已录内容`:`Export saved audio`}):null,J.localComplete||e.audioAvailable||e.localSave===`failed`?(0,$.jsx)(X,{onClick:()=>S(!1),children:e.localSave===`failed`?d.close:u===`zh`?`稍后查看`:`View later`}):null]})]})})})}let Le=N?.discussion.projectId&&N.discussion.projectInferenceSource!==`context`,Re=u===`zh`,ze=J.capture===`recording`?Re?`录音中`:`Recording`:d.status[J.capture],Be=N?.note.title&&!/^Discussion [·•]/.test(N.note.title)?N.note.title:Re?`语音笔记`:`Voice note`,Ve=e=>(0,$.jsxs)($.Fragment,{children:[f.phase===`recording`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,title:Re?`标重点`:`Highlight`,"aria-label":Re?`标重点`:`Highlight`,onClick:()=>void f.mark(),children:[(0,$.jsx)(En,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:Re?`标重点`:`Highlight`]}):null,f.phase===`recording`||f.phase===`waiting_for_audio`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,"aria-label":d.pause,title:d.pause,onClick:f.pause,children:[(0,$.jsx)(to,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.pause]}):null,f.phase===`paused`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,"aria-label":d.resume,title:d.resume,onClick:f.resume,children:[(0,$.jsx)(_o,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.resume]}):null,[`recording`,`waiting_for_audio`,`paused`].includes(f.phase)?(0,$.jsxs)(X,{variant:`primary`,className:e?`size-10 shrink-0 px-0`:`min-w-0 whitespace-nowrap`,"aria-label":d.stop,title:d.stop,disabled:R,onClick:()=>void ke(),children:[(0,$.jsx)(Wo,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.stop]}):null]}),He=G??f.error??f.markerError??(ue&&J.sync===`failed`?W:null),Ue=J.capture===`interrupted`?Re?`录音已中断,请展开查看已保存内容。`:`Recording interrupted. Review the saved content.`:f.markerError?Re?`重点未能保存,请稍后重试。`:`Highlight could not be saved. Try again.`:J.sync===`failed`?Re?`暂时无法同步,请稍后重试。`:`Sync is unavailable. Please try again later.`:Re?`操作未完成,请查看详情。`:`Could not complete this action. View details.`;return(0,$.jsx)(oY,{compact:v,onCompactChange:y,language:u,title:v?(0,$.jsx)(`span`,{className:`font-mono`,children:FY(f.elapsedMs)}):(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${J.capture===`recording`?`bg-danger`:`bg-accent`}`,"aria-hidden":!0}),ze]}),subtitle:v?ze:Be,compactActions:Ve(!0),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(uY,{status:J,language:u,compact:!0}),J.capture===`interrupted`||He?(0,$.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-danger`,children:Ue}):null,f.markerMessage?(0,$.jsx)(`p`,{role:`status`,className:`px-3 pb-2 text-xs text-accent-fg`,children:Re?`已标记重点`:`Highlight saved`}):null]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-3 px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`p`,{className:`font-mono text-[2.5rem] leading-none tabular-nums tracking-tight text-fg`,children:FY(f.elapsedMs)}),J.capture===`recording`?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[f.inputLevel==null?null:(0,$.jsx)(`div`,{role:`meter`,"aria-label":d.status.level,"aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":f.inputLevel,className:`flex h-6 items-center gap-0.5`,children:[0,1,2,3,4].map(e=>(0,$.jsx)(`span`,{className:`w-1 rounded-full ${f.inputLevel>e*.12?`bg-accent`:`bg-surface-active`}`,style:{height:6+Math.min(1,f.inputLevel*3)*(e%2?10:18)}},e))}),(0,$.jsx)(`span`,{children:f.inputLevel==null?d.status.levelUnknown:Re?`声音输入`:`Sound input`})]}):null]}),(0,$.jsx)(uY,{status:J,language:u}),J.sync===`offline`?(0,$.jsx)(`p`,{role:`status`,className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Re?`离线录音,联网后自动同步。`:`Recording offline. Sync resumes when connected.`}):null,J.ai===`textDelayed`?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:d.status.textDelayed}):null,(0,$.jsxs)(`details`,{className:`group rounded-xl bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:Re?`查看实时文字`:`Live transcript`}),(0,$.jsx)(VJ,{text:I?.text??``,placeholder:f.liveTranscriptionAvailable?Re?`说话后,文字会陆续显示。`:`Text will appear as you speak.`:d.liveUnavailable,zh:Re})]}),Le?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:d.projectLinked}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 shrink-0 items-center gap-1 text-accent-fg`,onClick:()=>void je(),children:[(0,$.jsx)(un,{className:`size-3`,"aria-hidden":!0}),d.undo]})]}):null,R&&te>0?(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":Re?`备份录音`:`Recording backup`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(te),className:`h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full bg-accent motion-safe:transition-[width]`,style:{width:`${te}%`}})}):null,f.markerMessage?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-accent-fg`,children:Re?`已标记重点,可稍后回听。`:`Highlight saved for review.`}):null,He?(0,$.jsx)(`div`,{role:`alert`,children:(0,$.jsxs)(`details`,{className:`text-sm leading-5 text-danger`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ue}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:He})]})}):null]}),(0,$.jsxs)(`footer`,{className:`space-y-2 border-t border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-flow-col auto-cols-fr gap-2`,children:Ve(!1)}),(f.phase===`error`||f.phase===`stopped`)&&f.draft&&!R?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{disabled:H||R||fe,onClick:()=>void Me(f.draft),children:d.recover}),(0,$.jsx)(X,{disabled:H||R||fe||f.draft.sealRequested,onClick:()=>void Ne(f.draft),children:Re?`继续录制`:`Continue recording`}),(0,$.jsx)(X,{disabled:H||R||fe,onClick:()=>void Fe(f.draft),children:Re?`导出原音包`:`Export originals`})]}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:d.maxDuration}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[N?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1 whitespace-nowrap text-accent-fg`,onClick:Ae,children:[(0,$.jsx)(Pi,{className:`size-3.5`,"aria-hidden":!0}),d.openNote]}):null,!Ie&&(!R||J.localComplete)?(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded px-2 hover:bg-surface-hover`,"aria-label":d.close,onClick:()=>S(!1),children:d.close}):null]})]})]})]})})}var LY=4e3;function RY(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function zY(e){let t=RY(e);if(!t||!e||typeof e!=`object`)return null;let n=e.status;return n!==`success`&&n!==`error`&&n!==`cancelled`&&n!==`suspended`?null:{...t,status:n}}async function BY(){let e=await S(T(`/api/session-runs`));if(!e.ok)throw Error(`Active session runs failed (${e.status})`);let t=await e.json();if(!Array.isArray(t.payload?.runs))throw Error(`Active session runs response is invalid`);return t.payload.runs.map(RY).filter(e=>!!e)}function VY(e){window.dispatchEvent(new CustomEvent(`session-transcript-updated`,{detail:{key:e}}))}function HY(){let e=!1,t,n,r=0,i=!1,a=new Map,o=({conversationId:e,runId:t})=>`${e}\u0000${t}`,s=({conversationId:e,runId:t},n=!1)=>{a.has(o({conversationId:e,runId:t}))||(Zs(e)!==t&&tc(e,t),Gs.retireOtherRun(e,t),Gs.setResumeRunId(e,t),he(e),n&&window.dispatchEvent(new CustomEvent(`run-started`,{detail:{conversationId:e,runId:t}})))},c=(e,t)=>{let n=Zs(e)??Gs.getResumeRunId(e);return!n||n===t?!1:(Gs.retireOtherRun(e,n),!0)},l=({conversationId:e,runId:t},n=!0)=>{if(c(e,t))return;let r=Gs.reconcileInactive(e,t,n),i=Js(e,t);!r&&i&&!Gs.isSubmittingFor(e)&&Ws.getState().clearStreamingState(e),(r||i&&!Gs.isSubmittingFor(e))&&(we(e),VY(e))},u=({conversationId:e,runId:t,status:n})=>{if(a.set(o({conversationId:e,runId:t}),Date.now()),c(e,t))return;let r=Gs.reconcileTerminal(e,t,n),i=Js(e,t);if(!r&&i&&!Gs.isSubmittingFor(e)){Ws.getState().clearStreamingState(e);let t=Ws.getState().focusedConversationId===e;n===`error`?Ae(e,!t):n===`suspended`?ye(e):n===`success`?Ee(e,!t):we(e),VY(e)}},d=()=>{e||t!==void 0||rc().length===0||(t=window.setTimeout(()=>{t=void 0,f()},LY))},f=()=>{if(n)return n;let t=r,o=rc();return n=BY().then(n=>{if(e)return;if(r!==t){i=!0;return}let c=Date.now()-10*6e4;for(let[e,t]of a)t<c&&a.delete(e);let u=new Map(n.map(e=>[e.conversationId,e.runId])),d=new Map(o.map(e=>[e.conversationId,e.runId]));for(let e of n){let t=Zs(e.conversationId),n=d.get(e.conversationId);t&&t!==n&&t!==e.runId||s(e,!0)}for(let e of o)u.get(e.conversationId)!==e.runId&&l(e)}).catch(()=>{}).finally(()=>{n=void 0,!e&&i?(i=!1,f()):d()}),n},p=e=>{let t=RY(e.detail);if(!t)return;r++;let a=Zs(t.conversationId);if(a&&a!==t.runId){n&&(i=!0),f();return}s(t),d()},m=e=>{let t=zY(e.detail);t&&(r++,u(t))},h=e=>{let t=RY(e.detail);t&&(r++,a.set(o(t),Date.now()),l(t,!1))},g=()=>void f();return window.addEventListener(`session-input-interrupt`,h),window.addEventListener(`run-started`,p),window.addEventListener(`run-completed`,m),window.addEventListener(`agent-run-ended`,m),window.addEventListener(`gateway-realtime-connected`,g),f(),()=>{e=!0,t!==void 0&&window.clearTimeout(t),window.removeEventListener(`session-input-interrupt`,h),window.removeEventListener(`run-started`,p),window.removeEventListener(`run-completed`,m),window.removeEventListener(`agent-run-ended`,m),window.removeEventListener(`gateway-realtime-connected`,g)}}var UY=new Set([`automation-chat-agents`,`channel-routing-agents`,`gateway-chat-agents`,`picker-agents-list`,`settings-gateway-agents`,`setup-checklist-agents`]);function WY(e){let t=Array.isArray(e)?e[0]:e;return typeof t==`string`&&UY.has(t)}function GY(){let e=(0,Q.c)(3),t=E(XY),n;e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),(0,Z.useEffect)(YY,n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[2]=r):r=e[2],(0,Z.useEffect)(KY,r)}function KY(){let e=JY,t=qY;return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}}function qY(){document.visibilityState===`visible`&&Rc()}function JY(){return Rc()}function YY(){return Fc()}function XY(e){return e.conversationId}function ZY(e){let t=new Set;return(n,r)=>{let i=lc.safeParse(r);if(!i.success)return;let a=i.data;n!==`resources:${a.kind}s`||t.has(a.eventId)||(t.add(a.eventId),t.size>1024&&t.delete(t.values().next().value),e(a))}}function QY(e,t){let n=Array.isArray(e)?e[0]:e;return typeof n==`string`&&(n===t||n.startsWith(`${t}-`)||n.startsWith(`${t}s`))}function $Y(){GY();let{mutate:e}=hc(),t=E(e=>e.conversationId);return(0,Z.useEffect)(()=>Lu(),[]),(0,Z.useEffect)(()=>HY(),[t]),(0,Z.useEffect)(()=>{let n=(t,n)=>{e(e=>QY(e,t)),t===`project`&&window.dispatchEvent(new CustomEvent(`project-resource-changed`,{detail:{id:n}})),t===`task`&&window.dispatchEvent(new CustomEvent(`task-updated`,{detail:{id:n}}))},r=ZY(e=>{e.kind!==`note`&&e.kind!==`task`&&e.kind!==`project`||(n(e.kind,e.id),e.kind===`note`&&window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.id}})))}),i=0,a=[],o=async()=>{let e=++i;a.forEach(e=>e()),a=[];try{let{capabilities:t}=await O(T(`/api/capabilities/operations`));if(e!==i)return;a=[`note`,`task`,`project`].filter(e=>t.some(t=>t.id===`xopc.${e}s.list`)).map(e=>{let t=kc(`resources:${e}s`,{onEvent:e=>{e.event===`resource.changed`&&r(e.topic,e.data)},onGap:()=>n(e)},0);return n(e),t})}catch{}},s=()=>{o()};return t&&o(),window.addEventListener(`gateway-realtime-connected`,s),()=>{i++,a.forEach(e=>e()),window.removeEventListener(`gateway-realtime-connected`,s)}},[e,t]),(0,Z.useEffect)(()=>{let t=()=>{Nd(),e(WY)},n=e=>{Uq();let t=bc(e.detail);t===`skills`?Fd():t===`agents`&&Nd()},r=t=>{let n=t.detail?.topic;(n===`gateway`||n===`sessions`)&&e(()=>!0)};return window.addEventListener(`agent-catalog`,t),window.addEventListener(`config-reload`,n),window.addEventListener(`realtime-gap`,r),()=>{window.removeEventListener(`agent-catalog`,t),window.removeEventListener(`config-reload`,n),window.removeEventListener(`realtime-gap`,r)}},[e]),null}async function eX(e){let t=window.electronAPI?.system;if(!tu()||!t?.showProductNotification)return!1;let n=await t.getBehavior().catch(()=>null);if(!n||!qt({notification:e,preferences:{enabled:n.notifyEnabled,completed:!0,failed:!0},permissionGranted:!0,appFocused:e.waitId?Wt(e):Jt(e),alreadyDelivered:Gt(e.id)}).notify)return!1;let r=await t.showProductNotification({id:e.id,title:e.title,body:e.body,target:e.target,...e.waitId&&!Wt(e)?{allowWhenFocused:!0}:{}}).catch(()=>null);return r?.ok&&r.outcome===`shown`?(Yt(e.id),!0):!1}var tX=`xopc.notifications.cursor.v1`,nX=`xopc.notifications.consumer.v1`;function rX(e){try{return window.localStorage.getItem(e)}catch{return null}}function iX(e,t){try{window.localStorage.setItem(e,t)}catch{}}function aX(){return rX(tX)}function oX(e){iX(tX,e)}function sX(){let e=rX(nX);if(e)return e;let t=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`;return iX(nX,t),t}async function cX(){let e=[],t=aX();for(let n=0;n<10;n+=1){let n=new URLSearchParams({since:String(Date.now()-5*6e4),limit:`100`});t&&n.set(`after`,t);let r=await S(`/api/notifications?${n}`);if(!r.ok)break;let i=await r.json().catch(()=>null);if(!Array.isArray(i?.items))break;let a=i.items.flatMap(e=>{let t=tB.safeParse(e);return t.success?[t.data]:[]});if(e.push(...a),t=a.at(-1)?.id??t,i.items.length<100||a.length===0)break}return e}async function lX(e){await S(`/api/notifications/${encodeURIComponent(e)}/ack`,{method:`POST`,body:JSON.stringify({consumerId:sX(),surface:tu()?`electron`:`web`})}).catch(()=>null)}async function uX(e){if(e.type!==`chat.needs_input`)return!0;if(e.target.kind!==`chat`||typeof e.payload.waitId!=`string`)return!1;let t=await S(`/api/sessions/${encodeURIComponent(e.target.conversationId)}/clarification`);if(t.status===404)return!1;if(!t.ok)throw Error(`Could not refresh clarification notification`);let n=(await t.json()).payload;return n.transcriptId===e.payload.transcriptId&&n.clarification?.id===e.payload.waitId&&n.clarification.status===`open`&&(n.clarification.expiresAt===void 0||n.clarification.expiresAt>Date.now())}function dX(e){let t=tB.safeParse(e);return t.success?t.data:null}function fX(e,t){let n=nB(e,t),r=e.type===`chat.failed`||e.type===`task.blocked`||e.type===`task.failed`||e.type===`task.needs_input`||e.type===`automation.failed`||e.type===`work_discovery.failed`,i=e.target.kind===`automation_run`?`automation`:e.target.kind===`work_discovery`?`understanding`:e.target.kind;return{systemAllowed:e.payload.deliveryMode!==`auto`&&(!e.payload.deliveryChannel||[`all`,`browser`].includes(String(e.payload.deliveryChannel))),id:e.id,title:n.localizedTitle,body:n.localizedBody??n.localizedTitle,route:rB(e.target,`web`),target:e.target,...e.type===`chat.needs_input`&&typeof e.payload.waitId==`string`?{waitId:e.payload.waitId}:{},status:e.type===`chat.needs_input`||e.type===`task.needs_input`?`attention`:r?`error`:`success`,source:i}}function pX(){let e=(0,Q.c)(3),t=D(vX),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=!0,n=null,r=new Set,i=new Map,a=Promise.resolve(),o=(n,o,s)=>{let c=o===void 0||o,l=s===void 0||s;return a=a.catch(_X).then(async()=>{if(!e)return;let a=dX(n);if(!a)return;if(r.has(a.id)){l&&oX(a.id);return}let o=await uX(a);if(!e)return;if(r.add(a.id),!o){l&&oX(a.id);return}let s=fX(a,t);s.waitId&&i.set(s.waitId,a.id),(s.waitId?Wt(s):Jt(s))||jl({tone:s.status===`attention`?`warning`:s.status===`success`?`success`:`error`,title:s.title,message:s.body,source:s.source,href:s.route,dedupeKey:s.id}),c&&(a.type!==`chat.needs_input`||a.createdAt>=Date.now()-3e5)&&(eX(s),Xt(s)),l&&oX(a.id),lX(a.id)}),a},s=()=>n||(n=cX().then(async t=>{if(e){let e=Date.now()-3e5;for(let n of t)await o(n,n.createdAt>=e)}}).catch(gX).finally(()=>{n=null}),n),c=e=>{o(e.detail,!0,!1).catch(hX),s().then(()=>s())},l=()=>void s(),u=e=>{let t=e.detail;if(!t||t.status===`open`)return;let n=i.get(t.id);if(!n)return;let r=Al.getState();for(let e of r.items)e.dedupeKey===n&&r.remove(e.id);i.delete(t.id)};window.addEventListener(`clarification-updated`,u),window.addEventListener(`notification-created`,c),window.addEventListener(`realtime-gap`,l),window.addEventListener(`gateway-realtime-connected`,l),window.addEventListener(`online`,l),window.addEventListener(`focus`,l),s();let d=mX;return navigator.serviceWorker?.addEventListener(`message`,d),()=>{e=!1,window.removeEventListener(`clarification-updated`,u),window.removeEventListener(`notification-created`,c),window.removeEventListener(`realtime-gap`,l),window.removeEventListener(`gateway-realtime-connected`,l),window.removeEventListener(`online`,l),window.removeEventListener(`focus`,l),navigator.serviceWorker?.removeEventListener(`message`,d)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function mX(e){let t=e.data;t?.type!==`xopc:notification-click`||typeof t.route!=`string`||t.route.startsWith(`/`)&&!t.route.startsWith(`//`)&&(window.location.hash=t.route)}function hX(){}function gX(){}function _X(){}function vX(e){return e.language}async function yX(e){let t=await O(T(`/api/support/report`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});return{report:t.report,investigationPrompt:t.investigationPrompt}}function bX(e){let t=new Date(e.capturedAt).toISOString().replace(/[:.]/g,`-`),n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`xopc-diagnostics-${t}.json`,i.click(),URL.revokeObjectURL(r)}function xX(e,t){let n=6e3,r=e.markdown.length<=n?e.markdown:`${e.markdown.slice(0,n)}\n\n---\n${t}`;return`https://github.com/xopcai/xopc/issues/new?${new URLSearchParams({title:e.title,body:r}).toString()}`}async function SX(e){let t=window.electronAPI?.shell?.openExternalUrl;if(t)try{return(await t(e)).ok}catch{return!1}return window.open(e,`_blank`,`noopener,noreferrer`)!==null}function CX(e){let t=new TextEncoder().encode(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return{type:`file`,mimeType:`text/markdown`,data:btoa(n),name:`xopc-diagnostics.md`,size:t.byteLength}}async function wX(e,t,n={}){let r=n.fetch??O,i=n.create?await n.create():(await new ic().createSession({agentId:`main`})).key;return await(n.send??Bu)(i,t,[CX(e.markdown)]),await r(T(`/api/sessions/${encodeURIComponent(i)}`),{method:`PATCH`,body:JSON.stringify({name:e.title,tags:[`support`],replaceTags:!0,customData:{kind:`support-investigation`,supportReportCapturedAt:e.capturedAt}})}).catch(()=>void 0),i}function TX({open:e,onOpenChange:t,seed:n}){let r=F(D(e=>e.language)).supportReport,i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{e&&(o(n?.problem??``),c(n?.reproduction??``),u(n?.expected??``),f(null),m(``),g(!1),v(!1),b(null),S(null))},[e,n]);async function C(){let e=a.trim();if(!e){b(r.problemRequired);return}g(!0),b(null),S(null);try{let t=await yX({...n,problem:e,reproduction:s.trim()||void 0,expected:l.trim()||void 0,occurredAt:n?.occurredAt??new Date().toISOString(),clientContext:{currentPage:window.location.href,surface:window.electronAPI?`electron`:`web`,userAgent:navigator.userAgent,...n?.clientContext}});f(t.report),m(t.investigationPrompt)}catch(e){b(e instanceof Error?e.message:r.collectFailed)}finally{g(!1)}}async function w(){if(!d)return!1;let e=await pl(d.markdown);return S(e?r.copied:r.copyFailed),e||(i.current?.focus(),i.current?.select()),e}async function T(){d&&(d.markdown.length>6e3&&await w(),await SX(xX(d,r.githubTruncated))||b(r.openFailed))}async function E(){if(!(!d||!p)){v(!0),b(null);try{let e=await wX(d,p);t(!1),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e}}))}catch(e){b(e instanceof Error?e.message:r.sessionFailed)}finally{v(!1)}}}return(0,$.jsx)(ne,{open:e,onOpenChange:t,children:(0,$.jsxs)(H,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[220] bg-scrim`}),(0,$.jsxs)(ee,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[221] flex h-[min(42rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:r.title}),(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 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":r.close,children:(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:[h?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.collecting,children:[(0,$.jsx)(ps,{className:`h-20 w-full`}),(0,$.jsx)(ps,{className:`h-24 w-full`}),(0,$.jsx)(ps,{className:`h-32 w-full`})]}):d?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-accent-soft px-3 py-2.5 text-sm text-accent-fg`,children:[(0,$.jsx)(Lo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium`,children:r.ready}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5`,children:r.readyDetail.replace(`{{checks}}`,String(d.doctor.length)).replace(`{{logs}}`,String(d.logs.length)).replace(`{{redactions}}`,String(d.redaction.replacements))})]})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-report-preview`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.preview}),(0,$.jsx)(`textarea`,{ref:i,id:`support-report-preview`,value:d.markdown,readOnly:!0,className:`h-96 w-full resize-none rounded-xl border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Vo,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.investigationHint]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-problem`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.problem}),(0,$.jsx)(`textarea`,{id:`support-problem`,value:a,onChange:e=>o(e.target.value),placeholder:r.problemPlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`,autoFocus:!0})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-reproduction`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.reproduction}),(0,$.jsx)(`textarea`,{id:`support-reproduction`,value:s,onChange:e=>c(e.target.value),placeholder:r.reproductionPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-expected`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.expected}),(0,$.jsx)(`textarea`,{id:`support-expected`,value:l,onChange:e=>u(e.target.value),placeholder:r.expectedPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Lo,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.privacy]})]}),y?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-warning`,role:`alert`,children:y}):null,x?(0,$.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-accent-fg`,role:`status`,children:[(0,$.jsx)(_r,{className:`size-4`,"aria-hidden":!0}),x]}):null]}),(0,$.jsx)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-3`,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:`ghost`,disabled:_,onClick:()=>{f(null),m(``)},children:r.back}),(0,$.jsxs)(X,{onClick:()=>void w(),children:[(0,$.jsx)(_y,{className:`size-4`,"aria-hidden":!0}),r.copy]}),(0,$.jsxs)(X,{onClick:()=>bX(d),children:[(0,$.jsx)(pi,{className:`size-4`,"aria-hidden":!0}),r.download]}),(0,$.jsxs)(X,{onClick:()=>void T(),children:[(0,$.jsx)(hi,{className:`size-4`,"aria-hidden":!0}),r.submit]}),(0,$.jsxs)(X,{variant:`primary`,disabled:_,onClick:()=>void E(),children:[_?(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vo,{className:`size-4`,"aria-hidden":!0}),_?r.startingInvestigation:r.startInvestigation]})]}):(0,$.jsxs)(X,{variant:`primary`,disabled:h,onClick:()=>void C(),children:[h?(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,h?r.collecting:r.collect]})})]})]})})}function EX(e){if(!e.startsWith(`/chat/`)||e.startsWith(`/chat/task/`))return;let t=e.slice(6);if(!(!t||t===`new`))try{return decodeURIComponent(t)}catch{return}}function DX(){let e=(0,Q.c)(6),{pathname:t}=m(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(),o,s;e[0]===t?(o=e[1],s=e[2]):(o=()=>{let e=e=>{let n=e.detail??{};a({conversationId:EX(t),...n}),r(!0)};return window.addEventListener(BH,e),()=>window.removeEventListener(BH,e)},s=[t],e[0]=t,e[1]=o,e[2]=s),(0,Z.useEffect)(o,s);let c;return e[3]!==n||e[4]!==i?(c=(0,$.jsx)(TX,{open:n,onOpenChange:r,seed:i}),e[3]=n,e[4]=i,e[5]=c):c=e[5],c}function OX(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var kX=`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent motion-safe:transition-colors`;function AX(){let e=(0,Q.c)(29),t=D(MX)===`zh`,n=Ht(),r=ut(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useId)(),s=n.source&&n.status!==`idle`,c=n.status===`preparing`,l=n.status===`playing`,u=n.status===`error`,d=n.status===`ended`,f=c?t?`正在准备语音`:`Preparing audio`:u?t?`朗读失败,请重试`:`Unable to play. Try again`:d?t?`播放完毕`:`Finished`:l?t?`正在朗读`:`Reading aloud`:t?`已暂停`:`Paused`,p;e[0]===n.source?p=e[1]:(p=e=>{let t=n.source?.targetId?document.getElementById(n.source.targetId):null;t&&(e.preventDefault(),t.scrollIntoView({behavior:`smooth`,block:`center`}))},e[0]=n.source,e[1]=p);let m=p,h;e[2]!==o||e[3]!==r||e[4]!==d||e[5]!==i||e[6]!==u||e[7]!==l||e[8]!==c||e[9]!==m||e[10]!==n||e[11]!==f||e[12]!==s||e[13]!==t?(h=s?(0,$.jsx)(`section`,{"aria-label":t?`语音播报`:`Read aloud`,className:Y(`shrink-0`,r?`pb-2`:`px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-2`),children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-16 items-center gap-1 p-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),"aria-expanded":i,"aria-controls":o,className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-lg px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.source?.title}),(0,$.jsxs)(`span`,{className:`block text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{role:`status`,children:f}),!u&&!c?(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,OX(n.currentTime)]}):null]})]}),(0,$.jsx)(vr,{"aria-hidden":!0,className:Y(`size-4 shrink-0 text-fg-muted`,i&&`rotate-180`)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:l?n.pause:n.resume,disabled:c,className:Y(kX,`disabled:opacity-50`),"aria-label":d?t?`重新播放`:`Replay`:u?t?`重试朗读`:`Retry reading`:l?t?`暂停朗读`:`Pause reading`:t?`继续朗读`:`Resume reading`,children:c?(0,$.jsx)(ps,{className:`size-5 rounded-full`}):u?(0,$.jsx)(Do,{className:`size-5`,"aria-hidden":!0}):l?(0,$.jsx)(to,{className:`size-5`,"aria-hidden":!0}):(0,$.jsx)(_o,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:n.stop,className:kX,"aria-label":t?`停止朗读`:`Stop reading`,children:(0,$.jsx)(ds,{className:`size-5`,"aria-hidden":!0})})]}),n.durationComplete&&!i?(0,$.jsx)(`div`,{className:`h-0.5 bg-surface-active`,"aria-hidden":!0,children:(0,$.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${Math.min(100,n.currentTime/n.duration*100)}%`}})}):null,i?(0,$.jsxs)(`div`,{id:o,className:`space-y-3 border-t border-edge-subtle p-4`,children:[n.durationComplete?(0,$.jsx)(NX,{duration:n.duration,currentTime:n.currentTime,disabled:c,onSeek:n.seek,label:t?`播放进度`:`Playback position`},`${n.source?.type}:${n.source?.id}`):null,n.currentText?(0,$.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.currentText}):null,n.source?.href?(0,$.jsx)(`a`,{href:n.source.href,onClick:m,className:`inline-flex min-h-11 items-center rounded-lg text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t?`返回来源`:`Return to source`}):null,u?(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:n.error}):null,(0,$.jsx)(kr,{contentClassName:`[&_button]:min-h-11`,value:String(n.rate),allowEmpty:!1,placeholder:`1×`,ariaLabel:t?`播放速度`:`Playback speed`,options:[.75,1,1.25,1.5,2].map(jX),triggerClassName:`min-h-11 w-28`,onChange:e=>n.setRate(Number(e))})]}):null]})}):null,e[2]=o,e[3]=r,e[4]=d,e[5]=i,e[6]=u,e[7]=l,e[8]=c,e[9]=m,e[10]=n,e[11]=f,e[12]=s,e[13]=t,e[14]=h):h=e[14];let g=h,_;e[15]!==r||e[16]!==g?(_=r?(0,Sf.createPortal)(g,r):g,e[15]=r,e[16]=g,e[17]=_):_=e[17];let v=t?`使用在线朗读`:`Use online read aloud`,y=t?`朗读默认使用 Microsoft Edge 在线语音服务,待朗读文本会发送至 Microsoft 进行语音合成。`:`Read aloud uses Microsoft Edge online speech by default. The text will be sent to Microsoft for speech synthesis.`,b=t?`同意并朗读`:`Agree and read`,x=t?`取消`:`Cancel`,S;e[18]!==n.acceptConsent||e[19]!==n.consentRequired||e[20]!==n.declineConsent||e[21]!==v||e[22]!==y||e[23]!==b||e[24]!==x?(S=(0,$.jsx)(rd,{open:n.consentRequired,title:v,description:y,confirmLabel:b,cancelLabel:x,onConfirm:n.acceptConsent,onCancel:n.declineConsent}),e[18]=n.acceptConsent,e[19]=n.consentRequired,e[20]=n.declineConsent,e[21]=v,e[22]=y,e[23]=b,e[24]=x,e[25]=S):S=e[25];let C;return e[26]!==_||e[27]!==S?(C=(0,$.jsxs)($.Fragment,{children:[_,S]}),e[26]=_,e[27]=S,e[28]=C):C=e[28],C}function jX(e){return{value:String(e),label:`${e}×`}}function MX(e){return e.language}function NX(e){let t=(0,Q.c)(25),{duration:n,currentTime:r,disabled:i,onSeek:a,label:o}=e,[s,c]=(0,Z.useState)(null),l;t[0]!==a||t[1]!==s?(l=()=>{s!==null&&(a(s),c(null))},t[0]=a,t[1]=s,t[2]=l):l=t[2];let u=l,d;t[3]===o?d=t[4]:(d=(0,$.jsx)(`span`,{children:o}),t[3]=o,t[4]=d);let f=s??r,p;t[5]===f?p=t[6]:(p=OX(f),t[5]=f,t[6]=p);let m;t[7]===n?m=t[8]:(m=OX(n),t[7]=n,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[p,` / `,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==h?(g=(0,$.jsxs)(`span`,{className:`flex justify-between gap-3`,children:[d,h]}),t[12]=d,t[13]=h,t[14]=g):g=t[14];let _=s??Math.min(r,n),v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>c(Number(e.target.value)),t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>c(null),t[16]=y):y=t[16];let b;t[17]!==u||t[18]!==i||t[19]!==n||t[20]!==_?(b=(0,$.jsx)(`input`,{type:`range`,min:0,max:n,step:.1,value:_,disabled:i,onChange:v,onPointerUp:u,onKeyUp:u,onBlur:u,onPointerCancel:y,className:`block h-11 w-full accent-accent`}),t[17]=u,t[18]=i,t[19]=n,t[20]=_,t[21]=b):b=t[21];let x;return t[22]!==b||t[23]!==g?(x=(0,$.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[g,b]}),t[22]=b,t[23]=g,t[24]=x):x=t[24],x}function PX(){let e=(0,Q.c)(45),t=D(RX)===`zh`,n=xt(LX),r=n&&!n.inline?n.entry:null,{playing:i,starting:a,failed:o,duration:s,position:c,toggle:l,seek:u}=it(r?.source.kind===`audio`?r.element:null),[d,f]=(0,Z.useState)(null),p=(0,Z.useRef)(null),m=nY(p,!!r,d,`[data-recording-window]`),h=(0,Z.useRef)(null),g=(0,Z.useRef)(!1),_;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],e[0]=_):_=e[0],(0,Z.useEffect)(IX,_);let v;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=function(e){h.current?.id===e.pointerId&&(g.current=h.current.moved,h.current=null)},e[1]=v):v=e[1];let y=v;if(!r)return null;let b=r.source.kind===`video`,x=b?rt:Wa,S=o?Do:a?_a:i?to:_o,C=o?t?`重试播放`:`Retry playback`:i||a?t?`暂停`:`Pause`:t?`播放`:`Play`,w=t?`移动播放器`:`Move player`,T=Math.min(c,s),E=t?`媒体浮窗`:`Floating media player`,O=t?`拖动或用方向键移动,点击回到默认位置`:`Drag or use arrow keys. Click to reset position.`,k;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{if(e.button!==0||!e.isPrimary)return;let t=p.current?.getBoundingClientRect();t&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}),g.current=!1,h.current={id:e.pointerId,pointer:{x:e.clientX,y:e.clientY},origin:{x:t.left,y:t.top},moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId))},e[2]=k):k=e[2];let A;e[3]===m?A=e[4]:(A=e=>{let t=h.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.pointer.x,r=e.clientY-t.pointer.y;!t.moved&&Math.hypot(n,r)<4||(t.moved=!0,f(m.clamp({x:t.origin.x+n,y:t.origin.y+r})))},e[3]=m,e[4]=A);let j;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{(!g.current||!e.detail)&&f(null),g.current=!1},e[5]=j):j=e[5];let M;e[6]===m?M=e[7]:(M=e=>{let t=e.shiftKey?48:16,n={ArrowLeft:{x:-t,y:0},ArrowRight:{x:t,y:0},ArrowUp:{x:0,y:-t},ArrowDown:{x:0,y:t}}[e.key],r=p.current?.getBoundingClientRect();n&&r&&(e.preventDefault(),f(m.clamp({x:r.left+n.x,y:r.top+n.y})))},e[6]=m,e[7]=M);let N;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(me,{size:16,"aria-hidden":!0}),e[8]=N):N=e[8];let P;e[9]!==w||e[10]!==O||e[11]!==A||e[12]!==M?(P=(0,$.jsx)(X,{variant:`ghost`,className:`size-10 shrink-0 touch-none cursor-grab rounded-lg p-0 select-none active:cursor-grabbing`,"aria-label":w,title:O,onPointerDown:k,onDragStart:FX,onPointerMove:A,onPointerUp:y,onPointerCancel:y,onLostPointerCapture:y,onClick:j,onKeyDown:M,children:N}),e[9]=w,e[10]=O,e[11]=A,e[12]=M,e[13]=P):P=e[13];let F;e[14]===x?F=e[15]:(F=(0,$.jsx)(x,{size:15,className:`shrink-0 text-fg-muted`,"aria-hidden":!0}),e[14]=x,e[15]=F);let I;e[16]===r.source.title?I=e[17]:(I=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,title:r.source.title,children:r.source.title}),e[16]=r.source.title,e[17]=I);let L;e[18]!==S||e[19]!==b||e[20]!==C||e[21]!==a||e[22]!==l?(L=!b&&(0,$.jsx)(X,{variant:`ghost`,className:`size-10 shrink-0 rounded-lg p-0`,"aria-label":C,onClick:l,children:(0,$.jsx)(S,{size:17,"aria-hidden":!0,className:a?`motion-safe:animate-spin`:void 0})}),e[18]=S,e[19]=b,e[20]=C,e[21]=a,e[22]=l,e[23]=L):L=e[23];let R=t?`关闭播放器`:`Close player`,z;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ds,{size:17,"aria-hidden":!0}),e[24]=z):z=e[24];let B;e[25]===R?B=e[26]:(B=(0,$.jsx)(X,{variant:`ghost`,className:`size-10 shrink-0 rounded-lg p-0`,onClick:We,"aria-label":R,children:z}),e[25]=R,e[26]=B);let V;e[27]!==F||e[28]!==I||e[29]!==L||e[30]!==B||e[31]!==P?(V=(0,$.jsxs)(`header`,{className:`flex min-w-0 shrink-0 items-center gap-1 p-1.5`,children:[P,F,I,L,B]}),e[27]=F,e[28]=I,e[29]=L,e[30]=B,e[31]=P,e[32]=V):V=e[32];let H;e[33]!==s||e[34]!==o||e[35]!==b||e[36]!==T||e[37]!==u||e[38]!==t?(H=b?(0,$.jsx)(`div`,{ref:ht,className:`min-h-0 overflow-y-auto px-2 pb-2 [&>video]:block [&>video]:max-h-[min(11rem,38dvh)]`}):(0,$.jsxs)(`div`,{className:`flex min-h-0 items-center gap-2 overflow-hidden px-3 pb-1 text-xs tabular-nums text-fg-muted`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:yt(T)}),(0,$.jsx)(`input`,{type:`range`,"aria-label":t?`播放进度`:`Playback position`,min:0,max:s||1,step:.1,value:T,disabled:!s||o,onChange:e=>u(e.currentTarget.valueAsNumber),className:`h-7 min-w-0 flex-1 cursor-pointer accent-accent focus-visible:outline-2 focus-visible:outline-accent`}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:s?yt(s):`—`})]}),e[33]=s,e[34]=o,e[35]=b,e[36]=T,e[37]=u,e[38]=t,e[39]=H):H=e[39];let ee;return e[40]!==m.style||e[41]!==V||e[42]!==H||e[43]!==E?(ee=(0,Sf.createPortal)((0,$.jsxs)(`aside`,{ref:p,"aria-label":E,className:`fixed z-[65] flex w-80 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg shadow-elevated [-webkit-app-region:no-drag]`,style:m.style,children:[V,H]}),document.body),e[40]=m.style,e[41]=V,e[42]=H,e[43]=E,e[44]=ee):ee=e[44],ee}function FX(e){return e.preventDefault()}function IX(){let e=Yd();return()=>{e(),We(),Xd()}}function LX(e){return e.active}function RX(e){return e.language}function zX(){let e=(0,Q.c)(11),t=x(),n=E(VX),r=Bd(BX),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(!1),o,s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=e=>{i.current=!!e.detail?.active};return window.addEventListener(Gd,e),()=>window.removeEventListener(Gd,e)},s=[],e[0]=o,e[1]=s):(o=e[0],s=e[1]),(0,Z.useEffect)(o,s);let c,l;e[2]!==t||e[3]!==n?(c=()=>{let e=window.electronAPI?.voiceInputHotkey;if(typeof e?.onEvent!=`function`)return;let r=e.onEvent(e=>{if(e===`press`){if(i.current||!n)return;a.current=!0}else{if(!a.current)return;a.current=!1}Id(`xopc-voice-input-toggle`,document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`)||(e===`press`?(Hd(),t(`/chat`)):zd())});return()=>{a.current=!1,r()}},l=[t,n],e[2]=t,e[3]=n,e[4]=c,e[5]=l):(c=e[4],l=e[5]),(0,Z.useEffect)(c,l);let u,d;return e[6]!==t||e[7]!==r||e[8]!==n?(u=()=>{let e=e=>{if(i.current||e.repeat||e.isComposing)return;let a=document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`;if(e.key===`Escape`){Id(`xopc-voice-input-cancel`,a)&&(e.preventDefault(),e.stopPropagation());return}Ld(e,r)&&(e.preventDefault(),e.stopPropagation(),n&&(Id(`xopc-voice-input-toggle`,a)||(Hd(),t(`/chat`))))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},d=[t,r,n],e[6]=t,e[7]=r,e[8]=n,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,Z.useEffect)(u,d),null}function BX(e){return e.shortcut}function VX(e){return e.conversationId}function HX(e){let t=(0,Q.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({contentRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let[i,a]=(0,Z.useState)(),o,s;if(t[3]===n?(o=t[4],s=t[5]):(o=()=>{let e=n.current?.getAnimations?.().find(WX),t=!0,r=e?.finished.catch(UX);return Promise.all([uu(),r]).then(e=>{let[n]=e,{TaskDetailView:r}=n;t&&(0,Z.startTransition)(()=>a({View:r}))},e=>{t&&a({error:e})}),()=>{t=!1}},s=[n],t[3]=n,t[4]=o,t[5]=s),(0,Z.useEffect)(o,s),!i){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsx)(ef,{})}),t[6]=e):e=t[6],e}if(`error`in i)throw i.error;let{View:c}=i,l;return t[7]!==c||t[8]!==r?(l=(0,$.jsx)(c,{...r},r.taskId),t[7]=c,t[8]=r,t[9]=l):l=t[9],l}function UX(){}function WX(e){return`animationName`in e&&e.animationName===`task-detail-enter`}function GX(e){let t=(0,Q.c)(40),{taskId:n,backgroundPath:r,initialTitle:i,workspacePanelWidth:a,onClose:o}=e,s=a===void 0?0:a,c=D(YX),l=yc(JX),u=s>0,[d,f]=(0,Z.useState)(),p=(0,Z.useRef)(null),m=d?.taskId===n?d:void 0,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!0},t[0]=h):h=t[0],$e(n,h);let g;t[1]!==o||t[2]!==l?(g=()=>{l(null),o()},t[1]=o,t[2]=l,t[3]=g):g=t[3];let _=g,v;t[4]===_?v=t[5]:(v=e=>{e||_()},t[4]=_,t[5]=v);let y=c===`zh`?`关闭任务详情`:`Close task details`,b;t[6]!==_||t[7]!==y?(b=(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`task-detail-modal-backdrop fixed inset-0 z-[80] bg-black/45`,"aria-label":y,onClick:_}),t[6]=_,t[7]=y,t[8]=b):b=t[8];let x=u?`true`:`false`,S=`${s/2}px`,C=`${s}px`,w;t[9]!==S||t[10]!==C?(w={"--task-detail-workspace-offset":S,"--task-detail-workspace-width":C},t[9]=S,t[10]=C,t[11]=w):w=t[11];let T=w,E=!m?.title&&i||(c===`zh`?`任务详情`:`Task details`),O=m?.title,k=m?.compact??!1,A;t[12]!==E||t[13]!==O||t[14]!==k?(A=(0,$.jsx)(te,{className:`min-w-0 flex-1 font-medium text-fg`,children:(0,$.jsx)(nf,{label:E,title:O,compact:k})}),t[12]=E,t[13]=O,t[14]=k,t[15]=A):A=t[15];let j=c===`zh`?`查看并操作任务详情`:`View and manage task details`,M;t[16]===j?M=t[17]:(M=(0,$.jsx)(B,{className:`sr-only`,children:j}),t[16]=j,t[17]=M);let N=c===`zh`?`关闭任务详情`:`Close task details`,P;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0}),t[18]=P):P=t[18];let F;t[19]===N?F=t[20]:(F=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,$.jsx)(V,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":N,children:P})}),t[19]=N,t[20]=F);let I;t[21]!==A||t[22]!==M||t[23]!==F?(I=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[A,M,F]}),t[21]=A,t[22]=M,t[23]=F,t[24]=I):I=t[24];let L;t[25]!==r||t[26]!==_||t[27]!==n?(L=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(HX,{contentRef:p,taskId:n,presentation:`modal`,backgroundPath:r,onHeaderChange:f,onDeleted:_})}),t[25]=r,t[26]=_,t[27]=n,t[28]=L):L=t[28];let R;t[29]!==T||t[30]!==I||t[31]!==L||t[32]!==x?(R=(0,$.jsxs)(ee,{ref:p,className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":x,style:T,onEscapeKeyDown:qX,onInteractOutside:KX,children:[I,L]}),t[29]=T,t[30]=I,t[31]=L,t[32]=x,t[33]=R):R=t[33];let z;t[34]!==R||t[35]!==b?(z=(0,$.jsxs)(H,{children:[b,R]}),t[34]=R,t[35]=b,t[36]=z):z=t[36];let U;return t[37]!==z||t[38]!==v?(U=(0,$.jsx)(ne,{modal:!1,open:!0,onOpenChange:v,children:z}),t[37]=z,t[38]=v,t[39]=U):U=t[39],U}function KX(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function qX(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function JX(e){return e.setPath}function YX(e){return e.language}var XX=[{value:`en`,label:`EN`},{value:`zh`,label:`中文`}];function ZX(e){let t=(0,Q.c)(5),{value:n,onChange:r}=e,i;t[0]!==r||t[1]!==n?(i=XX.map(e=>{let t=e.value===n;return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t,className:Y(Qu,`h-9 min-w-11 px-2`,t?Y(ed,`text-fg`):`text-fg-subtle hover:text-fg`),onClick:()=>r(e.value),children:e.label},e.value)}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(nd,{className:$u,role:`group`,"aria-label":`Language / 语言`,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:i}),t[3]=i,t[4]=a),a}var QX=new Set([`anthropic`,`deepseek`,`google`,`kimi-coding`,`minimax`,`openai`,`xopc-cloud`]);function $X(e){return QX.has(e)}function eZ(e){let t=(0,Q.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=Y(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,$.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 tZ(e){let t=(0,Q.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,$.jsx)(`path`,{fill:`#5786FE`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.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.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(eZ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function nZ(e){let t=(0,Q.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,$.jsx)(`path`,{fill:`#E73562`,d:`M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(eZ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function rZ(e){let t=(0,Q.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,$.jsx)(`path`,{fill:`currentColor`,d:`m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(eZ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function iZ(e){let t=(0,Q.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,$.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,$.jsx)(eZ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function aZ(e){let t=(0,Q.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,$.jsx)(`path`,{fill:`#D4A27F`,d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(eZ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function oZ(e){let t=(0,Q.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,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,$.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,$.jsxs)(eZ,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function sZ(e){let t=(0,Q.c)(22),{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`xopc-cloud`:{let e;return t[2]===r?e=t[3]:(e=(0,$.jsx)(Rl,{className:r,"aria-hidden":!0}),t[2]=r,t[3]=e),e}case`deepseek`:{let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)(tZ,{...a}),t[4]=a,t[5]=e),e}case`minimax`:{let e;return t[6]===a?e=t[7]:(e=(0,$.jsx)(nZ,{...a}),t[6]=a,t[7]=e),e}case`kimi-coding`:{let e;return t[8]===a?e=t[9]:(e=(0,$.jsx)(rZ,{...a}),t[8]=a,t[9]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[10]===a?e=t[11]:(e=(0,$.jsx)(rZ,{...a}),t[10]=a,t[11]=e),e}case`openai`:{let e;return t[12]===a?e=t[13]:(e=(0,$.jsx)(iZ,{...a}),t[12]=a,t[13]=e),e}case`anthropic`:{let e;return t[14]===a?e=t[15]:(e=(0,$.jsx)(aZ,{...a}),t[14]=a,t[15]=e),e}case`google`:{let e;return t[16]===a?e=t[17]:(e=(0,$.jsx)(oZ,{...a}),t[16]=a,t[17]=e),e}default:{let e;t[18]===r?e=t[19]:(e=Y(`flex items-center justify-center text-2xl`,r),t[18]=r,t[19]=e);let n;return t[20]===e?n=t[21]:(n=(0,$.jsx)(`span`,{className:e,children:`🤖`}),t[20]=e,t[21]=n),n}}}var cZ={id:`xopc-cloud`,name:`XOPC Cloud`,category:`common`,supportsOAuth:!0,supportsApiKey:!1,configured:!1,onboardingFeatured:!0,hint:`Connect your XOPC account. No API key required.`},lZ=[{id:`deepseek`,name:`DeepSeek`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`openai`,name:`OpenAI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`anthropic`,name:`Anthropic`,category:`common`,supportsOAuth:!0,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`google`,name:`Google AI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0}],uZ=new Map([cZ,...lZ].map((e,t)=>[e.id,t]));function dZ(e,t){let n=e?.filter(e=>e.onboardingFeatured&&$X(e.id)),r=n?.length?n:lZ;return(t?[e?.find(e=>e.id===`xopc-cloud`)??cZ,...r.filter(e=>e.id!==`google`&&e.id!==`xopc-cloud`)]:r).slice().sort((e,t)=>(uZ.get(e.id)??999)-(uZ.get(t.id)??999))[0]}function fZ(e){let t=e.recommendedModels?.map(e=>e.name||e.id).filter(Boolean).slice(0,2);return t?.length?t.join(`, `):e.hint}function pZ(e){let t=(0,Q.c)(24),{onSelect:n,onBrowseProviders:r,disabled:i,browseDisabled:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=D(mZ),l;t[0]===c?l=t[1]:(l=F(c),t[0]=c,t[1]=l);let u=l.onboarding.providerRecommended,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[2]=d):d=t[2];let{data:f}=gc(`onboarding-provider-meta`,mf,d),p;if(t[3]!==f||t[4]!==o||t[5]!==n||t[6]!==u){let e=dZ(f,tu());p=e?(0,$.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>n(e.id),className:`group flex w-full items-center gap-3.5 rounded-xl border border-accent/30 bg-accent-soft/45 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-accent/55 hover:bg-accent-soft/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-base/70`,children:(0,$.jsx)(sZ,{providerId:e.id,className:`size-7`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-on-accent`,children:u})]}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:fZ(e)})]}),(0,$.jsx)(br,{className:`size-4.5 shrink-0 text-accent-fg/80`,"aria-hidden":!0})]}):null,t[3]=f,t[4]=o,t[5]=n,t[6]=u,t[7]=p}else p=t[7];let m=o||s,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-panel text-fg-muted`,children:(0,$.jsx)(la,{className:`size-5`,"aria-hidden":!0})}),t[8]=h):h=t[8];let g=c===`zh`?`连接我自己的模型服务`:`Connect my own model service`,_;t[9]===g?_=t[10]:(_=(0,$.jsx)(`span`,{className:`block text-base font-semibold text-fg`,children:g}),t[9]=g,t[10]=_);let v=s&&!o?c===`zh`?`正在加载可用的模型服务…`:`Loading available model services…`:c===`zh`?`使用自己的账号、API Key、本地模型或私有接口。`:`Use your own account, API key, local model, or private endpoint.`,y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:v}),t[11]=v,t[12]=y);let b;t[13]!==y||t[14]!==_?(b=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[_,y]}),t[13]=y,t[14]=_,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(br,{className:`size-4.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[16]=x):x=t[16];let S;t[17]!==r||t[18]!==b||t[19]!==m?(S=(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:r,className:`mt-3 flex min-h-16 w-full items-center gap-3.5 rounded-xl border border-edge bg-surface-base/65 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-edge-strong hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[h,b,x]}),t[17]=r,t[18]=b,t[19]=m,t[20]=S):S=t[20];let C;return t[21]!==S||t[22]!==p?(C=(0,$.jsxs)(`div`,{children:[p,S]}),t[21]=S,t[22]=p,t[23]=C):C=t[23],C}function mZ(e){return e.language}var hZ={step:`callName`,selectedProvider:null,busy:!1,error:null,callName:``};function gZ(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`prefillCallName`:return e.callName.trim()?e:{...e,callName:t.value}}}var _Z=[`callName`,`provider`,`success`],vZ=e=>_Z.indexOf(e)+1;function yZ(e){let t=(0,Q.c)(5),{step:n,label:r}=e,i=vZ(n)-1,a;t[0]===i?a=t[1]:(a=_Z.map((e,t)=>(0,$.jsx)(`span`,{className:Y(`h-1.5 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none`,t===i?`w-5 bg-accent`:`w-1.5`,t<i?`bg-accent/45`:t>i?`bg-edge-strong`:void 0),"aria-hidden":!0},e)),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-label":r,children:a}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function bZ({onComplete:e,onDismiss:t,canDismiss:n=!0,onPendingChange:r}){let i=D(e=>e.language),a=D(e=>e.setLanguage),o=F(i).onboarding,[s,c]=(0,Z.useReducer)(gZ,hZ),[l,u]=(0,Z.useState)(!1),d=Ir(),f=tu(),p=(0,Z.useRef)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=m||d.cards.some(e=>e.id===`xopc-cloud`&&e.configured),{step:y,selectedProvider:b,busy:x,error:S,callName:C}=s;(0,Z.useEffect)(()=>(r?.(x),()=>r?.(!1)),[x,r]);let w=(0,Z.useMemo)(()=>o.stepOf.replace(`{{current}}`,String(vZ(y))).replace(`{{total}}`,String(_Z.length)),[o.stepOf,y]);(0,Z.useEffect)(()=>{let e=!1,t;return(async()=>{for(let n=0;n<3;n+=1)try{let{profile:t,suggestedCallName:n}=await nr();if(e)return;let r=t.callName.trim()||n?.trim();r&&c({type:`prefillCallName`,value:r});return}catch{n<2&&await new Promise(e=>{t=setTimeout(e,250*(n+1))})}})(),()=>{e=!0,t!==void 0&&clearTimeout(t)}},[]);let T=async()=>{let e=C.trim();c({type:`patch`,patch:{busy:!0,error:null}});try{await tr({...e?{callName:e}:{},timezone:rr(),locale:i===`zh`?`zh-CN`:`en-US`}),c({type:`patch`,patch:{step:`provider`}})}catch{c({type:`patch`,patch:{error:i===`zh`?`称呼暂未保存,可重试或稍后设置并继续连接模型。若登录已失效,请先重新连接本机服务。`:`Your name was not saved. Retry or set it later and continue to model setup. Reconnect the service if your sign-in has expired.`}})}finally{c({type:`patch`,patch:{busy:!1}})}},E=async()=>{if(!p.current){p.current=!0,c({type:`patch`,patch:{busy:!0,error:null}});try{let e={mode:`replace`},t=await Pr(`xopc-cloud`,e);if(!t.configured||!t.uses.find(e=>e.id===`chat`)?.recommended)throw Error(i===`zh`?`XOPC Cloud 尚未就绪,请稍后重试。`:`XOPC Cloud is not ready yet. Please retry.`);let n=t.uses.filter(e=>e.selected&&e.recommended).map(e=>e.id);await zr(`xopc-cloud`,{...e,selected:n},t.revision),_(t),c({type:`patch`,patch:{step:`success`}})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{p.current=!1,c({type:`patch`,patch:{busy:!1}})}}},O=async()=>{c({type:`patch`,patch:{busy:!0,error:null}});try{await e()}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{busy:!1}})}};return(0,$.jsxs)(`div`,{className:`xopc-onboarding-experience relative flex h-full min-h-0 w-full flex-col overflow-hidden`,"data-step":y,children:[(0,$.jsx)(`header`,{className:`relative z-20 flex h-18 shrink-0 items-center justify-end px-5 sm:px-8 lg:px-10`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ZX,{value:i,onChange:e=>{c({type:`patch`,patch:{error:null}}),a(e)}}),n?(0,$.jsx)(`button`,{type:`button`,"aria-label":o.skipSetup,disabled:x,className:`inline-flex size-10 items-center justify-center rounded-xl text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:t,children:(0,$.jsx)(ds,{className:`size-4`,"aria-hidden":!0})}):null]})}),(0,$.jsxs)(`main`,{className:`xopc-onboarding-scroll relative z-10 grid min-h-0 flex-1 overflow-y-auto lg:grid-cols-[minmax(18rem,0.8fr)_minmax(30rem,1.2fr)]`,children:[(0,$.jsx)(`section`,{className:`xopc-onboarding-visual relative hidden min-h-0 items-center justify-center overflow-hidden lg:flex`,children:(0,$.jsx)(Pu,{className:`size-72 text-fg-muted`,interactive:!0,language:i,mood:S?`care`:x?`work`:y===`success`?`done`:y===`callName`?`listen`:`decision`})}),(0,$.jsx)(`section`,{className:`app-main-surface xopc-onboarding-scroll flex min-h-[30rem] items-center overflow-y-auto bg-surface-panel px-5 py-8 sm:px-10 lg:min-h-0 lg:px-[clamp(3rem,6vw,6rem)]`,children:(0,$.jsxs)(`div`,{className:`xopc-onboarding-stage w-full max-w-[30rem]`,children:[(0,$.jsx)(`div`,{className:`mb-3 lg:hidden`,children:(0,$.jsx)(Pu,{className:`size-20`,mood:S?`care`:x?`work`:y===`success`?`done`:`listen`})}),y===`callName`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:o.title}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:o.step0Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:o.step0Subtitle}),(0,$.jsxs)(`label`,{className:`mt-9 block`,children:[(0,$.jsxs)(`span`,{className:`mb-2 flex items-center justify-between text-[13px] font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:o.profileCallNameLabel}),(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i===`zh`?`可选`:`Optional`})]}),(0,$.jsx)(`input`,{autoFocus:!0,autoComplete:`name`,value:C,onChange:e=>c({type:`patch`,patch:{callName:e.target.value}}),onKeyDown:e=>{e.key===`Enter`&&!x&&T()},placeholder:o.profileCallNamePlaceholder,className:`h-12 w-full rounded-xl border border-edge bg-surface-base/80 px-3.5 text-[15px] text-fg outline-none transition-[border-color,box-shadow,background-color] duration-200 placeholder:text-fg-subtle hover:border-edge-strong focus:border-accent focus:bg-surface-base focus:ring-4 focus:ring-accent/10 motion-reduce:transition-none`})]}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(yZ,{step:y,label:w}),(0,$.jsx)(X,{variant:`ghost`,disabled:x,onClick:()=>c({type:`patch`,patch:{step:`provider`,error:null}}),children:i===`zh`?`稍后设置称呼`:`Set name later`}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void T(),children:[x?(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,x?o.savingProfile:o.continue,x?null:(0,$.jsx)(br,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,y===`provider`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:f?`XOPC Cloud`:i===`zh`?`模型设置`:`Model setup`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:f?i===`zh`?`连接 XOPC Cloud`:`Connect XOPC Cloud`:o.step1Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:f?i===`zh`?`登录后自动配置聊天、图片、语音和任务模型,开启可用能力。电脑操作默认关闭,无需 API Key。`:`Sign in to set up chat, image, voice, and task models and enable available capabilities. Computer control stays off by default. No API key required.`:o.step1Subtitle}),(0,$.jsx)(`div`,{className:`mt-8`,children:f?(0,$.jsx)(`fieldset`,{disabled:x,className:`min-w-0`,children:(0,$.jsx)(_f,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:v,onConnected:()=>{h(!0),E()}})}):(0,$.jsx)(pZ,{onSelect:e=>{c({type:`patch`,patch:{selectedProvider:e,error:null}}),u(!0)},onBrowseProviders:()=>{c({type:`patch`,patch:{selectedProvider:null}}),u(!0)},disabled:x,browseDisabled:d.loading})}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-8`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`justify-self-start`,disabled:x,onClick:()=>c({type:`patch`,patch:{step:`callName`,error:null}}),children:o.back}),(0,$.jsx)(yZ,{step:y,label:w}),f&&v?(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void E(),children:[x?(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S?i===`zh`?`重试`:`Retry`:o.continue]}):(0,$.jsx)(`span`,{})]})]}):null,y===`success`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,$.jsx)(Nr,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium tracking-wide text-accent-fg`,children:i===`zh`?`模型设置完成`:`Model setup complete`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:i===`zh`?`一切准备好了`:`You’re ready to go`}),(0,$.jsxs)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:[g?i===`zh`?`已配置并开启账号可用的模型能力,电脑操作默认关闭。`:`Available model capabilities are configured and enabled. Computer control stays off by default.`:i===`zh`?`模型服务配置已保存,可以开始对话。`:`Model service settings are saved. You can start a conversation.`,g?.uses.some(e=>!e.selected)?i===`zh`?` 部分能力暂无可用模型,可稍后在模型设置中查看。`:` Some capabilities have no available model. Review them in Model settings.`:null]}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(yZ,{step:y,label:w}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void O(),children:[x?(0,$.jsx)(_a,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,i===`zh`?`开始使用 XOPC`:`Start using XOPC`,x?null:(0,$.jsx)(br,{className:`size-4`,"aria-hidden":!0})]})]})]}):null]},y)})]}),f?null:(0,$.jsx)(Lr,{open:l,initialProviderId:b??void 0,onOpenChange:u,builtinRows:d.builtinRows,customConfig:d.customConfig,labels:F(i).capabilitiesSettings.addProviderDialog,language:i,onSaved:e=>{if(e===`xopc-cloud`){u(!1),E();return}u(!1),c({type:`patch`,patch:{step:`success`,error:null}})}})]})}function xZ(e){return e?.enabled===!0&&(e.state.status===`not_started`||e.state.status===`in_progress`)}function SZ(e){let t=!e.settingsRoute&&e.modelSetupReady&&e.needsModelSetup&&!e.modelGuideDismissed,n=e.cloudOnboardingReady&&e.cloudOnboardingPending&&(!e.desktop||e.modelSetupReady)&&!(e.desktop&&t),r=t&&!n,i=!n&&!e.settingsRoute&&e.modelSetupReady&&!e.needsModelSetup&&xZ(e.workDiscovery);return{open:e.authenticated&&!e.closed&&(r||n||i),stage:n?`cloud`:r?`setup`:`work`}}function CZ(e){if(!e||typeof e!=`object`||Array.isArray(e))return!0;let t=e.agents;if(!t)return!0;let n=t.defaults?.models?.chat?.primary?.trim()??``;return!((t.list?.find(e=>e.enabled!==!1&&e.id===t.default))?.models?.chat?.primary?.trim()||n)}function wZ(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=CZ(a),c=!Array.isArray(o)||o.length===0;return s||c}function TZ(e){let t=(0,Q.c)(21),[n,r]=(0,Z.useState)(EZ),{data:i,error:a,isLoading:o,mutate:s}=Sc(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}=gc(e?Kc:null,Gc,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=wZ({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 v=_,y,b;t[11]!==e||t[12]!==f?(y=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},b=[e,f],t[11]=e,t[12]=f,t[13]=y,t[14]=b):(y=t[13],b=t[14]),(0,Z.useEffect)(y,b);let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{try{localStorage.setItem(gf,`1`)}catch{}r(!0)},t[15]=x):x=t[15];let S=x,C;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==v?(C={needsSetup:g,ready:p,refresh:v,guideDismissed:n,dismissPermanently:S},t[16]=n,t[17]=g,t[18]=p,t[19]=v,t[20]=C):C=t[20],C}function EZ(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}var DZ=hf;async function OZ(){let e=await S(T(DZ));if(!e.ok)throw Error(`Cloud onboarding: ${e.status}`);return(await e.json()).payload}function kZ(e){let t=(0,Q.c)(9),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!1},t[0]=n):n=t[0];let{data:r,error:i,mutate:a}=gc(e?DZ:null,OZ,n),o=!!r&&!i,s=r?.status===`unseen`&&!r.hasGrant,c,l;t[1]===a?(c=t[2],l=t[3]):(c=()=>a(),l=async()=>{let e=await S(T(DZ),{method:`PUT`});if(!e.ok)throw Error(`Cloud onboarding dismissal: ${e.status}`);await a({status:`dismissed`,hasGrant:!1},{revalidate:!1})},t[1]=a,t[2]=c,t[3]=l);let u;return t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l?(u={ready:o,pending:s,refresh:c,dismiss:l},t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8],u}function AZ({context:e,onDismiss:t,onConnected:n}){let r=D(e=>e.language)===`zh`,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),u=e===`chat`?r?`为对话连接更多模型`:`Connect more models for chat`:e===`personal`?r?`为个人 Agent 一次配好模型`:`Set up models for your personal agent`:r?`连接 XOPC Cloud,省去逐个配置模型`:`Connect XOPC Cloud to simplify model setup`,d=e===`chat`?r?`连接 XOPC Cloud 后,此账号可用的聊天、图片和语音模型会自动同步。你可以继续使用当前聊天模型,稍后再切换。`:`Connect XOPC Cloud to sync the chat, image, and voice models available to your account. You can keep using your current chat model and switch later.`:e===`personal`?r?`连接一次即可为个人 Agent 准备此账号可用的聊天、图片和语音模型。已有模型和明确设置不会改变。`:`Connect once to make the chat, image, and voice models available to your personal agent. Your current model and explicit settings stay in place.`:r?`授权后会同步此账号可用的聊天、图片和语音等模型。已有的默认聊天模型及明确设置保持不变,之后可自行切换。`:`Authorize once to sync the chat, image, and voice models available to your account. Your current default chat model and explicit settings stay in place.`,f=async()=>{a(!0);try{let e=await S(T(`/api/models/catalog`));if(!e.ok)throw Error(`Readiness unavailable`);let t=(await e.json()).payload.sources[`xopc-cloud`]?.models.filter(e=>e.availability===`available`)??[],n=new Set(t.map(e=>e.kind));s([...n.has(`language`)?[r?`聊天`:`chat`]:[],...t.some(e=>e.kind===`language`&&e.input.includes(`image`))?[r?`视觉理解`:`vision`]:[],...n.has(`image`)?[r?`图片生成`:`image generation`]:[],...n.has(`stt`)?[r?`语音识别`:`speech recognition`]:[],...n.has(`tts`)?[r?`语音合成`:`speech synthesis`]:[]]),l(t.length===0)}catch{l(!0)}};return(0,$.jsx)(`div`,{className:`p-5 sm:p-6`,children:(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)($r,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,"aria-label":i?r?`继续`:`Continue`:r?`暂时不用`:`Maybe later`,onClick:i?n:t,children:(0,$.jsx)(ds,{className:`size-4`})})]}),(0,$.jsx)(`h1`,{className:`mt-6 text-2xl font-semibold text-fg`,children:i?r?`XOPC Cloud 已连接`:`XOPC Cloud is connected`:u}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:i?c?r?`授权已完成,模型目录暂不可用。稍后可在模型设置中刷新。`:`Authorization completed, but the model catalog is temporarily unavailable. Refresh it later in model settings.`:r?`已同步可用能力:${o.join(`、`)||`模型目录`}。你可以稍后在模型设置中选择默认模型。`:`Available capabilities: ${o.join(`, `)||`model catalog`}. You can choose a default model later in model settings.`:d}),i?(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-7`,onClick:n,children:r?`继续聊天`:`Continue to chat`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-7`,children:(0,$.jsx)(_f,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:!1,onConnected:()=>void f()})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`mt-5`,onClick:t,children:r?`暂时不用,继续使用现有模型`:`Maybe later, keep using my current model`})]})]})})}function jZ(){let e=(0,Q.c)(75),t=E(BZ),n=D(zZ),r;e[0]===n?r=e[1]:(r=F(n),e[0]=n,e[1]=r);let i=r,{pathname:a}=m(),o=x(),s=TZ(!!t),c=kZ(!!t),l=a.startsWith(`/settings`)||a===`/personal`,[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),y;e[2]!==p||e[3]!==g||e[4]!==d||e[5]!==t?(y=()=>{if(p(!1),g(!1),!t){d(null);return}let e=!1;return Ci().then(t=>{e||d(t)}).catch(RZ),()=>{e=!0}},e[2]=p,e[3]=g,e[4]=d,e[5]=t,e[6]=y):y=e[6];let b;e[7]===t?b=e[8]:(b=[t],e[7]=t,e[8]=b),(0,Z.useEffect)(y,b);let S=SZ({authenticated:!!t,desktop:tu(),settingsRoute:l,modelSetupReady:s.ready,needsModelSetup:s.needsSetup||h,modelGuideDismissed:s.guideDismissed,cloudOnboardingReady:c.ready,cloudOnboardingPending:c.pending,workDiscovery:u,closed:f}),C;e[9]!==S.open||e[10]!==S.stage||e[11]!==g?(C=()=>{S.open&&S.stage===`setup`&&g(!0)},e[9]=S.open,e[10]=S.stage,e[11]=g,e[12]=C):C=e[12];let w;e[13]!==S.open||e[14]!==S.stage?(w=[S.open,S.stage],e[13]=S.open,e[14]=S.stage,e[15]=w):w=e[15],(0,Z.useEffect)(C,w);let T;e[16]!==p||e[17]!==g?(T=()=>{g(!1),p(!0)},e[16]=p,e[17]=g,e[18]=T):T=e[18];let O=T,k;e[19]!==O||e[20]!==o?(k=()=>{O(),o(`/chat`)},e[19]=O,e[20]=o,e[21]=k):k=e[21];let A=k,j;e[22]!==O||e[23]!==s?(j=()=>{O(),s.dismissPermanently(),wi().catch(LZ)},e[22]=O,e[23]=s,e[24]=j):j=e[24];let M=j,N;e[25]!==O||e[26]!==c||e[27]!==s.needsSetup||e[28]!==s.ready||e[29]!==u?(N=async()=>{await c.dismiss(),s.ready&&!s.needsSetup&&!xZ(u)&&O()},e[25]=O,e[26]=c,e[27]=s.needsSetup,e[28]=s.ready,e[29]=u,e[30]=N):N=e[30];let P=N,I=S.stage!==`cloud`,L=S.open,z;e[31]!==O||e[32]!==P||e[33]!==M||e[34]!==S.stage||e[35]!==A||e[36]!==_?(z=e=>{e||(S.stage===`setup`?_||M():S.stage===`cloud`?P().catch(O):A())},e[31]=O,e[32]=P,e[33]=M,e[34]=S.stage,e[35]=A,e[36]=_,e[37]=z):z=e[37];let V;e[38]===S.stage?V=e[39]:(V=S.stage===`cloud`?null:(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[55] bg-scrim backdrop-blur-md`}),e[38]=S.stage,e[39]=V);let U=S.stage===`cloud`?`bottom-4 right-4 max-h-[calc(100vh-2rem)] w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay shadow-xl`:`xopc-onboarding-dialog inset-0 overflow-hidden`,re;e[40]===U?re=e[41]:(re=Y(`app-chrome-shell fixed z-[56] outline-none`,U),e[40]=U,e[41]=re);let W;e[42]!==S.stage||e[43]!==_?(W=e=>{S.stage===`setup`&&_&&e.preventDefault()},e[42]=S.stage,e[43]=_,e[44]=W):W=e[44];let ie;e[45]===i.onboarding.title?ie=e[46]:(ie=(0,$.jsx)(te,{className:`sr-only`,children:i.onboarding.title}),e[45]=i.onboarding.title,e[46]=ie);let G;e[47]===i.onboarding.subtitle?G=e[48]:(G=(0,$.jsx)(B,{className:`sr-only`,children:i.onboarding.subtitle}),e[47]=i.onboarding.subtitle,e[48]=G);let K;e[49]!==O||e[50]!==c||e[51]!==P||e[52]!==M||e[53]!==S.stage||e[54]!==A||e[55]!==s||e[56]!==a||e[57]!==g||e[58]!==v||e[59]!==d?(K=S.stage===`setup`?(0,$.jsx)(bZ,{onComplete:async()=>{let e=await Ci().catch(PZ);d(e),await s.refresh();let t=await c.refresh().catch(NZ),n=t?.status===`unseen`&&!t.hasGrant;tu()&&n&&(await c.dismiss().catch(MZ),n=!1),g(!1),!xZ(e)&&!n&&A()},onPendingChange:v,onDismiss:M,canDismiss:!0}):S.stage===`cloud`?(0,$.jsx)(AZ,{context:a.startsWith(`/chat`)?`chat`:a===`/personal`?`personal`:`general`,onDismiss:()=>void P().catch(O),onConnected:()=>{c.refresh().catch(O)}}):(0,$.jsx)(`div`,{className:`xopc-onboarding-work-stage h-full overflow-hidden`,children:(0,$.jsx)(pn,{embedded:!0,onRequestClose:A,onNavigateAway:O})}),e[49]=O,e[50]=c,e[51]=P,e[52]=M,e[53]=S.stage,e[54]=A,e[55]=s,e[56]=a,e[57]=g,e[58]=v,e[59]=d,e[60]=K):K=e[60];let ae;e[61]!==re||e[62]!==W||e[63]!==ie||e[64]!==G||e[65]!==K?(ae=(0,$.jsxs)(ee,{className:re,onEscapeKeyDown:W,onPointerDownOutside:IZ,onOpenAutoFocus:FZ,children:[ie,G,K]}),e[61]=re,e[62]=W,e[63]=ie,e[64]=G,e[65]=K,e[66]=ae):ae=e[66];let q;e[67]!==V||e[68]!==ae?(q=(0,$.jsxs)(H,{children:[V,ae]}),e[67]=V,e[68]=ae,e[69]=q):q=e[69];let oe;return e[70]!==S.open||e[71]!==z||e[72]!==q||e[73]!==I?(oe=(0,$.jsx)(ne,{modal:I,open:L,onOpenChange:z,children:q}),e[70]=S.open,e[71]=z,e[72]=q,e[73]=I,e[74]=oe):oe=e[74],oe}function MZ(){}function NZ(){return null}function PZ(){return null}function FZ(e){return e.preventDefault()}function IZ(e){return e.preventDefault()}function LZ(){}function RZ(){}function zZ(e){return e.language}function BZ(e){return e.conversationId}function VZ(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=r),r}function HZ(){let e=(0,Q.c)(3),t=ir(WZ),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=UZ;e();let n=window.setInterval(e,t?1500:3e4);return window.addEventListener(`understanding-refresh-updated`,e),window.addEventListener(`focus`,e),()=>{window.clearInterval(n),window.removeEventListener(`understanding-refresh-updated`,e),window.removeEventListener(`focus`,e)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function UZ(){ir.getState().poll()}function WZ(e){return e.sources.some(GZ)}function GZ(e){return e.status===`queued`||e.status===`running`}var KZ=new Set([`queued`,`probing`,`analyzing`]),qZ=[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`];function JZ(){let e=(0,Q.c)(7),t=Oi(nQ),n=Oi(tQ),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[0]=r):r=e[0],(0,Z.useEffect)($Z,r);let i,a;e[1]!==t||e[2]!==n?(i=()=>{if(!t||!n||!KZ.has(n))return;let e=!1,r=async()=>{try{let n=await Ei(t);e||Oi.getState().updateDirectoryRun(n)}catch{}};r();let i=window.setInterval(()=>void r(),1200);return()=>{e=!0,window.clearInterval(i)}},a=[t,n],e[1]=t,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),(0,Z.useEffect)(i,a);let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],e[5]=o):o=e[5],(0,Z.useEffect)(YZ,o);let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(HZ,{}),e[6]=s):s=e[6],s}function YZ(){let e=XZ;for(let t of qZ)window.addEventListener(t,e);return()=>{for(let t of qZ)window.removeEventListener(t,e)}}function XZ(e){let t=e.detail?.runId;t&&Ei(t).then(QZ).catch(ZZ)}function ZZ(){}function QZ(e){return Oi.getState().updateDirectoryRun(e)}function $Z(){let e=!1;return Ci().then(async t=>{let{state:n}=t;if(n.status!==`in_progress`||!n.activeRunId)return;let r=await Ei(n.activeRunId);e||Oi.getState().updateDirectoryRun(r)}).catch(eQ),()=>{e=!0}}function eQ(){}function tQ(e){return e.directoryRun?.status}function nQ(e){return e.directoryRun?.id}var rQ=`workDiscovery`;function iQ(e){return new URLSearchParams(e).get(rQ)===`new`}function aQ(e){let t=new URLSearchParams(e);t.delete(rQ);let n=t.toString();return n?`?${n}`:``}var oQ=`settingsBackPath`;function sQ(e){if(!e||typeof e!=`object`)return`/chat`;let t=e[oQ];if(typeof t!=`string`)return`/chat`;let n=t.trim();return!n.startsWith(`/`)||n.startsWith(`//`)||/^\/settings(?:[/?#]|$)/u.test(n)?`/chat`:n}function cQ(){let e=(0,Q.c)(9),t=m(),n=x(),r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a;e[0]!==t.hash||e[1]!==t.pathname||e[2]!==t.search||e[3]!==t.state||e[4]!==n?(a=()=>{if(!/^\/settings(?:\/|$)/u.test(t.pathname)){r.current=`${t.pathname}${t.search}${t.hash}`,i.current=null;return}let e=t.state&&typeof t.state==`object`?t.state:{},a=e[oQ],o=typeof a==`string`&&a.trim()===sQ(e)?a.trim():void 0,s=o??i.current??r.current??(t.pathname===`/settings/personal`?`/personal`:`/chat`);i.current=s,o!==s&&n({pathname:t.pathname,search:t.search,hash:t.hash},{replace:!0,state:{...e,[oQ]:s}})},e[0]=t.hash,e[1]=t.pathname,e[2]=t.search,e[3]=t.state,e[4]=n,e[5]=a):a=e[5];let o;e[6]!==t||e[7]!==n?(o=[t,n],e[6]=t,e[7]=n,e[8]=o):o=e[8],(0,Z.useEffect)(a,o)}var lQ=(0,Z.lazy)(()=>cu().then(e=>({default:e.WorkDiscoveryOverlay})));function uQ(){let e=(0,Q.c)(3),t=x(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.conversationId&&t(`/chat/${encodeURIComponent(n.conversationId)}`)};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,Z.useEffect)(n,r),null}function dQ(){let e=(0,Q.c)(3),t=x(),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,Z.useEffect)(n,r),null}function fQ(){let e=(0,Q.c)(8),t=E(mQ),n=`${E(pQ)}:${t??``}`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(hQ,{}),e[0]=r):r=e[0];let i;e[1]===t?i=e[2]:(i=t?(0,$.jsx)(PX,{}):null,e[1]=t,e[2]=i);let a;e[3]===i?a=e[4]:(a=(0,$.jsxs)(qe,{children:[r,i]}),e[3]=i,e[4]=a);let o;return e[5]!==n||e[6]!==a?(o=(0,$.jsx)(gV,{children:a},n),e[5]=n,e[6]=a,e[7]=o):o=e[7],o}function pQ(e){return e.baseUrl}function mQ(e){return e.conversationId}function hQ(){let e=(0,Q.c)(168);cQ();let t=E(yQ),{pathname:n,search:r,state:i}=m(),a=x(),o;e[0]===n?o=e[1]:(o=n.startsWith(`/settings`),e[0]=n,e[1]=o);let s=o,c=n===`/onboarding/workspace`,l=D(vQ),u=xH(),d=se(_Q),[f,h]=(0,Z.useState)(0),g=aB(n),{profile:_}=Vu(n===`/personal`),v;e[2]!==n||e[3]!==r?(v=n===`/user-model`&&iQ(r),e[2]=n,e[3]=r,e[4]=v):v=e[4];let y=v,b;e[5]!==n||e[6]!==r?(b=n.startsWith(`/tasks/`)?null:new URLSearchParams(r).get(ka),e[5]=n,e[6]=r,e[7]=b):b=e[7];let S=b,C=i?.taskPreview,w;e[8]!==g||e[9]!==n||e[10]!==_?.conversationId||e[11]!==S||e[12]!==d?(w=S&&d?d:n===`/personal`?_?.conversationId??`new`:g??(n.startsWith(`/chat`)?`new`:d??`new`),e[8]=g,e[9]=n,e[10]=_?.conversationId,e[11]=S,e[12]=d,e[13]=w):w=e[13];let T=w,O;e[14]!==n||e[15]!==T?(O=e=>{if(n!==`/personal`)return!1;let t=e.panes[T],r=t?.tabs.find(e=>e.id===t.activeId);return!!(t?.open&&t.personalDetailsOpen&&(r?.kind===`file`||r?.kind===`browser`))},e[14]=n,e[15]=T,e[16]=O):O=e[16];let k=tl(O),A;if(e[17]!==n||e[18]!==r||e[19]!==S){let t=Da(n)?new URLSearchParams(r).get(ba):null;A=t&&!S?ya(t):null,e[17]=n,e[18]=r,e[19]=S,e[20]=A}else A=e[20];let j=A,M;e[21]!==n||e[22]!==r?(M=Aa(n,r),e[21]=n,e[22]=r,e[23]=M):M=e[23];let N=M,P;e[24]!==n||e[25]!==j||e[26]!==r||e[27]!==S?(P=!S&&!j&&Da(n)?new URLSearchParams(r).get(wa):null,e[24]=n,e[25]=j,e[26]=r,e[27]=S,e[28]=P):P=e[28];let F=P,I;e[29]!==n||e[30]!==r?(I=Ea(n,r),e[29]=n,e[30]=r,e[31]=I):I=e[31];let L=I,R;e[32]!==n||e[33]!==r?(R=Ta(n,r),e[32]=n,e[33]=r,e[34]=R):R=e[34];let z=R,[B,V]=(0,Z.useState)(y),H,ee;e[35]===y?(H=e[36],ee=e[37]):(H=()=>{y&&V(!0)},ee=[y],e[35]=y,e[36]=H,e[37]=ee),(0,Z.useEffect)(H,ee);let te;e[38]!==a||e[39]!==n||e[40]!==r?(te=()=>{a({pathname:n,search:aQ(r)},{replace:!0})},e[38]=a,e[39]=n,e[40]=r,e[41]=te):te=e[41];let ne=te,U;e[42]!==ne||e[43]!==y?(U=()=>{V(!1),y&&ne(),window.requestAnimationFrame(gQ)},e[42]=ne,e[43]=y,e[44]=U):U=e[44];let re=U,W;e[45]!==a||e[46]!==z?(W=()=>{a(z,{replace:!0})},e[45]=a,e[46]=z,e[47]=W):W=e[47];let ie=W;if(!t){let t=l===`zh`?`跳到主要内容`:`Skip to main content`,n;e[48]===t?n=e[49]:(n=(0,$.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:t}),e[48]=t,e[49]=n);let r,i,a;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(gK,{}),i=(0,$.jsx)(wq,{}),a=(0,$.jsx)(_B,{}),e[50]=r,e[51]=i,e[52]=a):(r=e[50],i=e[51],a=e[52]);let o;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(yV,{})}),e[53]=o):o=e[53];let s;return e[54]===n?s=e[55]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[n,r,i,a,o]}),e[54]=n,e[55]=s),s}let G;e[56]===n?G=e[57]:(G=n.split(`/`)[1]||`root`,e[56]=n,e[57]=G);let K=G,ae=K===`chat`||K===`notes`||K===`space`||K===`personal`||K===`automations`;if(c){let t,n,r,i,a,o,s,c;e[58]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Cq,{}),n=(0,$.jsx)($Y,{}),r=(0,$.jsx)(JZ,{}),i=(0,$.jsx)(pX,{}),a=(0,$.jsx)(wq,{}),o=(0,$.jsx)(_B,{}),s=(0,$.jsx)(gK,{}),c=_d()?(0,$.jsx)(`div`,{className:Y(`w-full`,Il,Pl),"aria-hidden":`true`}):null,e[58]=t,e[59]=n,e[60]=r,e[61]=i,e[62]=a,e[63]=o,e[64]=s,e[65]=c):(t=e[58],n=e[59],r=e[60],i=e[61],a=e[62],o=e[63],s=e[64],c=e[65]);let l;return e[66]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[t,n,r,i,a,o,s,c,(0,$.jsx)(`main`,{id:`app-main-content`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,$.jsx)(p,{})})]}),e[66]=l):l=e[66],l}let q;e[67]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(Cq,{}),e[67]=q):q=e[67];let oe=l===`zh`?`跳到主要内容`:`Skip to main content`,ce;e[68]===oe?ce=e[69]:(ce=(0,$.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:oe}),e[68]=oe,e[69]=ce);let le,ue,de,J,fe,pe,me,he,ge;e[70]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)($Y,{}),ue=(0,$.jsx)(JZ,{}),de=(0,$.jsx)(pX,{}),J=(0,$.jsx)(wq,{}),fe=(0,$.jsx)(_B,{}),pe=(0,$.jsx)(uQ,{}),me=(0,$.jsx)(dQ,{}),he=(0,$.jsx)(TJ,{}),ge=(0,$.jsx)(PJ,{}),e[70]=le,e[71]=ue,e[72]=de,e[73]=J,e[74]=fe,e[75]=pe,e[76]=me,e[77]=he,e[78]=ge):(le=e[70],ue=e[71],de=e[72],J=e[73],fe=e[74],pe=e[75],me=e[76],he=e[77],ge=e[78]);let _e=T===g?g:null,ve;e[79]===_e?ve=e[80]:(ve=(0,$.jsx)(lV,{conversationId:_e}),e[79]=_e,e[80]=ve);let ye,be,xe,Se;e[81]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(IY,{}),be=(0,$.jsx)(BJ,{}),xe=(0,$.jsx)(DX,{}),Se=(0,$.jsx)(zX,{}),e[81]=ye,e[82]=be,e[83]=xe,e[84]=Se):(ye=e[81],be=e[82],xe=e[83],Se=e[84]);let Ce;e[85]===g?Ce=e[86]:(Ce=(0,$.jsx)(QG,{conversationId:g}),e[85]=g,e[86]=Ce);let we;e[87]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,$.jsx)(iK,{}),e[87]=we):we=e[87];let Te;e[88]===n?Te=e[89]:(Te=!n.startsWith(`/mcp-setup/`)&&!n.startsWith(`/configuration/`)?(0,$.jsx)(jZ,{}):null,e[88]=n,e[89]=Te);let Ee;e[90]!==a||e[91]!==N||e[92]!==j?(Ee=j?(0,$.jsx)(uf,{target:j,backgroundPath:N,onClose:()=>a(N,{replace:!0})}):null,e[90]=a,e[91]=N,e[92]=j,e[93]=Ee):Ee=e[93];let De;e[94]!==a||e[95]!==L||e[96]!==F?(De=F?(0,$.jsx)(OJ,{noteId:F,backgroundPath:L,onClose:()=>a(L,{replace:!0})}):null,e[94]=a,e[95]=L,e[96]=F,e[97]=De):De=e[97];let Oe;e[98]!==ie||e[99]!==z||e[100]!==S||e[101]!==C||e[102]!==f?(Oe=S?(0,$.jsx)(GX,{taskId:S,initialTitle:C?.id===S?C.title:void 0,backgroundPath:z,workspacePanelWidth:f,onClose:ie}):null,e[98]=ie,e[99]=z,e[100]=S,e[101]=C,e[102]=f,e[103]=Oe):Oe=e[103];let ke;e[104]!==re||e[105]!==y||e[106]!==B?(ke=B?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(lQ,{requestedOpen:y,onExited:re})}):null,e[104]=re,e[105]=y,e[106]=B,e[107]=ke):ke=e[107];let Ae;e[108]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(gK,{}),e[108]=Ae):Ae=e[108];let je;e[109]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,$.jsx)(vK,{}),e[109]=je):je=e[109];let Me;e[110]===u?Me=e[111]:(Me=(0,$.jsx)(Pq,{reminder:u}),e[110]=u,e[111]=Me);let Ne;e[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(Aq,{}),e[112]=Ne):Ne=e[112];let Pe;e[113]===Me?Pe=e[114]:(Pe=(0,$.jsxs)(VZ,{children:[je,Me,Ne]}),e[113]=Me,e[114]=Pe);let Fe;e[115]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(fW,{}),e[115]=Fe):Fe=e[115];let Ie=K===`personal`&&`@container/personal-chat`,Le;e[116]===Ie?Le=e[117]:(Le=Y(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,Ie),e[116]=Ie,e[117]=Le);let Re=K===`chat`||K===`personal`?``:void 0,ze;e[118]===s?ze=e[119]:(ze=s?null:(0,$.jsx)(XV,{}),e[118]=s,e[119]=ze);let Be=n===`/`?``:void 0,Ve=n===`/`?`bg-surface-base`:`bg-surface-panel`,He=K!==`settings`&&K!==`chat`&&`page-enter`,Ue=K===`settings`||ae?`overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`,We;e[120]!==Ve||e[121]!==He||e[122]!==Ue?(We=Y(`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden`,Ve,He,Ue),e[120]=Ve,e[121]=He,e[122]=Ue,e[123]=We):We=e[123];let Ge;e[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,$.jsx)(p,{}),e[124]=Ge):Ge=e[124];let Ke;e[125]!==K||e[126]!==Be||e[127]!==We?(Ke=(0,$.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(`div`,{"data-workbench-page-scroll":Be,className:We,children:Ge},K)}),e[125]=K,e[126]=Be,e[127]=We,e[128]=Ke):Ke=e[128];let qe;e[129]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,$.jsx)(AX,{}),e[129]=qe):qe=e[129];let Je;e[130]!==s||e[131]!==n?(Je=!s&&!n.startsWith(`/chat`)?(0,$.jsx)(wB,{}):null,e[130]=s,e[131]=n,e[132]=Je):Je=e[132];let Ye;e[133]!==k||e[134]!==Le||e[135]!==Re||e[136]!==ze||e[137]!==Ke||e[138]!==Je?(Ye=(0,$.jsxs)(`div`,{className:Le,inert:k,"data-app-chat-shell":Re,children:[ze,Ke,qe,Je]}),e[133]=k,e[134]=Le,e[135]=Re,e[136]=ze,e[137]=Ke,e[138]=Je,e[139]=Ye):Ye=e[139];let Xe;e[140]!==s||e[141]!==n||e[142]!==S||e[143]!==d?(Xe=!s&&(n.startsWith(`/chat`)||n===`/personal`||n===`/automations`&&!!d||(!!S||n.startsWith(`/tasks/`))&&!!d),e[140]=s,e[141]=n,e[142]=S,e[143]=d,e[144]=Xe):Xe=e[144];let Ze=!!S,Qe;e[145]!==Xe||e[146]!==Ze||e[147]!==T?(Qe=(0,$.jsx)(qG,{scope:T,onDockedWidthChange:h,enabled:Xe,elevated:Ze}),e[145]=Xe,e[146]=Ze,e[147]=T,e[148]=Qe):Qe=e[148];let $e;e[149]!==Ye||e[150]!==Qe?($e=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[Fe,(0,$.jsx)(`div`,{className:`app-main-surface relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[Ye,Qe]})})]}),e[149]=Ye,e[150]=Qe,e[151]=$e):$e=e[151];let et;e[152]!==Pe||e[153]!==$e?(et=(0,$.jsxs)(`div`,{className:`app-chrome-shell flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Ae,Pe,$e]}),e[152]=Pe,e[153]=$e,e[154]=et):et=e[154];let tt;e[155]!==et||e[156]!==T?(tt=(0,$.jsx)(Ui.Provider,{value:T,children:et}),e[155]=et,e[156]=T,e[157]=tt):tt=e[157];let nt;return e[158]!==ce||e[159]!==ve||e[160]!==Ce||e[161]!==Te||e[162]!==Ee||e[163]!==De||e[164]!==Oe||e[165]!==ke||e[166]!==tt?(nt=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[q,ce,le,ue,de,J,fe,pe,me,he,ge,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,tt]}),e[158]=ce,e[159]=ve,e[160]=Ce,e[161]=Te,e[162]=Ee,e[163]=De,e[164]=Oe,e[165]=ke,e[166]=tt,e[167]=nt):nt=e[167],nt}function gQ(){document.querySelector(`[data-work-discovery-trigger]`)?.focus({preventScroll:!0})}function _Q(e){return e.conversationIdOverride}function vQ(e){return e.language}function yQ(e){return e.conversationId}var bQ={en:`https://xopc.ai/en#download`,zh:`https://xopc.ai/zh#download`};function xQ(e){if(e instanceof Error)return e.stack||e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function SQ(e=A()){return bQ[e]}function CQ(){let e=window.location.hash.replace(/^#\/?/,``).split(/[/?]/,1)[0];return`${window.location.origin}${window.location.pathname}${e?`#/${e}`:``}`}function wQ({error:e,source:t,componentStack:n,capturedAt:r=new Date}){let i=window.electronAPI?`Electron desktop app`:`Gateway web UI`,a=window.electronAPI?.platform??navigator.platform??`unknown`,o=SH.commit===`unknown`?`unknown`:SH.commit.slice(0,12),s=[`# xopc renderer error report`,``,`- xopc web version: ${SH.version}`,`- Commit: ${o}`,`- Build time: ${SH.buildTimeIso}`,`- Captured at: ${r.toISOString()}`,`- Source: ${t}`,`- Surface: ${i}`,`- Platform: ${a}`,`- Language: ${A()}`,`- Page: ${CQ()}`,`- User agent: ${navigator.userAgent}`,``,`## Error`,``,"```text",xQ(e),"```"];return n?.trim()&&s.push(``,`## React component stack`,``,"```text",n.trim(),"```"),s.join(`
|