pi-webapp 0.1.22 → 0.1.23

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.
@@ -1,4 +1,4 @@
1
- var Qr=Object.defineProperty;var en=(e,t,i)=>t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var V=(e,t,i)=>en(e,typeof t!="symbol"?t+"":t,i);import{B as tn,a as sn,b as Lt,H as cs,r as Pt,j as Ge,l as it,e as rn,d as nn}from"./app-D54rSb9U.js";import{d as on,a as an}from"./app.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a24ba779-9631-427d-aebe-04cbdc1e7323",e._sentryDebugIdIdentifier="sentry-dbid-a24ba779-9631-427d-aebe-04cbdc1e7323")}catch{}})();const ds={id:tn.terminal,name:{zh:"终端",en:"Terminal"}};/**
1
+ var Qr=Object.defineProperty;var en=(e,t,i)=>t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var V=(e,t,i)=>en(e,typeof t!="symbol"?t+"":t,i);import{B as tn,a as sn,b as Lt,H as cs,r as Pt,j as Ge,l as it,e as rn,d as nn}from"./app-C-H5rHq5.js";import{d as on,a as an}from"./app.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a24ba779-9631-427d-aebe-04cbdc1e7323",e._sentryDebugIdIdentifier="sentry-dbid-a24ba779-9631-427d-aebe-04cbdc1e7323")}catch{}})();const ds={id:tn.terminal,name:{zh:"终端",en:"Terminal"}};/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *
@@ -1,3 +1,3 @@
1
- import{l as t,b as ne,a as ie,r as h,j as e,f as u,g as re,h as Y,I as Q,u as U,i as ce,k as K,M as oe,m as le,o as de,F as Z,H as he,B as fe,d as ue}from"./app-D54rSb9U.js";import{d as me}from"./app.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new a.Error().stack;s&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[s]="81d2c7dd-b1ed-4a43-bc9d-98e4bfef1a50",a._sentryDebugIdIdentifier="sentry-dbid-81d2c7dd-b1ed-4a43-bc9d-98e4bfef1a50")}catch{}})();function W(a){const s={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."]},i=s[a]??s.git_failed;return t(...i)}async function M(a,s,i,o){return ne(await ie(`/api/workspace/git/${a}`,{method:"POST",headers:{Authorization:`Bearer ${me()}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,...i}),signal:o}))}const H={control:(a,s)=>M("control",a,{},s),write:(a,s)=>M("write",a,s),status:(a,s)=>M("status",a,{},s),diff:(a,s,i,o)=>M("diff",a,{path:s,area:i},o),history:(a,s,i)=>M("history",a,{cursor:s},i),commit:(a,s,i,o)=>M("commit-detail",a,{hash:s,parentIndex:i},o),commitDiff:(a,s,i,o,n)=>M("commit-diff",a,{hash:s,path:i,parentIndex:o},n)};function V(a,s,i,o=!0){const[n,_]=h.useState(null),[g,m]=h.useState(!0),[l,w]=h.useState(!1),[C,$]=h.useState(0),d=h.useCallback(()=>{m(!0),$(f=>f+1)},[]);return h.useEffect(()=>{if(!s)return;let f=!1,G=!1,v=!1;const E=new AbortController,N=async()=>{if(!(f||document.visibilityState==="hidden")){if(G){v=!0;return}G=!0,m(!0);try{const y=await a(E.signal);f||(_(p=>JSON.stringify(p)===JSON.stringify(y)?p:y),w(!1))}catch{f||w(!0)}finally{G=!1,f||(m(!1),v&&(v=!1,N()))}}};N();const j=o?window.setInterval(()=>{N()},5e3):void 0,b=()=>{N()};return window.addEventListener("focus",b),window.addEventListener("pi-workspace-git-changed",b),document.addEventListener("visibilitychange",b),()=>{f=!0,E.abort(),window.clearInterval(j),window.removeEventListener("pi-workspace-git-changed",b),window.removeEventListener("focus",b),document.removeEventListener("visibilitychange",b)}},[a,s,i,C,o]),{value:n,loading:g,error:l,refresh:d}}const pe="_panel_1ndkv_2",ge="_viewSwitch_1ndkv_3",be="_viewButton_1ndkv_4",xe="_repoBar_1ndkv_5",ke="_branchPicker_1ndkv_6",_e="_branchTrigger_1ndkv_7",je="_repoName_1ndkv_11",ye="_divergence_1ndkv_12",ve="_count_1ndkv_13",Ne="_scope_1ndkv_14",we="_changesScroll_1ndkv_15",Ce="_groupHeading_1ndkv_16",Se="_list_1ndkv_18",$e="_changeRow_1ndkv_19",Le="_change_1ndkv_15",Re="_diffScroll_1ndkv_23",Ge="_filename_1ndkv_25",Ee="_status_1ndkv_27",Be="_added_1ndkv_28",Te="_removed_1ndkv_29",De="_fileAction_1ndkv_30",Pe="_commitFooter_1ndkv_32",Ae="_commitForm_1ndkv_33",Fe="_rootHint_1ndkv_36",We="_actionRow_1ndkv_37",He="_hint_1ndkv_38",Ie="_feedback_1ndkv_38",Me="_feedbackRow_1ndkv_41",Oe="_actionButton_1ndkv_44",Ve="_branchPopover_1ndkv_46",qe="_pickerHeader_1ndkv_47",Ue="_branchSearch_1ndkv_49",Je="_field_1ndkv_49",ze="_branchList_1ndkv_50",Ke="_branchOption_1ndkv_52",Qe="_newBranch_1ndkv_56",Xe="_form_1ndkv_58",Ye="_checkbox_1ndkv_60",Ze="_diffSummary_1ndkv_64",et="_stats_1ndkv_65",tt="_diff_1ndkv_23",st="_diffLine_1ndkv_68",at="_lineNumber_1ndkv_69",nt="_lineText_1ndkv_70",it="_diffHunk_1ndkv_74",rt="_diffNotice_1ndkv_75",ct="_noNewline_1ndkv_76",ot="_reviewLayout_1ndkv_79",lt="_inlinePreview_1ndkv_81",dt="_inlineDiffToolbar_1ndkv_83",ht="_diffIdentity_1ndkv_84",ft="_diffDetails_1ndkv_85",ut="_diffArea_1ndkv_86",mt="_diffNavigation_1ndkv_88",pt="_diffPosition_1ndkv_89",gt="_diffViewport_1ndkv_91",c={panel:pe,viewSwitch:ge,viewButton:be,repoBar:xe,branchPicker:ke,branchTrigger:_e,repoName:je,divergence:ye,count:ve,scope:Ne,changesScroll:we,groupHeading:Ce,list:Se,changeRow:$e,change:Le,diffScroll:Re,filename:Ge,status:Ee,added:Be,removed:Te,fileAction:De,commitFooter:Pe,commitForm:Ae,rootHint:Fe,actionRow:We,hint:He,feedback:Ie,feedbackRow:Me,actionButton:Oe,branchPopover:Ve,pickerHeader:qe,branchSearch:Ue,field:Je,branchList:ze,branchOption:Ke,newBranch:Qe,form:Xe,checkbox:Ye,diffSummary:Ze,stats:et,diff:tt,diffLine:st,lineNumber:at,lineText:nt,diffHunk:it,diffNotice:rt,noNewline:ct,reviewLayout:ot,inlinePreview:lt,inlineDiffToolbar:dt,diffIdentity:ht,diffDetails:ft,diffArea:ut,diffNavigation:mt,diffPosition:pt,diffViewport:gt};function ee({children:a,preview:s,selectionKey:i,onClose:o}){const n=h.useRef(null),_=!!s;return h.useEffect(()=>{var g,m;_&&i&&((m=(g=n.current)==null?void 0:g.querySelector('[data-git-file][aria-pressed="true"]'))==null||m.scrollIntoView({block:"nearest",inline:"nearest"}))},[i,_]),e.jsxs("div",{className:c.reviewLayout,"data-preview":_,ref:n,children:[a,s&&e.jsx("div",{className:c.inlinePreview,role:"region","aria-label":t("差异预览","Diff preview"),onKeyDown:g=>{g.key==="Escape"&&!g.nativeEvent.isComposing&&!g.defaultPrevented&&(g.preventDefault(),o())},children:s})]})}function z(a){return a==="staged"?t("已暂存","Staged"):a==="unstaged"?t("未暂存","Unstaged"):t("未跟踪","Untracked")}function bt(a){let s=0,i=0,o=!1;const n=a.split(`
1
+ import{l as t,b as ne,a as ie,r as h,j as e,f as u,g as re,h as Y,I as Q,u as U,i as ce,k as K,M as oe,m as le,o as de,F as Z,H as he,B as fe,d as ue}from"./app-C-H5rHq5.js";import{d as me}from"./app.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new a.Error().stack;s&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[s]="81d2c7dd-b1ed-4a43-bc9d-98e4bfef1a50",a._sentryDebugIdIdentifier="sentry-dbid-81d2c7dd-b1ed-4a43-bc9d-98e4bfef1a50")}catch{}})();function W(a){const s={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."]},i=s[a]??s.git_failed;return t(...i)}async function M(a,s,i,o){return ne(await ie(`/api/workspace/git/${a}`,{method:"POST",headers:{Authorization:`Bearer ${me()}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,...i}),signal:o}))}const H={control:(a,s)=>M("control",a,{},s),write:(a,s)=>M("write",a,s),status:(a,s)=>M("status",a,{},s),diff:(a,s,i,o)=>M("diff",a,{path:s,area:i},o),history:(a,s,i)=>M("history",a,{cursor:s},i),commit:(a,s,i,o)=>M("commit-detail",a,{hash:s,parentIndex:i},o),commitDiff:(a,s,i,o,n)=>M("commit-diff",a,{hash:s,path:i,parentIndex:o},n)};function V(a,s,i,o=!0){const[n,_]=h.useState(null),[g,m]=h.useState(!0),[l,w]=h.useState(!1),[C,$]=h.useState(0),d=h.useCallback(()=>{m(!0),$(f=>f+1)},[]);return h.useEffect(()=>{if(!s)return;let f=!1,G=!1,v=!1;const E=new AbortController,N=async()=>{if(!(f||document.visibilityState==="hidden")){if(G){v=!0;return}G=!0,m(!0);try{const y=await a(E.signal);f||(_(p=>JSON.stringify(p)===JSON.stringify(y)?p:y),w(!1))}catch{f||w(!0)}finally{G=!1,f||(m(!1),v&&(v=!1,N()))}}};N();const j=o?window.setInterval(()=>{N()},5e3):void 0,b=()=>{N()};return window.addEventListener("focus",b),window.addEventListener("pi-workspace-git-changed",b),document.addEventListener("visibilitychange",b),()=>{f=!0,E.abort(),window.clearInterval(j),window.removeEventListener("pi-workspace-git-changed",b),window.removeEventListener("focus",b),document.removeEventListener("visibilitychange",b)}},[a,s,i,C,o]),{value:n,loading:g,error:l,refresh:d}}const pe="_panel_1ndkv_2",ge="_viewSwitch_1ndkv_3",be="_viewButton_1ndkv_4",xe="_repoBar_1ndkv_5",ke="_branchPicker_1ndkv_6",_e="_branchTrigger_1ndkv_7",je="_repoName_1ndkv_11",ye="_divergence_1ndkv_12",ve="_count_1ndkv_13",Ne="_scope_1ndkv_14",we="_changesScroll_1ndkv_15",Ce="_groupHeading_1ndkv_16",Se="_list_1ndkv_18",$e="_changeRow_1ndkv_19",Le="_change_1ndkv_15",Re="_diffScroll_1ndkv_23",Ge="_filename_1ndkv_25",Ee="_status_1ndkv_27",Be="_added_1ndkv_28",Te="_removed_1ndkv_29",De="_fileAction_1ndkv_30",Pe="_commitFooter_1ndkv_32",Ae="_commitForm_1ndkv_33",Fe="_rootHint_1ndkv_36",We="_actionRow_1ndkv_37",He="_hint_1ndkv_38",Ie="_feedback_1ndkv_38",Me="_feedbackRow_1ndkv_41",Oe="_actionButton_1ndkv_44",Ve="_branchPopover_1ndkv_46",qe="_pickerHeader_1ndkv_47",Ue="_branchSearch_1ndkv_49",Je="_field_1ndkv_49",ze="_branchList_1ndkv_50",Ke="_branchOption_1ndkv_52",Qe="_newBranch_1ndkv_56",Xe="_form_1ndkv_58",Ye="_checkbox_1ndkv_60",Ze="_diffSummary_1ndkv_64",et="_stats_1ndkv_65",tt="_diff_1ndkv_23",st="_diffLine_1ndkv_68",at="_lineNumber_1ndkv_69",nt="_lineText_1ndkv_70",it="_diffHunk_1ndkv_74",rt="_diffNotice_1ndkv_75",ct="_noNewline_1ndkv_76",ot="_reviewLayout_1ndkv_79",lt="_inlinePreview_1ndkv_81",dt="_inlineDiffToolbar_1ndkv_83",ht="_diffIdentity_1ndkv_84",ft="_diffDetails_1ndkv_85",ut="_diffArea_1ndkv_86",mt="_diffNavigation_1ndkv_88",pt="_diffPosition_1ndkv_89",gt="_diffViewport_1ndkv_91",c={panel:pe,viewSwitch:ge,viewButton:be,repoBar:xe,branchPicker:ke,branchTrigger:_e,repoName:je,divergence:ye,count:ve,scope:Ne,changesScroll:we,groupHeading:Ce,list:Se,changeRow:$e,change:Le,diffScroll:Re,filename:Ge,status:Ee,added:Be,removed:Te,fileAction:De,commitFooter:Pe,commitForm:Ae,rootHint:Fe,actionRow:We,hint:He,feedback:Ie,feedbackRow:Me,actionButton:Oe,branchPopover:Ve,pickerHeader:qe,branchSearch:Ue,field:Je,branchList:ze,branchOption:Ke,newBranch:Qe,form:Xe,checkbox:Ye,diffSummary:Ze,stats:et,diff:tt,diffLine:st,lineNumber:at,lineText:nt,diffHunk:it,diffNotice:rt,noNewline:ct,reviewLayout:ot,inlinePreview:lt,inlineDiffToolbar:dt,diffIdentity:ht,diffDetails:ft,diffArea:ut,diffNavigation:mt,diffPosition:pt,diffViewport:gt};function ee({children:a,preview:s,selectionKey:i,onClose:o}){const n=h.useRef(null),_=!!s;return h.useEffect(()=>{var g,m;_&&i&&((m=(g=n.current)==null?void 0:g.querySelector('[data-git-file][aria-pressed="true"]'))==null||m.scrollIntoView({block:"nearest",inline:"nearest"}))},[i,_]),e.jsxs("div",{className:c.reviewLayout,"data-preview":_,ref:n,children:[a,s&&e.jsx("div",{className:c.inlinePreview,role:"region","aria-label":t("差异预览","Diff preview"),onKeyDown:g=>{g.key==="Escape"&&!g.nativeEvent.isComposing&&!g.defaultPrevented&&(g.preventDefault(),o())},children:s})]})}function z(a){return a==="staged"?t("已暂存","Staged"):a==="unstaged"?t("未暂存","Unstaged"):t("未跟踪","Untracked")}function bt(a){let s=0,i=0,o=!1;const n=a.split(`
2
2
  `);return n.at(-1)===""&&n.pop(),n.map(_=>{const g=_.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(_.startsWith("diff --git ")&&(o=!1),g&&(s=Number(g[1]),i=Number(g[2]),o=!0),o&&!g){if(_.startsWith("+"))return{kind:"add",text:_,oldLine:null,newLine:i++};if(_.startsWith("-"))return{kind:"remove",text:_,oldLine:s++,newLine:null};if(_.startsWith(" "))return{kind:"context",text:_,oldLine:s++,newLine:i++}}return{kind:"meta",text:_,oldLine:null,newLine:null}})}function xt(a){const s=[],i=[],o=[];let n=null,_="",g="",m="";for(const l of bt(a)){if(l.kind!=="meta"){l.kind==="context"?n=null:n===null&&(n=i.length,i.push(s.length)),s.push({...l,kind:l.kind,change:n});continue}const w=l.text.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@\s?(.*)$/);if(w)n=null,s.push({kind:"hunk",oldLine:Number(w[1]),newLine:Number(w[2]),text:w[3],change:null});else if(l.text==="\"){const C=s.at(-1);C&&C.kind!=="hunk"&&(C.noNewline=!0)}else l.text.startsWith("diff --git ")?(n=null,_=g=m=""):l.text.startsWith("old mode ")?_=l.text.slice(9):l.text.startsWith("new mode ")?o.push({kind:"mode",from:_,to:l.text.slice(9)}):l.text.startsWith("rename from ")?g=l.text.slice(12):l.text.startsWith("rename to ")?o.push({kind:"rename",from:g,to:l.text.slice(10)}):l.text.startsWith("copy from ")?m=l.text.slice(10):l.text.startsWith("copy to ")?o.push({kind:"copy",from:m,to:l.text.slice(8)}):l.text.startsWith("new file mode ")?o.push({kind:"added",from:"",to:l.text.slice(14)}):l.text.startsWith("deleted file mode ")&&o.push({kind:"deleted",from:l.text.slice(18),to:""})}return{lines:s,changes:i,notices:o.filter(l=>!i.length||l.kind!=="added"&&l.kind!=="deleted")}}function te({path:a,label:s,value:i,loading:o,error:n,refresh:_,onClose:g}){const m=(i==null?void 0:i.kind)==="text"?i.patch:"",l=h.useMemo(()=>xt(m),[m,a]),{lines:w,changes:C,notices:$}=l,d=h.useRef(null),[f,G]=h.useState(null),v=(f==null?void 0:f.preview)===l?f.index:-1;h.useEffect(()=>{var p;(p=d.current)==null||p.scrollTo({top:0,left:0})},[l]);const E=p=>{if(o||n||p<0||p>=C.length)return;const R=d.current,A=R==null?void 0:R.querySelector(`[data-change="${p}"][data-change-start="true"]`);!R||!A||(R.scrollTo({top:R.scrollTop+A.getBoundingClientRect().top-R.getBoundingClientRect().top,left:R.scrollLeft}),G({preview:l,index:p}))},N=w.filter(p=>p.kind==="add").length,j=w.filter(p=>p.kind==="remove").length,b=(i==null?void 0:i.kind)==="text"&&e.jsxs("span",{className:c.stats,children:[e.jsxs("span",{className:c.added,children:["+",N]}),e.jsxs("span",{className:c.removed,children:["−",j]})]}),y={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 e.jsxs("div",{className:u.body,children:[e.jsxs("div",{className:g?c.inlineDiffToolbar:u.toolbar,children:[g?e.jsxs("div",{className:c.diffIdentity,children:[e.jsx("span",{className:u.path,title:a,children:a}),e.jsxs("div",{className:c.diffDetails,children:[e.jsx("span",{className:c.diffArea,title:s,children:s}),b]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:u.path,title:a,children:a}),e.jsx("span",{className:u.readonly,children:t("只读","Read only")})]}),e.jsxs("div",{className:c.diffNavigation,role:"group","aria-label":t("改动跳转","Change navigation"),children:[e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("上一处改动","Previous change"),title:t("上一处改动","Previous change"),disabled:o||n||v<=0,onClick:()=>E(v-1),children:e.jsx(re,{})}),e.jsxs("span",{className:c.diffPosition,role:"status","aria-label":t("改动位置","Change position"),"aria-live":"polite","aria-atomic":"true",title:t(`第 ${v+1} / ${C.length} 处改动`,`Change ${v+1} of ${C.length}`),children:[v+1,"/",C.length]}),e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("下一处改动","Next change"),title:t("下一处改动","Next change"),disabled:o||n||v+1>=C.length,onClick:()=>E(v+1),children:e.jsx(Y,{})})]}),e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("刷新差异","Refresh diff"),title:t("刷新差异","Refresh diff"),onClick:_,children:e.jsx(Q,{})}),g&&e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("关闭差异预览","Close diff preview"),title:t("关闭差异预览 · Esc","Close diff preview · Esc"),onClick:g,children:"×"})]}),!g&&e.jsxs("div",{className:c.diffSummary,children:[e.jsx("span",{children:s}),b]}),n&&e.jsxs("div",{className:u.state,role:"status",children:[t("差异读取失败,请重试。","Could not read this diff. Try again.")," ",e.jsx("button",{type:"button",className:u.textButton,onClick:_,children:t("重试","Retry")})]}),e.jsxs("div",{className:`${u.preview} ${c.diffViewport}`,"aria-busy":o,children:[!i&&!n&&e.jsx("p",{className:u.state,role:"status",children:t("正在读取差异…","Reading diff…")}),i&&i.kind!=="text"&&e.jsx("p",{className:u.state,role:"status",children:y[i.kind]}),(i==null?void 0:i.kind)==="text"&&e.jsxs("div",{ref:d,className:c.diffScroll,tabIndex:0,role:"region","aria-label":t("文件差异","File diff"),children:[$.map((p,R)=>e.jsx("p",{className:c.diffNotice,children:kt(p)},R)),!w.length&&!$.length&&e.jsx("p",{className:u.state,children:y.empty}),e.jsx("pre",{className:c.diff,children:e.jsx("code",{children:w.map((p,R)=>p.kind==="hunk"?e.jsxs("span",{className:c.diffHunk,"data-kind":"hunk",children:[e.jsx("span",{"aria-hidden":"true",children:"···"}),e.jsxs("span",{children:[t(`行 ${p.oldLine} / ${p.newLine}`,`Lines ${p.oldLine} / ${p.newLine}`),p.text&&` · ${p.text}`]})]},R):e.jsxs("span",{className:c.diffLine,"data-kind":p.kind,"data-change":p.change??void 0,"data-change-start":p.change!==null&&C[p.change]===R?"true":void 0,"data-active":p.change!==null&&v===p.change?"true":void 0,children:[e.jsx("span",{className:c.lineNumber,"aria-hidden":"true",children:p.oldLine}),e.jsx("span",{className:c.lineNumber,"aria-hidden":"true",children:p.newLine}),e.jsxs("span",{className:c.lineText,children:[p.text||" ",p.noNewline&&e.jsx("span",{className:c.noNewline,title:t("文件末尾无换行","No newline at end of file"),"aria-label":t("文件末尾无换行","No newline at end of file"),children:"↵"})]})]},R))})})]})]})]})}function kt(a){switch(a.kind){case"mode":return t(`文件权限:${a.from} → ${a.to}`,`File mode: ${a.from} → ${a.to}`);case"rename":return t(`重命名:${a.from} → ${a.to}`,`Renamed: ${a.from} → ${a.to}`);case"copy":return t(`复制:${a.from} → ${a.to}`,`Copied: ${a.from} → ${a.to}`);case"added":return t("新增空文件","Empty file added");case"deleted":return t("删除空文件","Empty file deleted")}}const se=h.memo(function({sessionId:s,path:i,area:o,visible:n,idle:_,onClose:g}){U();const m=h.useCallback(w=>H.diff(s,i,o,w),[s,i,o]),l=V(m,n,_);return e.jsx(te,{path:i,label:z(o),onClose:g,...l})});function _t(a,s){if(!a)return null;const i=s.find(n=>n.path===a.path);if(!i)return null;const o=i.conflict?["unstaged"]:i.untracked?["untracked"]:[...i.worktree!=="."?["unstaged"]:[],...i.index!=="."?["staged"]:[]];return o.includes(a.area)?a:o[0]?{path:a.path,area:o[0]}:null}function jt({branch:a,control:s,disabled:i,model:o,open:n,onOpenChange:_,onDraftChange:g,onWrite:m}){const l=h.useRef(null),w=h.useRef(null),C=h.useRef(null),[$,d]=h.useState(!1),[f,G]=h.useState(!1),[v,E]=h.useState("");ce(w,n,()=>_(!1)),h.useEffect(()=>{if(!n){d(!1),E(""),G(!1);return}const y=p=>{var R;p.target instanceof Node&&!((R=l.current)!=null&&R.contains(p.target))&&_(!1)};return document.addEventListener("pointerdown",y),()=>document.removeEventListener("pointerdown",y)},[n,_]),h.useEffect(()=>{var y;$&&((y=C.current)==null||y.focus())},[$]);const N=s!=null&&s.scope?"root_required":s!=null&&s.dirty?"dirty_worktree":null,j=(s==null?void 0:s.branches.filter(y=>y.name.toLocaleLowerCase().includes(v.toLocaleLowerCase())))??[],b=async(y,p)=>{G(!0),await m(y,p)&&_(!1)};return e.jsxs("div",{ref:l,className:c.branchPicker,children:[e.jsxs("button",{type:"button",className:c.branchTrigger,disabled:!s,"aria-label":t("管理分支","Manage branches"),"aria-haspopup":"dialog","aria-expanded":n,title:a??t("分离 HEAD","Detached HEAD"),onClick:()=>_(!n),children:[e.jsx(K,{}),e.jsx("span",{children:a??t("分离 HEAD","Detached HEAD")}),e.jsx(Y,{})]}),n&&e.jsxs(oe,{ref:w,className:c.branchPopover,compact:!0,role:"dialog","aria-modal":"true","aria-label":t("管理分支","Manage branches"),children:[e.jsxs("div",{className:c.pickerHeader,children:[e.jsx("span",{children:$?t("新建分支","New branch"):t("本地分支","Local branches")}),e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("关闭分支面板","Close branches"),onClick:()=>_(!1),children:"×"})]}),$?e.jsxs("form",{className:c.form,"aria-label":t("创建分支","Create branch"),onSubmit:y=>{y.preventDefault(),!i&&o.branch.trim()&&(s!=null&&s.head)&&!(o.checkout&&N)&&b("create-branch",{branch:o.branch,checkout:o.checkout})},children:[e.jsxs("label",{className:c.field,children:[t("分支名称","Branch name"),e.jsx("input",{ref:C,"aria-label":t("新分支名称","New branch name"),maxLength:256,value:o.branch,disabled:o.pending,placeholder:"feature/name",onChange:y=>{o.branch=y.target.value,g()}})]}),e.jsxs("label",{className:c.checkbox,children:[e.jsx("input",{type:"checkbox",checked:o.checkout,disabled:o.pending,onChange:y=>{o.checkout=y.target.checked,g()}}),t("创建后切换","Switch after creating")]}),o.checkout&&N&&e.jsx("p",{className:c.hint,children:W(N)}),e.jsxs("div",{className:c.actionRow,children:[e.jsx("button",{type:"button",className:u.textButton,onClick:()=>d(!1),children:t("返回","Back")}),e.jsx("button",{className:c.actionButton,type:"submit",disabled:i||!o.branch.trim()||!(s!=null&&s.head)||o.checkout&&!!N,children:t("创建分支","Create branch")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{className:c.branchSearch,type:"search","data-modal-autofocus":!0,"aria-label":t("搜索分支","Search branches"),value:v,placeholder:t("搜索分支…","Search branches…"),onChange:y=>E(y.target.value)}),e.jsxs("div",{className:c.branchList,role:"group","aria-label":t("本地分支","Local branches"),children:[j.map(y=>e.jsxs("button",{type:"button",className:c.branchOption,title:y.name,disabled:i||!!N||y.current||y.occupied||!(s!=null&&s.head),"aria-label":t(`切换到分支:${y.name}`,`Switch to branch: ${y.name}`),onClick:()=>{b("switch-branch",{branch:y.name})},children:[e.jsx(K,{}),e.jsx("span",{children:y.name}),(y.current||y.occupied)&&e.jsx("small",{children:y.current?t("当前","Current"):t("其他工作树","Other worktree")})]},y.name)),j.length===0&&e.jsx("p",{className:c.hint,children:t("没有匹配的分支。","No matching branches.")})]}),N&&e.jsx("p",{className:c.hint,children:W(N)}),e.jsxs("button",{type:"button",className:c.newBranch,disabled:o.pending||!(s!=null&&s.head),"aria-label":t("新建分支","New branch"),onClick:()=>d(!0),children:[e.jsx(le,{}),t("新建分支…","New branch…")]})]}),!(s!=null&&s.head)&&e.jsx("p",{className:c.hint,children:W("no_commits")}),o.pending&&e.jsx("p",{className:c.hint,role:"status",children:t("正在执行…","Running…")}),(s==null?void 0:s.blocked)&&e.jsx("p",{className:c.hint,children:W(s.blocked)}),f&&o.outcome&&!o.outcome.ok&&e.jsx("p",{className:c.feedback,"data-error":"true",role:"status",children:W(o.outcome.reason)})]})]})}function yt(a){let s=[],i=0,o=1;const n=[];for(const _ of a){const g=s.findIndex(d=>d.hash===_.hash),m=g<0?s.length:g,l=g<0?i++%4:s[m].color,w=[...s];g>=0&&s.splice(g,1);let C=Math.min(m,s.length);const $=[...new Set(_.parents)];for(const[d,f]of $.entries())s.some(G=>G.hash===f)||s.splice(C++,0,{hash:f,color:d===0?l:i++%4});n.push({lane:m,color:l,incoming:g>=0,rails:w.flatMap((d,f)=>d.hash===_.hash?[]:[{from:f,to:s.findIndex(G=>G.hash===d.hash),color:d.color}]),parents:$.map(d=>{const f=s.findIndex(G=>G.hash===d);return{hash:d,from:m,to:f,color:s[f].color}})}),o=Math.max(o,m+1,w.length,s.length)}return{rows:n,width:o*16+16}}const vt="_history_1fyyf_1",Nt="_historyToolbar_1fyyf_2",wt="_graphScroll_1fyyf_3",Ct="_historyList_1fyyf_4",St="_commitRow_1fyyf_5",$t="_loadMore_1fyyf_7",Lt="_parentLink_1fyyf_7",Rt="_graph_1fyyf_3",Gt="_commitCopy_1fyyf_15",Et="_subject_1fyyf_16",Bt="_refLine_1fyyf_17",Tt="_ref_1fyyf_17",Dt="_merge_1fyyf_20",Pt="_commitMeta_1fyyf_21",At="_detail_1fyyf_27",Ft="_message_1fyyf_33",Wt="_parentList_1fyyf_35",Ht="_parentSelect_1fyyf_36",It="_fileStats_1fyyf_38",B={history:vt,historyToolbar:Nt,graphScroll:wt,historyList:Ct,commitRow:St,loadMore:$t,parentLink:Lt,graph:Rt,commitCopy:Gt,subject:Et,refLine:Bt,ref:Tt,merge:Dt,commitMeta:Pt,detail:At,message:Ft,parentList:Wt,parentSelect:Ht,fileStats:It},Mt=h.memo(function({sessionId:s,visible:i,idle:o,model:n,onCommit:_}){const g=U(),m=h.useCallback(x=>H.history(s,void 0,x),[s]),{value:l,loading:w,error:C,refresh:$}=V(m,i,o),[d,f]=h.useState(n.history),[G,v]=h.useState(n.selected),[E,N]=h.useState(!1),[j,b]=h.useState(!1),y=()=>{b(!1),$()},p=h.useRef(null);h.useEffect(()=>{var x,D;l&&(((x=n.history)==null?void 0:x.snapshot)!==l.snapshot||!n.history.commits.length)&&((D=p.current)==null||D.abort(),N(!1),b(!1),n.history=l,f(l))},[l,n]),h.useEffect(()=>{var x;return i||((x=p.current)==null||x.abort(),N(!1)),()=>{var D;return(D=p.current)==null?void 0:D.abort()}},[i]);const R=async()=>{var k;const x=n.history;if(!(x!=null&&x.nextCursor)||E)return;const D=new AbortController;p.current=D,N(!0),b(!1);try{const F=await H.history(s,x.nextCursor,D.signal);if(D.signal.aborted||((k=n.history)==null?void 0:k.snapshot)!==F.snapshot||n.history.nextCursor!==x.nextCursor)return;const I=new Set(x.commits.map(L=>L.hash)),O={...F,commits:[...x.commits,...F.commits.filter(L=>!I.has(L.hash))]};n.history=O,f(O)}catch{D.signal.aborted||b(!0)}finally{D.signal.aborted||N(!1)}},A=h.useMemo(()=>yt((d==null?void 0:d.commits)??[]),[d==null?void 0:d.commits]),T=x=>x*16+12,J=x=>{n.selected=x,v(x),_(x)},q={"--git-graph-width":`${A.width}px`};return e.jsxs("div",{className:B.history,"aria-busy":w||E,children:[e.jsxs("div",{className:B.historyToolbar,children:[e.jsx("span",{children:t("提交历史与分支图","Commit history & graph")}),e.jsx("button",{className:u.textButton,type:"button",onClick:y,"aria-label":t("刷新提交历史","Refresh history"),children:t("刷新","Refresh")})]}),(d==null?void 0:d.scope)&&e.jsxs("p",{className:u.state,children:[t("展示仓库提交关系;文件差异仅限当前目录:","Repository history; file diffs are limited to: "),d.scope]}),(C||j)&&e.jsxs("p",{className:u.state,role:"status",children:[t("历史读取失败或分支已变化,请刷新历史。","Could not read history, or refs changed. Refresh history.")," ",e.jsx("button",{className:u.textButton,type:"button",onClick:y,children:t("重试","Retry")})]}),!d&&!C&&e.jsx("p",{className:u.state,role:"status",children:t("正在读取历史…","Reading history…")}),(d==null?void 0:d.kind)==="not-repository"&&e.jsx("p",{className:u.state,children:t("当前工作区不在 Git 仓库中。","This workspace is not in a Git repository.")}),(d==null?void 0:d.kind)==="unavailable"&&e.jsx("p",{className:u.state,children:t("Git 不可用。","Git is unavailable.")}),(d==null?void 0:d.kind)==="repository"&&d.commits.length===0&&e.jsx("p",{className:u.state,role:"status",children:t("仓库尚无提交。","This repository has no commits yet.")}),e.jsx("div",{className:B.graphScroll,children:e.jsx("ol",{className:B.historyList,style:q,"aria-label":t("提交历史","Commit history"),children:d==null?void 0:d.commits.map((x,D)=>{const k=A.rows[D],F=d.refs.filter(L=>L.hash===x.hash),I=new Date(x.authoredAt),O=Number.isNaN(I.getTime())?x.authoredAt:I.toLocaleDateString(g==="zh"?"zh-CN":"en-US");return e.jsx("li",{children:e.jsxs("button",{type:"button",className:B.commitRow,"data-commit":x.hash,"aria-current":G===x.hash?"true":void 0,"aria-label":t(`查看提交 ${x.hash.slice(0,7)}:${x.subject}`,`View commit ${x.hash.slice(0,7)}: ${x.subject}`),onClick:()=>J(x.hash),children:[e.jsxs("svg",{width:A.width,height:84,className:B.graph,"aria-hidden":"true","data-git-graph-row":x.hash,children:[k.rails.map((L,r)=>e.jsx("path",{"data-color":L.color,d:`M${T(L.from)} 0 L${T(L.from)} 42 C${T(L.from)} 64 ${T(L.to)} 64 ${T(L.to)} 84`},`r${r}`)),k.incoming&&e.jsx("path",{"data-color":k.color,d:`M${T(k.lane)} 0 V42`}),k.parents.map(L=>e.jsx("path",{"data-parent":L.hash,"data-color":L.color,d:`M${T(k.lane)} 42 C${T(k.lane)} 64 ${T(L.to)} 64 ${T(L.to)} 84`},L.hash)),e.jsx("circle",{"data-color":k.color,cx:T(k.lane),cy:42,r:4})]}),e.jsxs("span",{className:B.commitCopy,children:[e.jsx("span",{className:B.subject,children:x.subject||t("(无提交说明)","(No subject)")}),e.jsxs("span",{className:B.refLine,title:F.map(L=>`${L.kind}: ${L.name}`).join(" · "),children:[d.head===x.hash&&e.jsx("span",{className:B.ref,"data-kind":"head",children:"HEAD"}),F.map(L=>e.jsxs("span",{className:B.ref,"data-kind":L.kind,children:[L.kind==="tag"?`${t("标签","tag")}: `:L.kind==="remote"?`${t("远端","remote")}: `:"",L.name]},`${L.kind}/${L.name}`)),x.parents.length>1&&e.jsx("span",{className:B.merge,children:t("合并","Merge")})]}),e.jsxs("span",{className:B.commitMeta,children:[e.jsx("code",{children:x.hash.slice(0,7)}),e.jsx("span",{children:x.author}),e.jsx("time",{dateTime:x.authoredAt,title:x.authoredAt,children:O})]})]})]})},x.hash)})})}),(d==null?void 0:d.nextCursor)&&e.jsx("button",{type:"button",className:B.loadMore,disabled:E||w||d.snapshot!==(l==null?void 0:l.snapshot),onClick:()=>{R()},children:E?t("正在加载…","Loading…"):t("加载更多提交","Load more commits")})]})});function Ot(a){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")}[a]??a}const Vt=h.memo(function({sessionId:s,visible:i,idle:o,model:n,onCommit:_}){U();const g=h.useRef(null),[m,l]=h.useState(n.selection),w=h.useCallback(r=>{n.selection=r,l(r)},[n]),C=h.useCallback(()=>{var S;const r=(S=g.current)==null?void 0:S.querySelector('[data-git-file][aria-pressed="true"]');w(null),requestAnimationFrame(()=>r==null?void 0:r.focus({preventScroll:!0}))},[w]),[$,d]=h.useState(n.view),f=h.useRef(null);h.useEffect(()=>{if(!i)return;const r=de(document);return f.current=r,()=>{r.dispose(),f.current=null}},[i]);const G=h.useCallback(r=>H.status(s,r),[s]),{value:v,loading:E,error:N}=V(G,i&&$==="changes",o),j=h.useCallback(r=>H.control(s,r),[s]),{value:b,loading:y,error:p}=V(j,i&&$==="changes",o),[R,A]=h.useState(!1);h.useEffect(()=>{(!i||$!=="changes")&&A(!1)},[i,$]);const[,T]=h.useReducer(r=>r+1,0);h.useEffect(()=>{const r=()=>T();return window.addEventListener("pi-workspace-git-changed",r),()=>window.removeEventListener("pi-workspace-git-changed",r)},[]);const J=()=>window.dispatchEvent(new Event("pi-workspace-git-changed")),q=o?b==null?void 0:b.blocked:"agent_busy",x=n.pending||!(b!=null&&b.version)||y||p||N||!!q,D=async(r,S={})=>{if(x||n.pending||!b)return!1;n.pending=!0,n.outcome=null,T();try{return await H.write(s,{action:r,expected:b.version,...S}),n.outcome={ok:!0,reason:r},r==="commit"&&n.message===S.message&&(n.message=""),r==="create-branch"&&n.branch===S.branch&&(n.branch=""),!0}catch(P){return n.outcome={ok:!1,reason:P instanceof he?P.reason??(P.status<500?"git_failed":"outcome_unknown"):"outcome_unknown"},!1}finally{n.pending=!1,window.dispatchEvent(new Event("pi-workspace-git-changed"))}},k=(v==null?void 0:v.kind)==="repository"?v:null;h.useEffect(()=>{if(!i||$!=="changes"||E||N||!v)return;const r=_t(n.selection,v.kind==="repository"?v.entries:[]);r!==n.selection&&(n.selection=r,l(r))},[v,E,N,i,$,n]);const F=k?[{title:t("冲突","Conflicts"),area:"unstaged",changes:k.entries.filter(r=>r.conflict),conflict:!0},{title:z("staged"),area:"staged",changes:k.entries.filter(r=>!r.conflict&&!r.untracked&&r.index!==".")},{title:z("unstaged"),area:"unstaged",changes:k.entries.filter(r=>!r.conflict&&!r.untracked&&r.worktree!==".")},{title:z("untracked"),area:"untracked",changes:k.entries.filter(r=>r.untracked)}]:[],I=!x&&!(k!=null&&k.scope)&&!!(b!=null&&b.staged)&&!!n.message.trim(),O=(k==null?void 0:k.root.split(/[\\/]/).at(-1))??"",L=k?[k.root,k.head,k.upstream??t("未设置上游分支","No upstream branch")].filter(Boolean).join(`
3
3
  `):"";return e.jsxs("div",{ref:g,className:`${u.body} ${c.panel}`,children:[e.jsxs("div",{className:u.toolbar,children:[e.jsx("div",{className:c.viewSwitch,role:"group","aria-label":t("Git 视图","Git view"),children:["changes","history"].map(r=>e.jsx("button",{type:"button",className:`${u.textButton} ${c.viewButton}`,"aria-pressed":$===r,onClick:()=>{n.view=r,d(r)},children:r==="changes"?t("改动","Changes"):t("历史","History")},r))}),$==="history"&&e.jsx("span",{className:u.readonly,children:t("只读","Read only")}),$==="changes"&&e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("刷新 Git 状态","Refresh Git status"),title:t("刷新 Git 状态","Refresh Git status"),onClick:J,children:e.jsx(Q,{})})]}),$==="history"?e.jsx("div",{className:u.scroll,children:e.jsx(Mt,{sessionId:s,visible:i,idle:o,model:n,onCommit:_})}):e.jsxs(e.Fragment,{children:[k&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:c.repoBar,children:[e.jsx(jt,{branch:k.branch,control:b,disabled:x,model:n,open:R,onOpenChange:A,onDraftChange:T,onWrite:D}),e.jsx("span",{className:c.repoName,title:L,children:O}),k.upstream&&k.ahead!==null&&e.jsxs("span",{className:c.divergence,title:t("上游差异(本地记录)","Upstream divergence (local refs)"),children:["↑",k.ahead," ↓",k.behind]}),e.jsxs("span",{className:c.count,title:t("改动文件","Changed files"),children:[k.entries.length,k.truncated?"+":""]})]}),k.scope&&e.jsxs("div",{className:c.scope,title:k.scope,children:[t("当前目录:","Directory: "),k.scope]})]}),e.jsx(ee,{selectionKey:m?JSON.stringify(m):null,onClose:C,preview:m&&k?e.jsx(se,{sessionId:s,path:m.path,area:m.area,visible:i&&$==="changes",idle:o,onClose:C},JSON.stringify([s,m])):null,children:e.jsxs("div",{className:`${u.scroll} ${c.changesScroll}`,"aria-busy":E,role:"region","aria-label":t("改动文件","Changed files"),children:[N&&e.jsxs("div",{className:u.state,role:"status",children:[t("Git 读取失败,请检查仓库或重试。","Could not read Git. Check the repository or try again.")," ",e.jsx("button",{type:"button",className:u.textButton,onClick:J,children:t("重试","Retry")})]}),!v&&!N&&e.jsx("p",{className:u.state,role:"status",children:t("正在读取仓库…","Reading repository…")}),(v==null?void 0:v.kind)==="not-repository"&&e.jsx("p",{className:u.state,role:"status",children:t("当前工作区不在 Git 仓库中。","This workspace is not in a Git repository.")}),(v==null?void 0:v.kind)==="unavailable"&&e.jsx("p",{className:u.state,role:"status",children:t("Git 不可用,请在 Pi 所在机器安装 Git。","Git is unavailable. Install Git on the machine running Pi.")}),k&&e.jsxs(e.Fragment,{children:[k.entries.length===0&&e.jsx("p",{className:u.state,role:"status",children:k.scope?t("当前目录没有未提交改动。","No uncommitted changes in this directory."):t("工作区干净,没有未提交改动。","Working tree clean. No uncommitted changes.")}),F.filter(r=>r.changes.length>0).map(r=>e.jsxs("section",{"aria-label":r.title,children:[e.jsxs("h3",{className:c.groupHeading,children:[r.title,e.jsx("span",{children:r.changes.length})]}),e.jsx("ul",{className:c.list,children:r.changes.map(S=>{const P=r.conflict?"U":r.area==="staged"?S.index:S.worktree;return e.jsxs("li",{className:c.changeRow,children:[e.jsxs("button",{type:"button",className:c.change,title:S.originalPath?`${S.originalPath} → ${S.path}`:S.path,"data-git-file":JSON.stringify([r.area,S.path]),"aria-pressed":(m==null?void 0:m.path)===S.path&&m.area===r.area,onClick:()=>w({path:S.path,area:r.area}),"aria-label":`${S.path}, ${Ot(P)}`,children:[e.jsx(Z,{path:S.path,size:16}),e.jsxs("span",{className:c.filename,children:[S.path,S.originalPath&&e.jsxs("small",{children:[S.originalPath," → ",S.path]})]}),e.jsx("span",{className:c.status,"data-status":P,"aria-hidden":"true",children:P})]}),!r.conflict&&!S.submodule&&e.jsx("button",{type:"button",className:c.fileAction,disabled:x,"aria-label":r.area==="staged"?t(`取消暂存 ${S.path}`,`Unstage ${S.path}`):t(`暂存 ${S.path}`,`Stage ${S.path}`),title:r.area==="staged"?t("取消暂存","Unstage"):t("暂存","Stage"),onClick:()=>{D(r.area==="staged"?"unstage":"stage",{path:S.path})},children:r.area==="staged"?"−":"+"})]},S.path)})})]},r.title)),k.truncated&&e.jsx("p",{className:u.state,children:t("仅显示前 1000 个改动文件,请缩小工作区范围。","Showing the first 1000 changed files. Open a smaller workspace to see more.")})]})]})}),k&&e.jsxs("div",{className:c.commitFooter,"aria-busy":n.pending,children:[q&&e.jsx("p",{className:c.hint,role:"status",children:W(q)}),p&&e.jsx("p",{className:c.hint,role:"status",children:t("操作状态读取失败,请刷新。","Could not read operation state. Refresh to retry.")}),n.pending&&!R&&e.jsx("p",{className:c.hint,role:"status",children:t("正在执行 Git 操作…","Running Git operation…")}),n.outcome&&!R&&e.jsxs("div",{className:c.feedbackRow,children:[e.jsx("p",{className:c.feedback,"data-error":!n.outcome.ok,role:"status",children:W(n.outcome.reason)}),e.jsx("button",{type:"button",className:u.iconButton,"aria-label":t("关闭 Git 提示","Dismiss Git message"),onClick:()=>{n.outcome=null,T()},children:"×"})]}),k.scope?e.jsx("p",{className:c.rootHint,title:W("root_required"),children:t("提交请打开仓库根目录","Commit from repository root")}):e.jsxs("form",{className:c.commitForm,"aria-label":t("创建提交","Create commit"),onSubmit:r=>{r.preventDefault(),I&&D("commit",{message:n.message})},children:[e.jsx("textarea",{"aria-label":t("提交说明","Commit message"),rows:1,maxLength:8192,disabled:n.pending,value:n.message,placeholder:t("提交说明…","Commit message…"),onChange:r=>{n.message=r.target.value,T()},onKeyDown:r=>{var P,X;const S=((P=f.current)==null?void 0:P.guards(r.nativeEvent))??r.nativeEvent.isComposing;r.key==="Enter"&&(r.metaKey||r.ctrlKey)&&!S&&(r.preventDefault(),(X=r.currentTarget.form)==null||X.requestSubmit())}}),e.jsxs("div",{className:c.actionRow,children:[e.jsx("span",{className:c.hint,children:b!=null&&b.staged?t(`仅暂存区 · ${b.staged} 个文件`,`Staged only · ${b.staged} files`):t("先暂存要提交的文件","Stage files to commit")}),e.jsx("button",{className:c.actionButton,type:"submit",disabled:!I,title:t("仅提交暂存区 · ⌘/Ctrl+Enter","Commit staged files · ⌘/Ctrl+Enter"),children:t("提交","Commit")})]})]})]})]})]})}),qt=h.memo(function({sessionId:s,hash:i,visible:o,idle:n,onCommit:_}){U();const g=h.useRef(null),[m,l]=h.useState(null),w=()=>{var b;const j=(b=g.current)==null?void 0:b.querySelector('[data-git-file][aria-pressed="true"]');l(null),requestAnimationFrame(()=>j==null?void 0:j.focus({preventScroll:!0}))},[C,$]=h.useState(0),d=h.useCallback(j=>H.commit(s,i,C,j),[s,i,C]),{value:f,loading:G,error:v,refresh:E}=V(d,o,n,!1),N=(f==null?void 0:f.parentIndex)===C?f:null;return h.useEffect(()=>{N&&m&&!N.files.some(j=>j.path===m)&&l(null)},[N,m]),e.jsxs("div",{className:`${u.body} ${c.panel}`,ref:g,children:[e.jsxs("div",{className:u.toolbar,children:[e.jsxs("span",{className:u.path,children:[t("提交详情","Commit details")," · ",i.slice(0,7)]}),e.jsx("span",{className:u.readonly,children:t("只读","Read only")}),e.jsx("button",{className:u.iconButton,type:"button",onClick:E,"aria-label":t("刷新提交详情","Refresh commit"),children:e.jsx(Q,{})})]}),e.jsx(ee,{selectionKey:m,onClose:w,preview:m&&N?e.jsx(ae,{sessionId:s,hash:i,path:m,parentIndex:C,visible:o,idle:n,onClose:w},JSON.stringify([s,i,C,m])):null,children:e.jsxs("div",{className:u.scroll,"aria-busy":G,children:[v&&e.jsxs("p",{className:u.state,role:"status",children:[t("提交读取失败,可能已不可达。","Could not read this commit. It may no longer be reachable.")," ",e.jsx("button",{className:u.textButton,type:"button",onClick:E,children:t("重试","Retry")})]}),!f&&!v&&e.jsx("p",{className:u.state,role:"status",children:t("正在读取提交…","Reading commit…")}),f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:B.detail,children:[e.jsx("h2",{children:f.subject||t("(无提交说明)","(No subject)")}),e.jsxs("dl",{children:[e.jsx("dt",{children:t("提交","Commit")}),e.jsx("dd",{children:e.jsx("code",{children:f.hash})}),e.jsx("dt",{children:t("作者","Author")}),e.jsxs("dd",{children:[f.author," <",f.email,">"]}),e.jsx("dt",{children:t("创作时间","Authored")}),e.jsx("dd",{children:e.jsx("time",{dateTime:f.authoredAt,children:f.authoredAt})}),e.jsx("dt",{children:t("提交者","Committer")}),e.jsxs("dd",{children:[f.committer," <",f.committerEmail,">"]}),e.jsx("dt",{children:t("提交时间","Committed")}),e.jsx("dd",{children:e.jsx("time",{dateTime:f.committedAt,children:f.committedAt})}),e.jsx("dt",{children:t("父提交","Parents")}),e.jsx("dd",{className:B.parentList,children:f.parents.length?f.parents.map((j,b)=>e.jsx("button",{type:"button",className:B.parentLink,onClick:()=>_(j),"aria-label":t(`打开父提交 ${b+1}:${j.slice(0,7)}`,`Open parent ${b+1}: ${j.slice(0,7)}`),children:e.jsx("code",{children:j.slice(0,7)})},j)):t("根提交","Root commit")})]}),e.jsx("div",{className:B.message,"aria-label":t("完整提交说明","Full commit message"),children:f.message}),f.scope&&e.jsxs("p",{className:u.state,children:[t("文件改动仅限:","File changes limited to: "),f.scope]})]}),f.parents.length>1?e.jsxs("label",{className:B.parentSelect,children:[t("比较基准","Compare against"),e.jsx("select",{"aria-label":t("比较父提交","Compare parent"),value:C,onChange:j=>{l(null),$(Number(j.target.value))},children:f.parents.map((j,b)=>e.jsxs("option",{value:b,children:[t(`父提交 ${b+1}`,`Parent ${b+1}`)," · ",j.slice(0,7)]},`${b}/${j}`))})]}):e.jsx("p",{className:u.state,children:f.parents.length?t("与父提交比较","Compared with parent"):t("与空目录比较","Compared with empty tree")}),!N&&!v&&e.jsx("p",{className:u.state,role:"status",children:t("正在读取文件改动…","Reading changed files…")}),N&&e.jsxs("section",{"aria-label":t("提交文件","Commit files"),children:[e.jsxs("h3",{className:c.groupHeading,children:[t("改动文件","Changed files"),e.jsxs("span",{children:[N.files.length,N.truncated?"+":""]})]}),N.files.length===0&&e.jsx("p",{className:u.state,children:t("所选比较在当前目录中没有文件改动。","No file changes in this directory for this comparison.")}),e.jsx("ul",{className:c.list,children:N.files.map(j=>e.jsx("li",{children:e.jsxs("button",{className:c.change,type:"button","data-git-file":j.path,"aria-pressed":m===j.path,onClick:()=>l(j.path),"aria-label":t(`查看提交差异:${j.path}`,`View commit diff: ${j.path}`),children:[e.jsx(Z,{path:j.path,size:16}),e.jsx("span",{className:c.filename,children:j.path}),e.jsx("span",{className:B.fileStats,children:j.additions===null?t("二进制","Binary"):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:c.added,children:["+",j.additions]}),e.jsxs("span",{className:c.removed,children:["−",j.deletions]})]})}),e.jsx("span",{className:c.status,"data-status":j.status,children:j.status})]})},j.path))}),N.truncated&&e.jsx("p",{className:u.state,children:t("仅显示前 1000 个文件。","Showing the first 1000 files.")})]})]})]})})]})}),ae=h.memo(function({sessionId:s,hash:i,path:o,parentIndex:n,visible:_,idle:g,onClose:m}){U();const l=h.useCallback($=>H.commitDiff(s,i,o,n,$),[s,i,o,n]),w=V(l,_,g,!1),C=w.value?w.value.parentHash?`${t("父提交","Parent")} ${w.value.parentHash.slice(0,7)}`:t("空目录","Empty tree"):"";return e.jsx(te,{onClose:m,path:o,label:`${i.slice(0,7)}${C?` · ${C}`:""}`,...w})}),Ut=()=>({selection:null,view:"changes",history:null,selected:null,message:"",branch:"",checkout:!0,pending:!1,outcome:null}),Jt={id:fe.git},Qt=ue({id:Jt.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:K},panels:[{kind:"git",title:()=>e.jsxs(e.Fragment,{children:[e.jsx(K,{size:16}),e.jsx("span",{children:"Git"})]}),component:a=>e.jsx(Vt,{sessionId:a.session.sessionId,visible:a.visible,idle:a.session.idle,model:a.resource(Ut),onCommit:s=>a.open("git-commit",s,s.slice(0,7))})},{kind:"git-commit",component:a=>e.jsx(qt,{sessionId:a.session.sessionId,hash:a.contentId,visible:a.visible,idle:a.session.idle,onCommit:s=>a.open("git-commit",s,s.slice(0,7))})},{kind:"git-diff",component:a=>{const[s,i]=JSON.parse(a.contentId);return e.jsx(se,{sessionId:a.session.sessionId,area:s,path:i,visible:a.visible,idle:a.session.idle})}},{kind:"git-commit-diff",component:a=>{const[s,i,o]=JSON.parse(a.contentId);return e.jsx(ae,{sessionId:a.session.sessionId,hash:s,parentIndex:i,path:o,visible:a.visible,idle:a.session.idle})}}]}});export{Qt as default};
@@ -1 +1 @@
1
- import{B as P,b as z,a as W,r as c,j as e,f as s,I as R,l as r,F as C,c as _,C as M,d as O}from"./app-D54rSb9U.js";import{d as K}from"./app.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="3eb654bc-f8ef-4a70-9eef-1e4791188956",t._sentryDebugIdIdentifier="sentry-dbid-3eb654bc-f8ef-4a70-9eef-1e4791188956")}catch{}})();const E={id:P.files,name:{zh:"工作区文件",en:"Workspace files"}};async function L(t,o,a,u){return z(await W(`/api/workspace/files/${t}`,{method:"POST",headers:{Authorization:`Bearer ${K()}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:o,path:a}),signal:u}))}const A={list:(t,o,a)=>L("list",t,o,a),preview:(t,o,a)=>L("preview",t,o,a)},U=()=>({expanded:new Set,levels:new Map,scrollTop:0});function B({path:t,depth:o,tree:a}){const[u,n]=c.useState(()=>a.state.levels.get(t)),[v,x]=c.useState(!0),[h,g]=c.useState(!1),[m,N]=c.useState(0);return c.useEffect(()=>{const l=new AbortController;return x(!0),g(!1),A.list(a.sessionId,t,l.signal).then(i=>{l.signal.aborted||(a.state.levels.set(t,i),n(i),x(!1))}).catch(()=>{l.signal.aborted||(g(!0),x(!1))}),()=>l.abort()},[a.sessionId,a.state,t,a.revision,m]),e.jsxs(e.Fragment,{children:[v&&e.jsx("li",{role:"none",className:s.state,"aria-live":"polite",children:r("正在读取…","Reading…")}),h&&e.jsxs("li",{role:"none",className:s.state,children:[e.jsx("span",{role:"status",children:r("目录读取失败,可能已移动、删除或无权访问。","Could not read this directory. It may have moved, been deleted, or be inaccessible.")})," ",e.jsx("button",{type:"button",className:s.textButton,onClick:()=>N(l=>l+1),children:r("重试","Retry")})]}),!v&&!h&&(u==null?void 0:u.entries.length)===0&&e.jsx("li",{role:"none",className:s.state,children:r("空目录","Empty directory")}),u==null?void 0:u.entries.map(l=>{const i=l.kind==="directory",p=i&&a.expanded.has(l.path),d=l.kind==="other";return e.jsxs("li",{role:"treeitem",tabIndex:d?-1:0,"aria-label":l.name,"aria-level":o,"aria-expanded":i?p:void 0,"aria-disabled":d||void 0,"data-files-path":l.path,children:[e.jsxs("div",{className:s.row,style:{paddingInlineStart:`${12+(o-1)*16}px`},title:d?r("此条目不可访问或位于工作区之外","This entry is unavailable or outside the workspace"):l.path,onClick:j=>{var w;d||((w=j.currentTarget.parentElement)==null||w.focus(),i?a.toggle(l.path):a.open(l.path))},children:[e.jsx("span",{className:s.chevron,"aria-hidden":"true",children:i?p?"⌄":"›":""}),i?e.jsx(C,{kind:"folder",size:18}):e.jsx(C,{path:l.name,size:18}),e.jsx("span",{className:s.name,children:l.name})]}),p&&e.jsx("ul",{role:"group",className:s.level,children:e.jsx(B,{path:l.path,depth:o+1,tree:a})})]},l.path)}),(u==null?void 0:u.truncated)&&e.jsx("li",{role:"none",className:s.state,children:r("条目太多,只显示前 1000 项。","Too many entries. Showing the first 1,000.")})]})}function J({sessionId:t,cwd:o,state:a,onOpen:u}){const[n,v]=c.useState(()=>new Set(a.expanded)),[x,h]=c.useState(0),g=c.useRef(null);c.useLayoutEffect(()=>{g.current&&(g.current.scrollTop=a.scrollTop)},[a]);const m=i=>v(p=>{const d=new Set(p);return d.has(i)?d.delete(i):d.add(i),a.expanded=d,d}),N={sessionId:t,state:a,revision:x,expanded:n,toggle:m,open:u},l=i=>{var S;const p=i.target;if(p.getAttribute("role")!=="treeitem"||p.getAttribute("aria-disabled")==="true")return;const d=p.dataset.filesPath,j=p.hasAttribute("aria-expanded"),w=p.getAttribute("aria-expanded")==="true",b=[...i.currentTarget.querySelectorAll('[role="treeitem"]:not([aria-disabled="true"])')],y=b.indexOf(p);let f;switch(i.key){case"ArrowDown":f=b[y+1];break;case"ArrowUp":f=b[y-1];break;case"Home":f=b[0];break;case"End":f=b.at(-1);break;case"ArrowRight":j&&!w?m(d):w&&(f=b[y+1]);break;case"ArrowLeft":w?m(d):f=((S=p.parentElement)==null?void 0:S.closest('[role="treeitem"]'))??void 0;break;case"Enter":case" ":j?m(d):u(d);break;default:return}i.preventDefault(),i.stopPropagation(),f==null||f.focus()};return e.jsxs("div",{className:s.body,children:[e.jsxs("div",{className:s.toolbar,children:[e.jsx("span",{className:s.path,title:o,dir:"auto",children:o}),e.jsx("button",{type:"button",className:s.iconButton,"aria-label":r("重新读取文件列表","Reload files"),title:r("重新读取文件列表","Reload files"),onClick:()=>h(i=>i+1),children:e.jsx(R,{})})]}),e.jsx("div",{ref:g,className:s.scroll,onScroll:i=>{a.scrollTop=i.currentTarget.scrollTop},children:e.jsx("ul",{role:"tree","aria-label":r("工作区文件","Workspace files"),className:s.tree,onKeyDown:l,children:e.jsx(B,{path:"",depth:1,tree:N})})})]})}const V=c.memo(function({sessionId:o,path:a,renderMarkdown:u}){const[n,v]=c.useState(null),[x,h]=c.useState(!0),[g,m]=c.useState(!1),[N,l]=c.useState(0),[i,p]=c.useState(!1),[d,j]=c.useState(!1),[w,b]=c.useState(!1);c.useEffect(()=>{const k=new AbortController;return h(!0),m(!1),b(!1),j(!1),A.preview(o,a,k.signal).then(D=>{k.signal.aborted||(v(D),h(!1))}).catch(()=>{k.signal.aborted||(m(!0),h(!1))}),()=>k.abort()},[o,a,N]);const y=/\.(?:md|markdown|mdown)$/i.test(a),f=a.split("/").at(-1),S=f.includes(".")?f.split(".").at(-1).toLowerCase():f.toLowerCase(),F={mjs:"javascript",cjs:"javascript",mts:"typescript",cts:"typescript",md:"markdown",svg:"xml",gitignore:"text",dockerfile:"dockerfile",makefile:"make"}[S]??S,T=()=>l(k=>k+1),I=c.useMemo(()=>(n==null?void 0:n.kind)==="image"?`data:${n.mimeType};base64,${n.data}`:null,[n]),$=()=>x?e.jsx("p",{className:s.state,role:"status",children:r("正在读取…","Reading…")}):g?e.jsxs("div",{className:s.state,role:"status",children:[e.jsx("p",{children:r("文件读取失败,可能已移动、删除或无权访问。","Could not read this file. It may have moved, been deleted, or be inaccessible.")}),e.jsx("button",{type:"button",className:s.textButton,onClick:T,children:r("重试","Retry")})]}):n?n.kind==="too-large"?e.jsx("p",{className:s.state,children:n.unit==="lines"?r(`文件行数过多,最多预览 ${n.limit} 行。`,`File has too many lines. Limit: ${n.limit} lines.`):r(`文件过大,无法预览。大小上限:${n.limit/1024} KB`,`File is too large to preview. Limit: ${n.limit/1024} KB`)}):n.kind==="unsupported"?e.jsx("p",{className:s.state,children:r("暂不支持预览此文件类型。","Preview is unavailable for this file type.")}):n.kind==="image"&&I?w?e.jsx("p",{className:s.state,children:r("图片无法解码。","This image could not be decoded.")}):e.jsx("button",{type:"button",className:s.imageButton,"aria-label":r("放大图片","Enlarge image"),onClick:()=>j(!0),children:e.jsx("img",{className:s.image,src:I,alt:f,onError:()=>b(!0)})}):n.kind!=="text"?null:n.text===""?e.jsx("p",{className:s.state,children:r("空文件","Empty file")}):y&&!i?e.jsx("div",{className:s.markdown,children:u(n.text)}):e.jsx(M,{code:n.text,lang:F,lineNumbers:!0,className:s.code,copyLabel:r("复制","Copy"),copiedLabel:r("已复制","Copied"),toolbarLabels:{codeLabel:r("代码","Code"),wrapLabel:r("自动换行","Wrap"),unwrapLabel:r("取消换行","Unwrap")}}):null;return e.jsxs("div",{className:s.body,children:[e.jsxs("div",{className:s.toolbar,children:[e.jsx("span",{className:s.path,title:a,children:a}),e.jsx("span",{className:s.readonly,children:r("只读","Read only")}),y&&(n==null?void 0:n.kind)==="text"&&e.jsx("button",{type:"button",className:s.textButton,"aria-pressed":i,onClick:()=>p(k=>!k),children:i?r("预览","Preview"):r("源码","Source")}),e.jsx("button",{type:"button",className:s.iconButton,"aria-label":r("重新读取文件","Reload file"),title:r("重新读取文件","Reload file"),onClick:T,children:e.jsx(R,{})})]}),e.jsx("div",{className:s.preview,"aria-busy":x,children:$()}),d&&I&&e.jsx(_,{src:I,alt:f,labels:{dialog:r("图片预览","Image preview"),close:r("关闭图片预览","Close image preview")},onClose:()=>j(!1)})]})}),G=O({id:E.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:E.name,panelTitle:{zh:"文件",en:"Files"},description:{zh:"浏览当前会话的文件并打开预览",en:"Browse this session’s files and open previews"},kind:"files",icon:({size:t})=>e.jsx(C,{kind:"folder",size:t})},panels:[{kind:"files",component:t=>e.jsx(J,{sessionId:t.session.sessionId,cwd:t.session.cwd,state:t.resource(U),onOpen:o=>t.open("file-preview",o,o.split("/").at(-1))})},{kind:"file-preview",title:(t,o)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{path:t,size:16}),e.jsx("span",{children:o})]}),component:t=>e.jsx(V,{sessionId:t.session.sessionId,path:t.contentId,renderMarkdown:t.renderMarkdown})}]}});export{G as default};
1
+ import{B as P,b as z,a as W,r as c,j as e,f as s,I as R,l as r,F as C,c as _,C as M,d as O}from"./app-C-H5rHq5.js";import{d as K}from"./app.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="3eb654bc-f8ef-4a70-9eef-1e4791188956",t._sentryDebugIdIdentifier="sentry-dbid-3eb654bc-f8ef-4a70-9eef-1e4791188956")}catch{}})();const E={id:P.files,name:{zh:"工作区文件",en:"Workspace files"}};async function L(t,o,a,u){return z(await W(`/api/workspace/files/${t}`,{method:"POST",headers:{Authorization:`Bearer ${K()}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:o,path:a}),signal:u}))}const A={list:(t,o,a)=>L("list",t,o,a),preview:(t,o,a)=>L("preview",t,o,a)},U=()=>({expanded:new Set,levels:new Map,scrollTop:0});function B({path:t,depth:o,tree:a}){const[u,n]=c.useState(()=>a.state.levels.get(t)),[v,x]=c.useState(!0),[h,g]=c.useState(!1),[m,N]=c.useState(0);return c.useEffect(()=>{const l=new AbortController;return x(!0),g(!1),A.list(a.sessionId,t,l.signal).then(i=>{l.signal.aborted||(a.state.levels.set(t,i),n(i),x(!1))}).catch(()=>{l.signal.aborted||(g(!0),x(!1))}),()=>l.abort()},[a.sessionId,a.state,t,a.revision,m]),e.jsxs(e.Fragment,{children:[v&&e.jsx("li",{role:"none",className:s.state,"aria-live":"polite",children:r("正在读取…","Reading…")}),h&&e.jsxs("li",{role:"none",className:s.state,children:[e.jsx("span",{role:"status",children:r("目录读取失败,可能已移动、删除或无权访问。","Could not read this directory. It may have moved, been deleted, or be inaccessible.")})," ",e.jsx("button",{type:"button",className:s.textButton,onClick:()=>N(l=>l+1),children:r("重试","Retry")})]}),!v&&!h&&(u==null?void 0:u.entries.length)===0&&e.jsx("li",{role:"none",className:s.state,children:r("空目录","Empty directory")}),u==null?void 0:u.entries.map(l=>{const i=l.kind==="directory",p=i&&a.expanded.has(l.path),d=l.kind==="other";return e.jsxs("li",{role:"treeitem",tabIndex:d?-1:0,"aria-label":l.name,"aria-level":o,"aria-expanded":i?p:void 0,"aria-disabled":d||void 0,"data-files-path":l.path,children:[e.jsxs("div",{className:s.row,style:{paddingInlineStart:`${12+(o-1)*16}px`},title:d?r("此条目不可访问或位于工作区之外","This entry is unavailable or outside the workspace"):l.path,onClick:j=>{var w;d||((w=j.currentTarget.parentElement)==null||w.focus(),i?a.toggle(l.path):a.open(l.path))},children:[e.jsx("span",{className:s.chevron,"aria-hidden":"true",children:i?p?"⌄":"›":""}),i?e.jsx(C,{kind:"folder",size:18}):e.jsx(C,{path:l.name,size:18}),e.jsx("span",{className:s.name,children:l.name})]}),p&&e.jsx("ul",{role:"group",className:s.level,children:e.jsx(B,{path:l.path,depth:o+1,tree:a})})]},l.path)}),(u==null?void 0:u.truncated)&&e.jsx("li",{role:"none",className:s.state,children:r("条目太多,只显示前 1000 项。","Too many entries. Showing the first 1,000.")})]})}function J({sessionId:t,cwd:o,state:a,onOpen:u}){const[n,v]=c.useState(()=>new Set(a.expanded)),[x,h]=c.useState(0),g=c.useRef(null);c.useLayoutEffect(()=>{g.current&&(g.current.scrollTop=a.scrollTop)},[a]);const m=i=>v(p=>{const d=new Set(p);return d.has(i)?d.delete(i):d.add(i),a.expanded=d,d}),N={sessionId:t,state:a,revision:x,expanded:n,toggle:m,open:u},l=i=>{var S;const p=i.target;if(p.getAttribute("role")!=="treeitem"||p.getAttribute("aria-disabled")==="true")return;const d=p.dataset.filesPath,j=p.hasAttribute("aria-expanded"),w=p.getAttribute("aria-expanded")==="true",b=[...i.currentTarget.querySelectorAll('[role="treeitem"]:not([aria-disabled="true"])')],y=b.indexOf(p);let f;switch(i.key){case"ArrowDown":f=b[y+1];break;case"ArrowUp":f=b[y-1];break;case"Home":f=b[0];break;case"End":f=b.at(-1);break;case"ArrowRight":j&&!w?m(d):w&&(f=b[y+1]);break;case"ArrowLeft":w?m(d):f=((S=p.parentElement)==null?void 0:S.closest('[role="treeitem"]'))??void 0;break;case"Enter":case" ":j?m(d):u(d);break;default:return}i.preventDefault(),i.stopPropagation(),f==null||f.focus()};return e.jsxs("div",{className:s.body,children:[e.jsxs("div",{className:s.toolbar,children:[e.jsx("span",{className:s.path,title:o,dir:"auto",children:o}),e.jsx("button",{type:"button",className:s.iconButton,"aria-label":r("重新读取文件列表","Reload files"),title:r("重新读取文件列表","Reload files"),onClick:()=>h(i=>i+1),children:e.jsx(R,{})})]}),e.jsx("div",{ref:g,className:s.scroll,onScroll:i=>{a.scrollTop=i.currentTarget.scrollTop},children:e.jsx("ul",{role:"tree","aria-label":r("工作区文件","Workspace files"),className:s.tree,onKeyDown:l,children:e.jsx(B,{path:"",depth:1,tree:N})})})]})}const V=c.memo(function({sessionId:o,path:a,renderMarkdown:u}){const[n,v]=c.useState(null),[x,h]=c.useState(!0),[g,m]=c.useState(!1),[N,l]=c.useState(0),[i,p]=c.useState(!1),[d,j]=c.useState(!1),[w,b]=c.useState(!1);c.useEffect(()=>{const k=new AbortController;return h(!0),m(!1),b(!1),j(!1),A.preview(o,a,k.signal).then(D=>{k.signal.aborted||(v(D),h(!1))}).catch(()=>{k.signal.aborted||(m(!0),h(!1))}),()=>k.abort()},[o,a,N]);const y=/\.(?:md|markdown|mdown)$/i.test(a),f=a.split("/").at(-1),S=f.includes(".")?f.split(".").at(-1).toLowerCase():f.toLowerCase(),F={mjs:"javascript",cjs:"javascript",mts:"typescript",cts:"typescript",md:"markdown",svg:"xml",gitignore:"text",dockerfile:"dockerfile",makefile:"make"}[S]??S,T=()=>l(k=>k+1),I=c.useMemo(()=>(n==null?void 0:n.kind)==="image"?`data:${n.mimeType};base64,${n.data}`:null,[n]),$=()=>x?e.jsx("p",{className:s.state,role:"status",children:r("正在读取…","Reading…")}):g?e.jsxs("div",{className:s.state,role:"status",children:[e.jsx("p",{children:r("文件读取失败,可能已移动、删除或无权访问。","Could not read this file. It may have moved, been deleted, or be inaccessible.")}),e.jsx("button",{type:"button",className:s.textButton,onClick:T,children:r("重试","Retry")})]}):n?n.kind==="too-large"?e.jsx("p",{className:s.state,children:n.unit==="lines"?r(`文件行数过多,最多预览 ${n.limit} 行。`,`File has too many lines. Limit: ${n.limit} lines.`):r(`文件过大,无法预览。大小上限:${n.limit/1024} KB`,`File is too large to preview. Limit: ${n.limit/1024} KB`)}):n.kind==="unsupported"?e.jsx("p",{className:s.state,children:r("暂不支持预览此文件类型。","Preview is unavailable for this file type.")}):n.kind==="image"&&I?w?e.jsx("p",{className:s.state,children:r("图片无法解码。","This image could not be decoded.")}):e.jsx("button",{type:"button",className:s.imageButton,"aria-label":r("放大图片","Enlarge image"),onClick:()=>j(!0),children:e.jsx("img",{className:s.image,src:I,alt:f,onError:()=>b(!0)})}):n.kind!=="text"?null:n.text===""?e.jsx("p",{className:s.state,children:r("空文件","Empty file")}):y&&!i?e.jsx("div",{className:s.markdown,children:u(n.text)}):e.jsx(M,{code:n.text,lang:F,lineNumbers:!0,className:s.code,copyLabel:r("复制","Copy"),copiedLabel:r("已复制","Copied"),toolbarLabels:{codeLabel:r("代码","Code"),wrapLabel:r("自动换行","Wrap"),unwrapLabel:r("取消换行","Unwrap")}}):null;return e.jsxs("div",{className:s.body,children:[e.jsxs("div",{className:s.toolbar,children:[e.jsx("span",{className:s.path,title:a,children:a}),e.jsx("span",{className:s.readonly,children:r("只读","Read only")}),y&&(n==null?void 0:n.kind)==="text"&&e.jsx("button",{type:"button",className:s.textButton,"aria-pressed":i,onClick:()=>p(k=>!k),children:i?r("预览","Preview"):r("源码","Source")}),e.jsx("button",{type:"button",className:s.iconButton,"aria-label":r("重新读取文件","Reload file"),title:r("重新读取文件","Reload file"),onClick:T,children:e.jsx(R,{})})]}),e.jsx("div",{className:s.preview,"aria-busy":x,children:$()}),d&&I&&e.jsx(_,{src:I,alt:f,labels:{dialog:r("图片预览","Image preview"),close:r("关闭图片预览","Close image preview")},onClose:()=>j(!1)})]})}),G=O({id:E.id,apiVersion:1,activate(){},workbench:{apiVersion:1,entry:{label:E.name,panelTitle:{zh:"文件",en:"Files"},description:{zh:"浏览当前会话的文件并打开预览",en:"Browse this session’s files and open previews"},kind:"files",icon:({size:t})=>e.jsx(C,{kind:"folder",size:t})},panels:[{kind:"files",component:t=>e.jsx(J,{sessionId:t.session.sessionId,cwd:t.session.cwd,state:t.resource(U),onOpen:o=>t.open("file-preview",o,o.split("/").at(-1))})},{kind:"file-preview",title:(t,o)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{path:t,size:16}),e.jsx("span",{children:o})]}),component:t=>e.jsx(V,{sessionId:t.session.sessionId,path:t.contentId,renderMarkdown:t.renderMarkdown})}]}});export{G as default};
@@ -1 +1 @@
1
- import{h as a}from"./html-derivative-C2Epw9Yg.js";import c from"./cpp-WTsyTmWk.js";import t from"./python-D7_Ztkaq.js";import{j as o}from"./javascript-D_ijBMSX.js";import{s as r}from"./app-D54rSb9U.js";import s from"./yaml-jmrW97Mk.js";import l from"./cmake-DmzJtVCe.js";import i from"./ruby-BM86KL0M.js";import"./html-COcRjUs1.js";import"./css-D-q0lhfR.js";import"./c-BxgHfdNM.js";import"./app.js";import"./xml-DCBoxqhY.js";import"./java-K8yEFi64.js";import"./sql-B8q9hRYB.js";import"./graphql-DSgZM88T.js";import"./lua-DyIUvKwX.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="215cce73-a3fe-423f-9de9-4d6e3af6c2a9",e._sentryDebugIdIdentifier="sentry-dbid-215cce73-a3fe-423f-9de9-4d6e3af6c2a9")}catch{}})();const d=Object.freeze(JSON.parse('{"displayName":"reStructuredText","name":"rst","patterns":[{"include":"#body"}],"repository":{"anchor":{"match":"^\\\\.{2}\\\\s+(_[^:]+:)\\\\s*","name":"entity.name.tag.anchor"},"block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+\\\\S+::)(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable"}},"end":"^(?!\\\\1\\\\s|\\\\s*$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"block-comment":{"begin":"^(\\\\s*)\\\\.{2}(\\\\s+|$)","end":"^(?:(?=\\\\S)|\\\\s*$)","name":"comment.block","patterns":[{"begin":"^\\\\s{3,}(?=\\\\S)","name":"comment.block","while":"^(?:\\\\s{3}.*|\\\\s*$)"}]},"block-param":{"patterns":[{"captures":{"1":{"name":"keyword.control"},"2":{"name":"variable.parameter"}},"match":"(:param\\\\s+(.+?):)(?:\\\\s|$)"},{"captures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"match":"\\\\b(0x[A-Fa-f\\\\d]+|\\\\d+)\\\\b","name":"constant.numeric"},{"include":"#inline-markup"}]}},"match":"(:.+?:)(?:$|\\\\s+(.*))"}]},"blocks":{"patterns":[{"include":"#domains"},{"include":"#doctest"},{"include":"#code-block-cpp"},{"include":"#code-block-py"},{"include":"#code-block-console"},{"include":"#code-block-javascript"},{"include":"#code-block-yaml"},{"include":"#code-block-cmake"},{"include":"#code-block-kconfig"},{"include":"#code-block-ruby"},{"include":"#code-block-dts"},{"include":"#code-block"},{"include":"#doctest-block"},{"include":"#raw-html"},{"include":"#block"},{"include":"#literal-block"},{"include":"#block-comment"}]},"body":{"patterns":[{"include":"#title"},{"include":"#inline-markup"},{"include":"#anchor"},{"include":"#line-block"},{"include":"#replace-include"},{"include":"#footnote"},{"include":"#substitution"},{"include":"#blocks"},{"include":"#table"},{"include":"#simple-table"},{"include":"#options-list"}]},"bold":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*{2}[^*\\\\s]","end":"\\\\*{2}|^\\\\s*$","name":"markup.bold"},"citation":{"applyEndPatternLast":0,"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)`[^`\\\\s]","end":"`_{0,2}|^\\\\s*$","name":"entity.name.tag"},"code-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cmake":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(cmake)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cmake"}},"patterns":[{"include":"#block-param"},{"include":"source.cmake"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-console":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(console|shell|bash)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.console"}},"patterns":[{"include":"#block-param"},{"include":"source.shell"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(c|c\\\\+\\\\+|cpp|C|C\\\\+\\\\+|CPP|Cpp)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cpp"}},"patterns":[{"include":"#block-param"},{"include":"source.cpp"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-dts":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(dts|DTS|devicetree)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.dts"}},"patterns":[{"include":"#block-param"},{"include":"source.dts"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-javascript":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(javascript)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.js"}},"patterns":[{"include":"#block-param"},{"include":"source.js"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-kconfig":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*([Kk]config)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.kconfig"}},"patterns":[{"include":"#block-param"},{"include":"source.kconfig"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(python)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.py"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-ruby":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ruby)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.ruby"}},"patterns":[{"include":"#block-param"},{"include":"source.ruby"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-yaml":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ya?ml)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.yaml"}},"patterns":[{"include":"#block-param"},{"include":"source.yaml"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"doctest":{"begin":"^(>>>)\\\\s*(.*)","beginCaptures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"include":"source.python"}]}},"end":"^\\\\s*$"},"doctest-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+doctest::)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-auto":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+auto(?:class|module|exception|function|decorator|data|method|attribute|property)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control.py"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+c(?:pp|):(?:class|struct|function|member|var|type|enum|enum-struct|enum-class|enumerator|union|concept)::)\\\\s*(?:(@\\\\w+)|(.*))","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"entity.name.tag"},"4":{"patterns":[{"include":"source.cpp"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-js":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+js:\\\\w+::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.js"}]}},"end":"^(?!\\\\1[\\\\t ]|$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"domain-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+py:(?:module|function|data|exception|class|attribute|property|method|staticmethod|classmethod|decorator|decoratormethod)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domains":{"patterns":[{"include":"#domain-cpp"},{"include":"#domain-py"},{"include":"#domain-auto"},{"include":"#domain-js"}]},"escaped":{"match":"\\\\\\\\.","name":"constant.character.escape"},"footnote":{"match":"^\\\\s*\\\\.{2}\\\\s+\\\\[(?:[-.\\\\w]+|[#*]|#\\\\w+)]\\\\s+","name":"entity.name.tag"},"footnote-ref":{"match":"\\\\[(?:[-.\\\\w]+|[#*])]_","name":"entity.name.tag"},"ignore":{"patterns":[{"match":"\'[*`]+\'"},{"match":"<[*`]+>"},{"match":"\\\\{[*`]+}"},{"match":"\\\\([*`]+\\\\)"},{"match":"\\\\[[*`]+]"},{"match":"\\"[*`]+\\""}]},"inline-markup":{"patterns":[{"include":"#escaped"},{"include":"#ignore"},{"include":"#ref"},{"include":"#literal"},{"include":"#monospaced"},{"include":"#citation"},{"include":"#bold"},{"include":"#italic"},{"include":"#list"},{"include":"#macro"},{"include":"#reference"},{"include":"#footnote-ref"}]},"italic":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*[^*\\\\s]","end":"\\\\*|^\\\\s*$","name":"markup.italic"},"line-block":{"match":"^\\\\|\\\\s+","name":"keyword.control"},"list":{"match":"^\\\\s*(\\\\d+\\\\.|\\\\* -|[#A-Za-z]\\\\.|[CIMVXcimvx]+\\\\.|\\\\(\\\\d+\\\\)|\\\\d+\\\\)|[-*+])\\\\s+","name":"keyword.control"},"literal":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"}},"match":"(:\\\\S+:)(`.*?`\\\\\\\\?)"},"literal-block":{"begin":"^(\\\\s*)(.*)(::)\\\\s*$","beginCaptures":{"2":{"patterns":[{"include":"#inline-markup"}]},"3":{"name":"keyword.control"}},"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"macro":{"match":"\\\\|[^|]+\\\\|","name":"entity.name.tag"},"monospaced":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)``[^`\\\\s]","end":"``|^\\\\s*$","name":"string.interpolated"},"options-list":{"match":"(?:(?:^|,\\\\s+)(?:[-+]\\\\w|--?[A-Za-z][-\\\\w]+|/\\\\w+)(?:[ =](?:\\\\w+|<[^<>]+?>))?)+(?= |\\\\t|$)","name":"variable.parameter"},"raw-html":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+raw\\\\s*::)\\\\s+(html)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable.parameter.html"}},"patterns":[{"include":"#block-param"},{"include":"text.html.derivative"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"ref":{"begin":"(:ref:)`","beginCaptures":{"1":{"name":"keyword.control"}},"end":"`|^\\\\s*$","name":"entity.name.tag","patterns":[{"match":"<.*?>","name":"markup.underline.link"}]},"reference":{"match":"[-\\\\w]*[-A-Za-z\\\\d]__?\\\\b","name":"entity.name.tag"},"replace-include":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"},"3":{"name":"keyword.control"}},"match":"^\\\\s*(\\\\.{2})\\\\s+(\\\\|[^|]+\\\\|)\\\\s+(replace::)"},"simple-table":{"match":"^[=\\\\s]+$","name":"keyword.control.table"},"substitution":{"match":"^\\\\.{2}\\\\s*\\\\|([^|]+)\\\\|","name":"entity.name.tag"},"table":{"begin":"^\\\\s*\\\\+[-+=]+\\\\+\\\\s*$","beginCaptures":{"0":{"name":"keyword.control.table"}},"end":"^(?![+|])","patterns":[{"match":"[-+=|]","name":"keyword.control.table"}]},"title":{"match":"^(\\\\*{3,}|#{3,}|={3,}|~{3,}|\\\\+{3,}|-{3,}|`{3,}|\\\\^{3,}|:{3,}|\\"{3,}|_{3,}|\'{3,})$","name":"markup.heading"}},"scopeName":"source.rst","embeddedLangs":["html-derivative","cpp","python","javascript","shellscript","yaml","cmake","ruby"]}')),D=[...a,...c,...t,...o,...r,...s,...l,...i,d];export{D as default};
1
+ import{h as a}from"./html-derivative-C2Epw9Yg.js";import c from"./cpp-WTsyTmWk.js";import t from"./python-D7_Ztkaq.js";import{j as o}from"./javascript-D_ijBMSX.js";import{s as r}from"./app-C-H5rHq5.js";import s from"./yaml-jmrW97Mk.js";import l from"./cmake-DmzJtVCe.js";import i from"./ruby-CB8CtpFl.js";import"./html-COcRjUs1.js";import"./css-D-q0lhfR.js";import"./c-BxgHfdNM.js";import"./app.js";import"./xml-DCBoxqhY.js";import"./java-K8yEFi64.js";import"./sql-B8q9hRYB.js";import"./graphql-R1M_bSpj.js";import"./lua-DyIUvKwX.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="215cce73-a3fe-423f-9de9-4d6e3af6c2a9",e._sentryDebugIdIdentifier="sentry-dbid-215cce73-a3fe-423f-9de9-4d6e3af6c2a9")}catch{}})();const d=Object.freeze(JSON.parse('{"displayName":"reStructuredText","name":"rst","patterns":[{"include":"#body"}],"repository":{"anchor":{"match":"^\\\\.{2}\\\\s+(_[^:]+:)\\\\s*","name":"entity.name.tag.anchor"},"block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+\\\\S+::)(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable"}},"end":"^(?!\\\\1\\\\s|\\\\s*$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"block-comment":{"begin":"^(\\\\s*)\\\\.{2}(\\\\s+|$)","end":"^(?:(?=\\\\S)|\\\\s*$)","name":"comment.block","patterns":[{"begin":"^\\\\s{3,}(?=\\\\S)","name":"comment.block","while":"^(?:\\\\s{3}.*|\\\\s*$)"}]},"block-param":{"patterns":[{"captures":{"1":{"name":"keyword.control"},"2":{"name":"variable.parameter"}},"match":"(:param\\\\s+(.+?):)(?:\\\\s|$)"},{"captures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"match":"\\\\b(0x[A-Fa-f\\\\d]+|\\\\d+)\\\\b","name":"constant.numeric"},{"include":"#inline-markup"}]}},"match":"(:.+?:)(?:$|\\\\s+(.*))"}]},"blocks":{"patterns":[{"include":"#domains"},{"include":"#doctest"},{"include":"#code-block-cpp"},{"include":"#code-block-py"},{"include":"#code-block-console"},{"include":"#code-block-javascript"},{"include":"#code-block-yaml"},{"include":"#code-block-cmake"},{"include":"#code-block-kconfig"},{"include":"#code-block-ruby"},{"include":"#code-block-dts"},{"include":"#code-block"},{"include":"#doctest-block"},{"include":"#raw-html"},{"include":"#block"},{"include":"#literal-block"},{"include":"#block-comment"}]},"body":{"patterns":[{"include":"#title"},{"include":"#inline-markup"},{"include":"#anchor"},{"include":"#line-block"},{"include":"#replace-include"},{"include":"#footnote"},{"include":"#substitution"},{"include":"#blocks"},{"include":"#table"},{"include":"#simple-table"},{"include":"#options-list"}]},"bold":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*{2}[^*\\\\s]","end":"\\\\*{2}|^\\\\s*$","name":"markup.bold"},"citation":{"applyEndPatternLast":0,"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)`[^`\\\\s]","end":"`_{0,2}|^\\\\s*$","name":"entity.name.tag"},"code-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cmake":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(cmake)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cmake"}},"patterns":[{"include":"#block-param"},{"include":"source.cmake"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-console":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(console|shell|bash)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.console"}},"patterns":[{"include":"#block-param"},{"include":"source.shell"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(c|c\\\\+\\\\+|cpp|C|C\\\\+\\\\+|CPP|Cpp)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.cpp"}},"patterns":[{"include":"#block-param"},{"include":"source.cpp"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-dts":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(dts|DTS|devicetree)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.dts"}},"patterns":[{"include":"#block-param"},{"include":"source.dts"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-javascript":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(javascript)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.js"}},"patterns":[{"include":"#block-param"},{"include":"source.js"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-kconfig":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*([Kk]config)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.kconfig"}},"patterns":[{"include":"#block-param"},{"include":"source.kconfig"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(python)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.py"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-ruby":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ruby)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.ruby"}},"patterns":[{"include":"#block-param"},{"include":"source.ruby"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"code-block-yaml":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+(code(?:|-block))::)\\\\s*(ya?ml)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"4":{"name":"variable.parameter.codeblock.yaml"}},"patterns":[{"include":"#block-param"},{"include":"source.yaml"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"doctest":{"begin":"^(>>>)\\\\s*(.*)","beginCaptures":{"1":{"name":"keyword.control"},"2":{"patterns":[{"include":"source.python"}]}},"end":"^\\\\s*$"},"doctest-block":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+doctest::)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"}},"patterns":[{"include":"#block-param"},{"include":"source.python"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-auto":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+auto(?:class|module|exception|function|decorator|data|method|attribute|property)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control.py"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-cpp":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+c(?:pp|):(?:class|struct|function|member|var|type|enum|enum-struct|enum-class|enumerator|union|concept)::)\\\\s*(?:(@\\\\w+)|(.*))","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"entity.name.tag"},"4":{"patterns":[{"include":"source.cpp"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domain-js":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+js:\\\\w+::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.js"}]}},"end":"^(?!\\\\1[\\\\t ]|$)","patterns":[{"include":"#block-param"},{"include":"#body"}]},"domain-py":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+py:(?:module|function|data|exception|class|attribute|property|method|staticmethod|classmethod|decorator|decoratormethod)::)\\\\s*(.*)","beginCaptures":{"2":{"name":"keyword.control"},"3":{"patterns":[{"include":"source.python"}]}},"patterns":[{"include":"#block-param"},{"include":"#body"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"domains":{"patterns":[{"include":"#domain-cpp"},{"include":"#domain-py"},{"include":"#domain-auto"},{"include":"#domain-js"}]},"escaped":{"match":"\\\\\\\\.","name":"constant.character.escape"},"footnote":{"match":"^\\\\s*\\\\.{2}\\\\s+\\\\[(?:[-.\\\\w]+|[#*]|#\\\\w+)]\\\\s+","name":"entity.name.tag"},"footnote-ref":{"match":"\\\\[(?:[-.\\\\w]+|[#*])]_","name":"entity.name.tag"},"ignore":{"patterns":[{"match":"\'[*`]+\'"},{"match":"<[*`]+>"},{"match":"\\\\{[*`]+}"},{"match":"\\\\([*`]+\\\\)"},{"match":"\\\\[[*`]+]"},{"match":"\\"[*`]+\\""}]},"inline-markup":{"patterns":[{"include":"#escaped"},{"include":"#ignore"},{"include":"#ref"},{"include":"#literal"},{"include":"#monospaced"},{"include":"#citation"},{"include":"#bold"},{"include":"#italic"},{"include":"#list"},{"include":"#macro"},{"include":"#reference"},{"include":"#footnote-ref"}]},"italic":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)\\\\*[^*\\\\s]","end":"\\\\*|^\\\\s*$","name":"markup.italic"},"line-block":{"match":"^\\\\|\\\\s+","name":"keyword.control"},"list":{"match":"^\\\\s*(\\\\d+\\\\.|\\\\* -|[#A-Za-z]\\\\.|[CIMVXcimvx]+\\\\.|\\\\(\\\\d+\\\\)|\\\\d+\\\\)|[-*+])\\\\s+","name":"keyword.control"},"literal":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"}},"match":"(:\\\\S+:)(`.*?`\\\\\\\\?)"},"literal-block":{"begin":"^(\\\\s*)(.*)(::)\\\\s*$","beginCaptures":{"2":{"patterns":[{"include":"#inline-markup"}]},"3":{"name":"keyword.control"}},"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"macro":{"match":"\\\\|[^|]+\\\\|","name":"entity.name.tag"},"monospaced":{"begin":"(?<=[\\"\'(<\\\\[{\\\\s]|^)``[^`\\\\s]","end":"``|^\\\\s*$","name":"string.interpolated"},"options-list":{"match":"(?:(?:^|,\\\\s+)(?:[-+]\\\\w|--?[A-Za-z][-\\\\w]+|/\\\\w+)(?:[ =](?:\\\\w+|<[^<>]+?>))?)+(?= |\\\\t|$)","name":"variable.parameter"},"raw-html":{"begin":"^(\\\\s*)(\\\\.{2}\\\\s+raw\\\\s*::)\\\\s+(html)\\\\s*$","beginCaptures":{"2":{"name":"keyword.control"},"3":{"name":"variable.parameter.html"}},"patterns":[{"include":"#block-param"},{"include":"text.html.derivative"}],"while":"^(?:\\\\1(?=\\\\s)|\\\\s*$)"},"ref":{"begin":"(:ref:)`","beginCaptures":{"1":{"name":"keyword.control"}},"end":"`|^\\\\s*$","name":"entity.name.tag","patterns":[{"match":"<.*?>","name":"markup.underline.link"}]},"reference":{"match":"[-\\\\w]*[-A-Za-z\\\\d]__?\\\\b","name":"entity.name.tag"},"replace-include":{"captures":{"1":{"name":"keyword.control"},"2":{"name":"entity.name.tag"},"3":{"name":"keyword.control"}},"match":"^\\\\s*(\\\\.{2})\\\\s+(\\\\|[^|]+\\\\|)\\\\s+(replace::)"},"simple-table":{"match":"^[=\\\\s]+$","name":"keyword.control.table"},"substitution":{"match":"^\\\\.{2}\\\\s*\\\\|([^|]+)\\\\|","name":"entity.name.tag"},"table":{"begin":"^\\\\s*\\\\+[-+=]+\\\\+\\\\s*$","beginCaptures":{"0":{"name":"keyword.control.table"}},"end":"^(?![+|])","patterns":[{"match":"[-+=|]","name":"keyword.control.table"}]},"title":{"match":"^(\\\\*{3,}|#{3,}|={3,}|~{3,}|\\\\+{3,}|-{3,}|`{3,}|\\\\^{3,}|:{3,}|\\"{3,}|_{3,}|\'{3,})$","name":"markup.heading"}},"scopeName":"source.rst","embeddedLangs":["html-derivative","cpp","python","javascript","shellscript","yaml","cmake","ruby"]}')),D=[...a,...c,...t,...o,...r,...s,...l,...i,d];export{D as default};