pi-webapp 0.1.52-alpha.3 → 0.1.52-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.js +3 -3
- package/dist/hosted-recovery.js +2 -2
- package/dist/hosted-worker.js +2 -2
- package/package.json +2 -2
- package/web/dist/.vite/manifest.json +4 -4
- package/web/dist/assets/{app-_Ug70Gwo.js → app-Cw3IG84J.js} +79 -79
- package/web/dist/assets/app.css +1 -1
- package/web/dist/assets/app.js +4 -4
- package/web/dist/assets/{plugin-0Vwjcj6k.js → plugin-9n52Wk_0.js} +2 -2
- package/web/dist/assets/{plugin-Bn9YQlEA.js → plugin-Bspt8wEA.js} +2 -2
- package/web/dist/assets/{plugin-q4wA1M0I.js → plugin-CEuq9NFD.js} +2 -2
package/web/dist/assets/app.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-Cw3IG84J.js","assets/dist-DvRDAAjZ.js","assets/WorkspacePanel.module-7fbly3iv.js","assets/WorkspacePanel.css","assets/typescript-dAcDzF3q.js","assets/shellscript-DugvE863.js","assets/json-Hfsf52vC.js","assets/app.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`a8223723-b13c-412e-a3ec-1e68fab09a71`,e._sentryDebugIdIdentifier=`sentry-dbid-a8223723-b13c-412e-a3ec-1e68fab09a71`)}catch{}})(),(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=new Set([`bash`,`powershell`,`read`,`write`,`edit`,`grep`,`find`,`ls`]),t=new Set([`cancelled`,`blocked`,`validation`,`not_found`,`permission`,`timeout`,`process_exit`,`unknown`]),n={userInfo:!1,cookies:!1,httpHeaders:!1,httpBodies:[],urlQueryParams:!1,genAI:{inputs:!1,outputs:!1},graphQL:{document:!1,variables:!1},databaseQueryData:!1,queues:!1,stackFrameVariables:!1,frameContextLines:0},r=new Set(`stage.route.method.status.durationMs.connection.idle.model.thinkingLevel.messageCount.attachmentCount.session.requestId.operationId.errorId.repeats.dropped.componentStack.eventType.sequence.nodeVersion.piVersion.platform.browser.buildId.code.toolName.toolId.toolCallId.failureKind.errorCode.exitCode.timeoutMs.diagnosticSource.originalStackAvailable.errorSummary.summaryOmitted.summaryOmittedReason.level.networkKind.networkStage.causeCodes`.split(`.`)),i=new Set(`/api/workspace/git/control./api/workspace/git/write./api/workspace/git/status./api/workspace/git/diff./api/workspace/git/history./api/workspace/git/commit-detail./api/workspace/git/commit-diff./api/workspace/files/list./api/workspace/files/preview./api/workspace/files/raw./api/plugins./api/plugin-action./api/plugin-interaction./api/resume./api/update./api/update/version./api/update/channel./api/provider/models./api/provider/logout./api/provider/login/active./api/telemetry/config./api/image./api/attachment./api/attachment/remove./api/session./api/providers./api/models./api/config./api/workspaces./api/commands./api/events./api/message./api/prompt-queue./api/abort./api/compact./api/new-session./api/model./api/thinking-level./api/provider/login./api/provider/login/respond./api/provider/login/cancel./api/provider/custom./api/workspace/add./api/workspace/select./api/workspace/new-session./api/workspace/remove./api/session/select./api/directory/capability./api/directory/list./api/directory/create./api/directory/pick`.split(`.`));function a(e){return e===`/api/message`||e===`/api/prompt-queue`||e.startsWith(`/api/provider/`)||e.startsWith(`/api/workspace/files/`)||e.startsWith(`/api/workspace/git/`)||[`/api/plugin-action`,`/api/plugin-interaction`,`/api/resume`,`/api/compact`].includes(e)}function o(e){return e.slice(0,8192).replace(/-----BEGIN [^-\n]+-----[\s\S]*?(?:-----END [^-\n]+-----|$)/g,`[redacted]`).replace(/(["'`])[\s\S]*?\1/g,`[quoted]`).replace(/(?:Bearer\s+\S+|(?:api[_-]?key|token|password|secret|authorization)\s*[=:]\s*\S+)/gi,`[redacted]`).replace(/\b(?:sk-|sntrys_|eyJ)[A-Za-z0-9_.-]+/g,`[redacted]`).replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,`[email]`).replace(/https?:\/\/[^\s)]+/gi,`[url]`).replace(/(?:file:\/\/)?(?:\/[\w.~-]+){2,}(?::\d+(?::\d+)?)?/g,`[path]`).replace(/[A-Za-z]:\\[^\s)]+/g,`[path]`).replace(/(?:^|\s)(?:\.\.?[\\/]|~[\\/])[^\s)]+/g,` [path]`).replace(/\b(?:[\w.-]+[\\/])+[\w.-]+/g,`[path]`).replace(/\{[^\n]*\}/g,`[object]`).replace(/\b[A-Za-z0-9_-]{24,}\b/g,`[redacted]`).slice(0,1024)}function s(n){let a={};for(let s of r){let r=n[s];s===`toolName`?typeof r==`string`&&(e.has(r)||r===`custom`)&&(a[s]=r):s===`failureKind`?t.has(r)&&(a[s]=r):s===`level`?(r===`warning`||r===`error`)&&(a[s]=r):s===`diagnosticSource`?(r===`tool_execution_end`||r===`message_end`)&&(a[s]=r):s===`errorCode`?typeof r==`string`&&/^(?:E[A-Z0-9]{1,20}|nonzero_exit|timeout|cancelled|blocked|invalid_arguments|tool_not_found|unknown)$/.test(r)&&(a[s]=r):s===`toolId`?typeof r==`string`&&/^[a-f0-9]{16}$/.test(r)&&(a[s]=r):s===`route`&&typeof r==`string`?a[s]=i.has(r.split(`?`)[0])?r.split(`?`)[0]:`[route]`:s===`model`&&typeof r==`string`&&/^[\w.-]+\/[\w.-]+$/.test(r)?a[s]=r.split(`/`).map(o).join(`/`):typeof r==`string`?a[s]=[`requestId`,`operationId`,`errorId`,`session`,`buildId`,`toolId`,`toolCallId`].includes(s)&&/^[\w-]{1,80}$/.test(r)?r:o(r).slice(0,s===`errorSummary`?512:1024):(typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r)||r===null)&&(a[s]=r)}return a}function c(e){let t=e.replace(/\\/g,`/`).split(/[?#]/)[0];return t.startsWith(`node:`)?t.slice(0,150):`app:///${(t.match(/(?:^|\/)((?:web\/src|extension|shared|dist|assets)\/[^\s:)]+)$/)?.[1]??t.split(`/`).pop()??`unknown`).replace(/[^\w./-]/g,`_`).slice(-200)}`}function l(e,t=0){let n=e instanceof Error?e:Error(typeof e==`string`?e:`Non-Error rejection`),r=Error(o(n.message));if(r.name=o(n.name).slice(0,100),n.stack){let e=n.stack.split(`
|
|
3
3
|
`).slice(1,31).map(e=>{let t=e.match(/((?:file:\/\/|https?:\/\/|\/|[A-Za-z]:\\)[^\s()]+):(\d+):(\d+)(\)?)$/);return t?`${o(e.slice(0,t.index))}${t[1]}:${t[2]}:${t[3]}${t[4]}`:o(e)});r.stack=`${r.name}: ${r.message}\n${e.join(`
|
|
4
4
|
`)}`}else r.stack=void 0;return t<3&&n.cause!==void 0&&(r.cause=l(n.cause,t+1)),r}function u(e,t){let n=Error(t);return e instanceof Error&&(n.name=e.name,e.stack&&(n.stack=`${n.name}: ${t}\n${e.stack.split(`
|
|
5
5
|
`).slice(1).join(`
|
|
6
6
|
`)}`)),n}function d(e){return{...e.filename?{filename:c(e.filename)}:{},...e.abs_path?{abs_path:c(e.abs_path)}:{},...e.function?{function:o(e.function)}:{},lineno:e.lineno,colno:e.colno,in_app:e.in_app}}function f(e){let t=s(e.contexts?.diagnostic??{}),n=p(t);return{event_id:e.event_id,timestamp:e.timestamp,platform:e.platform,level:e.level,release:e.release,dist:e.dist,environment:o(e.environment??`production`),...e.message?{message:o(e.message)}:{},exception:e.exception?{values:e.exception.values?.slice(0,4).map(e=>({type:o(e.type??`Error`),value:o(e.value??``),...e.stacktrace?{stacktrace:{frames:e.stacktrace.frames?.slice(-30).map(d)}}:{},...e.mechanism?{mechanism:{type:e.mechanism.type,handled:e.mechanism.handled}}:{}}))}:void 0,tags:{side:e.tags?.side,buildId:e.tags?.buildId,...t.toolName?{toolName:t.toolName}:{},...t.failureKind?{failureKind:t.failureKind}:{},...t.errorCode?{errorCode:t.errorCode}:{}},...n?{fingerprint:n}:{},contexts:{diagnostic:t},breadcrumbs:e.breadcrumbs?.slice(-100).map(e=>({timestamp:e.timestamp,category:o(e.category??`app`),data:s(e.data??{})})),debug_meta:e.debug_meta?{images:e.debug_meta.images?.slice(0,10).map(e=>({type:e.type,debug_id:e.debug_id,...e.code_file?{code_file:c(e.code_file)}:{}}))}:void 0}}function p(e){if(e.stage===`tool`&&e.originalStackAvailable===!1&&e.toolName&&e.failureKind)return[`pi-webapp-tool-result`,String(e.toolName),String(e.toolId??`builtin`),String(e.failureKind),String(e.errorCode??`unknown`)]}function m(e,t){return t.attachments=[],f(e)}var h=class{items=[];bytes=0;encoder=new TextEncoder;add(e,t={}){let n={timestamp:Date.now()/1e3,category:o(e),data:s(t)},r=this.encoder.encode(JSON.stringify(n)).byteLength+1;for(this.items.push({item:n,size:r}),this.bytes+=r;this.items.length>100||this.bytes>65534;)this.bytes-=this.items.shift().size}snapshot(){return this.items.map(({item:e})=>e)}},g=class{windowAt=-1;total=0;seen=new Map;take(e,t=Date.now()){(this.windowAt<0||t-this.windowAt>=6e4)&&(this.windowAt=t,this.total=0);let n=this.seen.get(e);if(n&&t-n.at<6e4)n.repeats++;else if(!(this.total>=20))return this.total++,this.seen.size>=64&&!n&&this.seen.delete(this.seen.keys().next().value),this.seen.set(e,{at:t,repeats:0}),{repeats:n?.repeats??0}}},_=new Set(`目录路径必须是绝对路径.父目录路径必须是绝对路径.文件夹名称无效.工作区目录不可用,请恢复目录或从列表移除后重新添加.会话已切换.Pi 正在运行,请等待当前回复结束.请等待当前回复结束.请等待当前回复结束再切换工作区.请等待当前回复结束再切换会话.请先切换到其他工作区.新会话已取消.已有登录正在进行.模型不可用.模型提供方未配置认证.当前模型不支持此推理强度.其他提供方的登录正在进行,请先完成或取消当前登录.当前会话没有暂停的任务.请先完成当前交互或审批.请先选择模型.请先连接当前模型.插件未启用.会话运行实例已切换.提供方已存在.文件超过 20 MB.请求内容过大.会话不属于该工作区.推理强度无效.会话名称过长.会话不存在.插件会话不能重命名或删除.该会话正在 Pi 终端中使用,请在终端里切换到其他会话后再删除`.split(`.`));function v(e){return e instanceof Error&&(e.name===`AbortError`||_.has(e.message))}var y=class{budget=new g;breadcrumbs;scopeClass;seen=new WeakSet;state={};client;side;buildId;constructor(e,t,n,r,i=new h){this.client=e,this.side=t,this.buildId=n,this.scopeClass=r.Scope,this.breadcrumbs=i,e.addIntegration(r.linkedErrorsIntegration({limit:4}))}setState(e){this.state=s(e)}capture(e,t={},n){try{if(v(e))return;if(typeof e==`object`&&e){if(this.seen.has(e))return;this.seen.add(e)}let r=l(e),i=s({...this.state,...t}),a=p(i),o=a?JSON.stringify(a):`${r.name}:${r.message}:${r.stack?.split(`
|
|
7
|
-
`)[1]??``}:${t.stage??``}`,c=this.budget.take(o);if(!c)return;let u=new this.scopeClass;u.setClient(this.client),u.setTags({side:this.side,buildId:this.buildId}),i.level===`warning`&&u.setLevel(`warning`),a&&u.setFingerprint(a),u.setContext(`diagnostic`,{...i,repeats:c.repeats});for(let e of this.breadcrumbs.snapshot())u.addBreadcrumb(e,100);return u.captureException(r,n?{event_id:n}:void 0)}catch{return}}ignore(e){this.seen.add(e)}};function b(e,t){return e({...t,bufferSize:20},async({body:e})=>{let n=await fetch(t.url,{method:`POST`,body:e,signal:AbortSignal.timeout(3e3),credentials:`omit`,referrerPolicy:`no-referrer`,redirect:`error`,headers:{"Content-Type":`application/x-sentry-envelope`}});return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get(`x-sentry-rate-limits`),"retry-after":n.headers.get(`retry-after`)}}})}var x;function S(){if(x!==void 0)return x;let e=location.hash.slice(1);try{x=e||sessionStorage.getItem(`pi-web-token`),e&&sessionStorage.setItem(`pi-web-token`,e)}catch{x=e||null}return e&&history.replaceState(null,``,location.pathname),x}var C=`pi-webapp@0.1.52-alpha.
|
|
8
|
-
//# debugId=
|
|
7
|
+
`)[1]??``}:${t.stage??``}`,c=this.budget.take(o);if(!c)return;let u=new this.scopeClass;u.setClient(this.client),u.setTags({side:this.side,buildId:this.buildId}),i.level===`warning`&&u.setLevel(`warning`),a&&u.setFingerprint(a),u.setContext(`diagnostic`,{...i,repeats:c.repeats});for(let e of this.breadcrumbs.snapshot())u.addBreadcrumb(e,100);return u.captureException(r,n?{event_id:n}:void 0)}catch{return}}ignore(e){this.seen.add(e)}};function b(e,t){return e({...t,bufferSize:20},async({body:e})=>{let n=await fetch(t.url,{method:`POST`,body:e,signal:AbortSignal.timeout(3e3),credentials:`omit`,referrerPolicy:`no-referrer`,redirect:`error`,headers:{"Content-Type":`application/x-sentry-envelope`}});return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get(`x-sentry-rate-limits`),"retry-after":n.headers.get(`retry-after`)}}})}var x;function S(){if(x!==void 0)return x;let e=location.hash.slice(1);try{x=e||sessionStorage.getItem(`pi-web-token`),e&&sessionStorage.setItem(`pi-web-token`,e)}catch{x=e||null}return e&&history.replaceState(null,``,location.pathname),x}var C=`pi-webapp@0.1.52-alpha.5+b40ea391e67f6106500d`,w=`b40ea391e67f6106500d`;function T(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var E=`modulepreload`,D=function(e){return`/`+e},O={},k=function(e){return e.pathname.endsWith(`.css`)},A=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=D(t,n);let r=s(t),i=k(r);return A(O,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:E,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},M,N=!0,P=!1,F=!1,I=[],L=new WeakSet,R=new Map,z={};function B(e,t={}){try{if(v(e))return;if(typeof e==`object`&&e){if(L.has(e))return;L.add(e)}if(M)return M.capture(e,t);N&&I.length<20&&I.push({error:l(e),context:s(t)})}catch{}}function V(e){L.add(e)}function H(e,t={}){M?.breadcrumbs.add(e,t)}function U(e){e.sessionId&&(R.has(e.sessionId)||(R.size>=32&&R.delete(R.keys().next().value),R.set(e.sessionId,T())),e={...e,session:R.get(e.sessionId)}),z=s({...z,...e}),M?.setState(z)}function W(){P||(P=!0,F=new URL(location.href).searchParams.get(`sentry_release_probe`)===`1`,window.addEventListener(`error`,e=>{e instanceof ErrorEvent?B(e.error??Error(e.message),{stage:`global`}):(e.target instanceof HTMLScriptElement||e.target instanceof HTMLLinkElement)&&B(Error(`Application resource failed to load`),{stage:`resource`})},!0),window.addEventListener(`unhandledrejection`,e=>B(e.reason,{stage:`unhandled_rejection`})),G())}async function G(){try{let e=S();if(!e)return;let t=await fetch(`/api/telemetry/config`,{headers:{Authorization:`Bearer ${e}`},signal:AbortSignal.timeout(1e3)});if(!t.ok)return;let n=await t.json();if(!n.enabled||!n.dsn)return;let{createBrowserReporter:r}=await j(async()=>{let{createBrowserReporter:e}=await import(`./telemetry-client-BBuLBxwh.js`);return{createBrowserReporter:e}},[]);M=r({...n,buildId:w,release:C});let i=navigator.userAgent.match(/(?:Firefox|Edg|Chrome|Version)\/[\d.]+/)?.[0]??`unknown`;M.setState({...z,browser:i,platform:navigator.platform}),z={...z,browser:i,platform:navigator.platform};for(let e of I)M.capture(e.error,e.context);n.environment===`sentry-verification`&&F&&M.capture(Error(`Sentry browser release verification`),{stage:`release_verification`,code:`sentry_release_probe`})}catch{}finally{I=[],N=!1}}W(),j(()=>import(`./app-Cw3IG84J.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7])).catch(e=>B(e,{stage:`startup`}));export{j as a,y as c,u as d,m as f,U as i,b as l,V as n,T as o,n as p,B as r,S as s,H as t,a as u};
|
|
8
|
+
//# debugId=a8223723-b13c-412e-a3ec-1e68fab09a71
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`
|
|
2
|
-
//# debugId=
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`997bdd82-8de2-4fc9-bf9f-c2290927246d`,e._sentryDebugIdIdentifier=`sentry-dbid-997bdd82-8de2-4fc9-bf9f-c2290927246d`)}catch{}})();import{a as e,d as t,h as n,i as r,l as i,o as a,t as o,v as s}from"./dist-DvRDAAjZ.js";import{A as c,t as l,x as u}from"./WorkspacePanel.module-7fbly3iv.js";import{s as d}from"./app.js";import{a as f,o as p}from"./app-Cw3IG84J.js";var m={id:a.files,kind:`builtin`,version:`1.0.0`,name:{zh:`工作区文件`,en:`Workspace files`},description:{zh:`浏览工作区目录,只读预览代码、Markdown 与图片。`,en:`Browse workspace directories and preview code, Markdown and images read-only.`}},h=s(n(),1);async function g(t,n,i,a){return e(await r(`/api/workspace/files/${t}`,{method:`POST`,headers:{Authorization:`Bearer ${d()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:n,path:i}),signal:a}))}async function _(t,n,i){let a=await r(`/api/workspace/files/raw`,{method:`POST`,headers:{Authorization:`Bearer ${d()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:t,path:n}),signal:i});return a.response.ok?a.response.blob():e(a)}var v={raw:_,list:(e,t,n)=>g(`list`,e,t,n),preview:(e,t,n)=>g(`preview`,e,t,n)},y=i(),b=()=>({expanded:new Set,levels:new Map,scrollTop:0});function x({path:e,depth:n,tree:r}){let[i,a]=(0,h.useState)(()=>r.state.levels.get(e)),[o,s]=(0,h.useState)(!0),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(0);return(0,h.useEffect)(()=>{let t=new AbortController;return s(!0),d(!1),v.list(r.sessionId,e,t.signal).then(n=>{t.signal.aborted||(r.state.levels.set(e,n),a(n),s(!1))}).catch(()=>{t.signal.aborted||(d(!0),s(!1))}),()=>t.abort()},[r.sessionId,r.state,e,r.revision,f]),(0,y.jsxs)(y.Fragment,{children:[o&&(0,y.jsx)(`li`,{role:`none`,className:l.state,"aria-live":`polite`,children:t(`正在读取…`,`Reading…`)}),u&&(0,y.jsxs)(`li`,{role:`none`,className:l.state,children:[(0,y.jsx)(`span`,{role:`status`,children:t(`目录读取失败,可能已移动、删除或无权访问。`,`Could not read this directory. It may have moved, been deleted, or be inaccessible.`)}),` `,(0,y.jsx)(`button`,{type:`button`,className:l.textButton,onClick:()=>p(e=>e+1),children:t(`重试`,`Retry`)})]}),!o&&!u&&i?.entries.length===0&&(0,y.jsx)(`li`,{role:`none`,className:l.state,children:t(`空目录`,`Empty directory`)}),i?.entries.map(e=>{let i=e.kind===`directory`,a=i&&r.expanded.has(e.path),o=e.kind===`other`;return(0,y.jsxs)(`li`,{role:`treeitem`,tabIndex:o?-1:0,"aria-label":e.name,"aria-level":n,"aria-expanded":i?a:void 0,"aria-disabled":o||void 0,"data-files-path":e.path,children:[(0,y.jsxs)(`div`,{className:l.row,style:{paddingInlineStart:`${12+(n-1)*16}px`},title:o?t(`此条目不可访问或位于工作区之外`,`This entry is unavailable or outside the workspace`):e.path,onClick:t=>{o||(t.currentTarget.parentElement?.focus(),i?r.toggle(e.path):r.open(e.path))},children:[(0,y.jsx)(`span`,{className:l.chevron,"aria-hidden":`true`,children:i?a?`⌄`:`›`:``}),i?(0,y.jsx)(c,{kind:`folder`,size:18}):(0,y.jsx)(c,{path:e.name,size:18}),(0,y.jsx)(`span`,{className:l.name,children:e.name})]}),a&&(0,y.jsx)(`ul`,{role:`group`,className:l.level,children:(0,y.jsx)(x,{path:e.path,depth:n+1,tree:r})})]},e.path)}),i?.truncated&&(0,y.jsx)(`li`,{role:`none`,className:l.state,children:t(`条目太多,只显示前 1000 项。`,`Too many entries. Showing the first 1,000.`)})]})}function S({sessionId:e,cwd:n,state:r,onOpen:i}){let[a,o]=(0,h.useState)(()=>new Set(r.expanded)),[s,c]=(0,h.useState)(0),d=(0,h.useRef)(null);(0,h.useLayoutEffect)(()=>{d.current&&(d.current.scrollTop=r.scrollTop)},[r]);let f=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),r.expanded=n,n}),p={sessionId:e,state:r,revision:s,expanded:a,toggle:f,open:i};return(0,y.jsxs)(`div`,{className:l.body,children:[(0,y.jsxs)(`div`,{className:l.toolbar,children:[(0,y.jsx)(`span`,{className:l.path,title:n,dir:`auto`,children:n}),(0,y.jsx)(`button`,{type:`button`,className:l.iconButton,"aria-label":t(`重新读取文件列表`,`Reload files`),title:t(`重新读取文件列表`,`Reload files`),onClick:()=>c(e=>e+1),children:(0,y.jsx)(u,{})})]}),(0,y.jsx)(`div`,{ref:d,className:l.scroll,onScroll:e=>{r.scrollTop=e.currentTarget.scrollTop},children:(0,y.jsx)(`ul`,{role:`tree`,"aria-label":t(`工作区文件`,`Workspace files`),className:l.tree,onKeyDown:e=>{let t=e.target;if(t.getAttribute(`role`)!==`treeitem`||t.getAttribute(`aria-disabled`)===`true`)return;let n=t.dataset.filesPath,r=t.hasAttribute(`aria-expanded`),a=t.getAttribute(`aria-expanded`)===`true`,o=[...e.currentTarget.querySelectorAll(`[role="treeitem"]:not([aria-disabled="true"])`)],s=o.indexOf(t),c;switch(e.key){case`ArrowDown`:c=o[s+1];break;case`ArrowUp`:c=o[s-1];break;case`Home`:c=o[0];break;case`End`:c=o.at(-1);break;case`ArrowRight`:r&&!a?f(n):a&&(c=o[s+1]);break;case`ArrowLeft`:a?f(n):c=t.parentElement?.closest(`[role="treeitem"]`)??void 0;break;case`Enter`:case` `:r?f(n):i(n);break;default:return}e.preventDefault(),e.stopPropagation(),c?.focus()},children:(0,y.jsx)(x,{path:``,depth:1,tree:p})})})]})}function C(e,t){let n=t.replace(/[?#].*$/u,``);try{n=decodeURI(n)}catch{}if(n===``||n.includes(`\\`)||n.includes(`\0`)||/^[a-z][a-z\d+.-]*:/iu.test(n)||n.startsWith(`//`))return;let r=n.startsWith(`/`)?[]:e.split(`/`).slice(0,-1);for(let e of n.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(r.pop()===void 0)return}else r.push(e)}return r.length?r.join(`/`):void 0}var w=(0,h.memo)(function({sessionId:e,path:n,renderMarkdown:r}){let[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!0),[c,d]=(0,h.useState)(!1),[m,g]=(0,h.useState)(0),[_,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(!1),[w,T]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=new AbortController;return s(!0),d(!1),T(!1),S(!1),v.preview(e,n,t.signal).then(e=>{t.signal.aborted||(a(e),s(!1))}).catch(()=>{t.signal.aborted||(d(!0),s(!1))}),()=>t.abort()},[e,n,m]);let E=/\.(?:md|markdown|mdown)$/i.test(n),D=n.split(`/`).at(-1),O=D.includes(`.`)?D.split(`.`).at(-1).toLowerCase():D.toLowerCase(),k={mjs:`javascript`,cjs:`javascript`,mts:`typescript`,cts:`typescript`,md:`markdown`,svg:`xml`,gitignore:`text`,dockerfile:`dockerfile`,makefile:`make`}[O]??O,[A,j]=(0,h.useState)(0),M=(0,h.useRef)(new Map);(0,h.useEffect)(()=>{let e=M.current;return e.clear(),()=>{for(let t of e.values())t&&URL.revokeObjectURL(t);e.clear()}},[e,n,m]);let N=(0,h.useMemo)(()=>({resolve(t){let r=C(n,t);if(r===void 0)return;let i=M.current,a=i.get(r);if(a!==void 0)return a??void 0;i.set(r,null),v.raw(e,r,new AbortController().signal).then(e=>{M.current===i&&i.get(r)===null&&(i.set(r,URL.createObjectURL(e)),j(e=>e+1))}).catch(()=>{})}}),[e,n,m,A]),P=()=>g(e=>e+1),F=(0,h.useMemo)(()=>i?.kind===`image`?`data:${i.mimeType};base64,${i.data}`:null,[i]);return(0,y.jsxs)(`div`,{className:l.body,children:[(0,y.jsxs)(`div`,{className:l.toolbar,children:[(0,y.jsx)(`span`,{className:l.path,title:n,children:n}),(0,y.jsx)(`span`,{className:l.readonly,children:t(`只读`,`Read only`)}),E&&i?.kind===`text`&&(0,y.jsx)(`button`,{type:`button`,className:l.textButton,"aria-pressed":_,onClick:()=>b(e=>!e),children:_?t(`预览`,`Preview`):t(`源码`,`Source`)}),(0,y.jsx)(`button`,{type:`button`,className:l.iconButton,"aria-label":t(`重新读取文件`,`Reload file`),title:t(`重新读取文件`,`Reload file`),onClick:P,children:(0,y.jsx)(u,{})})]}),(0,y.jsx)(`div`,{className:l.preview,"aria-busy":o,children:o?(0,y.jsx)(`p`,{className:l.state,role:`status`,children:t(`正在读取…`,`Reading…`)}):c?(0,y.jsxs)(`div`,{className:l.state,role:`status`,children:[(0,y.jsx)(`p`,{children:t(`文件读取失败,可能已移动、删除或无权访问。`,`Could not read this file. It may have moved, been deleted, or be inaccessible.`)}),(0,y.jsx)(`button`,{type:`button`,className:l.textButton,onClick:P,children:t(`重试`,`Retry`)})]}):i?i.kind===`too-large`?(0,y.jsx)(`p`,{className:l.state,children:i.unit===`lines`?t(`文件行数过多,最多预览 ${i.limit} 行。`,`File has too many lines. Limit: ${i.limit} lines.`):t(`文件过大,无法预览。大小上限:${i.limit/1024} KB`,`File is too large to preview. Limit: ${i.limit/1024} KB`)}):i.kind===`unsupported`?(0,y.jsx)(`p`,{className:l.state,children:t(`暂不支持预览此文件类型。`,`Preview is unavailable for this file type.`)}):i.kind===`image`&&F?w?(0,y.jsx)(`p`,{className:l.state,children:t(`图片无法解码。`,`This image could not be decoded.`)}):(0,y.jsx)(`button`,{type:`button`,className:l.imageButton,"aria-label":t(`放大图片`,`Enlarge image`),onClick:()=>S(!0),children:(0,y.jsx)(`img`,{className:l.image,src:F,alt:D,onError:()=>T(!0)})}):i.kind===`text`?i.text===``?(0,y.jsx)(`p`,{className:l.state,children:t(`空文件`,`Empty file`)}):E&&!_?(0,y.jsx)(`div`,{className:l.markdown,children:r(i.text,N)}):(0,y.jsx)(f,{code:i.text,lang:k,lineNumbers:!0,className:l.code,copyLabel:t(`复制`,`Copy`),copiedLabel:t(`已复制`,`Copied`),toolbarLabels:{codeLabel:t(`代码`,`Code`),wrapLabel:t(`自动换行`,`Wrap`),unwrapLabel:t(`取消换行`,`Unwrap`)}}):null:null}),x&&F&&(0,y.jsx)(p,{src:F,alt:D,labels:{dialog:t(`图片预览`,`Image preview`),close:t(`关闭图片预览`,`Close image preview`)},onClose:()=>S(!1)})]})}),T=o({id:m.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:m.name,panelTitle:{zh:`文件`,en:`Files`},description:{zh:`浏览当前会话的文件并打开预览`,en:`Browse this session’s files and open previews`},kind:`files`,icon:({size:e})=>(0,y.jsx)(c,{kind:`folder`,size:e})},panels:[{kind:`files`,component:e=>(0,y.jsx)(S,{sessionId:e.session.sessionId,cwd:e.session.cwd,state:e.resource(b),onOpen:t=>e.open(`file-preview`,t,t.split(`/`).at(-1))})},{kind:`file-preview`,title:(e,t)=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(c,{path:e,size:16}),(0,y.jsx)(`span`,{children:t})]}),component:e=>(0,y.jsx)(w,{sessionId:e.session.sessionId,path:e.contentId,renderMarkdown:e.renderMarkdown})}]}});export{T as default};
|
|
2
|
+
//# debugId=997bdd82-8de2-4fc9-bf9f-c2290927246d
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`fed095f0-6a58-4c5b-a1c4-c346252679a7`,e._sentryDebugIdIdentifier=`sentry-dbid-fed095f0-6a58-4c5b-a1c4-c346252679a7`)}catch{}})();import{a as e,d as t,h as n,i as r,l as i,m as a,o,s,t as c,v as l}from"./dist-DvRDAAjZ.js";import{A as u,a as d,o as f,r as p,t as m,x as h,y as g}from"./WorkspacePanel.module-7fbly3iv.js";import{i as _,r as v,s as y}from"./app-Cw3IG84J.js";import{s as b}from"./app.js";var x=l(n(),1);function S(e){let n={stage:[`已暂存文件。`,`File staged.`],unstage:[`已取消暂存,工作区内容保留。`,`File unstaged. Working content preserved.`],commit:[`提交成功。`,`Commit created.`],"create-branch":[`分支已创建。`,`Branch created.`],"switch-branch":[`已切换分支。`,`Branch switched.`],state_changed:[`仓库状态已变化,已刷新;请检查后重新操作。`,`Repository changed. Review the refreshed state before trying again.`],busy:[`Git 操作正在进行,请稍后刷新。`,`A Git operation is in progress. Refresh shortly.`],agent_busy:[`共用此工作树的聊天正在运行,请等待回复结束。`,`A chat sharing this working tree is running. Wait for it to finish.`],session_changed:[`聊天已切换,请返回原聊天检查仓库状态。`,`Chat switched. Return to the original chat to check the repository.`],root_required:[`提交和切换分支请在仓库根目录工作区操作。`,`Open the repository root workspace to commit or switch branches.`],operation_in_progress:[`请先在终端完成冲突处理或正在进行的 Git 操作。`,`Finish conflict resolution or the ongoing Git operation in the terminal first.`],index_locked:[`Git 锁被占用,请等待其他 Git 操作完成。`,`Git is locked. Wait for other Git operations to finish.`],too_many_changes:[`仓库改动或分支过多,请在终端操作。`,`Too many changes or branches. Use the terminal for this operation.`],dirty_worktree:[`切换分支前请先提交或处理全部改动,包括未跟踪文件。`,`Commit or resolve all changes, including untracked files, before switching branches.`],nothing_staged:[`请先暂存要提交的文件。`,`Stage files before committing.`],identity_missing:[`请先在终端配置 Git user.name 和 user.email。`,`Configure Git user.name and user.email in the terminal first.`],invalid_branch:[`分支名称无效,请检查后重试。`,`Invalid branch name. Check the name and try again.`],branch_exists:[`同名分支已存在。`,`A branch with this name already exists.`],branch_in_use:[`该分支正在其他工作树中使用。`,`This branch is checked out in another worktree.`],no_commits:[`创建分支前请先完成首次提交。`,`Create an initial commit before creating a branch.`],invalid_path:[`该文件不支持此操作,请刷新检查。`,`This file cannot be changed here. Refresh and check it.`],invalid_message:[`请填写提交说明(最多 8 KB)。`,`Enter a commit message (up to 8 KB).`],git_failed:[`Git 操作失败。请检查仓库、身份、签名或 hooks 配置,再刷新确认。`,`Git operation failed. Check repository, identity, signing or hooks configuration, then refresh.`],outcome_unknown:[`未能确认操作结果。请刷新检查暂存区、历史和分支,确认前不要重复提交。`,`Operation outcome is unknown. Refresh and check staging, history and branches before repeating it.`]},r=n[e]??n.git_failed;return t(...r)}async function C(t,n,i,a){return e(await r(`/api/workspace/git/${t}`,{method:`POST`,headers:{Authorization:`Bearer ${b()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:n,...i}),signal:a}))}var w={control:(e,t)=>C(`control`,e,{},t),write:(e,t)=>C(`write`,e,t),status:(e,t)=>C(`status`,e,{},t),diff:(e,t,n,r)=>C(`diff`,e,{path:t,area:n},r),history:(e,t,n)=>C(`history`,e,{cursor:t},n),commit:(e,t,n,r)=>C(`commit-detail`,e,{hash:t,parentIndex:n},r),commitDiff:(e,t,n,r,i)=>C(`commit-diff`,e,{hash:t,path:n,parentIndex:r},i)};function T(e,t,n,r=!0){let[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(0),f=(0,x.useCallback)(()=>{s(!0),d(e=>e+1)},[]);return(0,x.useEffect)(()=>{if(!t)return;let n=!1,i=!1,o=!1,c=new AbortController,u=async()=>{if(!(n||document.visibilityState===`hidden`)){if(i)o=!0;else{i=!0,s(!0);try{let t=await e(c.signal);n||(a(e=>JSON.stringify(e)===JSON.stringify(t)?e:t),l(!1))}catch{n||l(!0)}finally{i=!1,n||(s(!1),o&&(o=!1,u()))}}}};u();let d=r?window.setInterval(()=>{u()},5e3):void 0,f=()=>{u()};return window.addEventListener(`focus`,f),window.addEventListener(`pi-workspace-git-changed`,f),document.addEventListener(`visibilitychange`,f),()=>{n=!0,c.abort(),window.clearInterval(d),window.removeEventListener(`pi-workspace-git-changed`,f),window.removeEventListener(`focus`,f),document.removeEventListener(`visibilitychange`,f)}},[e,t,n,u,r]),{value:i,loading:o,error:c,refresh:f}}var E={panel:`_panel_1ndkv_2`,viewSwitch:`_viewSwitch_1ndkv_3`,viewButton:`_viewButton_1ndkv_4`,repoBar:`_repoBar_1ndkv_5`,branchPicker:`_branchPicker_1ndkv_6`,branchTrigger:`_branchTrigger_1ndkv_7`,repoName:`_repoName_1ndkv_11`,divergence:`_divergence_1ndkv_12`,count:`_count_1ndkv_13`,scope:`_scope_1ndkv_14`,changesScroll:`_changesScroll_1ndkv_15`,groupHeading:`_groupHeading_1ndkv_16`,list:`_list_1ndkv_18`,changeRow:`_changeRow_1ndkv_19`,change:`_change_1ndkv_15`,diffScroll:`_diffScroll_1ndkv_23`,filename:`_filename_1ndkv_25`,status:`_status_1ndkv_27`,added:`_added_1ndkv_28`,removed:`_removed_1ndkv_29`,fileAction:`_fileAction_1ndkv_30`,commitFooter:`_commitFooter_1ndkv_32`,commitForm:`_commitForm_1ndkv_33`,rootHint:`_rootHint_1ndkv_36`,actionRow:`_actionRow_1ndkv_37`,hint:`_hint_1ndkv_38`,feedback:`_feedback_1ndkv_38`,feedbackRow:`_feedbackRow_1ndkv_41`,actionButton:`_actionButton_1ndkv_44`,branchPopover:`_branchPopover_1ndkv_46`,pickerHeader:`_pickerHeader_1ndkv_47`,branchSearch:`_branchSearch_1ndkv_49`,field:`_field_1ndkv_49`,branchList:`_branchList_1ndkv_50`,branchOption:`_branchOption_1ndkv_52`,newBranch:`_newBranch_1ndkv_56`,form:`_form_1ndkv_58`,checkbox:`_checkbox_1ndkv_60`,diffSummary:`_diffSummary_1ndkv_64`,stats:`_stats_1ndkv_65`,diff:`_diff_1ndkv_23`,diffLine:`_diffLine_1ndkv_68`,lineNumber:`_lineNumber_1ndkv_69`,lineText:`_lineText_1ndkv_70`,diffHunk:`_diffHunk_1ndkv_74`,diffNotice:`_diffNotice_1ndkv_75`,noNewline:`_noNewline_1ndkv_76`,reviewLayout:`_reviewLayout_1ndkv_79`,inlinePreview:`_inlinePreview_1ndkv_81`,inlineDiffToolbar:`_inlineDiffToolbar_1ndkv_83`,diffIdentity:`_diffIdentity_1ndkv_84`,diffDetails:`_diffDetails_1ndkv_85`,diffArea:`_diffArea_1ndkv_86`,diffNavigation:`_diffNavigation_1ndkv_88`,diffPosition:`_diffPosition_1ndkv_89`,diffViewport:`_diffViewport_1ndkv_91`},D=i();function O({children:e,preview:n,selectionKey:r,onClose:i}){let a=(0,x.useRef)(null),o=!!n;return(0,x.useEffect)(()=>{o&&r&&a.current?.querySelector(`[data-git-file][aria-pressed="true"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[r,o]),(0,D.jsxs)(`div`,{className:E.reviewLayout,"data-preview":o,ref:a,children:[e,n&&(0,D.jsx)(`div`,{className:E.inlinePreview,role:`region`,"aria-label":t(`差异预览`,`Diff preview`),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&!e.defaultPrevented&&(e.preventDefault(),i())},children:n})]})}function k(e){return e===`staged`?t(`已暂存`,`Staged`):e===`unstaged`?t(`未暂存`,`Unstaged`):t(`未跟踪`,`Untracked`)}function A(e){let t=0,n=0,r=!1,i=e.split(`
|
|
2
2
|
`);return i.at(-1)===``&&i.pop(),i.map(e=>{let i=e.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(e.startsWith(`diff --git `)&&(r=!1),i&&(t=Number(i[1]),n=Number(i[2]),r=!0),r&&!i){if(e.startsWith(`+`))return{kind:`add`,text:e,oldLine:null,newLine:n++};if(e.startsWith(`-`))return{kind:`remove`,text:e,oldLine:t++,newLine:null};if(e.startsWith(` `))return{kind:`context`,text:e,oldLine:t++,newLine:n++}}return{kind:`meta`,text:e,oldLine:null,newLine:null}})}function j(e){let t=[],n=[],r=[],i=null,a=``,o=``,s=``;for(let c of A(e)){if(c.kind!==`meta`){c.kind===`context`?i=null:i===null&&(i=n.length,n.push(t.length)),t.push({...c,kind:c.kind,change:i});continue}let e=c.text.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@\s?(.*)$/);if(e)i=null,t.push({kind:`hunk`,oldLine:Number(e[1]),newLine:Number(e[2]),text:e[3],change:null});else if(c.text===`\`){let e=t.at(-1);e&&e.kind!==`hunk`&&(e.noNewline=!0)}else c.text.startsWith(`diff --git `)?(i=null,a=o=s=``):c.text.startsWith(`old mode `)?a=c.text.slice(9):c.text.startsWith(`new mode `)?r.push({kind:`mode`,from:a,to:c.text.slice(9)}):c.text.startsWith(`rename from `)?o=c.text.slice(12):c.text.startsWith(`rename to `)?r.push({kind:`rename`,from:o,to:c.text.slice(10)}):c.text.startsWith(`copy from `)?s=c.text.slice(10):c.text.startsWith(`copy to `)?r.push({kind:`copy`,from:s,to:c.text.slice(8)}):c.text.startsWith(`new file mode `)?r.push({kind:`added`,from:``,to:c.text.slice(14)}):c.text.startsWith(`deleted file mode `)&&r.push({kind:`deleted`,from:c.text.slice(18),to:``})}return{lines:t,changes:n,notices:r.filter(e=>!n.length||e.kind!==`added`&&e.kind!==`deleted`)}}function M({path:e,label:n,value:r,loading:i,error:a,refresh:o,onClose:s}){let c=r?.kind===`text`?r.patch:``,l=(0,x.useMemo)(()=>j(c),[c,e]),{lines:u,changes:p,notices:g}=l,_=(0,x.useRef)(null),[v,y]=(0,x.useState)(null),b=v?.preview===l?v.index:-1;(0,x.useEffect)(()=>{_.current?.scrollTo({top:0,left:0})},[l]);let S=e=>{if(i||a||e<0||e>=p.length)return;let t=_.current,n=t?.querySelector(`[data-change="${e}"][data-change-start="true"]`);t&&n&&(t.scrollTo({top:t.scrollTop+n.getBoundingClientRect().top-t.getBoundingClientRect().top,left:t.scrollLeft}),y({preview:l,index:e}))},C=u.filter(e=>e.kind===`add`).length,w=u.filter(e=>e.kind===`remove`).length,T=r?.kind===`text`&&(0,D.jsxs)(`span`,{className:E.stats,children:[(0,D.jsxs)(`span`,{className:E.added,children:[`+`,C]}),(0,D.jsxs)(`span`,{className:E.removed,children:[`−`,w]})]}),O={empty:t(`此文件在所选范围内没有文本差异,或已不在改动列表中。`,`No text differences in this scope, or this file is no longer changed.`),binary:t(`二进制文件不支持文本差异预览。`,`Text diff is unavailable for binary files.`),"too-large":t(`差异过大,最多显示 512 KB / 10000 行。`,`Diff exceeds the preview limit of 512 KB / 10000 lines.`),unsupported:t(`此文件类型不支持差异预览。`,`Diff is unavailable for this file type.`),conflict:t(`此文件存在未解决的合并冲突,请在工作区文件或终端中检查。`,`This file has unresolved merge conflicts. Inspect it in workspace files or the terminal.`),submodule:t(`子模块已发生变化,请在子模块工作区中查看具体差异。`,`Submodule changed. Open its workspace to inspect the changes.`)};return(0,D.jsxs)(`div`,{className:m.body,children:[(0,D.jsxs)(`div`,{className:s?E.inlineDiffToolbar:m.toolbar,children:[s?(0,D.jsxs)(`div`,{className:E.diffIdentity,children:[(0,D.jsx)(`span`,{className:m.path,title:e,children:e}),(0,D.jsxs)(`div`,{className:E.diffDetails,children:[(0,D.jsx)(`span`,{className:E.diffArea,title:n,children:n}),T]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:m.path,title:e,children:e}),(0,D.jsx)(`span`,{className:m.readonly,children:t(`只读`,`Read only`)})]}),(0,D.jsxs)(`div`,{className:E.diffNavigation,role:`group`,"aria-label":t(`改动跳转`,`Change navigation`),children:[(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`上一处改动`,`Previous change`),title:t(`上一处改动`,`Previous change`),disabled:i||a||b<=0,onClick:()=>S(b-1),children:(0,D.jsx)(f,{})}),(0,D.jsxs)(`span`,{className:E.diffPosition,role:`status`,"aria-label":t(`改动位置`,`Change position`),"aria-live":`polite`,"aria-atomic":`true`,title:t(`第 ${b+1} / ${p.length} 处改动`,`Change ${b+1} of ${p.length}`),children:[b+1,`/`,p.length]}),(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`下一处改动`,`Next change`),title:t(`下一处改动`,`Next change`),disabled:i||a||b+1>=p.length,onClick:()=>S(b+1),children:(0,D.jsx)(d,{})})]}),(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`刷新差异`,`Refresh diff`),title:t(`刷新差异`,`Refresh diff`),onClick:o,children:(0,D.jsx)(h,{})}),s&&(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`关闭差异预览`,`Close diff preview`),title:t(`关闭差异预览 · Esc`,`Close diff preview · Esc`),onClick:s,children:`×`})]}),!s&&(0,D.jsxs)(`div`,{className:E.diffSummary,children:[(0,D.jsx)(`span`,{children:n}),T]}),a&&(0,D.jsxs)(`div`,{className:m.state,role:`status`,children:[t(`差异读取失败,请重试。`,`Could not read this diff. Try again.`),` `,(0,D.jsx)(`button`,{type:`button`,className:m.textButton,onClick:o,children:t(`重试`,`Retry`)})]}),(0,D.jsxs)(`div`,{className:`${m.preview} ${E.diffViewport}`,"aria-busy":i,children:[!r&&!a&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`正在读取差异…`,`Reading diff…`)}),r&&r.kind!==`text`&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:O[r.kind]}),r?.kind===`text`&&(0,D.jsxs)(`div`,{ref:_,className:E.diffScroll,tabIndex:0,role:`region`,"aria-label":t(`文件差异`,`File diff`),children:[g.map((e,t)=>(0,D.jsx)(`p`,{className:E.diffNotice,children:N(e)},t)),!u.length&&!g.length&&(0,D.jsx)(`p`,{className:m.state,children:O.empty}),(0,D.jsx)(`pre`,{className:E.diff,children:(0,D.jsx)(`code`,{children:u.map((e,n)=>e.kind===`hunk`?(0,D.jsxs)(`span`,{className:E.diffHunk,"data-kind":`hunk`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,children:`···`}),(0,D.jsxs)(`span`,{children:[t(`行 ${e.oldLine} / ${e.newLine}`,`Lines ${e.oldLine} / ${e.newLine}`),e.text&&` · ${e.text}`]})]},n):(0,D.jsxs)(`span`,{className:E.diffLine,"data-kind":e.kind,"data-change":e.change??void 0,"data-change-start":e.change!==null&&p[e.change]===n?`true`:void 0,"data-active":e.change!==null&&b===e.change?`true`:void 0,children:[(0,D.jsx)(`span`,{className:E.lineNumber,"aria-hidden":`true`,children:e.oldLine}),(0,D.jsx)(`span`,{className:E.lineNumber,"aria-hidden":`true`,children:e.newLine}),(0,D.jsxs)(`span`,{className:E.lineText,children:[e.text||` `,e.noNewline&&(0,D.jsx)(`span`,{className:E.noNewline,title:t(`文件末尾无换行`,`No newline at end of file`),"aria-label":t(`文件末尾无换行`,`No newline at end of file`),children:`↵`})]})]},n))})})]})]})]})}function N(e){switch(e.kind){case`mode`:return t(`文件权限:${e.from} → ${e.to}`,`File mode: ${e.from} → ${e.to}`);case`rename`:return t(`重命名:${e.from} → ${e.to}`,`Renamed: ${e.from} → ${e.to}`);case`copy`:return t(`复制:${e.from} → ${e.to}`,`Copied: ${e.from} → ${e.to}`);case`added`:return t(`新增空文件`,`Empty file added`);case`deleted`:return t(`删除空文件`,`Empty file deleted`)}}var P=(0,x.memo)(function({sessionId:e,path:t,area:n,visible:r,idle:i,onClose:o}){a();let s=T((0,x.useCallback)(r=>w.diff(e,t,n,r),[e,t,n]),r,i);return(0,D.jsx)(M,{path:t,label:k(n),onClose:o,...s})});function F(e,t){if(!e)return null;let n=t.find(t=>t.path===e.path);if(!n)return null;let r=n.conflict?[`unstaged`]:n.untracked?[`untracked`]:[...n.worktree===`.`?[]:[`unstaged`],...n.index===`.`?[]:[`staged`]];return r.includes(e.area)?e:r[0]?{path:e.path,area:r[0]}:null}function I({branch:e,control:n,disabled:r,model:i,open:a,onOpenChange:o,onDraftChange:s,onWrite:c}){let l=(0,x.useRef)(null),u=(0,x.useRef)(null),f=(0,x.useRef)(null),[h,_]=(0,x.useState)(!1),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``);v(u,a,()=>o(!1)),(0,x.useEffect)(()=>{if(!a){_(!1),T(``),C(!1);return}let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a,o]),(0,x.useEffect)(()=>{h&&f.current?.focus()},[h]);let O=n?.scope?`root_required`:n?.dirty?`dirty_worktree`:null,k=n?.branches.filter(e=>e.name.toLocaleLowerCase().includes(w.toLocaleLowerCase()))??[],A=async(e,t)=>{C(!0),await c(e,t)&&o(!1)};return(0,D.jsxs)(`div`,{ref:l,className:E.branchPicker,children:[(0,D.jsxs)(`button`,{type:`button`,className:E.branchTrigger,disabled:!n,"aria-label":t(`管理分支`,`Manage branches`),"aria-haspopup":`dialog`,"aria-expanded":a,title:e??t(`分离 HEAD`,`Detached HEAD`),onClick:()=>o(!a),children:[(0,D.jsx)(p,{}),(0,D.jsx)(`span`,{children:e??t(`分离 HEAD`,`Detached HEAD`)}),(0,D.jsx)(d,{})]}),a&&(0,D.jsxs)(y,{ref:u,className:E.branchPopover,compact:!0,role:`dialog`,"aria-modal":`true`,"aria-label":t(`管理分支`,`Manage branches`),children:[(0,D.jsxs)(`div`,{className:E.pickerHeader,children:[(0,D.jsx)(`span`,{children:h?t(`新建分支`,`New branch`):t(`本地分支`,`Local branches`)}),(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`关闭分支面板`,`Close branches`),onClick:()=>o(!1),children:`×`})]}),h?(0,D.jsxs)(`form`,{className:E.form,"aria-label":t(`创建分支`,`Create branch`),onSubmit:e=>{e.preventDefault(),!r&&i.branch.trim()&&n?.head&&!(i.checkout&&O)&&A(`create-branch`,{branch:i.branch,checkout:i.checkout})},children:[(0,D.jsxs)(`label`,{className:E.field,children:[t(`分支名称`,`Branch name`),(0,D.jsx)(`input`,{ref:f,"aria-label":t(`新分支名称`,`New branch name`),maxLength:256,value:i.branch,disabled:i.pending,placeholder:`feature/name`,onChange:e=>{i.branch=e.target.value,s()}})]}),(0,D.jsxs)(`label`,{className:E.checkbox,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:i.checkout,disabled:i.pending,onChange:e=>{i.checkout=e.target.checked,s()}}),t(`创建后切换`,`Switch after creating`)]}),i.checkout&&O&&(0,D.jsx)(`p`,{className:E.hint,children:S(O)}),(0,D.jsxs)(`div`,{className:E.actionRow,children:[(0,D.jsx)(`button`,{type:`button`,className:m.textButton,onClick:()=>_(!1),children:t(`返回`,`Back`)}),(0,D.jsx)(`button`,{className:E.actionButton,type:`submit`,disabled:r||!i.branch.trim()||!n?.head||i.checkout&&!!O,children:t(`创建分支`,`Create branch`)})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{className:E.branchSearch,type:`search`,"data-modal-autofocus":!0,"aria-label":t(`搜索分支`,`Search branches`),value:w,placeholder:t(`搜索分支…`,`Search branches…`),onChange:e=>T(e.target.value)}),(0,D.jsxs)(`div`,{className:E.branchList,role:`group`,"aria-label":t(`本地分支`,`Local branches`),children:[k.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:E.branchOption,title:e.name,disabled:r||!!O||e.current||e.occupied||!n?.head,"aria-label":t(`切换到分支:${e.name}`,`Switch to branch: ${e.name}`),onClick:()=>{A(`switch-branch`,{branch:e.name})},children:[(0,D.jsx)(p,{}),(0,D.jsx)(`span`,{children:e.name}),(e.current||e.occupied)&&(0,D.jsx)(`small`,{children:e.current?t(`当前`,`Current`):t(`其他工作树`,`Other worktree`)})]},e.name)),k.length===0&&(0,D.jsx)(`p`,{className:E.hint,children:t(`没有匹配的分支。`,`No matching branches.`)})]}),O&&(0,D.jsx)(`p`,{className:E.hint,children:S(O)}),(0,D.jsxs)(`button`,{type:`button`,className:E.newBranch,disabled:i.pending||!n?.head,"aria-label":t(`新建分支`,`New branch`),onClick:()=>_(!0),children:[(0,D.jsx)(g,{}),t(`新建分支…`,`New branch…`)]})]}),!n?.head&&(0,D.jsx)(`p`,{className:E.hint,children:S(`no_commits`)}),i.pending&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:t(`正在执行…`,`Running…`)}),n?.blocked&&(0,D.jsx)(`p`,{className:E.hint,children:S(n.blocked)}),b&&i.outcome&&!i.outcome.ok&&(0,D.jsx)(`p`,{className:E.feedback,"data-error":`true`,role:`status`,children:S(i.outcome.reason)})]})]})}function L(e){let t=[],n=0,r=1,i=[];for(let a of e){let e=t.findIndex(e=>e.hash===a.hash),o=e<0?t.length:e,s=e<0?n++%4:t[o].color,c=[...t];e>=0&&t.splice(e,1);let l=Math.min(o,t.length),u=[...new Set(a.parents)];for(let[e,r]of u.entries())t.some(e=>e.hash===r)||t.splice(l++,0,{hash:r,color:e===0?s:n++%4});i.push({lane:o,color:s,incoming:e>=0,rails:c.flatMap((e,n)=>e.hash===a.hash?[]:[{from:n,to:t.findIndex(t=>t.hash===e.hash),color:e.color}]),parents:u.map(e=>{let n=t.findIndex(t=>t.hash===e);return{hash:e,from:o,to:n,color:t[n].color}})}),r=Math.max(r,o+1,c.length,t.length)}return{rows:i,width:r*16+16}}var R={history:`_history_1fyyf_1`,historyToolbar:`_historyToolbar_1fyyf_2`,graphScroll:`_graphScroll_1fyyf_3`,historyList:`_historyList_1fyyf_4`,commitRow:`_commitRow_1fyyf_5`,loadMore:`_loadMore_1fyyf_7`,parentLink:`_parentLink_1fyyf_7`,graph:`_graph_1fyyf_3`,commitCopy:`_commitCopy_1fyyf_15`,subject:`_subject_1fyyf_16`,refLine:`_refLine_1fyyf_17`,ref:`_ref_1fyyf_17`,merge:`_merge_1fyyf_20`,commitMeta:`_commitMeta_1fyyf_21`,detail:`_detail_1fyyf_27`,message:`_message_1fyyf_33`,parentList:`_parentList_1fyyf_35`,parentSelect:`_parentSelect_1fyyf_36`,fileStats:`_fileStats_1fyyf_38`},z=(0,x.memo)(function({sessionId:e,visible:n,idle:r,model:i,onCommit:o}){let s=a(),{value:c,loading:l,error:u,refresh:d}=T((0,x.useCallback)(t=>w.history(e,void 0,t),[e]),n,r),[f,p]=(0,x.useState)(i.history),[h,g]=(0,x.useState)(i.selected),[_,v]=(0,x.useState)(!1),[y,b]=(0,x.useState)(!1),S=()=>{b(!1),d()},C=(0,x.useRef)(null);(0,x.useEffect)(()=>{c&&(i.history?.snapshot===c.snapshot&&i.history.commits.length||(C.current?.abort(),v(!1),b(!1),i.history=c,p(c)))},[c,i]),(0,x.useEffect)(()=>(n||(C.current?.abort(),v(!1)),()=>C.current?.abort()),[n]);let E=async()=>{let t=i.history;if(!t?.nextCursor||_)return;let n=new AbortController;C.current=n,v(!0),b(!1);try{let r=await w.history(e,t.nextCursor,n.signal);if(n.signal.aborted||i.history?.snapshot!==r.snapshot||i.history.nextCursor!==t.nextCursor)return;let a=new Set(t.commits.map(e=>e.hash)),o={...r,commits:[...t.commits,...r.commits.filter(e=>!a.has(e.hash))]};i.history=o,p(o)}catch{n.signal.aborted||b(!0)}finally{n.signal.aborted||v(!1)}},O=(0,x.useMemo)(()=>L(f?.commits??[]),[f?.commits]),k=e=>e*16+12,A=e=>{i.selected=e,g(e),o(e)},j={"--git-graph-width":`${O.width}px`};return(0,D.jsxs)(`div`,{className:R.history,"aria-busy":l||_,children:[(0,D.jsxs)(`div`,{className:R.historyToolbar,children:[(0,D.jsx)(`span`,{children:t(`提交历史与分支图`,`Commit history & graph`)}),(0,D.jsx)(`button`,{className:m.textButton,type:`button`,onClick:S,"aria-label":t(`刷新提交历史`,`Refresh history`),children:t(`刷新`,`Refresh`)})]}),f?.scope&&(0,D.jsxs)(`p`,{className:m.state,children:[t(`展示仓库提交关系;文件差异仅限当前目录:`,`Repository history; file diffs are limited to: `),f.scope]}),(u||y)&&(0,D.jsxs)(`p`,{className:m.state,role:`status`,children:[t(`历史读取失败或分支已变化,请刷新历史。`,`Could not read history, or refs changed. Refresh history.`),` `,(0,D.jsx)(`button`,{className:m.textButton,type:`button`,onClick:S,children:t(`重试`,`Retry`)})]}),!f&&!u&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`正在读取历史…`,`Reading history…`)}),f?.kind===`not-repository`&&(0,D.jsx)(`p`,{className:m.state,children:t(`当前工作区不在 Git 仓库中。`,`This workspace is not in a Git repository.`)}),f?.kind===`unavailable`&&(0,D.jsx)(`p`,{className:m.state,children:t(`Git 不可用。`,`Git is unavailable.`)}),f?.kind===`repository`&&f.commits.length===0&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`仓库尚无提交。`,`This repository has no commits yet.`)}),(0,D.jsx)(`div`,{className:R.graphScroll,children:(0,D.jsx)(`ol`,{className:R.historyList,style:j,"aria-label":t(`提交历史`,`Commit history`),children:f?.commits.map((e,n)=>{let r=O.rows[n],i=f.refs.filter(t=>t.hash===e.hash),a=new Date(e.authoredAt),o=Number.isNaN(a.getTime())?e.authoredAt:a.toLocaleDateString(s===`zh`?`zh-CN`:`en-US`);return(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{type:`button`,className:R.commitRow,"data-commit":e.hash,"aria-current":h===e.hash?`true`:void 0,"aria-label":t(`查看提交 ${e.hash.slice(0,7)}:${e.subject}`,`View commit ${e.hash.slice(0,7)}: ${e.subject}`),onClick:()=>A(e.hash),children:[(0,D.jsxs)(`svg`,{width:O.width,height:84,className:R.graph,"aria-hidden":`true`,"data-git-graph-row":e.hash,children:[r.rails.map((e,t)=>(0,D.jsx)(`path`,{"data-color":e.color,d:`M${k(e.from)} 0 L${k(e.from)} 42 C${k(e.from)} 64 ${k(e.to)} 64 ${k(e.to)} 84`},`r${t}`)),r.incoming&&(0,D.jsx)(`path`,{"data-color":r.color,d:`M${k(r.lane)} 0 V42`}),r.parents.map(e=>(0,D.jsx)(`path`,{"data-parent":e.hash,"data-color":e.color,d:`M${k(r.lane)} 42 C${k(r.lane)} 64 ${k(e.to)} 64 ${k(e.to)} 84`},e.hash)),(0,D.jsx)(`circle`,{"data-color":r.color,cx:k(r.lane),cy:42,r:4})]}),(0,D.jsxs)(`span`,{className:R.commitCopy,children:[(0,D.jsx)(`span`,{className:R.subject,children:e.subject||t(`(无提交说明)`,`(No subject)`)}),(0,D.jsxs)(`span`,{className:R.refLine,title:i.map(e=>`${e.kind}: ${e.name}`).join(` · `),children:[f.head===e.hash&&(0,D.jsx)(`span`,{className:R.ref,"data-kind":`head`,children:`HEAD`}),i.map(e=>(0,D.jsxs)(`span`,{className:R.ref,"data-kind":e.kind,children:[e.kind===`tag`?`${t(`标签`,`tag`)}: `:e.kind===`remote`?`${t(`远端`,`remote`)}: `:``,e.name]},`${e.kind}/${e.name}`)),e.parents.length>1&&(0,D.jsx)(`span`,{className:R.merge,children:t(`合并`,`Merge`)})]}),(0,D.jsxs)(`span`,{className:R.commitMeta,children:[(0,D.jsx)(`code`,{children:e.hash.slice(0,7)}),(0,D.jsx)(`span`,{children:e.author}),(0,D.jsx)(`time`,{dateTime:e.authoredAt,title:e.authoredAt,children:o})]})]})]})},e.hash)})})}),f?.nextCursor&&(0,D.jsx)(`button`,{type:`button`,className:R.loadMore,disabled:_||l||f.snapshot!==c?.snapshot,onClick:()=>{E()},children:_?t(`正在加载…`,`Loading…`):t(`加载更多提交`,`Load more commits`)})]})});function B(e){return{A:t(`新增`,`Added`),M:t(`修改`,`Modified`),D:t(`删除`,`Deleted`),R:t(`重命名`,`Renamed`),C:t(`复制`,`Copied`),T:t(`类型变化`,`Type changed`),U:t(`冲突`,`Conflict`),"?":t(`未跟踪`,`Untracked`)}[e]??e}var V=(0,x.memo)(function({sessionId:e,visible:n,idle:r,model:i,onCommit:o}){a();let c=(0,x.useRef)(null),[l,d]=(0,x.useState)(i.selection),f=(0,x.useCallback)(e=>{i.selection=e,d(e)},[i]),p=(0,x.useCallback)(()=>{let e=c.current?.querySelector(`[data-git-file][aria-pressed="true"]`);f(null),requestAnimationFrame(()=>e?.focus({preventScroll:!0}))},[f]),[g,v]=(0,x.useState)(i.view),y=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!n)return;let e=_(document);return y.current=e,()=>{e.dispose(),y.current=null}},[n]);let{value:b,loading:C,error:A}=T((0,x.useCallback)(t=>w.status(e,t),[e]),n&&g===`changes`,r),{value:j,loading:M,error:N}=T((0,x.useCallback)(t=>w.control(e,t),[e]),n&&g===`changes`,r),[L,R]=(0,x.useState)(!1);(0,x.useEffect)(()=>{n&&g===`changes`||R(!1)},[n,g]);let[,V]=(0,x.useReducer)(e=>e+1,0);(0,x.useEffect)(()=>{let e=()=>V();return window.addEventListener(`pi-workspace-git-changed`,e),()=>window.removeEventListener(`pi-workspace-git-changed`,e)},[]);let H=()=>window.dispatchEvent(new Event(`pi-workspace-git-changed`)),U=r?j?.blocked:`agent_busy`,W=i.pending||!j?.version||M||N||A||!!U,G=async(t,n={})=>{if(W||i.pending||!j)return!1;i.pending=!0,i.outcome=null,V();try{return await w.write(e,{action:t,expected:j.version,...n}),i.outcome={ok:!0,reason:t},t===`commit`&&i.message===n.message&&(i.message=``),t===`create-branch`&&i.branch===n.branch&&(i.branch=``),!0}catch(e){return i.outcome={ok:!1,reason:e instanceof s?e.reason??(e.status<500?`git_failed`:`outcome_unknown`):`outcome_unknown`},!1}finally{i.pending=!1,window.dispatchEvent(new Event(`pi-workspace-git-changed`))}},K=b?.kind===`repository`?b:null;(0,x.useEffect)(()=>{if(!n||g!==`changes`||C||A||!b)return;let e=F(i.selection,b.kind===`repository`?b.entries:[]);e!==i.selection&&(i.selection=e,d(e))},[b,C,A,n,g,i]);let q=K?[{title:t(`冲突`,`Conflicts`),area:`unstaged`,changes:K.entries.filter(e=>e.conflict),conflict:!0},{title:k(`staged`),area:`staged`,changes:K.entries.filter(e=>!e.conflict&&!e.untracked&&e.index!==`.`)},{title:k(`unstaged`),area:`unstaged`,changes:K.entries.filter(e=>!e.conflict&&!e.untracked&&e.worktree!==`.`)},{title:k(`untracked`),area:`untracked`,changes:K.entries.filter(e=>e.untracked)}]:[],J=!W&&!K?.scope&&!!j?.staged&&!!i.message.trim(),Y=K?.root.split(/[\\/]/).at(-1)??``,X=K?[K.root,K.head,K.upstream??t(`未设置上游分支`,`No upstream branch`)].filter(Boolean).join(`
|
|
3
3
|
`):``;return(0,D.jsxs)(`div`,{ref:c,className:`${m.body} ${E.panel}`,children:[(0,D.jsxs)(`div`,{className:m.toolbar,children:[(0,D.jsx)(`div`,{className:E.viewSwitch,role:`group`,"aria-label":t(`Git 视图`,`Git view`),children:[`changes`,`history`].map(e=>(0,D.jsx)(`button`,{type:`button`,className:`${m.textButton} ${E.viewButton}`,"aria-pressed":g===e,onClick:()=>{i.view=e,v(e)},children:e===`changes`?t(`改动`,`Changes`):t(`历史`,`History`)},e))}),g===`history`&&(0,D.jsx)(`span`,{className:m.readonly,children:t(`只读`,`Read only`)}),g===`changes`&&(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`刷新 Git 状态`,`Refresh Git status`),title:t(`刷新 Git 状态`,`Refresh Git status`),onClick:H,children:(0,D.jsx)(h,{})})]}),g===`history`?(0,D.jsx)(`div`,{className:m.scroll,children:(0,D.jsx)(z,{sessionId:e,visible:n,idle:r,model:i,onCommit:o})}):(0,D.jsxs)(D.Fragment,{children:[K&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:E.repoBar,children:[(0,D.jsx)(I,{branch:K.branch,control:j,disabled:W,model:i,open:L,onOpenChange:R,onDraftChange:V,onWrite:G}),(0,D.jsx)(`span`,{className:E.repoName,title:X,children:Y}),K.upstream&&K.ahead!==null&&(0,D.jsxs)(`span`,{className:E.divergence,title:t(`上游差异(本地记录)`,`Upstream divergence (local refs)`),children:[`↑`,K.ahead,` ↓`,K.behind]}),(0,D.jsxs)(`span`,{className:E.count,title:t(`改动文件`,`Changed files`),children:[K.entries.length,K.truncated?`+`:``]})]}),K.scope&&(0,D.jsxs)(`div`,{className:E.scope,title:K.scope,children:[t(`当前目录:`,`Directory: `),K.scope]})]}),(0,D.jsx)(O,{selectionKey:l?JSON.stringify(l):null,onClose:p,preview:l&&K?(0,D.jsx)(P,{sessionId:e,path:l.path,area:l.area,visible:n&&g===`changes`,idle:r,onClose:p},JSON.stringify([e,l])):null,children:(0,D.jsxs)(`div`,{className:`${m.scroll} ${E.changesScroll}`,"aria-busy":C,role:`region`,"aria-label":t(`改动文件`,`Changed files`),children:[A&&(0,D.jsxs)(`div`,{className:m.state,role:`status`,children:[t(`Git 读取失败,请检查仓库或重试。`,`Could not read Git. Check the repository or try again.`),` `,(0,D.jsx)(`button`,{type:`button`,className:m.textButton,onClick:H,children:t(`重试`,`Retry`)})]}),!b&&!A&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`正在读取仓库…`,`Reading repository…`)}),b?.kind===`not-repository`&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`当前工作区不在 Git 仓库中。`,`This workspace is not in a Git repository.`)}),b?.kind===`unavailable`&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`Git 不可用,请在 Pi 所在机器安装 Git。`,`Git is unavailable. Install Git on the machine running Pi.`)}),K&&(0,D.jsxs)(D.Fragment,{children:[K.entries.length===0&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:K.scope?t(`当前目录没有未提交改动。`,`No uncommitted changes in this directory.`):t(`工作区干净,没有未提交改动。`,`Working tree clean. No uncommitted changes.`)}),q.filter(e=>e.changes.length>0).map(e=>(0,D.jsxs)(`section`,{"aria-label":e.title,children:[(0,D.jsxs)(`h3`,{className:E.groupHeading,children:[e.title,(0,D.jsx)(`span`,{children:e.changes.length})]}),(0,D.jsx)(`ul`,{className:E.list,children:e.changes.map(n=>{let r=e.conflict?`U`:e.area===`staged`?n.index:n.worktree;return(0,D.jsxs)(`li`,{className:E.changeRow,children:[(0,D.jsxs)(`button`,{type:`button`,className:E.change,title:n.originalPath?`${n.originalPath} → ${n.path}`:n.path,"data-git-file":JSON.stringify([e.area,n.path]),"aria-pressed":l?.path===n.path&&l.area===e.area,onClick:()=>f({path:n.path,area:e.area}),"aria-label":`${n.path}, ${B(r)}`,children:[(0,D.jsx)(u,{path:n.path,size:16}),(0,D.jsxs)(`span`,{className:E.filename,children:[n.path,n.originalPath&&(0,D.jsxs)(`small`,{children:[n.originalPath,` → `,n.path]})]}),(0,D.jsx)(`span`,{className:E.status,"data-status":r,"aria-hidden":`true`,children:r})]}),!e.conflict&&!n.submodule&&(0,D.jsx)(`button`,{type:`button`,className:E.fileAction,disabled:W,"aria-label":e.area===`staged`?t(`取消暂存 ${n.path}`,`Unstage ${n.path}`):t(`暂存 ${n.path}`,`Stage ${n.path}`),title:e.area===`staged`?t(`取消暂存`,`Unstage`):t(`暂存`,`Stage`),onClick:()=>{G(e.area===`staged`?`unstage`:`stage`,{path:n.path})},children:e.area===`staged`?`−`:`+`})]},n.path)})})]},e.title)),K.truncated&&(0,D.jsx)(`p`,{className:m.state,children:t(`仅显示前 1000 个改动文件,请缩小工作区范围。`,`Showing the first 1000 changed files. Open a smaller workspace to see more.`)})]})]})}),K&&(0,D.jsxs)(`div`,{className:E.commitFooter,"aria-busy":i.pending,children:[U&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:S(U)}),N&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:t(`操作状态读取失败,请刷新。`,`Could not read operation state. Refresh to retry.`)}),i.pending&&!L&&(0,D.jsx)(`p`,{className:E.hint,role:`status`,children:t(`正在执行 Git 操作…`,`Running Git operation…`)}),i.outcome&&!L&&(0,D.jsxs)(`div`,{className:E.feedbackRow,children:[(0,D.jsx)(`p`,{className:E.feedback,"data-error":!i.outcome.ok,role:`status`,children:S(i.outcome.reason)}),(0,D.jsx)(`button`,{type:`button`,className:m.iconButton,"aria-label":t(`关闭 Git 提示`,`Dismiss Git message`),onClick:()=>{i.outcome=null,V()},children:`×`})]}),K.scope?(0,D.jsx)(`p`,{className:E.rootHint,title:S(`root_required`),children:t(`提交请打开仓库根目录`,`Commit from repository root`)}):(0,D.jsxs)(`form`,{className:E.commitForm,"aria-label":t(`创建提交`,`Create commit`),onSubmit:e=>{e.preventDefault(),J&&G(`commit`,{message:i.message})},children:[(0,D.jsx)(`textarea`,{"aria-label":t(`提交说明`,`Commit message`),rows:1,maxLength:8192,disabled:i.pending,value:i.message,placeholder:t(`提交说明…`,`Commit message…`),onChange:e=>{i.message=e.target.value,V()},onKeyDown:e=>{let t=y.current?.guards(e.nativeEvent)??e.nativeEvent.isComposing;e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!t&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,D.jsxs)(`div`,{className:E.actionRow,children:[(0,D.jsx)(`span`,{className:E.hint,children:j?.staged?t(`仅暂存区 · ${j.staged} 个文件`,`Staged only · ${j.staged} files`):t(`先暂存要提交的文件`,`Stage files to commit`)}),(0,D.jsx)(`button`,{className:E.actionButton,type:`submit`,disabled:!J,title:t(`仅提交暂存区 · ⌘/Ctrl+Enter`,`Commit staged files · ⌘/Ctrl+Enter`),children:t(`提交`,`Commit`)})]})]})]})]})]})}),H=(0,x.memo)(function({sessionId:e,hash:n,visible:r,idle:i,onCommit:o}){a();let s=(0,x.useRef)(null),[c,l]=(0,x.useState)(null),d=()=>{let e=s.current?.querySelector(`[data-git-file][aria-pressed="true"]`);l(null),requestAnimationFrame(()=>e?.focus({preventScroll:!0}))},[f,p]=(0,x.useState)(0),{value:g,loading:_,error:v,refresh:y}=T((0,x.useCallback)(t=>w.commit(e,n,f,t),[e,n,f]),r,i,!1),b=g?.parentIndex===f?g:null;return(0,x.useEffect)(()=>{b&&c&&!b.files.some(e=>e.path===c)&&l(null)},[b,c]),(0,D.jsxs)(`div`,{className:`${m.body} ${E.panel}`,ref:s,children:[(0,D.jsxs)(`div`,{className:m.toolbar,children:[(0,D.jsxs)(`span`,{className:m.path,children:[t(`提交详情`,`Commit details`),` · `,n.slice(0,7)]}),(0,D.jsx)(`span`,{className:m.readonly,children:t(`只读`,`Read only`)}),(0,D.jsx)(`button`,{className:m.iconButton,type:`button`,onClick:y,"aria-label":t(`刷新提交详情`,`Refresh commit`),children:(0,D.jsx)(h,{})})]}),(0,D.jsx)(O,{selectionKey:c,onClose:d,preview:c&&b?(0,D.jsx)(U,{sessionId:e,hash:n,path:c,parentIndex:f,visible:r,idle:i,onClose:d},JSON.stringify([e,n,f,c])):null,children:(0,D.jsxs)(`div`,{className:m.scroll,"aria-busy":_,children:[v&&(0,D.jsxs)(`p`,{className:m.state,role:`status`,children:[t(`提交读取失败,可能已不可达。`,`Could not read this commit. It may no longer be reachable.`),` `,(0,D.jsx)(`button`,{className:m.textButton,type:`button`,onClick:y,children:t(`重试`,`Retry`)})]}),!g&&!v&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`正在读取提交…`,`Reading commit…`)}),g&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:R.detail,children:[(0,D.jsx)(`h2`,{children:g.subject||t(`(无提交说明)`,`(No subject)`)}),(0,D.jsxs)(`dl`,{children:[(0,D.jsx)(`dt`,{children:t(`提交`,`Commit`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`code`,{children:g.hash})}),(0,D.jsx)(`dt`,{children:t(`作者`,`Author`)}),(0,D.jsxs)(`dd`,{children:[g.author,` <`,g.email,`>`]}),(0,D.jsx)(`dt`,{children:t(`创作时间`,`Authored`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`time`,{dateTime:g.authoredAt,children:g.authoredAt})}),(0,D.jsx)(`dt`,{children:t(`提交者`,`Committer`)}),(0,D.jsxs)(`dd`,{children:[g.committer,` <`,g.committerEmail,`>`]}),(0,D.jsx)(`dt`,{children:t(`提交时间`,`Committed`)}),(0,D.jsx)(`dd`,{children:(0,D.jsx)(`time`,{dateTime:g.committedAt,children:g.committedAt})}),(0,D.jsx)(`dt`,{children:t(`父提交`,`Parents`)}),(0,D.jsx)(`dd`,{className:R.parentList,children:g.parents.length?g.parents.map((e,n)=>(0,D.jsx)(`button`,{type:`button`,className:R.parentLink,onClick:()=>o(e),"aria-label":t(`打开父提交 ${n+1}:${e.slice(0,7)}`,`Open parent ${n+1}: ${e.slice(0,7)}`),children:(0,D.jsx)(`code`,{children:e.slice(0,7)})},e)):t(`根提交`,`Root commit`)})]}),(0,D.jsx)(`div`,{className:R.message,"aria-label":t(`完整提交说明`,`Full commit message`),children:g.message}),g.scope&&(0,D.jsxs)(`p`,{className:m.state,children:[t(`文件改动仅限:`,`File changes limited to: `),g.scope]})]}),g.parents.length>1?(0,D.jsxs)(`label`,{className:R.parentSelect,children:[t(`比较基准`,`Compare against`),(0,D.jsx)(`select`,{"aria-label":t(`比较父提交`,`Compare parent`),value:f,onChange:e=>{l(null),p(Number(e.target.value))},children:g.parents.map((e,n)=>(0,D.jsxs)(`option`,{value:n,children:[t(`父提交 ${n+1}`,`Parent ${n+1}`),` · `,e.slice(0,7)]},`${n}/${e}`))})]}):(0,D.jsx)(`p`,{className:m.state,children:g.parents.length?t(`与父提交比较`,`Compared with parent`):t(`与空目录比较`,`Compared with empty tree`)}),!b&&!v&&(0,D.jsx)(`p`,{className:m.state,role:`status`,children:t(`正在读取文件改动…`,`Reading changed files…`)}),b&&(0,D.jsxs)(`section`,{"aria-label":t(`提交文件`,`Commit files`),children:[(0,D.jsxs)(`h3`,{className:E.groupHeading,children:[t(`改动文件`,`Changed files`),(0,D.jsxs)(`span`,{children:[b.files.length,b.truncated?`+`:``]})]}),b.files.length===0&&(0,D.jsx)(`p`,{className:m.state,children:t(`所选比较在当前目录中没有文件改动。`,`No file changes in this directory for this comparison.`)}),(0,D.jsx)(`ul`,{className:E.list,children:b.files.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{className:E.change,type:`button`,"data-git-file":e.path,"aria-pressed":c===e.path,onClick:()=>l(e.path),"aria-label":t(`查看提交差异:${e.path}`,`View commit diff: ${e.path}`),children:[(0,D.jsx)(u,{path:e.path,size:16}),(0,D.jsx)(`span`,{className:E.filename,children:e.path}),(0,D.jsx)(`span`,{className:R.fileStats,children:e.additions===null?t(`二进制`,`Binary`):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:E.added,children:[`+`,e.additions]}),(0,D.jsxs)(`span`,{className:E.removed,children:[`−`,e.deletions]})]})}),(0,D.jsx)(`span`,{className:E.status,"data-status":e.status,children:e.status})]})},e.path))}),b.truncated&&(0,D.jsx)(`p`,{className:m.state,children:t(`仅显示前 1000 个文件。`,`Showing the first 1000 files.`)})]})]})]})})]})}),U=(0,x.memo)(function({sessionId:e,hash:n,path:r,parentIndex:i,visible:o,idle:s,onClose:c}){a();let l=T((0,x.useCallback)(t=>w.commitDiff(e,n,r,i,t),[e,n,r,i]),o,s,!1),u=l.value?l.value.parentHash?`${t(`父提交`,`Parent`)} ${l.value.parentHash.slice(0,7)}`:t(`空目录`,`Empty tree`):``;return(0,D.jsx)(M,{onClose:c,path:r,label:`${n.slice(0,7)}${u?` · ${u}`:``}`,...l})}),W=()=>({selection:null,view:`changes`,history:null,selected:null,message:``,branch:``,checkout:!0,pending:!1,outcome:null}),G={id:o.git,kind:`builtin`,version:`1.0.0`,name:{zh:`Git`,en:`Git`},description:{zh:`审阅工作区改动与提交历史,暂存文件、提交并管理本地分支。`,en:`Review workspace changes and history, stage files, commit and manage local branches.`}},K=c({id:G.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:{zh:`Git 改动`,en:`Git changes`},description:{zh:`查看分支、工作区改动与文件差异`,en:`Review branches, workspace changes and file diffs`},kind:`git`,icon:p},panels:[{kind:`git`,title:()=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(p,{size:16}),(0,D.jsx)(`span`,{children:`Git`})]}),component:e=>(0,D.jsx)(V,{sessionId:e.session.sessionId,visible:e.visible,idle:e.session.idle,model:e.resource(W),onCommit:t=>e.open(`git-commit`,t,t.slice(0,7))})},{kind:`git-commit`,component:e=>(0,D.jsx)(H,{sessionId:e.session.sessionId,hash:e.contentId,visible:e.visible,idle:e.session.idle,onCommit:t=>e.open(`git-commit`,t,t.slice(0,7))})},{kind:`git-diff`,component:e=>{let[t,n]=JSON.parse(e.contentId);return(0,D.jsx)(P,{sessionId:e.session.sessionId,area:t,path:n,visible:e.visible,idle:e.session.idle})}},{kind:`git-commit-diff`,component:e=>{let[t,n,r]=JSON.parse(e.contentId);return(0,D.jsx)(U,{sessionId:e.session.sessionId,hash:t,parentIndex:n,path:r,visible:e.visible,idle:e.session.idle})}}]}});export{K as default};
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=fed095f0-6a58-4c5b-a1c4-c346252679a7
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6872579e-e113-42e1-8087-80f243da1f80`,e._sentryDebugIdIdentifier=`sentry-dbid-6872579e-e113-42e1-8087-80f243da1f80`)}catch{}})();import{a as e,d as t,h as n,i as r,l as i,o as a,s as o,t as s,v as c}from"./dist-DvRDAAjZ.js";import{o as l,s as u}from"./app.js";import{c as d,n as f}from"./app-_Ug70Gwo.js";var p={id:a.terminal,kind:`builtin`,version:`1.0.0`,name:{zh:`终端`,en:`Terminal`},description:{zh:`在工作区运行交互式 Shell。停用会结束此服务的所有终端进程。`,en:`Run an interactive shell in the workspace. Disabling ends all terminals on this service.`}},m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,r)=>{for(var i=r>1?void 0:r?h(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&m(t,n,i),i},v=(e,t)=>(n,r)=>t(n,r,e),ee=`Terminal input`,te={get:()=>ee,set:e=>ee=e},ne=`Too much output to announce, navigate to rows manually to read`,re={get:()=>ne,set:e=>ne=e};function ie(e){return e.replace(/\r?\n/g,`\r`)}function ae(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function se(e,t,n,r){e.stopPropagation(),e.clipboardData&&y(e.clipboardData.getData(`text/plain`),t,n,r)}function y(e,t,n,r){e=ie(e),e=ae(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function b(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function le(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ue(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var de=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},x=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},S=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?le(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,C=new Map;function ve(e){return e[_e]||[]}function w(e){if(C.has(e))return C.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ye(t,e,r)};return t._id=e,C.set(e,t),t}function ye(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var T=w(`BufferService`),be=w(`CoreMouseService`),xe=w(`CoreService`),Se=w(`CharsetService`),Ce=w(`InstantiationService`),we=w(`LogService`),E=w(`OptionsService`),Te=w(`OscLinkService`),Ee=w(`UnicodeService`),De=w(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new S,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=_([v(0,T),v(1,E),v(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`8df53bee-0ee9-4848-a55b-4603dd7b7c03`,e._sentryDebugIdIdentifier=`sentry-dbid-8df53bee-0ee9-4848-a55b-4603dd7b7c03`)}catch{}})();import{a as e,d as t,h as n,i as r,l as i,o as a,s as o,t as s,v as c}from"./dist-DvRDAAjZ.js";import{o as l,s as u}from"./app.js";import{c as d,n as f}from"./app-Cw3IG84J.js";var p={id:a.terminal,kind:`builtin`,version:`1.0.0`,name:{zh:`终端`,en:`Terminal`},description:{zh:`在工作区运行交互式 Shell。停用会结束此服务的所有终端进程。`,en:`Run an interactive shell in the workspace. Disabling ends all terminals on this service.`}},m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,r)=>{for(var i=r>1?void 0:r?h(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&m(t,n,i),i},v=(e,t)=>(n,r)=>t(n,r,e),ee=`Terminal input`,te={get:()=>ee,set:e=>ee=e},ne=`Too much output to announce, navigate to rows manually to read`,re={get:()=>ne,set:e=>ne=e};function ie(e){return e.replace(/\r?\n/g,`\r`)}function ae(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function se(e,t,n,r){e.stopPropagation(),e.clipboardData&&y(e.clipboardData.getData(`text/plain`),t,n,r)}function y(e,t,n,r){e=ie(e),e=ae(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function b(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function le(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ue(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var de=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},x=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},S=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?le(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,C=new Map;function ve(e){return e[_e]||[]}function w(e){if(C.has(e))return C.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ye(t,e,r)};return t._id=e,C.set(e,t),t}function ye(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var T=w(`BufferService`),be=w(`CoreMouseService`),xe=w(`CoreService`),Se=w(`CharsetService`),Ce=w(`InstantiationService`),we=w(`LogService`),E=w(`OptionsService`),Te=w(`OscLinkService`),Ee=w(`UnicodeService`),De=w(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new S,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=_([v(0,T),v(1,E),v(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ae=w(`CharSizeService`),je=w(`CoreBrowserService`),Me=w(`MouseService`),Ne=w(`RenderService`),Pe=w(`SelectionService`),Fe=w(`CharacterJoinerService`),Ie=w(`ThemeService`),Le=w(`LinkProviderService`),Re=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?We.isErrorNoTelemetry(e)?new We(e.message+`
|
|
4
4
|
|
|
@@ -15,4 +15,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
15
15
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===ts+1&&(this._liveRegion.textContent+=re.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};ns=_([v(1,Ce),v(2,je),v(3,Ne)],ns);var rs=class extends k{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new M),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new M),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(O(()=>{tt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(P(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(P(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(P(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(P(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&is(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,tt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};rs=_([v(1,Me),v(2,Ne),v(3,T),v(4,Le)],rs);function is(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var as=class extends Go{constructor(e={}){super(e),this._linkifier=this._register(new at),this.browser=wi,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new at),this._onCursorMove=this._register(new M),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new M),this.onKey=this._onKey.event,this._onRender=this._register(new M),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new M),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new M),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new M),this.onBell=this._onBell.event,this._onFocus=this._register(new M),this._onBlur=this._register(new M),this._onA11yCharEmitter=this._register(new M),this._onA11yTabEmitter=this._register(new M),this._onWillOpen=this._register(new M),this._setup(),this._decorationService=this._instantiationService.createInstance(Zo),this._instantiationService.setService(De,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(yi),this._instantiationService.setService(Le,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Oe)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(j.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(j.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(j.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(j.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(O(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=U.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${L.ESC}]${n};${ko(r)}${Vr.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=H.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=H.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ns,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(P(this.element,`copy`,e=>{this.hasSelection()&&oe(e,this._selectionService)}));let e=e=>se(e,this.textarea,this.coreService,this.optionsService);this._register(P(this.textarea,`paste`,e)),this._register(P(this.element,`paste`,e)),Oi?this._register(P(this.element,`mousedown`,e=>{e.button===2&&b(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(P(this.element,`contextmenu`,e=>{b(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ii&&this._register(P(this.element,`auxclick`,e=>{e.button===1&&ce(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(P(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(P(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(P(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(P(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(P(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(P(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(P(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(P(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,te.get()),Li||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(_i,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(je,this._coreBrowserService),this._register(P(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(P(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(pi,this._document,this._helperContainer),this._instantiationService.setService(Ae,this._charSizeService),this._themeService=this._instantiationService.createInstance(ba),this._instantiationService.setService(Ie,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Jr),this._instantiationService.setService(Fe,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ui,this.rows,this.screenElement)),this._instantiationService.setService(Ne,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Hr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Si),this._instantiationService.setService(Me,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(rs,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Nr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(da,this.element,this.screenElement,r)),this._instantiationService.setService(Pe,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(j.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Pr,this.screenElement)),this._register(P(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ns,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(zr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(zr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(fi,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(P(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(P(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=L.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){y(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=qo(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===L.ETX||n.key===L.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(os(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Y));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(L.ESC+`[I`):this.coreService.triggerDataEvent(L.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function os(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var ss=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},cs=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new S)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},ls=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new cs(t)}getNullCell(){return new S}},us=class extends k{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new M),this.onBufferChange=this._onBufferChange.event,this._normal=new ls(this._core.buffers.normal,`normal`),this._alternate=new ls(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},ds=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},fs=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ps=[`cols`,`rows`],ms=0,hs=class extends k{constructor(e){super(),this._core=this._register(new as(e)),this._addonManager=this._register(new ss),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(ps.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new ds(this._core),this._parser}get unicode(){return this._checkProposedApi(),new fs(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new us(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
16
16
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return te.get()},set promptLabel(e){te.set(e)},get tooMuchOutput(){return re.get()},set tooMuchOutput(e){re.set(e)}}}_verifyIntegers(...e){for(ms of e)if(ms===1/0||isNaN(ms)||ms%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(ms of e)if(ms&&(ms===1/0||isNaN(ms)||ms%1!=0||ms<0))throw Error(`This API only accepts positive integers`)}},gs=2,_s=1,vs=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(gs,Math.floor(u/e.css.cell.width)),rows:Math.max(_s,Math.floor(l/e.css.cell.height))}}};function ys(e,t){let n=document.querySelector(`meta[name="pi-style-nonce"]`)?.content,r=document.createElement;document.createElement=function(e,t){let i=r.call(document,e,t);return n&&i instanceof HTMLStyleElement&&(i.nonce=n),i};try{e.open(t)}finally{document.createElement=r}}var bs=class{element=document.createElement(`div`);terminal=new hs({cursorBlink:!0,scrollback:2e3,fontSize:13,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,minimumContrastRatio:4.5,macOptionClickForcesSelection:!0});fit=new vs;state={phase:`starting`};listeners=new Set;lifetime;retry;opened=!1;created=!1;disposed=!1;commands=Promise.resolve();queued=0;active=!0;creation;offline=()=>{this.state.phase!==`exited`&&this.state.phase!==`failed`&&(this.lifetime?.abort(),this.patch({phase:`disconnected`}))};online=()=>{this.connect()};id;sessionId;constructor(e,t){this.id=e,this.sessionId=t,this.element.style.cssText=`width:100%;height:100%;min-width:0;overflow:hidden`,this.terminal.loadAddon(this.fit),window.addEventListener(`offline`,this.offline),window.addEventListener(`online`,this.online),this.terminal.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.ctrlKey||e.metaKey)&&!e.altKey&&e.key.toLowerCase()===`c`&&this.terminal.hasSelection()?(d(this.terminal.getSelection()),!1):!0),this.terminal.onData(e=>this.input(e)),this.terminal.onResize(e=>{this.state.phase===`connected`&&this.active&&this.enqueue(`resize`,e)})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;patch(e){this.state=e,this.terminal.options.disableStdin=e.phase!==`connected`||!this.active;for(let e of this.listeners)e()}activate(e){this.active=e,this.terminal.options.disableStdin=!e||this.state.phase!==`connected`,e&&this.opened&&!this.lifetime&&this.state.phase===`disconnected`&&this.connect()}mount(e){e.append(this.element),this.opened||(this.opened=!0,ys(this.terminal,this.element),this.terminal.textarea?.setAttribute(`aria-label`,`Terminal input`),this.connect())}measure(){if(!this.element.isConnected||!this.element.clientWidth||!this.element.clientHeight||this.element.closest(`[aria-hidden=true]`))return;let e=document.body.hasAttribute(`data-ds-dark-theme`);this.terminal.options.theme=e?{background:`#151618`,foreground:`#e5e5e5`,cursor:`#e5e5e5`,selectionBackground:`#264f78`,selectionInactiveBackground:`#3a3d41`}:{background:`#ffffff`,foreground:`#242424`,cursor:`#242424`,selectionBackground:`#add6ff`,selectionInactiveBackground:`#e5ebf1`};let t=this.fit.proposeDimensions();t&&this.terminal.resize(Math.min(500,Math.max(2,t.cols)),Math.min(300,Math.max(1,t.rows)))}async request(e,t,n){return r(`/api/terminal/${e}`,{method:`POST`,headers:{Authorization:`Bearer ${u()}`,"Content-Type":`application/json`},body:JSON.stringify({sessionId:this.sessionId,id:this.id,...t}),signal:n},{expectedNetworkFailure:!0})}async connect(){if(this.disposed||this.lifetime||!this.active||!navigator.onLine||this.state.phase===`exited`)return;clearTimeout(this.retry);let t=new AbortController;this.lifetime=t,this.patch({phase:this.created?`disconnected`:`starting`});try{if(this.created||=(this.creation=this.request(`create`,{cols:this.terminal.cols,rows:this.terminal.rows}).then(e),await this.creation,!0),this.disposed)return;let n=await this.request(`attach`,{},t.signal);n.response.ok||await e(n);let r=n.response.body.getReader();try{let e=new TextDecoder,t=``;for(;!this.disposed;){let{done:n,value:i}=await r.read();if(n)break;if(t+=e.decode(i,{stream:!0}),t.length>2097152)throw Error(`Terminal stream overflow`);let a;for(;(a=t.indexOf(`
|
|
17
17
|
`))>=0;){let e=JSON.parse(t.slice(0,a));if(t=t.slice(a+1),e.type===`snapshot`)this.terminal.reset(),this.terminal.resize(e.cols,e.rows),await new Promise(t=>this.terminal.write(e.screen,t)),this.patch({phase:`connected`}),this.measure(),this.active&&this.enqueue(`resize`,{cols:this.terminal.cols,rows:this.terminal.rows});else if(e.type===`output`)await new Promise(t=>this.terminal.write(e.data,t));else if(e.type===`resize`)continue;else if(e.type===`exit`){this.patch({phase:`exited`,exitCode:e.exitCode});return}}}throw Error(`Terminal disconnected`)}finally{await r.cancel().catch(()=>{}),r.releaseLock()}}catch(e){if(this.disposed)return;let t=e instanceof o&&e.status!==409&&e.status<500;this.patch({phase:t?`failed`:`disconnected`,reason:e instanceof o?e.reason:void 0}),t||(this.retry=setTimeout(()=>{this.connect()},1500))}finally{this.lifetime===t&&(this.lifetime=void 0)}}input(e){if(this.state.phase!==`connected`||!this.active)return;if(this.queued+e.length>65536){this.lifetime?.abort();return}let t=``;for(let n of e)t+=n,t.length>=4e3&&(this.enqueue(`input`,{data:t}),t=``);t&&this.enqueue(`input`,{data:t})}enqueue(t,n){let r=this.lifetime,i=n.data?.length??0;this.queued+=i,this.commands=this.commands.then(async()=>{this.disposed||!this.active||this.state.phase!==`connected`||r!==this.lifetime||r?.signal.aborted||await e(await this.request(t,n,r?.signal))}).catch(e=>{e instanceof o&&e.status===409||r?.abort()}).finally(()=>{this.queued-=i})}dispose(){this.disposed=!0,clearTimeout(this.retry),this.lifetime?.abort(),window.removeEventListener(`offline`,this.offline),window.removeEventListener(`online`,this.online),(async()=>{try{await this.creation,this.created&&await e(await this.request(`close`,{}))}catch{}this.terminal.dispose(),this.element.remove(),this.listeners.clear()})()}},xs=c(n(),1),Ss={root:`_root_nznr3_1`,screen:`_screen_nznr3_3`,status:`_status_nznr3_4`},Cs=i();function ws(e){switch(e){case`terminal_shell_unavailable`:return t(`终端不可用:默认 shell 不存在或不可执行。请修正 SHELL(Windows 为 COMSPEC)后重启应用。`,`Terminal unavailable: the default shell is missing or not executable. Correct SHELL (COMSPEC on Windows) and restart the app.`);case`terminal_workspace_unavailable`:return t(`终端不可用:工作区目录不存在或不可访问。请切换到有效工作区后新建终端。`,`Terminal unavailable: the workspace directory is missing or inaccessible. Select a valid workspace, then open a new terminal.`);case`terminal_runtime_unavailable`:return t(`终端不可用:本机终端组件启动失败。请重新安装或修复应用的 node-pty 依赖后重启。`,`Terminal unavailable: the native terminal component failed to start. Reinstall or repair the app's node-pty dependency, then restart.`);case`terminal_limit`:return t(`终端数量已达上限,请关闭不用的终端后重试。`,`Terminal limit reached. Close unused terminals and try again.`);default:return t(`终端不可用,请检查默认 shell 和工作区目录后重新打开。`,`Terminal unavailable. Check the default shell and workspace directory, then open a new terminal.`)}}function Ts({model:e,visible:n,onNew:r}){let i=e,a=t(`终端输入`,`Terminal input`),o=(0,xs.useRef)(null),s=(0,xs.useSyncExternalStore)(e.subscribe,e.getSnapshot);return(0,xs.useLayoutEffect)(()=>{let e=o.current;i.mount(e);let t=new ResizeObserver(()=>i.measure());t.observe(e);let n=new MutationObserver(()=>i.measure());return n.observe(document.body,{attributes:!0,attributeFilter:[`data-ds-dark-theme`]}),()=>{t.disconnect(),n.disconnect(),i.element.remove()}},[e]),(0,xs.useLayoutEffect)(()=>{e.terminal.textarea?.setAttribute(`aria-label`,a),n&&(e.measure(),e.terminal.focus())},[e,n,s.phase,a]),(0,Cs.jsxs)(`section`,{className:Ss.root,"data-workspace-terminal":e.id,"data-terminal-phase":s.phase,children:[s.phase!==`connected`&&(0,Cs.jsxs)(`div`,{className:Ss.status,role:`status`,children:[(0,Cs.jsx)(`span`,{children:s.phase===`starting`?t(`正在启动终端…`,`Starting terminal…`):s.phase===`disconnected`?t(`连接断开,正在重连…`,`Disconnected. Reconnecting…`):s.phase===`exited`?t(`进程已退出(${s.exitCode})`,`Process exited (${s.exitCode})`):ws(s.reason)}),(s.phase===`failed`||s.phase===`exited`)&&(0,Cs.jsx)(f,{size:`sm`,onClick:r,children:t(`新建终端`,`New terminal`)})]}),(0,Cs.jsx)(`div`,{className:Ss.screen,ref:o})]})}var Es=s({id:p.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:{zh:`打开终端`,en:`Open terminal`},panelTitle:p.name,description:{zh:`在当前工作区中运行交互式 Shell`,en:`Run an interactive shell in this workspace`},kind:`terminal`,multiple:!0,icon:()=>(0,Cs.jsx)(`span`,{"aria-hidden":`true`,style:{fontFamily:`monospace`,fontSize:24},children:`›_`})},panels:[{kind:`terminal`,component:e=>(0,Cs.jsx)(Ts,{model:e.resource(()=>new bs(e.contentId,e.session.sessionId),e=>e.dispose(),(e,t)=>e.activate(t)),visible:e.visible,onNew:()=>e.open(`terminal`,l(),e.locale===`zh`?`终端`:`Terminal`)})}]}});export{Es as default};
|
|
18
|
-
//# debugId=
|
|
18
|
+
//# debugId=8df53bee-0ee9-4848-a55b-4603dd7b7c03
|