@xbzbing/dsh-git-panel 0.3.1 → 0.3.2
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/lib/client.js +6 -7
- package/lib/host/index.js +13 -22
- package/package.json +2 -1
package/lib/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({ id: "@xbzbing/dsh-git-panel", factory: (require) => {
|
|
2
2
|
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
-
"use strict";var
|
|
3
|
+
"use strict";var Ie=require("react");var nr=`
|
|
4
4
|
.gp-panel{display:flex;flex-direction:column;height:100%;min-height:0;color:var(--dsw-alias-label-primary);font-size:13px;position:relative}
|
|
5
5
|
.gp-panel[data-font-delta="1"]{zoom:1.08;font-size:14px}
|
|
6
6
|
.gp-panel[data-font-delta="-1"]{zoom:.92;font-size:12px}
|
|
@@ -297,14 +297,13 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
297
297
|
|
|
298
298
|
/* pill wrapper + rounded hover tooltip panel (openviking-manager style):
|
|
299
299
|
* soft radius, layered shadow, subtle border, portaled above the pill. */
|
|
300
|
-
.gp-pill-wrap{display:inline-flex}
|
|
301
300
|
.gp-tip{position:fixed;z-index:60;max-width:520px;padding:8px 12px;border:1px solid var(--dsw-alias-border-l1,var(--dsw-alias-border-l2));border-radius:12px;background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));box-shadow:0 6px 24px rgba(0,0,0,.18),0 1px 3px rgba(0,0,0,.12);font-size:12px;line-height:1.5;pointer-events:none}
|
|
302
301
|
.gp-tip__path{color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-mono,ui-monospace,monospace);word-break:break-all}
|
|
303
302
|
.gp-tip__note{margin-top:4px;color:var(--dsw-alias-label-tertiary)}
|
|
304
|
-
`,Xe=!1;function rt(){if(Xe||typeof document>"u")return;let e="dsh-git-panel/client.css";if(document.querySelector(`style[data-plugin-css="${e}"]`)!==null){Xe=!0;return}let t=document.createElement("style");t.dataset.plugin="@xbzbing/dsh-git-panel",t.dataset.pluginCss=e,t.textContent=tn,document.head.appendChild(t),Xe=!0}var it={"panel.tab":"Git","panel.fontDecrease":"\u7F29\u5C0F\u5B57\u4F53","panel.fontReset":"\u91CD\u7F6E\u5B57\u4F53\u5927\u5C0F","panel.fontIncrease":"\u653E\u5927\u5B57\u4F53","tab.overview":"Git \u603B\u89C8","tab.changes":"\u53D8\u66F4\u8BB0\u5F55","tab.files":"\u6587\u4EF6\u6D4F\u89C8","pill.unavailable":"Git \u4E0D\u53EF\u7528","pill.detached":"\u6E38\u79BB HEAD","pill.synced":"\u672C\u5730\u5DF2\u540C\u6B65","pill.dirty":"\u6709\u5F85\u63D0\u4EA4\u7684\u53D8\u66F4","common.loading":"\u52A0\u8F7D\u4E2D\u2026","common.retry":"\u91CD\u8BD5","common.close":"\u5173\u95ED","version.check":"\u68C0\u67E5\u65B0\u7248\u672C","version.checking":"\u68C0\u67E5\u4E2D\u2026","version.upToDate":"\u5DF2\u662F\u6700\u65B0\uFF08{current}\uFF09","version.updateAvailable":"\u6709\u65B0\u7248\u672C {latest}\uFF08\u5F53\u524D {current}\uFF09","version.viewRelease":"\u67E5\u770B\u53D1\u5E03","version.error":"\u68C0\u67E5\u5931\u8D25","version.noRepo":"\u672A\u914D\u7F6E\u4ED3\u5E93\u5730\u5740","version.openRepo":"\u5728 GitHub \u4E0A\u6253\u5F00\u4ED3\u5E93","overview.head":"HEAD\uFF08\u5F53\u524D\u5206\u652F\uFF09","overview.local":"\u672C\u5730","overview.remote":"\u8FDC\u7A0B","overview.tags":"\u6807\u7B7E","overview.search":"\u641C\u7D22\u63D0\u4EA4\uFF08\u6D88\u606F / \u54C8\u5E0C\uFF09","overview.allUsers":"\u5168\u90E8\u4F5C\u8005","overview.allTime":"\u5168\u90E8\u65F6\u95F4","overview.today":"\u4ECA\u5929","overview.last7d":"\u8FD1 7 \u5929","overview.last30d":"\u8FD1 30 \u5929","overview.selectCommit":"\u9009\u62E9\u4E00\u4E2A\u63D0\u4EA4\u67E5\u770B\u8BE6\u60C5","overview.noMessage":"\uFF08\u65E0\u63D0\u4EA4\u6B63\u6587\uFF09","overview.noResults":"\u6CA1\u6709\u5339\u914D\u7684\u63D0\u4EA4","overview.loadFailed":"\u52A0\u8F7D\u5931\u8D25","overview.detailFailed":"\u8BE6\u60C5\u52A0\u8F7D\u5931\u8D25","overview.diffFailed":"\u5DEE\u5F02\u52A0\u8F7D\u5931\u8D25","overview.openFileDiff":"\u67E5\u770B\u8BE5\u6587\u4EF6\u5728\u6B64\u63D0\u4EA4\u4E2D\u7684\u53D8\u66F4","overview.fetch":"\u62C9\u53D6\u8FDC\u7A0B","overview.branchesError":"\u5206\u652F\u52A0\u8F7D\u5931\u8D25","changes.groupStaged":"\u5DF2\u6682\u5B58\u7684\u66F4\u6539","changes.groupUnstaged":"\u66F4\u6539","changes.groupUntracked":"\u672A\u7248\u672C\u63A7\u5236\u7684\u6587\u4EF6","changes.selectFile":"\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6\u67E5\u770B\u53D8\u66F4","changes.noChanges":"\u6CA1\u6709\u672A\u63D0\u4EA4\u7684\u53D8\u66F4","changes.stageAll":"\u5168\u90E8\u6682\u5B58","changes.unstageAll":"\u5168\u90E8\u53D6\u6D88\u6682\u5B58","changes.stage":"\u6682\u5B58","changes.unstage":"\u53D6\u6D88\u6682\u5B58","changes.discard":"\u653E\u5F03\u66F4\u6539","changes.discardConfirm":"\u518D\u6B21\u70B9\u51FB\u4EE5\u786E\u8BA4\u653E\u5F03","files.selectFile":"\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6\u67E5\u770B\u5185\u5BB9","files.loadFailed":"\u52A0\u8F7D\u5931\u8D25","files.truncated":"\u6761\u76EE\u8FC7\u591A\uFF0C\u5DF2\u622A\u65AD","files.tooLarge":"\u6587\u4EF6\u8FC7\u5927\uFF0C\u65E0\u6CD5\u9884\u89C8","files.binary":"\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\u9884\u89C8","files.previewMode":"Markdown \u9884\u89C8\u65B9\u5F0F","files.source":"\u6E90\u7801","files.render":"\u6E32\u67D3","files.copyPath":"\u590D\u5236\u76F8\u5BF9\u8DEF\u5F84","files.pathCopied":"\u8DEF\u5F84\u5DF2\u590D\u5236","files.pathCopyFailed":"\u590D\u5236\u5931\u8D25","files.ignored":"\u5DF2\u88AB Git \u5FFD\u7565","files.copy":"\u590D\u5236\u4EE3\u7801","files.copied":"\u5DF2\u590D\u5236","files.footnotes":"\u6CE8\u91CA","stats.files":"{n} \u4E2A\u6587\u4EF6","stats.lastChange":"\u6700\u8FD1\u53D8\u66F4 {time}","stats.lastCommit":"\u4E0A\u6B21\u63D0\u4EA4 {time}","stats.staged":"\u5DF2\u6682\u5B58 {n}","stats.modified":"\u5DF2\u4FEE\u6539 {n}","stats.untracked":"\u672A\u8DDF\u8E2A {n}","commit.placeholder":"\u63D0\u4EA4\u4FE1\u606F","commit.commit":"\u63D0\u4EA4","commit.amend":"\u4FEE\u6B63\u4E0A\u6B21\u63D0\u4EA4\uFF08amend\uFF09","diff.unified":"\u7EDF\u4E00","diff.split":"\u5BF9\u7167","diff.before":"\u53D8\u66F4\u524D","diff.after":"\u53D8\u66F4\u540E","diff.binary":"\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\u663E\u793A\u5BF9\u7167","diff.tooLarge":"\u56FE\u7247\u8FC7\u5927\uFF0C\u65E0\u6CD5\u663E\u793A\u5BF9\u7167","diff.imageMissing":"\u4E0D\u5B58\u5728","diff.empty":"\u65E0\u5DEE\u5F02","diff.expandAll":"\u5C55\u5F00\u5168\u90E8","diff.collapse":"\u6298\u53E0\u672A\u53D8\u66F4","diff.expandGap":"\u5C55\u5F00\u5168\u90E8 {n} \u884C","diff.expandUp":"\u5411\u4E0A\u5C55\u5F00 {n} \u884C","diff.expandDown":"\u5411\u4E0B\u5C55\u5F00 {n} \u884C","time.justNow":"\u521A\u521A","time.minutesAgo":"{n} \u5206\u949F\u524D","time.hoursAgo":"{n} \u5C0F\u65F6\u524D","time.daysAgo":"{n} \u5929\u524D","error.generic":"\u64CD\u4F5C\u5931\u8D25","error.notARepo":"\u5F53\u524D\u76EE\u5F55\u4E0D\u662F Git \u4ED3\u5E93","error.noCwd":"\u5F53\u524D\u4F1A\u8BDD\u65E0\u5DE5\u4F5C\u76EE\u5F55","error.localChangesBlock":"\u672C\u5730\u6709\u672A\u63D0\u4EA4\u53D8\u66F4\uFF0C\u65E0\u6CD5\u5207\u6362","error.emptyMessage":"\u63D0\u4EA4\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A","cfg.title":"\u8F93\u5165\u6846\u5206\u652F\u6807\u8BB0","cfg.toggle":"\u663E\u793A\u8F93\u5165\u6846\u6807\u8BB0","cfg.hint":"\u5F00\u542F\u65F6\u5728\u8F93\u5165\u6846\u663E\u793A zsh \u98CE\u683C\u7684 <\u4ED3\u5E93\u540D> (\u5206\u652F) \u6807\u8BB0\uFF1B\u5173\u95ED\u540E\u6539\u4E3A\u5728 Git \u6807\u7B7E\u65C1\u663E\u793A\u72B6\u6001\u5706\u70B9\u3002\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\u3002","cfg.diffTitle":"\u5DEE\u5F02\u5BF9\u6BD4\u9ED8\u8BA4\u89C6\u56FE","cfg.diffHint":"\u9009\u62E9\u53D8\u66F4\u5BF9\u6BD4\u9ED8\u8BA4\u6253\u5F00\u7684\u5E03\u5C40\uFF1A\u7EDF\u4E00\u89C6\u56FE\u4E3A\u5355\u680F\u884C\u5185\u5BF9\u6BD4\uFF0C\u5E76\u6392\u89C6\u56FE\u4E3A\u5DE6\u53F3\u5206\u680F\u5BF9\u6BD4\u3002\u4ECD\u53EF\u5728\u6BCF\u4E2A\u5DEE\u5F02\u89C6\u56FE\u4E2D\u4E34\u65F6\u5207\u6362\u3002\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\u3002","cfg.diffUnified":"\u7EDF\u4E00\u89C6\u56FE\uFF08\u5355\u680F\u884C\u5185\uFF09","cfg.diffSplit":"\u5E76\u6392\u89C6\u56FE\uFF08\u5DE6\u53F3\u5206\u680F\uFF09","cfg.notLoaded":"\u914D\u7F6E\u672A\u52A0\u8F7D\uFF1A\u8BE5\u914D\u7F6E\u7531\u8FD0\u884C\u4E2D\u7684\u5BBF\u4E3B\u63D0\u4F9B\uFF0C\u82E5\u957F\u65F6\u95F4\u7A7A\u767D\u8BF7\u91CD\u542F DSH \u540E\u91CD\u8BD5\u3002","cfg.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"},at={"panel.tab":"Git","panel.fontDecrease":"Decrease font size","panel.fontReset":"Reset font size","panel.fontIncrease":"Increase font size","tab.overview":"Overview","tab.changes":"Changes","tab.files":"Files","pill.unavailable":"Git unavailable","pill.detached":"detached HEAD","pill.synced":"Everything committed","pill.dirty":"Uncommitted changes","common.loading":"Loading\u2026","common.retry":"Retry","common.close":"Close","version.check":"Check for updates","version.checking":"Checking\u2026","version.upToDate":"Up to date ({current})","version.updateAvailable":"New version {latest} available (current {current})","version.viewRelease":"View release","version.error":"Check failed","version.noRepo":"Repository not configured","version.openRepo":"Open repository on GitHub","overview.head":"HEAD (Current Branch)","overview.local":"Local","overview.remote":"Remote","overview.tags":"Tags","overview.search":"Search commits (message / hash)","overview.allUsers":"All authors","overview.allTime":"All time","overview.today":"Today","overview.last7d":"Last 7 days","overview.last30d":"Last 30 days","overview.selectCommit":"Select a commit to see details","overview.noMessage":"(no commit body)","overview.noResults":"No matching commits","overview.loadFailed":"Load failed","overview.detailFailed":"Failed to load details","overview.diffFailed":"Failed to load diff","overview.openFileDiff":"View this file\u2019s changes in this commit","overview.fetch":"Fetch","overview.branchesError":"Failed to load branches","changes.groupStaged":"Staged changes","changes.groupUnstaged":"Changes","changes.groupUntracked":"Unversioned files","changes.selectFile":"Select a file to see its diff","changes.noChanges":"No uncommitted changes","changes.stageAll":"Stage all","changes.unstageAll":"Unstage all","changes.stage":"Stage","changes.unstage":"Unstage","changes.discard":"Discard changes","changes.discardConfirm":"Click again to confirm discard","files.selectFile":"Select a file to preview","files.loadFailed":"Load failed","files.truncated":"Too many entries \u2014 truncated","files.tooLarge":"File too large to preview","files.binary":"Binary file \u2014 no preview","files.previewMode":"Markdown preview mode","files.source":"Source","files.render":"Rendered","files.copyPath":"Copy relative path","files.pathCopied":"Path copied","files.pathCopyFailed":"Copy failed","files.ignored":"Ignored by Git","files.copy":"Copy code","files.copied":"Copied","files.footnotes":"Footnotes","stats.files":"{n} files","stats.lastChange":"changed {time}","stats.lastCommit":"last commit {time}","stats.staged":"{n} staged","stats.modified":"{n} modified","stats.untracked":"{n} untracked","commit.placeholder":"Commit message","commit.commit":"Commit","commit.amend":"Amend previous commit","diff.unified":"Unified","diff.split":"Split","diff.before":"Before","diff.after":"After","diff.binary":"Binary file \u2014 no diff to show","diff.tooLarge":"Image too large to compare","diff.imageMissing":"Does not exist","diff.empty":"No differences","diff.expandAll":"Expand all","diff.collapse":"Collapse unchanged","diff.expandGap":"Expand all {n} lines","diff.expandUp":"Expand up {n} lines","diff.expandDown":"Expand down {n} lines","time.justNow":"just now","time.minutesAgo":"{n}m ago","time.hoursAgo":"{n}h ago","time.daysAgo":"{n}d ago","error.generic":"Operation failed","error.notARepo":"Not a Git repository","error.noCwd":"This session has no working directory","error.localChangesBlock":"Local changes block the checkout","error.emptyMessage":"Commit message cannot be empty","cfg.title":"Input-bar branch marker","cfg.toggle":"Show input-bar marker","cfg.hint":"When on, the input bar shows the zsh-style <repo> (branch) marker; when off, a status dot appears beside the Git tab instead. Saved changes apply immediately.","cfg.diffTitle":"Default diff view","cfg.diffHint":"Choose the layout diffs open with: unified is a single inline column, split is side-by-side. You can still switch per diff. Saved changes apply immediately.","cfg.diffUnified":"Unified (single inline column)","cfg.diffSplit":"Split (side-by-side)","cfg.notLoaded":"Config not loaded: it is served by the running host. Restart DSH if this stays blank.","cfg.saveFailed":"Save failed, please retry"};var Ge=require("react");var nn=new Set(["cwd-unavailable"]),qe=3e4,rn=6e4,Ce=class{constructor(t,n){this.remote=t;this.sessionId=n}view={state:"cold"};listeners=new Set;timer;inflight;pendingRefresh=!1;disposed=!1;pollMs=qe;subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getSnapshot(){return this.view}ensure(){this.view.state!=="cold"&&this.view.state!=="no-cwd"||this.refresh()}refresh(){return this.inflight!==void 0?(this.pendingRefresh=!0,this.inflight):this.disposed?Promise.resolve():(this.view.state==="cold"&&this.setView({state:"loading"}),this.inflight=this.remote.snapshot({sessionId:this.sessionId}).then(t=>{if(!this.disposed){if(t.ok)this.pollMs=t.value.refreshIntervalMs||qe,this.setView({state:"ready",snapshot:t.value});else if(t.error.code!=="cancelled")if(nn.has(t.error.code))this.pollMs=rn,this.setView({state:"no-cwd"});else if(t.error.code==="not-a-git-repo"){let n=t.error;this.setView({state:"error",error:{code:"not-a-git-repo",...n.cwd?{cwd:n.cwd}:{},...n.showInputPill!==void 0?{showInputPill:n.showInputPill}:{}}})}else this.setView({state:"error",error:{code:t.error.code,..."detail"in t.error?{detail:t.error.detail}:{}}})}}).catch(t=>{this.disposed||this.setView({state:"error",error:{code:"git-unavailable",detail:t instanceof Error?t.message:String(t)}})}).finally(()=>{this.inflight=void 0,this.pendingRefresh&&!this.disposed?(this.pendingRefresh=!1,this.refresh()):this.schedulePoll()}),this.inflight)}resync(){this.disposed||this.refresh()}accept(t){this.disposed||(this.pollMs=t.refreshIntervalMs||qe,this.setView({state:"ready",snapshot:t}),this.schedulePoll())}schedulePoll(){this.disposed||(this.timer!==void 0&&clearTimeout(this.timer),!(this.pollMs<=0)&&(this.timer=setTimeout(()=>{this.refresh()},this.pollMs)))}setView(t){this.view=t;for(let n of this.listeners)n()}dispose(){this.disposed=!0,this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.listeners.clear()}};var an="/api",on="gitPanel";function sn(e){try{let t=e.get("connection")?.rpc,n=t?.call;if(t!==void 0&&typeof n=="function")return(i,r,a)=>n.call(t,an,i,r,a)}catch{}}function ln(e){let t=e;if(t===null||typeof t!="object")return{ok:!1,error:{code:"git-unavailable",message:"malformed rpc result"}};if(t.ok!==!0){let n=t.error;return{ok:!1,error:{code:typeof n?.code=="string"?n.code:"git-unavailable",message:typeof n?.message=="string"?n.message:void 0}}}return t.value===void 0?{ok:!1,error:{code:"git-unavailable",message:"missing value"}}:t.value}function q(e,t){return!e.ok||e.value.kind!==t?null:e.value}function ae(e){return e!==void 0&&e!==""}var ot=new WeakMap;function we(e){let t=ot.get(e);if(t!==void 0)return t;let n=async(r,a,s)=>{let o=sn(e);if(o===void 0)return{ok:!1,error:{code:"git-unavailable",message:"no connection"}};try{let l=await o(`${on}/${r}`,{args:{request:a}},s);return ln(l)}catch(l){return{ok:!1,error:{code:"git-unavailable",message:l instanceof Error?l.message:String(l)}}}},i={snapshot:(r,a)=>n("snapshot",r,a),run:(r,a)=>n("run",r,a),query:(r,a)=>n("query",r,a),version:(r,a)=>n("version",r,a)};return ot.set(e,i),i}var se=new Map,st,Ke;function lt(e){Ke=e,st=we(e)}function Je(e){let t=se.get(e);if(t===void 0){let n=st??(Ke?we(Ke):void 0);t=new Ce(n??fn(),e),se.set(e,t)}return t}var dn=6e4,Ne=new Map;function cn(e){let t=Ne.get(e);t!==void 0&&(clearTimeout(t),Ne.delete(e)),ue.set(e,(ue.get(e)??0)+1)}function pn(e){let t=(ue.get(e)??1)-1;if(t>0){ue.set(e,t);return}ue.delete(e);let n=setTimeout(()=>{Ne.delete(e),!((ue.get(e)??0)>0)&&(se.get(e)?.dispose(),se.delete(e))},dn);Ne.set(e,n)}var ue=new Map;function le(){for(let e of se.values())e.resync()}function dt(){for(let e of se.values())e.dispose();se.clear()}function fn(){let e=async()=>({ok:!1,error:{code:"git-unavailable"}});return{snapshot:e,run:e,query:e,version:e}}function Re(e){let[,t]=(0,Ge.useState)(0),n=e?Je(e):void 0;return(0,Ge.useEffect)(()=>{if(n===void 0||e===void 0)return;cn(e);let i=n.subscribe(()=>t(r=>r+1));return n.ensure(),()=>{i(),pn(e)}},[n,e]),n?n.getSnapshot():{state:"cold"}}var k=require("react");var ct="[data-conversation-tabs]",Be='[data-conversation-tabs] button[role="tab"]',We=new Map,xe=new Map;function pt(e,t){let n=xe.get(e);if(n!==void 0&&n.size>0){for(let i of n)i(t);return}We.set(e,t)}function ft(e){let t=We.get(e);return t===void 0?null:(We.delete(e),t)}function gt(e,t){let n=xe.get(e);return n===void 0&&(n=new Set,xe.set(e,n)),n.add(t),()=>{let i=xe.get(e);i!==void 0&&(i.delete(t),i.size===0&&xe.delete(e))}}function ut(e){if(typeof document>"u")return!1;let t=document.querySelectorAll(Be);for(let n of t)if((n.textContent??"").trim()===e)return n.getAttribute("aria-selected")!=="true"&&n.click(),!0;return!1}var d=require("react"),Ye=require("react-dom");var M=require("react");function Y(e,t=15){return(0,M.createElement)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"},e)}function Te({size:e}){return Y([(0,M.createElement)("circle",{key:"c",cx:8,cy:8,r:2.4}),(0,M.createElement)("line",{key:"l1",x1:8,y1:1.5,x2:8,y2:5.6}),(0,M.createElement)("line",{key:"l2",x1:8,y1:10.4,x2:8,y2:14.5})],e)}function mt({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M4 2v8"}),(0,M.createElement)("path",{key:"b",d:"M2 4h4"}),(0,M.createElement)("circle",{key:"c",cx:4,cy:12,r:1.6}),(0,M.createElement)("circle",{key:"d",cx:12,cy:4,r:1.6}),(0,M.createElement)("path",{key:"e",d:"M12 6v4"}),(0,M.createElement)("path",{key:"f",d:"M10 12h4"})],e)}function Oe({size:e}){return Y([(0,M.createElement)("circle",{key:"a",cx:4,cy:3,r:1.6}),(0,M.createElement)("circle",{key:"b",cx:4,cy:13,r:1.6}),(0,M.createElement)("circle",{key:"c",cx:12,cy:5,r:1.6}),(0,M.createElement)("path",{key:"d",d:"M4 4.6v6.8"}),(0,M.createElement)("path",{key:"e",d:"M12 6.6c0 3-4 2.4-8 4"})],e)}function ht({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M2 7V3h4l8 8-4 4z"}),(0,M.createElement)("circle",{key:"b",cx:4.5,cy:5.5,r:.8,fill:"currentColor"})],e)}function de({size:e,open:t}){return Y([(0,M.createElement)("path",{key:"a",d:t?"M3 6l5 5 5-5":"M6 3l5 5-5 5"})],e)}function yt({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M4 4l8 8M12 4l-8 8"})],e)}function Ee({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M13 8a5 5 0 1 1-1.5-3.5"}),(0,M.createElement)("path",{key:"b",d:"M13 2v3h-3"})],e)}function bt({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M4 2h5l3 3v9H4z"}),(0,M.createElement)("path",{key:"b",d:"M9 2v3h3"})],e)}function vt({size:e}){return Y([(0,M.createElement)("path",{key:"a",d:"M5 2.5h4l2.5 2.5v7.5h-6.5z"}),(0,M.createElement)("path",{key:"b",d:"M9 2.5V5h2.5"}),(0,M.createElement)("path",{key:"c",d:"M11 12.5v1.5h-6.5V6"})],e)}function wt({size:e=15}){return(0,M.createElement)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"currentColor"},(0,M.createElement)("path",{"fill-rule":"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"}))}function xt(e){let t=0;for(let n of e){t=Math.max(t,n.lane+1);for(let i of n.edges)t=Math.max(t,i.fromLane+1,i.toLane+1)}return t}function kt(e){let t=[],n=[],i=new Map,r=0,a=s=>{let o=i.get(s);return o===void 0&&(o=r++,i.set(s,o)),o};for(let s of e){let o=n.findIndex(u=>u===s.hash);o===-1&&(o=n.findIndex(u=>u===null),o===-1&&(o=n.length,n.push(null)),n[o]=s.hash);let l=a(s.hash),c=[...n],p=s.parents,f=p.length>=2;for(let u=0;u<n.length;u++)u!==o&&n[u]===s.hash&&(n[u]=null);if(p.length===0)n[o]=null;else{n[o]=p[0],a(p[0]);for(let u=1;u<p.length;u++){let g=p[u],b=n.findIndex(E=>E===g);b===-1&&(b=n.findIndex(E=>E===null),b===-1&&(b=n.length,n.push(null)),n[b]=g),a(g)}}let h=[],y=n;for(let u=0;u<c.length;u++){let g=c[u];if(g!==null)if(g===s.hash)h.push({fromLane:u,toLane:o,color:a(s.hash)});else{let b=y.findIndex(E=>E===g);b!==-1&&h.push({fromLane:u,toLane:b,color:a(g)})}}for(let u of p){let g=y.findIndex(b=>b===u);g!==-1&&h.push({fromLane:o,toLane:g,color:a(u)})}for(t.push({commit:s,lane:o,color:l,edges:h,merge:f});n.length>0&&n[n.length-1]===null;)n=n.slice(0,-1)}return t}function _t(e){let t={name:"",path:"",dir:!0,children:[]};for(let n of e){let i=n.path.split("/").filter(s=>s!==""),r=t,a="";for(let s=0;s<i.length;s++){let o=i[s];a=a===""?o:`${a}/${o}`;let l=s===i.length-1,c=r.children.find(p=>p.name===o&&p.dir===!l);c===void 0&&(c={name:o,path:a,dir:!l,children:[],...l?{meta:n.meta}:{}},r.children.push(c)),r=c}}return St(t),Ct(t.children)}function St(e){e.children.sort((t,n)=>t.dir!==n.dir?t.dir?-1:1:t.name.localeCompare(n.name));for(let t of e.children)St(t)}function Ct(e){return e.map(t=>{if(!t.dir)return t;let n=t;for(;n.children.length===1&&n.children[0].dir;){let i=n.children[0];n={name:`${n.name}/${i.name}`,path:i.path,dir:!0,children:i.children}}return{...n,children:Ct(n.children)}})}function me(e,t,n){if(e===null)return"";let i=typeof e=="number"?e:Date.parse(e);if(!Number.isFinite(i))return"";let r=Math.max(0,t-i),a=Math.floor(r/6e4);if(a<1)return n("time.justNow");if(a<60)return n("time.minutesAgo",{n:a});let s=Math.floor(a/60);if(s<24)return n("time.hoursAgo",{n:s});let o=Math.floor(s/24);return n("time.daysAgo",{n:o})}function he(e){if(e===null)return"";let t=new Date(typeof e=="number"?e:Date.parse(e));if(Number.isNaN(t.getTime()))return"";let n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}var De={added:"A",modified:"M",deleted:"D",renamed:"R",untracked:"U",conflicted:"!",typechange:"T"};function Me(e){return e==="added"||e==="untracked"?"gp-status--added":e==="deleted"?"gp-status--deleted":e==="renamed"?"gp-status--renamed":"gp-status--modified"}var S=require("react");var gn={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",svg:"image/svg+xml",ico:"image/x-icon",tif:"image/tiff",tiff:"image/tiff"};function je(e){let t=e.lastIndexOf(".");return t<0?null:gn[e.slice(t+1).toLowerCase()]??null}function Nt(e){return/^Binary files .* differ$/m.test(e)||/^GIT binary patch$/m.test(e)}function Gt(e){return je(e)!==null}function un(e){let t=Ue(e);return t.length===0?!1:t.every(n=>n.startsWith("+")||n.startsWith(" "))&&t.some(n=>n.startsWith("+"))&&/^\+\+\+ /m.test(e)&&/--- \/dev\/null/m.test(e)}function mn(e){let t=Ue(e);return t.length===0?!1:t.every(n=>n.startsWith("-")||n.startsWith(" "))&&t.some(n=>n.startsWith("-"))&&/^\+\+\+ \/dev\/null/m.test(e)}function Ue(e){let t=e.split(`
|
|
305
|
-
`),
|
|
306
|
-
`),i=0,r=0,a=!0,s=!1,o=0;for(;o<n.length&&!n[o].startsWith("@@");o++);for(;o<n.length;o++){let l=n[o];if(l.startsWith("@@")){let f=hn.exec(l);if(f){let h=Number(f[1]),y=Number(f[3]),u=h-y;if(a)y>1&&t.push(ye({rightStart:1,count:y-1,delta:u,atStart:!0,atEnd:!1}));else{let g=y-r;g>0&&t.push(ye({rightStart:r,count:g,delta:u,atStart:!1,atEnd:!1}))}i=h,r=y,a=!1}t.push({kind:"hunk",leftNo:null,rightNo:null,leftText:null,rightText:null,text:l});continue}if(l.startsWith("\\"))continue;let c=l[0],p=l.slice(1);c==="+"?(t.push({kind:"add",leftNo:null,rightNo:r,leftText:null,rightText:p}),r++,s=!0):c==="-"?(t.push({kind:"del",leftNo:i,rightNo:null,leftText:p,rightText:null}),i++,s=!0):c===" "&&(t.push({kind:"context",leftNo:i,rightNo:r,leftText:p,rightText:p}),i++,r++,s=!0)}return s&&!a&&!un(e)&&!mn(e)&&t.push(ye({rightStart:r,count:null,delta:i-r,atStart:!1,atEnd:!0})),yn(t)}function ye(e){return{kind:"gap",leftNo:null,rightNo:null,leftText:null,rightText:null,gap:e}}function yn(e){let t=[],n=0;for(;n<e.length;){let i=e[n];if(i.kind==="del"){let r=[],a=n;for(;a<e.length&&e[a].kind==="del";)r.push(e[a]),a++;let s=[];for(;a<e.length&&e[a].kind==="add";)s.push(e[a]),a++;let o=Math.max(r.length,s.length);for(let l=0;l<o;l++){let c=r[l],p=s[l];if(c&&p){let f=bn(c.leftText??"",p.rightText??"");t.push({kind:"mod",leftNo:c.leftNo,rightNo:p.rightNo,leftText:c.leftText,rightText:p.rightText,...f!==null?{leftWord:f.left,rightWord:f.right}:{}})}else c?t.push({kind:"del",leftNo:c.leftNo,rightNo:null,leftText:c.leftText,rightText:null}):p&&t.push({kind:"add",leftNo:null,rightNo:p.rightNo,leftText:null,rightText:p.rightText})}n=a}else t.push(i),n++}return t}function bn(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i++;let r=0;for(;r<n-i&&e[e.length-1-r]===t[t.length-1-r];)r++;return i===0&&r===0?null:{left:[i,e.length-r],right:[i,t.length-r]}}function vn(e,t,n){return n.map((i,r)=>{let a=t+r;return{kind:"context",leftNo:a+e,rightNo:a,leftText:i,rightText:i}})}var Q=20;function Et(e){let t=[];for(let n of e)n.kind==="mod"?(t.push({kind:"del",leftNo:n.leftNo,rightNo:null,leftText:n.leftText,rightText:null,...n.leftWord!==void 0?{leftWord:n.leftWord}:{}}),t.push({kind:"add",leftNo:null,rightNo:n.rightNo,leftText:null,rightText:n.rightText,...n.rightWord!==void 0?{rightWord:n.rightWord}:{}})):t.push(n);return t}function Dt(e,t,n,i,r,a){let s=e.findIndex(f=>f.kind==="gap"&&f.gap?.rightStart===t);if(s<0)return e.slice();let o=e[s].gap,l=vn(o.delta,i,r),c=[];if(o.atEnd)return c.push(...l),!a&&r.length>0&&c.push(ye({rightStart:i+r.length,count:null,delta:o.delta,atStart:!1,atEnd:!0})),[...e.slice(0,s),...c,...e.slice(s+1)];let p=o.count??r.length;if(n==="all"||r.length>=p)c.push(...l);else if(n==="down"){c.push(...l);let f=p-r.length;c.push(ye({rightStart:o.rightStart+r.length,count:f,delta:o.delta,atStart:!1,atEnd:!1}))}else{let f=p-r.length;c.push(ye({rightStart:o.rightStart,count:f,delta:o.delta,atStart:o.atStart,atEnd:!1})),c.push(...l)}return[...e.slice(0,s),...c,...e.slice(s+1)]}var Ae=require("@deepseek-ai/dsh-client-ui-primitives");function Mt(e,t){let n=[[],[],[]],i=0;for(let r of e){let a=i+r.text.length,s=[i,Math.max(i,Math.min(a,t[0])),Math.max(i,Math.min(a,t[1])),a];for(let o=0;o<3;o++){let l=r.text.slice(s[o]-i,s[o+1]-i);l!==""&&n[o].push({text:l,style:r.style})}i=a}return n}var Z=require("react");function Pe(e,t,n){let i=n(`diff.${e}`);return(0,Z.createElement)("div",{className:`gp-imgcmp__pane gp-imgcmp__pane--${e}`},[(0,Z.createElement)("div",{key:"head",className:"gp-imgcmp__head"},i),t===void 0?(0,Z.createElement)("div",{key:"missing",className:"gp-imgcmp__missing"},n("diff.imageMissing")):(0,Z.createElement)("div",{key:"img",className:"gp-imgcmp__img"},(0,Z.createElement)("img",{src:t,alt:i}))])}function Pt({oldUrl:e,newUrl:t,mode:n,t:i}){return n==="before"?(0,Z.createElement)("div",{className:"gp-imgcmp gp-imgcmp--single"},Pe("before",e,i)):n==="after"?(0,Z.createElement)("div",{className:"gp-imgcmp gp-imgcmp--single"},Pe("after",t,i)):(0,Z.createElement)("div",{className:"gp-imgcmp"},[Pe("before",e,i),Pe("after",t,i)])}var ze=(0,S.memo)(function({text:t,mode:n,path:i,remote:r,sessionId:a,imageSpec:s,t:o}){let l=(0,S.useMemo)(()=>Tt(t),[t]),c=Nt(t),p=(0,Ae.useCodeHighlighter)(i===void 0?void 0:(0,Ae.languageForPath)(i)),[f,h]=(0,S.useState)(l);(0,S.useEffect)(()=>{h(l)},[l]);let y=wn(f,h,r,a,i,s),u=c&&i!==void 0&&Gt(i)&&r!==void 0&&a!==void 0&&s!==void 0,g=kn(u?r:void 0,u?a:void 0,u?i:void 0,u?s:void 0);if(c){if(u){if(g.kind==="idle"||g.kind==="loading")return(0,S.createElement)("div",{className:"gp-empty"},o("common.loading"));if(g.kind==="ready"){let b=g.res;if(b.tooLarge===!0)return(0,S.createElement)("div",{className:"gp-empty"},o("diff.tooLarge"));if(b.mime!==null&&(b.old!==void 0||b.new!==void 0))return(0,S.createElement)(Pt,{oldUrl:b.old,newUrl:b.new,mode:n,t:o})}}return(0,S.createElement)("div",{className:"gp-empty"},o("diff.binary"))}if(t.trim()==="")return(0,S.createElement)("div",{className:"gp-empty"},o("diff.empty"));if(n==="before")return Ft(_n(f),p);if(n==="after")return Ft(Sn(f),p);if(n==="unified"){let b=Et(f);return(0,S.createElement)("div",{className:"gp-diff__unified"},b.flatMap((E,P)=>Nn(E,P,p,y,o)))}return(0,S.createElement)("div",{className:"gp-diff__side"},f.flatMap((b,E)=>Cn(b,E,p,y,o)))});function wn(e,t,n,i,r,a){let[s,o]=(0,S.useState)(null),l=(0,S.useRef)(0);(0,S.useEffect)(()=>{l.current+=1,o(null)},[e]);let c=(0,S.useCallback)((p,f)=>{if(n===void 0||i===void 0||r===void 0||a===void 0)return;let h=`${p.rightStart}:${f}`;o(h);let y=++l.current,{start:u,end:g}=xn(p,f),b=a.base==="commit"&&a.commit!==void 0?{kind:"file-lines",path:r,base:"commit",commit:a.commit,start:u,end:g}:a.base==="staged"?{kind:"file-lines",path:r,base:"staged",start:u,end:g}:{kind:"file-lines",path:r,base:"worktree",start:u,end:g};n.query({sessionId:i,query:b}).then(E=>{if(y!==l.current)return;let P=q(E,"file-lines");o(null),P!==null&&t(w=>Dt(w,p.rightStart,f,P.start,P.lines,P.eof))}).catch(()=>{y===l.current&&o(null)})},[n,i,r,a,t]);return{busy:s,run:c}}function xn(e,t){if(e.atEnd)return{start:e.rightStart,end:e.rightStart+Q-1};let n=e.count??Q;return t==="all"||n<=Q?{start:e.rightStart,end:e.rightStart+n-1}:t==="down"?{start:e.rightStart,end:e.rightStart+Q-1}:{start:e.rightStart+n-Q,end:e.rightStart+n-1}}function kn(e,t,n,i){let[r,a]=(0,S.useState)({kind:"idle"}),s=i?.base,o=i?.commit;return(0,S.useEffect)(()=>{if(e===void 0||t===void 0||n===void 0||s===void 0)return;let l=!0;a({kind:"loading"});let c=s==="commit"&&o!==void 0?{kind:"image-diff",path:n,base:"commit",commit:o}:s==="staged"?{kind:"image-diff",path:n,base:"staged"}:{kind:"image-diff",path:n,base:"worktree"};return e.query({sessionId:t,query:c}).then(p=>{if(!l)return;let f=q(p,"image-diff");a(f!==null?{kind:"ready",res:f}:{kind:"failed"})}).catch(()=>{l&&a({kind:"failed"})}),()=>{l=!1}},[e,t,n,s,o]),r}function Fe(e,t=""){return e.map((n,i)=>(0,S.createElement)("span",{key:`${t}${i}`,style:n.style},n.text))}function Le(e,t,n,i){if(n==="")return(0,S.createElement)("div",{key:t,className:e},"\xA0");let r=i(n)?.[0];return(0,S.createElement)("div",{key:t,className:e},r===void 0?n:Fe(r))}function Qe(e,t,n,i,r,a){let s=a(n)?.[0]??[{text:n,style:{}}],[o,l,c]=Mt(s,i);return(0,S.createElement)("div",{key:t,className:e},[...Fe(o,"p"),(0,S.createElement)("span",{key:"w",className:r},l.length===0?"\xA0":Fe(l)),...Fe(c,"s")])}function _n(e){return e.filter(t=>t.leftText!==null).map(t=>({no:t.leftNo,text:t.leftText}))}function Sn(e){return e.filter(t=>t.rightText!==null).map(t=>({no:t.rightNo,text:t.rightText}))}function Ft(e,t){return(0,S.createElement)("div",{className:"gp-diff__single"},e.flatMap((n,i)=>[(0,S.createElement)("div",{key:`n${i}`,className:"gp-diff-no"},n.no??""),Le("gp-diff-cell",`c${i}`,n.text,t)]))}function Cn(e,t,n,i,r){if(e.kind==="hunk")return[(0,S.createElement)("div",{key:`h${t}`,className:"gp-diff-row--hunk gp-diff-cell",style:{gridColumn:"1 / -1"}},e.text??"")];if(e.kind==="gap")return[Lt(e.gap,t,i,r)];let a=e.kind==="del"||e.kind==="mod"?"gp-diff-row--del":"",s=e.kind==="add"||e.kind==="mod"?"gp-diff-row--add":"",o=e.leftText===null?(0,S.createElement)("div",{key:`l${t}`,className:`gp-diff-cell ${a}`}):e.kind==="mod"&&e.leftWord!==void 0?Qe(`gp-diff-cell ${a}`,`l${t}`,e.leftText,e.leftWord,"gp-diff-word gp-diff-word--del",n):Le(`gp-diff-cell ${a}`,`l${t}`,e.leftText,n),l=e.rightText===null?(0,S.createElement)("div",{key:`r${t}`,className:`gp-diff-cell ${s}`}):e.kind==="mod"&&e.rightWord!==void 0?Qe(`gp-diff-cell ${s}`,`r${t}`,e.rightText,e.rightWord,"gp-diff-word gp-diff-word--add",n):Le(`gp-diff-cell ${s}`,`r${t}`,e.rightText,n);return[(0,S.createElement)("div",{key:`ln${t}`,className:"gp-diff-no"},e.leftNo??""),o,(0,S.createElement)("div",{key:`rn${t}`,className:"gp-diff-no"},e.rightNo??""),l]}function Nn(e,t,n,i,r){if(e.kind==="hunk")return[(0,S.createElement)("div",{key:`h${t}`,className:"gp-diff-row--hunk gp-diff-cell",style:{gridColumn:"1 / -1"}},e.text??"")];if(e.kind==="gap")return[Lt(e.gap,t,i,r)];let a=e.kind==="del",s=e.kind==="add",o=s?"gp-diff-row--add":a?"gp-diff-row--del":"",l=s?"+":a?"\u2212":"\xA0",c=e.rightText??e.leftText??"",p=s?e.rightWord:a?e.leftWord:void 0,f=s?"gp-diff-word gp-diff-word--add":"gp-diff-word gp-diff-word--del",h=`gp-diff-cell gp-diff-uni__code ${o}`,y=p!==void 0?Qe(h,`c${t}`,c,p,f,n):Le(h,`c${t}`,c,n);return[(0,S.createElement)("div",{key:`ol${t}`,className:"gp-diff-no"},e.leftNo??""),(0,S.createElement)("div",{key:`nl${t}`,className:"gp-diff-no"},e.rightNo??""),(0,S.createElement)("div",{key:`sg${t}`,className:`gp-diff-uni__sign ${o}`},l),y]}function Lt(e,t,n,i){let r=n.busy===`${e.rightStart}:all`,a=n.busy===`${e.rightStart}:up`,s=n.busy===`${e.rightStart}:down`,o=(c,p,f)=>(0,S.createElement)("button",{key:c,type:"button",className:"gp-gap__btn",disabled:n.busy!==null,onClick:h=>{h.stopPropagation(),n.run(e,c)}},f?i("common.loading"):p),l=[];if(e.atEnd)l.push(o("down",i("diff.expandDown",{n:Q}),s));else{let c=e.count??0;c>0&&c<=Q?l.push(o("all",i("diff.expandGap",{n:c}),r)):(e.atStart||l.push(o("up",i("diff.expandUp",{n:Q}),a)),l.push(o("all",i("diff.expandGap",{n:c}),r)),l.push(o("down",i("diff.expandDown",{n:Q}),s)))}return(0,S.createElement)("div",{key:`g${t}`,className:"gp-diff-row--gap",style:{gridColumn:"1 / -1"}},l)}function $e(e){return Rt(e)}var _=require("react");var Gn=100;function At(e,t,n){let[i,r]=(0,_.useState)(null),[a,s]=(0,_.useState)(!1),[o,l]=(0,_.useState)([]),c=(0,_.useCallback)(()=>{s(!1),(async()=>{let[p,f]=await Promise.all([e.query({sessionId:t,query:{kind:"branches"}}),e.query({sessionId:t,query:{kind:"tags"}})]),h=q(p,"branches");if(h===null){s(!0);return}let y=q(f,"tags");r({current:h.current,defaultBranch:h.defaultBranch,local:h.local,remote:h.remote,tags:y?.tags??[]}),e.query({sessionId:t,query:{kind:"authors"}}).then(u=>{l(q(u,"authors")?.authors??[])})})()},[e,t]);return(0,_.useEffect)(()=>{c()},[n]),{tree:i,treeError:a,authors:o,reload:c}}function zt(e,t,n,i,r){let[a,s]=(0,_.useState)([]),[o,l]=(0,_.useState)(0),[c,p]=(0,_.useState)(!1),[f,h]=(0,_.useState)(!1),y=(0,_.useRef)(0),u=(0,_.useRef)(!1),g=(0,_.useRef)(null),b=(0,_.useCallback)(async($,L)=>{if(u.current)return;u.current=!0;let V=y.current;p(!0),h(!1);let C=await e.query({sessionId:t,query:{kind:"history",limit:Gn,skip:$,...L.ref?{ref:L.ref}:{},...L.search?{search:L.search}:{},...L.author?{author:L.author}:{},...L.since?{since:L.since}:{}}});if(u.current=!1,V!==y.current)return;p(!1);let N=q(C,"history");if(N===null){h(!0);return}let R=N.commits;s(H=>$===0?R:[...H,...R]),l(N.total)},[e,t]),E=(0,_.useRef)(n);(0,_.useEffect)(()=>{y.current+=1,u.current=!1,E.current!==n&&(E.current=n,r(),g.current&&(g.current.scrollTop=0)),b(0,n)},[n,i]);let P=o<0?!0:a.length<o,w=(0,_.useCallback)(()=>{u.current||!P||b(a.length,n)},[b,a.length,n,P]);return{commits:a,total:o,loading:c,listError:f,hasMore:P,listRef:g,loadMore:w}}function $t(e,t,n){let[i,r]=(0,_.useState)(null),[a,s]=(0,_.useState)(null),[o,l]=(0,_.useState)(!1),[c,p]=(0,_.useState)(null),[f,h]=(0,_.useState)(null),[y,u]=(0,_.useState)(!1),[g,b]=(0,_.useState)(n),[E,P]=(0,_.useState)(!1),w=(0,_.useRef)(0),$=(0,_.useRef)(null),L=(0,_.useRef)(new Map),V=(0,_.useCallback)(()=>{r(null),s(null),$.current=null},[]),C=(0,_.useCallback)(async T=>{$.current=T.hash,r(T),l(!1),w.current+=1,p(null),h(null),u(!1);let K=L.current.get(T.hash);if(K!==void 0){s(K);return}s(null);let B=await e.query({sessionId:t,query:{kind:"show",ref:T.hash}});if($.current!==T.hash)return;let J=q(B,"show");if(J!==null){let re={commit:J.commit,body:J.body,stats:J.stats},X=L.current;for(X.set(T.hash,re);X.size>50;){let ie=X.keys().next().value;if(ie===void 0)break;X.delete(ie)}s(re)}else l(!0)},[e,t]),N=(0,_.useCallback)(async(T,K,B,J=!1)=>{let re=++w.current;p({path:T,hash:K,shortHash:B}),h(null),u(!1),P(J);let X=await e.query({sessionId:t,query:{kind:"diff",path:T,base:"commit",commit:K,...J?{context:1e5}:{}}});if(re!==w.current)return;let ie=q(X,"diff");ie!==null?h(ie.text):u(!0)},[e,t]),R=(0,_.useCallback)(()=>{w.current+=1,p(null),h(null),u(!1),P(!1)},[]);(0,_.useEffect)(()=>{if(c===null)return;let T=K=>{K.key==="Escape"&&R()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[c,R]);let[H,j]=(0,_.useState)(null),[te,U]=(0,_.useState)(null),I=(0,_.useRef)(void 0),ne=(0,_.useRef)(null),fe=(0,_.useCallback)((T,K,B)=>{I.current!==void 0&&clearTimeout(I.current),I.current=setTimeout(()=>{ne.current=T.hash,j({commit:T,x:K,y:B});let J=L.current.get(T.hash);if(J!==void 0){U(J.body);return}U(null),e.query({sessionId:t,query:{kind:"show",ref:T.hash}}).then(re=>{if(ne.current!==T.hash)return;let X=q(re,"show");X!==null?(L.current.set(T.hash,{commit:X.commit,body:X.body,stats:X.stats}),U(X.body)):U("")})},260)},[e,t]),G=(0,_.useCallback)(()=>{I.current!==void 0&&clearTimeout(I.current),ne.current=null,j(null),U(null)},[]);return(0,_.useEffect)(()=>()=>{I.current!==void 0&&clearTimeout(I.current)},[]),{selected:i,detail:a,detailError:o,select:C,clearSelection:V,fileDiff:c,fileDiffText:f,fileDiffError:y,fileDiffMode:g,setFileDiffMode:b,fileDiffExpanded:E,openFileDiff:N,closeFileDiff:R,hover:H,hoverBody:te,onHoverEnter:fe,onHoverLeave:G}}var O=require("react"),Rn=(e,t,n)=>Math.max(t,Math.min(n,e));function Tn(e,t){try{let n=typeof localStorage<"u"?localStorage.getItem(e):null,i=n===null?NaN:Number(n);return Number.isFinite(i)?i:t}catch{return t}}function En(e,t){try{typeof localStorage<"u"&&localStorage.setItem(e,String(Math.round(t)))}catch{}}function ce(e){let{storageKey:t,initial:n,min:i,reserve:r,edge:a}=e,[s,o]=(0,O.useState)(()=>Tn(t,n)),l=(0,O.useRef)(null),c=(0,O.useRef)(null),p=(0,O.useCallback)(h=>{let u=l.current?.parentElement?.clientWidth??Number.MAX_SAFE_INTEGER;c.current={x:h.clientX,w:s,max:Math.max(i,u-r)},h.preventDefault(),typeof document<"u"&&(document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[s,i,r]);(0,O.useEffect)(()=>{if(typeof window>"u")return;let h=u=>{let g=c.current;if(g===null)return;let b=u.clientX-g.x;o(Rn(g.w+(a==="end"?b:-b),i,g.max))},y=()=>{c.current!==null&&(c.current=null,typeof document<"u"&&(document.body.style.cursor="",document.body.style.userSelect=""),o(u=>(En(t,u),u)))};return window.addEventListener("pointermove",h),window.addEventListener("pointerup",y),()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",y)}},[a,i,t]);let f=(0,O.createElement)("div",{key:`rz-${t}`,ref:l,className:"gp-resizer",role:"separator","aria-orientation":"vertical",onPointerDown:p});return{width:s,divider:f}}var be=14,ke=30;function Ht({remote:e,sessionId:t,refreshKey:n,defaultDiffView:i,t:r}){let[a,s]=(0,d.useState)({ref:null,search:"",author:"",since:""}),[o,l]=(0,d.useState)(""),[c,p]=(0,d.useState)(new Set(["tags","remote"])),{tree:f,treeError:h,authors:y,reload:u}=At(e,t,n),g=$t(e,t,i),{commits:b,loading:E,listError:P,hasMore:w,listRef:$,loadMore:L}=zt(e,t,a,n,g.clearSelection);(0,d.useEffect)(()=>{let G=setTimeout(()=>s(T=>T.search===o?T:{...T,search:o}),300);return()=>clearTimeout(G)},[o]);let V=a.search!=="",C=(0,d.useMemo)(()=>V?b.map(G=>({commit:G,lane:0,color:0,edges:[],merge:!1})):kt(b),[b,V]),N=(0,d.useMemo)(()=>V?0:xt(C),[C,V]),R=V?12:Math.max(be,N*be),H=`${R}px minmax(120px,1fr) 72px 120px 96px`,j=()=>{let G=$.current;G===null||!w||G.scrollTop+G.clientHeight>=G.scrollHeight-240&&L()},te=(0,d.useMemo)(()=>Date.now(),[b]),U=(0,d.useMemo)(()=>g.detail===null?[]:_t(g.detail.stats.map(G=>({path:G.path,meta:G.status}))),[g.detail]),I=g.selected,ne=ce({storageKey:"gp.overview.left",initial:200,min:130,reserve:360,edge:"end"}),fe=ce({storageKey:"gp.overview.right",initial:340,min:190,reserve:360,edge:"start"});return(0,d.createElement)("div",{className:"gp-overview"},[An(g.fileDiff,{text:g.fileDiffText,error:g.fileDiffError,mode:g.fileDiffMode,onMode:g.setFileDiffMode,expanded:g.fileDiffExpanded,onExpand:G=>{g.fileDiff!==null&&g.openFileDiff(g.fileDiff.path,g.fileDiff.hash,g.fileDiff.shortHash,G)},onClose:g.closeFileDiff,remote:e,sessionId:t,t:r}),(0,d.createElement)("div",{key:"left",className:"gp-col gp-col--left",style:{flex:`0 0 ${ne.width}px`}},Mn(f,h,a.ref,c,{onFilter:G=>s(T=>({...T,ref:G})),onToggle:G=>p(T=>{let K=new Set(T);return K.has(G)?K.delete(G):K.add(G),K}),onRetry:u,t:r})),ne.divider,(0,d.createElement)("div",{key:"mid",className:"gp-col gp-col--mid gp-history"},[(0,d.createElement)("div",{key:"tb",className:"gp-toolbar"},[(0,d.createElement)("input",{key:"search",className:"gp-search",placeholder:r("overview.search"),value:o,onChange:G=>l(G.target.value)}),(0,d.createElement)("select",{key:"author",className:"gp-select",value:a.author,onChange:G=>s(T=>({...T,author:G.target.value}))},[(0,d.createElement)("option",{key:"",value:""},r("overview.allUsers")),...y.map(G=>(0,d.createElement)("option",{key:G,value:G},G))]),(0,d.createElement)("select",{key:"since",className:"gp-select",value:a.since,onChange:G=>s(T=>({...T,since:G.target.value}))},[(0,d.createElement)("option",{key:"",value:""},r("overview.allTime")),(0,d.createElement)("option",{key:"today",value:"1 day ago"},r("overview.today")),(0,d.createElement)("option",{key:"7d",value:"7 days ago"},r("overview.last7d")),(0,d.createElement)("option",{key:"30d",value:"30 days ago"},r("overview.last30d"))]),(0,d.createElement)("button",{key:"fetch",type:"button",className:"gp-icon-btn",title:r("overview.fetch"),onClick:()=>{e.run({sessionId:t,action:{kind:"fetch"}}).then(()=>u())}},(0,d.createElement)(Ee,{size:14}))]),(0,d.createElement)("div",{key:"list",className:"gp-history__list",ref:$,onScroll:j},b.length===0?(0,d.createElement)("div",{className:"gp-empty"},r(E?"common.loading":P?"overview.loadFailed":"overview.noResults")):C.map(G=>Pn(G,{selected:I?.hash===G.commit.hash,gridTpl:H,graphW:R,laneCount:N,searching:V,now:te,onSelect:()=>void g.select(G.commit),onHoverEnter:g.onHoverEnter,onHoverLeave:g.onHoverLeave,t:r})))]),fe.divider,(0,d.createElement)("div",{key:"right",className:"gp-col gp-col--right gp-detail",style:{flex:`0 0 ${fe.width}px`}},I===null?(0,d.createElement)("div",{className:"gp-empty"},[(0,d.createElement)(Te,{key:"i",size:20}),r("overview.selectCommit")]):[(0,d.createElement)("div",{key:"files",className:"gp-detail__files"},g.detail===null?(0,d.createElement)("div",{className:"gp-empty"},g.detailError?r("overview.detailFailed"):r("common.loading")):Ln(U,{activePath:g.fileDiff?.path??null,openTitle:r("overview.openFileDiff"),onOpen:G=>{I!==null&&g.openFileDiff(G,I.hash,I.shortHash)}})),(0,d.createElement)("div",{key:"msg",className:"gp-detail__msg"},[(0,d.createElement)("div",{key:"subj",className:"gp-detail__subject"},I.subject),(0,d.createElement)("div",{key:"meta",className:"gp-detail__meta"},[(0,d.createElement)("span",{key:"h",className:"gp-commit-hash"},I.shortHash),(0,d.createElement)("span",{key:"a"},I.author),(0,d.createElement)("span",{key:"t",title:he(I.dateIso)},me(I.dateIso,te,r))]),g.detail!==null&&g.detail.body!==""?(0,d.createElement)("pre",{key:"body",className:"gp-detail__body"},g.detail.body):(0,d.createElement)("div",{key:"nb",className:"gp-empty"},r("overview.noMessage"))])]),Dn(g.hover,g.hoverBody,r)])}function Dn(e,t,n){if(e===null||typeof document>"u")return null;let i=460,r=Math.min(e.x+16,(typeof window<"u"?window.innerWidth:1200)-i-12),a=e.y+14,s=(0,d.createElement)("div",{className:"gp-hovercard",style:{left:r,top:a,maxWidth:i}},[(0,d.createElement)("div",{key:"subj",className:"gp-hovercard__subject"},e.commit.subject),(0,d.createElement)("div",{key:"meta",className:"gp-hovercard__meta"},[(0,d.createElement)("span",{key:"h",className:"gp-commit-hash"},e.commit.shortHash),(0,d.createElement)("span",{key:"a"},e.commit.author)]),t===null?(0,d.createElement)("div",{key:"l",className:"gp-hovercard__loading"},n("common.loading")):t===""?(0,d.createElement)("div",{key:"e",className:"gp-hovercard__loading"},n("overview.noMessage")):(0,d.createElement)("pre",{key:"body",className:"gp-hovercard__body"},t)]);return(0,Ye.createPortal)(s,document.body,"commit-hovercard")}function Mn(e,t,n,i,r){if(t)return(0,d.createElement)("div",{className:"gp-empty"},[(0,d.createElement)("span",{key:"m"},r.t("overview.branchesError")),(0,d.createElement)("button",{key:"r",type:"button",className:"gp-btn",style:{marginTop:8},onClick:r.onRetry},r.t("common.retry"))]);if(e===null)return(0,d.createElement)("div",{className:"gp-empty"},r.t("common.loading"));let a=(s,o,l,c,p="")=>(0,d.createElement)("div",{key:s,className:"gp-branch-group"},[(0,d.createElement)("div",{key:"head",className:"gp-branch-group__head",onClick:()=>r.onToggle(s)},[(0,d.createElement)(de,{key:"c",size:11,open:!i.has(s)}),`${r.t(o)} (${l.length})`]),i.has(s)?null:l.map(f=>{let h=p+f.name,y=e.current===f.name,u=`gp-branch-row${n===h?" gp-branch-row--active":""}${y?" gp-branch-row--current":""}`;return(0,d.createElement)("div",{key:f.name,className:u,title:f.name,onClick:()=>r.onFilter(n===h?null:h)},[(0,d.createElement)("span",{key:"i",style:{display:"inline-flex",width:14}},c),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},f.name),f.ahead||f.behind?(0,d.createElement)("span",{key:"t",className:"gp-branch-row__track"},`${f.ahead?`\u2191${f.ahead}`:""}${f.behind?`\u2193${f.behind}`:""}`):null])})]);return(0,d.createElement)("div",{},[(0,d.createElement)("div",{key:"head-row",className:"gp-branch-row",style:{fontWeight:600,paddingLeft:10},onClick:()=>r.onFilter(null)},r.t("overview.head")),a("local","overview.local",e.local,(0,d.createElement)(Oe,{size:13})),a("remote","overview.remote",e.remote,(0,d.createElement)(Oe,{size:13})),a("tags","overview.tags",e.tags,(0,d.createElement)(ht,{size:13}))])}function Pn(e,t){let n=e.commit;return(0,d.createElement)("div",{key:n.hash,className:`gp-commit-row${t.selected?" gp-commit-row--active":""}`,style:{gridTemplateColumns:t.gridTpl},onClick:t.onSelect,onMouseEnter:i=>t.onHoverEnter(n,i.clientX,i.clientY),onMouseLeave:t.onHoverLeave},[(0,d.createElement)("div",{key:"g",className:"gp-graph-cell"},t.searching?null:Fn(e,t.laneCount)),(0,d.createElement)("div",{key:"s",className:"gp-commit-subject"},[...n.refs.map(i=>(0,d.createElement)("span",{key:i.name,className:`gp-ref-chip${i.head?" gp-ref-chip--head":""}${i.kind==="remote"?" gp-ref-chip--remote":""}${i.kind==="tag"?" gp-ref-chip--tag":""}`},i.name)),n.subject]),(0,d.createElement)("div",{key:"h",className:"gp-commit-hash"},n.shortHash),(0,d.createElement)("div",{key:"a",className:"gp-commit-author"},n.author),(0,d.createElement)("div",{key:"d",className:"gp-commit-date",title:he(n.dateIso)},me(n.dateIso,t.now,t.t))])}var He=["#4e9bff","#3fb950","#e0982e","#d05ce3","#e5534b","#2dc6c6","#d29922","#8b949e"];function Fn(e,t){let n=Math.max(be,t*be),i=a=>a*be+be/2,r=[];for(let a of e.edges){let s=He[a.color%He.length];r.push((0,d.createElement)("path",{key:`e${a.fromLane}-${a.toLane}-${a.color}`,d:`M ${i(a.fromLane)} 0 C ${i(a.fromLane)} ${ke/2}, ${i(a.toLane)} ${ke/2}, ${i(a.toLane)} ${ke}`,stroke:s,strokeWidth:1.6,fill:"none"}))}return r.push((0,d.createElement)("circle",{key:"node",cx:i(e.lane),cy:ke/2,r:e.merge?4:3.2,fill:He[e.color%He.length],stroke:"var(--dsw-alias-bg-layer-1)",strokeWidth:1})),(0,d.createElement)("svg",{className:"gp-graph-svg",width:n,height:ke},r)}function Ln(e,t){let n=[],i=(r,a)=>{for(let s of r)if(s.dir)n.push((0,d.createElement)("div",{key:s.path,className:"gp-tree-row",style:{paddingLeft:10+a*14}},[(0,d.createElement)(de,{key:"c",size:11,open:!0}),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},s.name)])),i(s.children,a+1);else{let o=String(s.meta??"modified"),l=t.activePath===s.path;n.push((0,d.createElement)("div",{key:s.path,className:`gp-tree-row${l?" gp-tree-row--active":""}`,style:{paddingLeft:10+a*14},title:t.openTitle,onClick:()=>t.onOpen(s.path)},[(0,d.createElement)("span",{key:"st",className:`gp-status-badge ${Me(o)}`},(De[o]??o[0]??"M").toUpperCase()),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},s.name)]))}};return i(e,0),(0,d.createElement)("div",{},n)}function An(e,t){if(e===null||typeof document>"u")return null;let{text:n,error:i,mode:r,onMode:a,expanded:s,onExpand:o,onClose:l,remote:c,sessionId:p,t:f}=t,h=(0,d.createElement)("div",{className:"gp-modal-backdrop",onClick:y=>{y.target===y.currentTarget&&l()}},(0,d.createElement)("div",{className:"gp-modal",role:"dialog","aria-modal":!0},[(0,d.createElement)("div",{key:"bar",className:"gp-modal__bar"},[(0,d.createElement)("span",{key:"fileicon",className:"gp-modal__fileicon"},(0,d.createElement)(bt,{size:15})),(0,d.createElement)("span",{key:"path",className:"gp-modal__path",title:e.path},zn(e.path)),(0,d.createElement)("span",{key:"hash",className:"gp-modal__hash"},e.shortHash),n!==null&&n!==""?(()=>{let y=$e(n);return(0,d.createElement)("span",{key:"sum",className:"gp-modal__sum"},[(0,d.createElement)("span",{key:"a",className:"gp-stats__add"},`+${y.add}`),(0,d.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${y.del}`)])})():null,(0,d.createElement)("button",{key:"expand",type:"button",className:`gp-seg__btn gp-diff__expand${s?" gp-seg__btn--active":""}`,disabled:r!=="split"&&r!=="unified",title:f(s?"diff.collapse":"diff.expandAll"),onClick:()=>o(!s)},f(s?"diff.collapse":"diff.expandAll")),(0,d.createElement)("div",{key:"seg",className:"gp-seg"},["unified","split","before","after"].map(y=>(0,d.createElement)("button",{key:y,type:"button",className:`gp-seg__btn${r===y?" gp-seg__btn--active":""}`,onClick:()=>a(y)},f(`diff.${y}`)))),(0,d.createElement)("button",{key:"close",type:"button",className:"gp-icon-btn gp-modal__close",title:f("common.close"),onClick:l},(0,d.createElement)(yt,{size:15}))]),(0,d.createElement)("div",{key:"scroll",className:"gp-modal__scroll"},n===null?(0,d.createElement)("div",{className:"gp-empty"},f(i?"overview.diffFailed":"common.loading")):(0,d.createElement)(ze,{text:n,mode:r,path:e.path,remote:c,sessionId:p,imageSpec:{base:"commit",commit:e.hash},t:f}))]));return(0,Ye.createPortal)(h,document.body,"file-diff-modal")}function zn(e){let t=e.lastIndexOf("/");return t<0?[(0,d.createElement)("span",{key:"n",className:"gp-modal__name"},e)]:[(0,d.createElement)("span",{key:"d",className:"gp-modal__dir"},e.slice(0,t+1)),(0,d.createElement)("span",{key:"n",className:"gp-modal__name"},e.slice(t+1))]}var m=require("react");var W=require("react");function It({stats:e,t}){let n=Date.now(),i=[(0,W.createElement)("span",{key:"files",className:"gp-stats__item"},t("stats.files",{n:e.fileCount})),(0,W.createElement)("span",{key:"lines",className:"gp-stats__item"},[(0,W.createElement)("span",{key:"a",className:"gp-stats__add"},`+${e.insertions}`)," ",(0,W.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${e.deletions}`)])];e.staged>0&&i.push((0,W.createElement)("span",{key:"st",className:"gp-stats__item"},t("stats.staged",{n:e.staged}))),e.modified>0&&i.push((0,W.createElement)("span",{key:"mo",className:"gp-stats__item"},t("stats.modified",{n:e.modified}))),e.untracked>0&&i.push((0,W.createElement)("span",{key:"un",className:"gp-stats__item"},t("stats.untracked",{n:e.untracked})));let r=[];return e.lastChangeAt!==null&&r.push((0,W.createElement)("span",{key:"lc",className:"gp-stats__item",title:he(e.lastChangeAt)},t("stats.lastChange",{time:me(e.lastChangeAt,n,t)}))),e.headCommittedAt!==null&&r.push((0,W.createElement)("span",{key:"hc",className:"gp-stats__item",title:he(e.headCommittedAt)},t("stats.lastCommit",{time:me(e.headCommittedAt,n,t)}))),r.length>0&&i.push((0,W.createElement)("span",{key:"times",className:"gp-stats__times"},r)),(0,W.createElement)("div",{className:"gp-stats"},i)}function Vt({remote:e,sessionId:t,snapshot:n,onAction:i,t:r}){let[a,s]=(0,m.useState)(new Set),[o,l]=(0,m.useState)(""),[c,p]=(0,m.useState)(!1),[f,h]=(0,m.useState)(!1),[y,u]=(0,m.useState)(null),[g,b]=(0,m.useState)(new Set),[E,P]=(0,m.useState)(null),[w,$]=(0,m.useState)(null),[L,V]=(0,m.useState)(null),[C,N]=(0,m.useState)(()=>n.defaultDiffView),[R,H]=(0,m.useState)(!1),[j,te]=(0,m.useState)(!1),U=(0,m.useRef)(0),I=(0,m.useMemo)(()=>n.changes.filter(x=>x.staged).sort(Ze),[n]),ne=(0,m.useMemo)(()=>n.changes.filter(x=>!x.staged&&x.status!=="untracked").sort(Ze),[n]),fe=(0,m.useMemo)(()=>n.changes.filter(x=>x.status==="untracked").sort(Ze),[n]),G=[{key:"staged",labelKey:"changes.groupStaged",items:I},{key:"unstaged",labelKey:"changes.groupUnstaged",items:ne},{key:"untracked",labelKey:"changes.groupUntracked",items:fe}].filter(x=>x.items.length>0);(0,m.useEffect)(()=>{s(x=>{if(x.size===0)return x;let D=new Set(n.changes.map(oe=>oe.path+(oe.staged?":s":":w"))),A=new Set,ge=!1;for(let oe of x)D.has(oe)?A.add(oe):ge=!0;return ge?A:x})},[n]),(0,m.useEffect)(()=>{if(!c||j||o.trim()!=="")return;let x=!0;return e.query({sessionId:t,query:{kind:"last-commit-message"}}).then(D=>{let A=q(D,"last-commit-message");x&&A!==null&&(l(A.message),te(!0))}),()=>{x=!1}},[c,j,o,e,t]);let T=(0,m.useCallback)(async(x,D,A=!1,ge=!1)=>{let oe=++U.current;$({path:x,base:D}),ge||V(null),H(A);let en=await e.query({sessionId:t,query:{kind:"diff",path:x,base:D,...A?{context:1e5}:{}}});if(oe!==U.current)return;let nt=q(en,"diff");V(nt!==null?nt.text:"")},[e,t]);(0,m.useEffect)(()=>{if(w===null)return;if(!n.changes.some(D=>D.path===w.path)){$(null),V(null);return}T(w.path,w.base,R,!0)},[n]),(0,m.useEffect)(()=>{P(null)},[n]);let K=x=>{s(D=>{let A=new Set(D);return A.has(x)?A.delete(x):A.add(x),A})},B=async x=>{if(f)return!1;h(!0),u(null);try{let D=await i(x);return D.ok?!0:(u(D.error??r("error.generic")),!1)}catch(D){return u(D instanceof Error?D.message:r("error.generic")),!1}finally{h(!1)}},J=async()=>{let x=o.trim();if(x===""&&!c){u(r("error.emptyMessage"));return}let D=a.size>0?[...new Set([...a].map(ge=>ge.replace(/:[sw]$/,"")))]:void 0;await B({kind:"commit",message:x,...D?{paths:D}:{},...c?{amend:!0}:{}})&&(l(""),s(new Set),p(!1),te(!1))},re=x=>{b(D=>{let A=new Set(D);return A.has(x)?A.delete(x):A.add(x),A})},X=L!==null&&L!==""?$e(L):null,ie=ce({storageKey:"gp.changes.left",initial:380,min:220,reserve:200,edge:"end"});return(0,m.createElement)("div",{className:"gp-changes"},[(0,m.createElement)("div",{key:"left",className:"gp-changes__left",style:{flex:`0 0 ${ie.width}px`}},[(0,m.createElement)(It,{key:"stats",stats:n.stats,t:r}),(0,m.createElement)("div",{key:"toolbar",className:"gp-toolbar"},[(0,m.createElement)("button",{key:"sa",type:"button",className:"gp-btn",disabled:f||n.changes.length===0,onClick:()=>void B({kind:"stage-all"})},r("changes.stageAll")),(0,m.createElement)("button",{key:"ua",type:"button",className:"gp-btn",disabled:f||n.staged===0,onClick:()=>void B({kind:"unstage-all"})},r("changes.unstageAll"))]),y!==null?(0,m.createElement)("div",{key:"err",className:"gp-feedback"},y):null,(0,m.createElement)("div",{key:"list",className:"gp-changes__list"},n.changes.length===0?(0,m.createElement)("div",{className:"gp-empty"},r("changes.noChanges")):G.map(x=>(0,m.createElement)("div",{key:x.key},[(0,m.createElement)("div",{key:"head",className:"gp-group-head",onClick:()=>re(x.key)},[(0,m.createElement)(de,{key:"chev",size:12,open:!g.has(x.key)}),`${r(x.labelKey)} (${x.items.length})`]),g.has(x.key)?null:x.items.map(D=>{let A=D.path+(D.staged?":s":":w");return $n(D,{selected:a.has(A),active:w?.path===D.path&&w.base===(D.staged?"staged":"worktree"),busy:f,armed:E===A,onToggle:()=>K(A),onOpen:()=>void T(D.path,D.staged?"staged":"worktree"),onStage:()=>void B(D.staged?{kind:"unstage",paths:[D.path]}:{kind:"stage",paths:[D.path]}),onDiscard:()=>{E===A?(B({kind:"discard",paths:[D.path]}),P(null)):P(A)},t:r})})]))),(0,m.createElement)("div",{key:"box",className:"gp-commitbox"},[(0,m.createElement)("textarea",{key:"msg",className:"gp-commitbox__msg",placeholder:r("commit.placeholder"),value:o,onChange:x=>l(x.target.value)}),(0,m.createElement)("div",{key:"row",className:"gp-commitbox__row"},[(0,m.createElement)("label",{key:"amend",className:"gp-commitbox__amend"},[(0,m.createElement)("input",{key:"cb",type:"checkbox",className:"gp-check",checked:c,onChange:()=>{p(x=>!x),te(!1)}}),r("commit.amend")]),(0,m.createElement)("div",{key:"actions",className:"gp-commitbox__actions"},[(0,m.createElement)("button",{key:"commit",type:"button",className:"gp-btn gp-btn--primary",disabled:f||o.trim()==="",onClick:()=>void J()},r("commit.commit"))])])])]),ie.divider,(0,m.createElement)("div",{key:"right",className:"gp-changes__right"},w===null?(0,m.createElement)("div",{className:"gp-empty"},r("changes.selectFile")):(0,m.createElement)("div",{className:"gp-diff"},[(0,m.createElement)("div",{key:"tb",className:"gp-diff__toolbar"},[(0,m.createElement)("span",{key:"path",className:"gp-diff__path"},w.path),X?(0,m.createElement)("span",{key:"sum",className:"gp-stats__item",style:{marginLeft:"auto"}},[(0,m.createElement)("span",{key:"a",className:"gp-stats__add"},`+${X.add}`)," ",(0,m.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${X.del}`)]):null,(0,m.createElement)("button",{key:"expand",type:"button",className:`gp-seg__btn gp-diff__expand${R?" gp-seg__btn--active":""}`,style:X?{}:{marginLeft:"auto"},disabled:C!=="split"&&C!=="unified",title:r(R?"diff.collapse":"diff.expandAll"),onClick:()=>void T(w.path,w.base,!R)},r(R?"diff.collapse":"diff.expandAll")),(0,m.createElement)("div",{key:"seg",className:"gp-seg"},["unified","split","before","after"].map(x=>(0,m.createElement)("button",{key:x,type:"button",className:`gp-seg__btn${C===x?" gp-seg__btn--active":""}`,onClick:()=>N(x)},r(`diff.${x}`))))]),(0,m.createElement)("div",{key:"scroll",className:"gp-diff__scroll"},L===null?(0,m.createElement)("div",{className:"gp-empty"},r("common.loading")):(0,m.createElement)(ze,{text:L,mode:C,path:w.path,remote:e,sessionId:t,imageSpec:{base:w.base},t:r}))]))])}function Ze(e,t){return e.path.localeCompare(t.path)}function $n(e,t){let n=e.path.split("/").pop()??e.path,i=e.path.includes("/")?e.path.slice(0,e.path.lastIndexOf("/")):"";return(0,m.createElement)("div",{key:e.path+(e.staged?":s":":w"),className:`gp-file-row${t.active?" gp-file-row--active":""}`,onClick:t.onOpen},[(0,m.createElement)("input",{key:"cb",type:"checkbox",className:"gp-check",checked:t.selected,onClick:r=>r.stopPropagation(),onChange:t.onToggle}),(0,m.createElement)("span",{key:"st",className:`gp-status-badge ${Me(e.status)}`},De[e.status]??"?"),(0,m.createElement)("span",{key:"nm",className:"gp-tree-name",title:e.path},[n,i?(0,m.createElement)("span",{key:"d",style:{color:"var(--dsw-alias-label-tertiary)",marginLeft:6,fontSize:11}},i):null]),(0,m.createElement)("span",{key:"act",className:"gp-file-row__actions"},[(0,m.createElement)("button",{key:"stg",type:"button",className:"gp-icon-btn",title:e.staged?t.t("changes.unstage"):t.t("changes.stage"),disabled:t.busy,onClick:r=>{r.stopPropagation(),t.onStage()}},e.staged?"\u2212":"+"),(0,m.createElement)("button",{key:"dis",type:"button",className:"gp-icon-btn",title:t.armed?t.t("changes.discardConfirm"):t.t("changes.discard"),style:t.armed?{color:"var(--dsw-alias-state-error-primary)"}:{},disabled:t.busy,onClick:r=>{r.stopPropagation(),t.onDiscard()}},"\u21BA")])])}var v=require("react");var ee=require("@deepseek-ai/dsh-client-ui-primitives");function Xt(e){return/\.(?:md|markdown)$/i.test(e)}function et({remote:e,sessionId:t,t:n}){let[i,r]=(0,v.useState)(new Map),[a,s]=(0,v.useState)(new Set([""])),[o,l]=(0,v.useState)(null),[c,p]=(0,v.useState)({kind:"idle"}),[f,h]=(0,v.useState)(!1),[y,u]=(0,v.useState)("idle"),g=(0,v.useMemo)(()=>({code:{copyLabel:n("files.copy"),copiedLabel:n("files.copied")},footnotes:n("files.footnotes")}),[n]),b=(0,v.useRef)(0),E=ce({storageKey:"gp.files.left",initial:300,min:180,reserve:220,edge:"end"}),P=(0,v.useCallback)(C=>{r(N=>{let R=N.get(C);if(R!==void 0&&R.status!=="error")return N;let H=new Map(N);return H.set(C,{status:"loading"}),H}),e.query({sessionId:t,query:{kind:"dir-list",path:C}}).then(N=>{let R=q(N,"dir-list");r(H=>{let j=new Map(H);return j.set(C,R===null?{status:"error"}:{status:"ready",entries:R.entries,truncated:R.truncated}),j})}).catch(()=>{r(N=>{let R=new Map(N);return R.set(C,{status:"error"}),R})})},[e,t]);(0,v.useEffect)(()=>{P("")},[P]);let w=(0,v.useCallback)(C=>{s(N=>{let R=new Set(N);return R.has(C)?(R.delete(C),R):(R.add(C),i.get(C)===void 0&&P(C),R)})},[i,P]),$=(0,v.useCallback)(C=>{l(C),h(!1),u("idle");let N=++b.current;p({kind:"loading",path:C}),e.query({sessionId:t,query:{kind:"file-content",path:C}}).then(R=>{if(N!==b.current)return;let H=q(R,"file-content");if(H===null){p({kind:"error",path:C});return}if(H.tooLarge===!0){p({kind:"tooLarge",path:C});return}if(H.variant==="image"&&H.dataUrl!==void 0){p({kind:"image",path:C,dataUrl:H.dataUrl});return}if(H.variant==="text"){p({kind:"text",path:C,content:H.content??"",lines:H.lines??0});return}p({kind:"binary",path:C})}).catch(()=>{N===b.current&&p({kind:"error",path:C})})},[e,t]),L=(0,v.useMemo)(()=>qt("",0,{dirs:i,open:a,selected:o,toggleDir:w,selectFile:$,t:n}),[i,a,o,w,$,n]),V=async()=>{if(o===null)return;let C=b.current;try{await navigator.clipboard.writeText(o),C===b.current&&u("copied")}catch{C===b.current&&u("error")}};return(0,v.createElement)("div",{className:"gp-files"},[(0,v.createElement)("div",{key:"left",className:"gp-files__tree",style:{flex:`0 0 ${E.width}px`}},L),E.divider,(0,v.createElement)("div",{key:"right",className:"gp-files__preview"},[o!==null?(0,v.createElement)("div",{key:"bar",className:"gp-files__bar"},[(0,v.createElement)("code",{key:"path",className:"gp-files__path",title:o},o),c.kind==="text"&&Xt(c.path)?(0,v.createElement)("div",{key:"mode",className:"gp-files__mode",role:"group","aria-label":n("files.previewMode")},[(0,v.createElement)("button",{key:"source",type:"button",className:`gp-files__mode-btn${f?"":" gp-files__mode-btn--active"}`,"aria-pressed":!f,onClick:()=>h(!1)},n("files.source")),(0,v.createElement)("button",{key:"render",type:"button",className:`gp-files__mode-btn${f?" gp-files__mode-btn--active":""}`,"aria-pressed":f,onClick:()=>h(!0)},n("files.render"))]):null,(0,v.createElement)("button",{key:"copy",type:"button",className:`gp-files__copy-path${y==="error"?" gp-files__copy-path--error":""}`,"aria-live":"polite",onClick:()=>{V()}},n(y==="copied"?"files.pathCopied":y==="error"?"files.pathCopyFailed":"files.copyPath"))]):null,(0,v.createElement)("div",{key:"content",className:"gp-files__preview-content"},c.kind==="text"&&f&&Xt(c.path)?(0,v.createElement)("div",{className:"gp-files__markdown"},(0,v.createElement)(ee.MarkdownText,{text:c.content,labels:g,variant:"body"})):Hn(c,n))])])}function qt(e,t,n){let i=n.dirs.get(e);if(i===void 0||i.status==="loading")return t===0?[(0,v.createElement)("div",{key:"l",className:"gp-empty"},n.t("common.loading"))]:[(0,v.createElement)("div",{key:`l${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},n.t("common.loading"))];if(i.status==="error")return[(0,v.createElement)("div",{key:`e${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},n.t("files.loadFailed"))];let r=[];for(let a of i.entries){let s=e===""?a.name:`${e}/${a.name}`;if(a.dir){let o=n.open.has(s);r.push((0,v.createElement)("button",{key:s,type:"button",className:`gp-tree-row gp-files__entry gp-files__entry--dir${a.ignored?" gp-tree-row--ignored":""}`,style:{paddingLeft:10+t*14},"aria-expanded":o,"aria-label":a.ignored?`${a.name} (${n.t("files.ignored")})`:a.name,onClick:()=>n.toggleDir(s)},[(0,v.createElement)("span",{key:"c",className:"gp-tree-chev"},(0,v.createElement)(de,{size:11,open:o})),(0,v.createElement)("span",{key:"i",className:"gp-tree-ic"},(0,v.createElement)(ee.FileTypeIcon,{kind:"folder",size:18})),(0,v.createElement)("span",{key:"n",className:"gp-tree-name"},a.name)])),o&&r.push(...qt(s,t+1,n))}else{let o=n.selected===s;r.push((0,v.createElement)("button",{key:s,type:"button",className:`gp-tree-row gp-files__entry${o?" gp-tree-row--active":""}${a.ignored?" gp-tree-row--ignored":""}`,style:{paddingLeft:10+t*14},"aria-current":o?"true":void 0,"aria-label":a.ignored?`${a.name} (${n.t("files.ignored")})`:a.name,onClick:()=>n.selectFile(s)},[(0,v.createElement)("span",{key:"c",className:"gp-tree-chev"}),(0,v.createElement)("span",{key:"i",className:"gp-tree-ic"},(0,v.createElement)(ee.FileTypeIcon,{path:s,size:18})),(0,v.createElement)("span",{key:"n",className:"gp-tree-name"},a.name)]))}}return i.truncated&&r.push((0,v.createElement)("div",{key:`t${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},n.t("files.truncated"))),r}function Hn(e,t){switch(e.kind){case"idle":return(0,v.createElement)("div",{className:"gp-empty"},t("files.selectFile"));case"loading":return(0,v.createElement)("div",{className:"gp-empty"},t("common.loading"));case"error":return(0,v.createElement)("div",{className:"gp-empty"},t("files.loadFailed"));case"tooLarge":return(0,v.createElement)("div",{className:"gp-empty"},t("files.tooLarge"));case"binary":return(0,v.createElement)("div",{className:"gp-empty"},t("files.binary"));case"image":return(0,v.createElement)("div",{className:"gp-files__image"},(0,v.createElement)("img",{src:e.dataUrl,alt:e.path}));case"text":return(0,v.createElement)("div",{className:"gp-files__code gp-diff__scroll"},(0,v.createElement)(In,{content:e.content,path:e.path}))}}function In({content:e,path:t}){let n=(0,ee.languageForPath)(t),i=(0,ee.useCodeHighlighter)(n),r=(0,v.useMemo)(()=>{let s=e.split(`
|
|
307
|
-
`);return s.length>0&&s[s.length-1]===""&&s.pop(),s},[e]),a=(0,
|
|
308
|
-
`)),[i,r]);return(0,v.createElement)("div",{className:"gp-files__single"},r.flatMap((s,o)=>[(0,v.createElement)("div",{key:`n${o}`,className:"gp-diff-no"},o+1),(0,v.createElement)("div",{key:`c${o}`,className:"gp-diff-cell"},s===""?"\xA0":a?.[o]!==void 0?a[o].map((l,c)=>(0,v.createElement)("span",{key:c,style:l.style},l.text)):s)]))}var Kt="gp.panel.fontDelta";function Vn(){if(typeof localStorage>"u")return 0;let e=Number(localStorage.getItem(Kt));return e===-1||e===1?e:0}function Jt({ctx:e,sessionId:t,t:n}){let[i,r]=(0,k.useState)(Vn),[a,s]=(0,k.useState)(null),o=Re(t),l=we(e),c=o.state==="error"&&o.error.code==="not-a-git-repo",p=c?"files":a!==null&&a.sessionId===t?a.tab:null,f=(0,k.useRef)({tabs:new Set});f.current.sessionId!==t&&(f.current={sessionId:t,tabs:new Set}),p!==null&&f.current.tabs.add(p);let h=f.current.tabs.has("files");(0,k.useEffect)(()=>{if(!ae(t))return;if(c){s(null);return}if(a?.sessionId===t)return;let w=ft(t);if(w!==null){s({sessionId:t,tab:w});return}o.state==="ready"&&s({sessionId:t,tab:o.snapshot.dirty?"changes":"overview"})},[t,o,c,a?.sessionId]),(0,k.useEffect)(()=>{if(ae(t))return gt(t,w=>s({sessionId:t,tab:w}))},[t]);let y=o.state==="ready"?o.snapshot.checkedAt:0,u=async w=>{if(!ae(t))return{ok:!1,error:n("error.noCwd")};let $=await l.run({sessionId:t,action:w});return $.ok?(Je(t).accept($.snapshot),{ok:!0}):{ok:!1,error:Xn($.error.code,$.error.message,n)}},g=w=>{r(w),typeof localStorage<"u"&&localStorage.setItem(Kt,String(w))},b=[{key:"overview",label:n("tab.overview"),icon:(0,k.createElement)(Te,{size:14})},{key:"changes",label:n("tab.changes"),icon:(0,k.createElement)(mt,{size:14})},{key:"files",label:n("tab.files"),icon:(0,k.createElement)(vt,{size:14})}],E=c?b.filter(w=>w.key==="files"):b,P=(()=>{if(!ae(t))return(0,k.createElement)("div",{className:"gp-empty"},n("error.noCwd"));if(o.state==="no-cwd")return(0,k.createElement)("div",{className:"gp-empty"},n("error.noCwd"));if(c)return(0,k.createElement)("div",{style:{display:"contents"}},h?(0,k.createElement)(et,{key:t,remote:l,sessionId:t,t:n}):null);if(o.state==="error")return(0,k.createElement)("div",{className:"gp-empty"},n("pill.unavailable"));if(o.state==="cold"||o.state==="loading"||p===null)return(0,k.createElement)("div",{className:"gp-empty"},n("common.loading"));let w=o.snapshot;return(0,k.createElement)("div",{style:{display:"contents"}},[f.current.tabs.has("overview")?(0,k.createElement)("div",{key:"overview",style:p==="overview"?{display:"contents"}:{display:"none"}},(0,k.createElement)(Ht,{key:t,remote:l,sessionId:t,refreshKey:y,defaultDiffView:w.defaultDiffView,t:n})):null,f.current.tabs.has("changes")?(0,k.createElement)("div",{key:"changes",style:p==="changes"?{display:"contents"}:{display:"none"}},(0,k.createElement)(Vt,{key:t,remote:l,sessionId:t,snapshot:w,onAction:u,t:n})):null,h?(0,k.createElement)("div",{key:"files",style:p==="files"?{display:"contents"}:{display:"none"}},(0,k.createElement)(et,{key:t,remote:l,sessionId:t,t:n})):null])})();return(0,k.createElement)("div",{className:"gp-panel","data-conversation-composer-overlay":"","data-font-delta":i},[(0,k.createElement)("div",{key:"tabs",className:"gp-tabbar",role:"tablist"},[...E.map(w=>(0,k.createElement)("button",{key:w.key,type:"button",role:"tab","aria-selected":p===w.key,className:`gp-tab${p===w.key?" gp-tab--active":""}`,onClick:()=>{ae(t)&&s({sessionId:t,tab:w.key})}},[(0,k.createElement)("span",{key:"i",className:"gp-tab__icon"},w.icon),w.label])),(0,k.createElement)("div",{key:"font",className:"gp-font"},[(0,k.createElement)("button",{key:"dec",type:"button",className:"gp-font__decrease",onClick:()=>g(-1),"aria-label":n("panel.fontDecrease")},"A\u2212"),(0,k.createElement)("button",{key:"reset",type:"button",className:"gp-font__reset",onClick:()=>g(0),"aria-label":n("panel.fontReset")},"A"),(0,k.createElement)("button",{key:"inc",type:"button",className:"gp-font__increase",onClick:()=>g(1),"aria-label":n("panel.fontIncrease")},"A+")]),(0,k.createElement)(qn,{key:"ver",remote:l,t:n})]),(0,k.createElement)("div",{key:"body",className:"gp-body"},P)])}function Xn(e,t,n){switch(e){case"empty-message":return n("error.emptyMessage");case"not-a-git-repo":return n("error.notARepo");case"cwd-unavailable":return n("error.noCwd");case"local-changes-block":return n("error.localChangesBlock");default:return t??n("error.generic")}}function qn({remote:e,t}){let[n,i]=(0,k.useState)({kind:"idle"});(0,k.useEffect)(()=>{let o=!0;return e.version({}).then(l=>{o&&"current"in l&&i(c=>({...c,info:l}))}),()=>{o=!1}},[e]);let r=async()=>{i(l=>({kind:"checking",info:l.info}));let o=await e.version({check:!0});i({kind:"idle",info:"current"in o?o:void 0})},a=n.info,s=n.kind==="checking"?(0,k.createElement)("span",{className:"gp-verbar__status"},t("version.checking")):a===void 0||!a.checkedRemote?null:a.error!==void 0?(0,k.createElement)("span",{className:"gp-verbar__status gp-verbar__status--err",title:a.error},a.error==="repository is not configured"?t("version.noRepo"):t("version.error")):a.updateAvailable&&a.latest!==void 0?(0,k.createElement)("span",{},[(0,k.createElement)("span",{key:"s",className:"gp-verbar__status gp-verbar__status--new"},t("version.updateAvailable",{latest:a.latest,current:a.current})),a.releaseUrl!==void 0?(0,k.createElement)("a",{key:"l",className:"gp-verbar__link",href:a.releaseUrl,target:"_blank",rel:"noreferrer",style:{marginLeft:8}},t("version.viewRelease")):null]):(0,k.createElement)("span",{className:"gp-verbar__status gp-verbar__status--ok"},t("version.upToDate",{current:a.current}));return(0,k.createElement)("div",{className:"gp-verbar"},[a!==void 0?(0,k.createElement)("span",{key:"tag",className:"gp-verbar__tag"},`v${a.current}`):null,s,(0,k.createElement)("button",{key:"btn",type:"button",className:"gp-verbar__btn",disabled:n.kind==="checking",onClick:()=>void r()},[(0,k.createElement)("span",{key:"i",className:"gp-tab__icon"},(0,k.createElement)(Ee,{size:12})),t("version.check")]),a?.repositoryUrl!==void 0?(0,k.createElement)("a",{key:"gh",className:"gp-icon-btn gp-verbar__gh",href:a.repositoryUrl,target:"_blank",rel:"noreferrer",title:t("version.openRepo"),"aria-label":t("version.openRepo")},(0,k.createElement)(wt,{size:15})):null])}var z=require("react"),Qt=require("react-dom");var Wt="data-gp-tab-dot",ve,tt=null,Bt="",_e=null,pe;function Kn(e){if(typeof document>"u")return null;let t=document.querySelectorAll(Be);for(let n of t)if((n.textContent??"").trim()===e)return n;return null}function Ie(){let e=Kn(Bt);if(e===null)return;let t=e.querySelector(`[${Wt}]`);if(_e===null){t?.remove();return}let n=`gp-tab-dot gp-tab-dot--${_e}`;if(t!==null){t.className!==n&&(t.className=n);return}let i=document.createElement("span");i.className=n,i.setAttribute(Wt,""),i.setAttribute("aria-hidden","true"),e.appendChild(i)}function Jn(){if(typeof document>"u"||typeof MutationObserver>"u")return;let e=document.querySelector(ct);if(e!==tt){if(ve?.disconnect(),tt=e,e===null){ve=void 0;return}ve=new MutationObserver(()=>Ie()),ve.observe(e,{childList:!0,subtree:!0})}}function Ot(){ve?.disconnect(),ve=void 0,tt=null}function jt(e,t,n){if(!(typeof document>"u")){if(n===null){if(pe!==void 0&&pe!==e)return;pe=void 0,_e=null,Ie(),Ot();return}pe=e,Bt=t,_e=n,Jn(),Ie()}}function Ut(e){pe!==void 0&&pe!==e||(pe=void 0,_e=null,Ie(),Ot())}function Wn(e){let t=e.replace(/[/\\]+$/,"").split(/[/\\]/);return t[t.length-1]||e}function Bn(){let[e,t]=(0,z.useState)(!1),[n,i]=(0,z.useState)(null),r=(0,z.useRef)(null);return(0,z.useLayoutEffect)(()=>{if(!e||r.current===null){i(null);return}let o=r.current.getBoundingClientRect();i({left:o.left,bottom:window.innerHeight-o.top+8})},[e]),{bind:{ref:o=>{r.current=o},onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1)},render:o=>!e||n===null||typeof document>"u"?null:(0,Qt.createPortal)((0,z.createElement)("div",{className:"gp-tip",style:{left:n.left,bottom:n.bottom}},o.map((l,c)=>(0,z.createElement)("div",{key:c,className:c===0?"gp-tip__path":"gp-tip__note"},l))),document.body)}}function On(e){let[t,n]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if(e===null||typeof ResizeObserver>"u")return;let r=e.closest("[data-conversation-region]")??document.body,a=()=>n(r.clientWidth>0&&r.clientWidth<jn);a();let s=new ResizeObserver(a);return s.observe(r),()=>s.disconnect()},[e]),t}var jn=620;function Yt({sessionId:e,t}){let n=Re(e),i=Bn(),[r,a]=(0,z.useState)(null),s=On(r),o=(0,z.useRef)(Symbol("gp-tab-dot")),l=n.state==="ready"&&n.snapshot.showInputPill===!1?n.snapshot.dirty?"dirty":"synced":null,c=t("panel.tab");if((0,z.useEffect)(()=>{jt(o.current,c,l);let b=o.current;return()=>{Ut(b)}},[c,l]),n.state==="cold"||n.state==="loading"||n.state==="no-cwd")return null;if(n.state==="error")return n.error.code==="not-a-git-repo"||n.error.showInputPill===!1?null:(0,z.createElement)("span",{className:"gp-pill gp-pill--degraded",title:n.error.detail??t("pill.unavailable")},t("pill.unavailable"));let p=n.snapshot;if(p.showInputPill===!1)return null;let f=Wn(p.root),h=p.branch??`(${t("pill.detached")})`,y=p.dirty,u=y?"gp-pill--dirty":"gp-pill--synced",g=()=>{ae(e)&&pt(e,y?"changes":"overview"),ut(t("panel.tab"))};return(0,z.createElement)("span",{className:"gp-pill-wrap",ref:a},[(0,z.createElement)("button",{key:"btn",type:"button",className:`gp-pill ${u}${s?" gp-pill--compact":""}`,onClick:g,ref:i.bind.ref,onMouseEnter:i.bind.onMouseEnter,onMouseLeave:i.bind.onMouseLeave},[(0,z.createElement)("span",{key:"dot",className:"gp-pill__dot","aria-hidden":"true"}),(0,z.createElement)("span",{key:"repo",className:"gp-pill__repo"},f),(0,z.createElement)("span",{key:"git",className:"gp-pill__git"},["(",(0,z.createElement)("span",{key:"b",className:"gp-pill__branch"},h),")"])]),i.render([p.root,t(y?"pill.dirty":"pill.synced")])])}var F=require("react");function Un(e){for(let t of e){let n=t.schema?.dict;if(n!==void 0&&"showInputPill"in n||JSON.stringify(t.schema).includes("showInputPill"))return t.ns}}function Zt({ctx:e,t}){let[,n]=(0,F.useState)(0),[i,r]=(0,F.useState)(!1),[a,s]=(0,F.useState)(!1),[o,l]=(0,F.useState)(null),[c,p]=(0,F.useState)(null),f=()=>{n(N=>N+1)},h=e.get("configForms"),y=(0,F.useMemo)(()=>h?.describe(),[h]);(0,F.useEffect)(()=>{if(y!==void 0)return y.ensure(),y.subscribe(f)},[y]);let u=y?.getSnapshot().view,g=(0,F.useMemo)(()=>u===void 0?void 0:Un(u.namespaces),[u]),b=(0,F.useMemo)(()=>h!==void 0&&g!==void 0?h.get(g):void 0,[h,g]);(0,F.useEffect)(()=>{if(b!==void 0)return b.subscribe(f)},[b]);let E=b?.getSnapshot(),P=b!==void 0&&E!==void 0&&E.status==="ready",w=y?.getSnapshot().status,$=o??(typeof E?.value?.showInputPill=="boolean"?E.value.showInputPill:!0),L=c??(E?.value?.defaultDiffView==="split"?"split":"unified"),V=async N=>{if(b!==void 0){l(N),s(!1),r(!0);try{let R=await b.set("showInputPill",N);l(null),R?(le(),setTimeout(()=>le(),1e3)):s(!0)}catch{l(null),s(!0)}finally{r(!1)}}},C=async N=>{if(!(b===void 0||N===L)){p(N),s(!1),r(!0);try{let R=await b.set("defaultDiffView",N);p(null),R?(le(),setTimeout(()=>le(),1e3)):s(!0)}catch{p(null),s(!0)}finally{r(!1)}}};return h===void 0?(0,F.createElement)("p",{className:"gp-cfg__hint"},t("cfg.notLoaded")):P?(0,F.createElement)("div",{className:"gp-cfg"},[(0,F.createElement)("h3",{key:"title",className:"gp-cfg__title"},t("cfg.title")),(0,F.createElement)("label",{key:"row",className:"gp-cfg__row"},[(0,F.createElement)("input",{key:"switch",type:"checkbox",role:"switch",className:"gp-cfg__switch",checked:$,disabled:i||E?.writable===!1,onChange:N=>{V(N.currentTarget.checked)}}),(0,F.createElement)("span",{key:"text",className:"gp-cfg__text"},t("cfg.toggle"))]),(0,F.createElement)("p",{key:"hint",className:"gp-cfg__hint"},t("cfg.hint")),(0,F.createElement)("h3",{key:"difftitle",className:"gp-cfg__title",style:{marginTop:6}},t("cfg.diffTitle")),(0,F.createElement)("div",{key:"diffseg",className:"gp-seg gp-cfg__seg"},["unified","split"].map(N=>(0,F.createElement)("button",{key:N,type:"button",className:`gp-seg__btn${L===N?" gp-seg__btn--active":""}`,disabled:i||E?.writable===!1,onClick:()=>{C(N)}},t(N==="unified"?"cfg.diffUnified":"cfg.diffSplit")))),(0,F.createElement)("p",{key:"diffhint",className:"gp-cfg__hint"},t("cfg.diffHint")),a?(0,F.createElement)("p",{key:"error",className:"gp-cfg__err",role:"alert"},t("cfg.saveFailed")):null]):w==="idle"||w==="loading"?(0,F.createElement)("p",{className:"gp-cfg__hint"},t("common.loading")):(0,F.createElement)("p",{className:"gp-cfg__hint"},t("cfg.notLoaded"))}var Se="gitPanel",Qn=["dsh-git-panel","@xbzbing/dsh-git-panel"],Yn=["slots","locale","connection"],Zn="dsh-git-panel";function er(e){rt(),lt(e),e.effect(()=>e.locale.register(Se,{zh:it,en:at})??void 0,"dsh-git-panel: dictionaries");let t=e.locale.bind(Se),n=[],i=r=>{typeof r=="function"&&n.push(r)};i(e.slots.inject("conversation.view",()=>e.slots.register({name:"conversation.view",id:"git-panel",order:30,locale:Se,label:()=>t("panel.tab")},r=>(0,Ve.createElement)(Jt,{ctx:e,sessionId:r.sessionId,t})))),i(e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"git-panel-pill",order:100,locale:Se},r=>(0,Ve.createElement)(Yt,{sessionId:r.sessionId,t}))));for(let r of Qn)i(e.slots.inject("plugins.bundle.config",()=>e.slots.register({name:"plugins.bundle.config",key:r,locale:Se},a=>a.view==="summary"?t("cfg.title"):(0,Ve.createElement)(Zt,{ctx:e,t}))));e.effect(()=>{let r=e.on("connection/reset",()=>le());return()=>{typeof r=="function"&&r();for(let a of n.splice(0))try{a()}catch{}dt()}},"dsh-git-panel: lifecycle")}module.exports={name:Zn,inject:Yn,apply:er};
|
|
303
|
+
`,qe=!1;function ot(){if(qe||typeof document>"u")return;let e="dsh-git-panel/client.css";if(document.querySelector(`style[data-plugin-css="${e}"]`)!==null){qe=!0;return}let t=document.createElement("style");t.dataset.plugin="@xbzbing/dsh-git-panel",t.dataset.pluginCss=e,t.textContent=nr,document.head.appendChild(t),qe=!0}var st={"panel.tab":"Git","panel.fontDecrease":"\u7F29\u5C0F\u5B57\u4F53","panel.fontReset":"\u91CD\u7F6E\u5B57\u4F53\u5927\u5C0F","panel.fontIncrease":"\u653E\u5927\u5B57\u4F53","tab.overview":"Git \u603B\u89C8","tab.changes":"\u53D8\u66F4\u8BB0\u5F55","tab.files":"\u6587\u4EF6\u6D4F\u89C8","pill.unavailable":"Git \u4E0D\u53EF\u7528","pill.detached":"\u6E38\u79BB HEAD","pill.synced":"\u672C\u5730\u5DF2\u540C\u6B65","pill.dirty":"\u6709\u5F85\u63D0\u4EA4\u7684\u53D8\u66F4","common.loading":"\u52A0\u8F7D\u4E2D\u2026","common.retry":"\u91CD\u8BD5","common.close":"\u5173\u95ED","version.check":"\u68C0\u67E5\u65B0\u7248\u672C","version.checking":"\u68C0\u67E5\u4E2D\u2026","version.upToDate":"\u5DF2\u662F\u6700\u65B0\uFF08{current}\uFF09","version.updateAvailable":"\u6709\u65B0\u7248\u672C {latest}\uFF08\u5F53\u524D {current}\uFF09","version.viewRelease":"\u67E5\u770B\u53D1\u5E03","version.error":"\u68C0\u67E5\u5931\u8D25","version.noRepo":"\u672A\u914D\u7F6E\u4ED3\u5E93\u5730\u5740","version.openRepo":"\u5728 GitHub \u4E0A\u6253\u5F00\u4ED3\u5E93","overview.head":"HEAD\uFF08\u5F53\u524D\u5206\u652F\uFF09","overview.local":"\u672C\u5730","overview.remote":"\u8FDC\u7A0B","overview.tags":"\u6807\u7B7E","overview.search":"\u641C\u7D22\u63D0\u4EA4\uFF08\u6D88\u606F / \u54C8\u5E0C\uFF09","overview.allUsers":"\u5168\u90E8\u4F5C\u8005","overview.allTime":"\u5168\u90E8\u65F6\u95F4","overview.today":"\u4ECA\u5929","overview.last7d":"\u8FD1 7 \u5929","overview.last30d":"\u8FD1 30 \u5929","overview.selectCommit":"\u9009\u62E9\u4E00\u4E2A\u63D0\u4EA4\u67E5\u770B\u8BE6\u60C5","overview.noMessage":"\uFF08\u65E0\u63D0\u4EA4\u6B63\u6587\uFF09","overview.noResults":"\u6CA1\u6709\u5339\u914D\u7684\u63D0\u4EA4","overview.loadFailed":"\u52A0\u8F7D\u5931\u8D25","overview.detailFailed":"\u8BE6\u60C5\u52A0\u8F7D\u5931\u8D25","overview.diffFailed":"\u5DEE\u5F02\u52A0\u8F7D\u5931\u8D25","overview.openFileDiff":"\u67E5\u770B\u8BE5\u6587\u4EF6\u5728\u6B64\u63D0\u4EA4\u4E2D\u7684\u53D8\u66F4","overview.fetch":"\u62C9\u53D6\u8FDC\u7A0B","overview.branchesError":"\u5206\u652F\u52A0\u8F7D\u5931\u8D25","changes.groupStaged":"\u5DF2\u6682\u5B58\u7684\u66F4\u6539","changes.groupUnstaged":"\u66F4\u6539","changes.groupUntracked":"\u672A\u7248\u672C\u63A7\u5236\u7684\u6587\u4EF6","changes.selectFile":"\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6\u67E5\u770B\u53D8\u66F4","changes.noChanges":"\u6CA1\u6709\u672A\u63D0\u4EA4\u7684\u53D8\u66F4","changes.stageAll":"\u5168\u90E8\u6682\u5B58","changes.unstageAll":"\u5168\u90E8\u53D6\u6D88\u6682\u5B58","changes.stage":"\u6682\u5B58","changes.unstage":"\u53D6\u6D88\u6682\u5B58","changes.discard":"\u653E\u5F03\u66F4\u6539","changes.discardConfirm":"\u518D\u6B21\u70B9\u51FB\u4EE5\u786E\u8BA4\u653E\u5F03","files.selectFile":"\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6\u67E5\u770B\u5185\u5BB9","files.loadFailed":"\u52A0\u8F7D\u5931\u8D25","files.truncated":"\u6761\u76EE\u8FC7\u591A\uFF0C\u5DF2\u622A\u65AD","files.tooLarge":"\u6587\u4EF6\u8FC7\u5927\uFF0C\u65E0\u6CD5\u9884\u89C8","files.binary":"\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\u9884\u89C8","files.previewMode":"Markdown \u9884\u89C8\u65B9\u5F0F","files.source":"\u6E90\u7801","files.render":"\u6E32\u67D3","files.copyPath":"\u590D\u5236\u76F8\u5BF9\u8DEF\u5F84","files.pathCopied":"\u8DEF\u5F84\u5DF2\u590D\u5236","files.pathCopyFailed":"\u590D\u5236\u5931\u8D25","files.ignored":"\u5DF2\u88AB Git \u5FFD\u7565","files.copy":"\u590D\u5236\u4EE3\u7801","files.copied":"\u5DF2\u590D\u5236","files.footnotes":"\u6CE8\u91CA","stats.files":"{n} \u4E2A\u6587\u4EF6","stats.lastChange":"\u6700\u8FD1\u53D8\u66F4 {time}","stats.lastCommit":"\u4E0A\u6B21\u63D0\u4EA4 {time}","stats.staged":"\u5DF2\u6682\u5B58 {n}","stats.modified":"\u5DF2\u4FEE\u6539 {n}","stats.untracked":"\u672A\u8DDF\u8E2A {n}","commit.placeholder":"\u63D0\u4EA4\u4FE1\u606F","commit.commit":"\u63D0\u4EA4","commit.amend":"\u4FEE\u6B63\u4E0A\u6B21\u63D0\u4EA4\uFF08amend\uFF09","diff.unified":"\u7EDF\u4E00","diff.split":"\u5BF9\u7167","diff.before":"\u53D8\u66F4\u524D","diff.after":"\u53D8\u66F4\u540E","diff.binary":"\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\u663E\u793A\u5BF9\u7167","diff.tooLarge":"\u56FE\u7247\u8FC7\u5927\uFF0C\u65E0\u6CD5\u663E\u793A\u5BF9\u7167","diff.imageMissing":"\u4E0D\u5B58\u5728","diff.empty":"\u65E0\u5DEE\u5F02","diff.expandAll":"\u5C55\u5F00\u5168\u90E8","diff.collapse":"\u6298\u53E0\u672A\u53D8\u66F4","diff.expandGap":"\u5C55\u5F00\u5168\u90E8 {n} \u884C","diff.expandUp":"\u5411\u4E0A\u5C55\u5F00 {n} \u884C","diff.expandDown":"\u5411\u4E0B\u5C55\u5F00 {n} \u884C","time.justNow":"\u521A\u521A","time.minutesAgo":"{n} \u5206\u949F\u524D","time.hoursAgo":"{n} \u5C0F\u65F6\u524D","time.daysAgo":"{n} \u5929\u524D","error.generic":"\u64CD\u4F5C\u5931\u8D25","error.notARepo":"\u5F53\u524D\u76EE\u5F55\u4E0D\u662F Git \u4ED3\u5E93","error.noCwd":"\u5F53\u524D\u4F1A\u8BDD\u65E0\u5DE5\u4F5C\u76EE\u5F55","error.localChangesBlock":"\u672C\u5730\u6709\u672A\u63D0\u4EA4\u53D8\u66F4\uFF0C\u65E0\u6CD5\u5207\u6362","error.emptyMessage":"\u63D0\u4EA4\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A","cfg.title":"\u8F93\u5165\u6846\u5206\u652F\u6807\u8BB0","cfg.toggle":"\u663E\u793A\u8F93\u5165\u6846\u6807\u8BB0","cfg.hint":"\u5F00\u542F\u65F6\u5728\u8F93\u5165\u6846\u663E\u793A zsh \u98CE\u683C\u7684 <\u4ED3\u5E93\u540D> (\u5206\u652F) \u6807\u8BB0\uFF1B\u5173\u95ED\u540E\u6539\u4E3A\u5728 Git \u6807\u7B7E\u65C1\u663E\u793A\u72B6\u6001\u5706\u70B9\u3002\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\u3002","cfg.diffTitle":"\u5DEE\u5F02\u5BF9\u6BD4\u9ED8\u8BA4\u89C6\u56FE","cfg.diffHint":"\u9009\u62E9\u53D8\u66F4\u5BF9\u6BD4\u9ED8\u8BA4\u6253\u5F00\u7684\u5E03\u5C40\uFF1A\u7EDF\u4E00\u89C6\u56FE\u4E3A\u5355\u680F\u884C\u5185\u5BF9\u6BD4\uFF0C\u5E76\u6392\u89C6\u56FE\u4E3A\u5DE6\u53F3\u5206\u680F\u5BF9\u6BD4\u3002\u4ECD\u53EF\u5728\u6BCF\u4E2A\u5DEE\u5F02\u89C6\u56FE\u4E2D\u4E34\u65F6\u5207\u6362\u3002\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\u3002","cfg.diffUnified":"\u7EDF\u4E00\u89C6\u56FE\uFF08\u5355\u680F\u884C\u5185\uFF09","cfg.diffSplit":"\u5E76\u6392\u89C6\u56FE\uFF08\u5DE6\u53F3\u5206\u680F\uFF09","cfg.notLoaded":"\u914D\u7F6E\u672A\u52A0\u8F7D\uFF1A\u8BE5\u914D\u7F6E\u7531\u8FD0\u884C\u4E2D\u7684\u5BBF\u4E3B\u63D0\u4F9B\uFF0C\u82E5\u957F\u65F6\u95F4\u7A7A\u767D\u8BF7\u91CD\u542F DSH \u540E\u91CD\u8BD5\u3002","cfg.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"},lt={"panel.tab":"Git","panel.fontDecrease":"Decrease font size","panel.fontReset":"Reset font size","panel.fontIncrease":"Increase font size","tab.overview":"Overview","tab.changes":"Changes","tab.files":"Files","pill.unavailable":"Git unavailable","pill.detached":"detached HEAD","pill.synced":"Everything committed","pill.dirty":"Uncommitted changes","common.loading":"Loading\u2026","common.retry":"Retry","common.close":"Close","version.check":"Check for updates","version.checking":"Checking\u2026","version.upToDate":"Up to date ({current})","version.updateAvailable":"New version {latest} available (current {current})","version.viewRelease":"View release","version.error":"Check failed","version.noRepo":"Repository not configured","version.openRepo":"Open repository on GitHub","overview.head":"HEAD (Current Branch)","overview.local":"Local","overview.remote":"Remote","overview.tags":"Tags","overview.search":"Search commits (message / hash)","overview.allUsers":"All authors","overview.allTime":"All time","overview.today":"Today","overview.last7d":"Last 7 days","overview.last30d":"Last 30 days","overview.selectCommit":"Select a commit to see details","overview.noMessage":"(no commit body)","overview.noResults":"No matching commits","overview.loadFailed":"Load failed","overview.detailFailed":"Failed to load details","overview.diffFailed":"Failed to load diff","overview.openFileDiff":"View this file\u2019s changes in this commit","overview.fetch":"Fetch","overview.branchesError":"Failed to load branches","changes.groupStaged":"Staged changes","changes.groupUnstaged":"Changes","changes.groupUntracked":"Unversioned files","changes.selectFile":"Select a file to see its diff","changes.noChanges":"No uncommitted changes","changes.stageAll":"Stage all","changes.unstageAll":"Unstage all","changes.stage":"Stage","changes.unstage":"Unstage","changes.discard":"Discard changes","changes.discardConfirm":"Click again to confirm discard","files.selectFile":"Select a file to preview","files.loadFailed":"Load failed","files.truncated":"Too many entries \u2014 truncated","files.tooLarge":"File too large to preview","files.binary":"Binary file \u2014 no preview","files.previewMode":"Markdown preview mode","files.source":"Source","files.render":"Rendered","files.copyPath":"Copy relative path","files.pathCopied":"Path copied","files.pathCopyFailed":"Copy failed","files.ignored":"Ignored by Git","files.copy":"Copy code","files.copied":"Copied","files.footnotes":"Footnotes","stats.files":"{n} files","stats.lastChange":"changed {time}","stats.lastCommit":"last commit {time}","stats.staged":"{n} staged","stats.modified":"{n} modified","stats.untracked":"{n} untracked","commit.placeholder":"Commit message","commit.commit":"Commit","commit.amend":"Amend previous commit","diff.unified":"Unified","diff.split":"Split","diff.before":"Before","diff.after":"After","diff.binary":"Binary file \u2014 no diff to show","diff.tooLarge":"Image too large to compare","diff.imageMissing":"Does not exist","diff.empty":"No differences","diff.expandAll":"Expand all","diff.collapse":"Collapse unchanged","diff.expandGap":"Expand all {n} lines","diff.expandUp":"Expand up {n} lines","diff.expandDown":"Expand down {n} lines","time.justNow":"just now","time.minutesAgo":"{n}m ago","time.hoursAgo":"{n}h ago","time.daysAgo":"{n}d ago","error.generic":"Operation failed","error.notARepo":"Not a Git repository","error.noCwd":"This session has no working directory","error.localChangesBlock":"Local changes block the checkout","error.emptyMessage":"Commit message cannot be empty","cfg.title":"Input-bar branch marker","cfg.toggle":"Show input-bar marker","cfg.hint":"When on, the input bar shows the zsh-style <repo> (branch) marker; when off, a status dot appears beside the Git tab instead. Saved changes apply immediately.","cfg.diffTitle":"Default diff view","cfg.diffHint":"Choose the layout diffs open with: unified is a single inline column, split is side-by-side. You can still switch per diff. Saved changes apply immediately.","cfg.diffUnified":"Unified (single inline column)","cfg.diffSplit":"Split (side-by-side)","cfg.notLoaded":"Config not loaded: it is served by the running host. Restart DSH if this stays blank.","cfg.saveFailed":"Save failed, please retry"};var Ge=require("react");var ir=new Set(["cwd-unavailable"]),Je=3e4,ar=6e4,Ce=class{constructor(t,r){this.remote=t;this.sessionId=r}view={state:"cold"};listeners=new Set;timer;inflight;pendingRefresh=!1;disposed=!1;pollMs=Je;subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getSnapshot(){return this.view}ensure(){this.view.state!=="cold"&&this.view.state!=="no-cwd"||this.refresh()}refresh(){return this.inflight!==void 0?(this.pendingRefresh=!0,this.inflight):this.disposed?Promise.resolve():(this.view.state==="cold"&&this.setView({state:"loading"}),this.inflight=this.remote.snapshot({sessionId:this.sessionId}).then(t=>{if(!this.disposed){if(t.ok)this.pollMs=t.value.refreshIntervalMs||Je,this.setView({state:"ready",snapshot:t.value});else if(t.error.code!=="cancelled")if(ir.has(t.error.code))this.pollMs=ar,this.setView({state:"no-cwd"});else if(t.error.code==="not-a-git-repo"){let r=t.error;this.setView({state:"error",error:{code:"not-a-git-repo",...r.cwd?{cwd:r.cwd}:{},...r.showInputPill!==void 0?{showInputPill:r.showInputPill}:{}}})}else this.setView({state:"error",error:{code:t.error.code,..."detail"in t.error?{detail:t.error.detail}:{}}})}}).catch(t=>{this.disposed||this.setView({state:"error",error:{code:"git-unavailable",detail:t instanceof Error?t.message:String(t)}})}).finally(()=>{this.inflight=void 0,this.pendingRefresh&&!this.disposed?(this.pendingRefresh=!1,this.refresh()):this.schedulePoll()}),this.inflight)}resync(){this.disposed||this.refresh()}accept(t){this.disposed||(this.pollMs=t.refreshIntervalMs||Je,this.setView({state:"ready",snapshot:t}),this.schedulePoll())}schedulePoll(){this.disposed||(this.timer!==void 0&&clearTimeout(this.timer),!(this.pollMs<=0)&&(this.timer=setTimeout(()=>{this.refresh()},this.pollMs)))}setView(t){this.view=t;for(let r of this.listeners)r()}dispose(){this.disposed=!0,this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.listeners.clear()}};var or="/api",sr="gitPanel";function lr(e){try{let t=e.get("connection")?.rpc,r=t?.call;if(t!==void 0&&typeof r=="function")return(i,n,a)=>r.call(t,or,i,n,a)}catch{}}function dr(e){let t=e;if(t===null||typeof t!="object")return{ok:!1,error:{code:"git-unavailable",message:"malformed rpc result"}};if(t.ok!==!0){let r=t.error;return{ok:!1,error:{code:typeof r?.code=="string"?r.code:"git-unavailable",message:typeof r?.message=="string"?r.message:void 0}}}return t.value===void 0?{ok:!1,error:{code:"git-unavailable",message:"missing value"}}:t.value}function I(e,t){return!e.ok||e.value.kind!==t?null:e.value}function ae(e){return e!==void 0&&e!==""}var dt=new WeakMap;function we(e){let t=dt.get(e);if(t!==void 0)return t;let r=async(n,a,s)=>{let o=lr(e);if(o===void 0)return{ok:!1,error:{code:"git-unavailable",message:"no connection"}};try{let l=await o(`${sr}/${n}`,{args:{request:a}},s);return dr(l)}catch(l){return{ok:!1,error:{code:"git-unavailable",message:l instanceof Error?l.message:String(l)}}}},i={snapshot:(n,a)=>r("snapshot",n,a),run:(n,a)=>r("run",n,a),query:(n,a)=>r("query",n,a),version:(n,a)=>r("version",n,a)};return dt.set(e,i),i}var se=new Map,ct,Ke;function pt(e){Ke=e,ct=we(e)}function Be(e){let t=se.get(e);if(t===void 0){let r=ct??(Ke?we(Ke):void 0);t=new Ce(r??gr(),e),se.set(e,t)}return t}var cr=6e4,Ne=new Map;function pr(e){let t=Ne.get(e);t!==void 0&&(clearTimeout(t),Ne.delete(e)),fe.set(e,(fe.get(e)??0)+1)}function fr(e){let t=(fe.get(e)??1)-1;if(t>0){fe.set(e,t);return}fe.delete(e);let r=setTimeout(()=>{Ne.delete(e),!((fe.get(e)??0)>0)&&(se.get(e)?.dispose(),se.delete(e))},cr);Ne.set(e,r)}var fe=new Map;function xe(){for(let e of se.values())e.resync()}function ft(){for(let e of se.values())e.dispose();se.clear()}function gr(){let e=async()=>({ok:!1,error:{code:"git-unavailable"}});return{snapshot:e,run:e,query:e,version:e}}function Te(e){let[,t]=(0,Ge.useState)(0),r=e?Be(e):void 0;return(0,Ge.useEffect)(()=>{if(r===void 0||e===void 0)return;pr(e);let i=r.subscribe(()=>t(n=>n+1));return r.ensure(),()=>{i(),fr(e)}},[r,e]),r?r.getSnapshot():{state:"cold"}}var x=require("react");var gt="[data-conversation-tabs]",Oe='[data-conversation-tabs] button[role="tab"]',We=new Map,ke=new Map;function ut(e,t){let r=ke.get(e);if(r!==void 0&&r.size>0){for(let i of r)i(t);return}We.set(e,t)}function mt(e){let t=We.get(e);return t===void 0?null:(We.delete(e),t)}function ht(e,t){let r=ke.get(e);return r===void 0&&(r=new Set,ke.set(e,r)),r.add(t),()=>{let i=ke.get(e);i!==void 0&&(i.delete(t),i.size===0&&ke.delete(e))}}function yt(e){if(typeof document>"u")return!1;let t=document.querySelectorAll(Oe);for(let r of t)if((r.textContent??"").trim()===e)return r.getAttribute("aria-selected")!=="true"&&r.click(),!0;return!1}var d=require("react"),Ze=require("react-dom");var M=require("react");function ee(e,t=15){return(0,M.createElement)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"},e)}function Re({size:e}){return ee([(0,M.createElement)("circle",{key:"c",cx:8,cy:8,r:2.4}),(0,M.createElement)("line",{key:"l1",x1:8,y1:1.5,x2:8,y2:5.6}),(0,M.createElement)("line",{key:"l2",x1:8,y1:10.4,x2:8,y2:14.5})],e)}function bt({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M4 2v8"}),(0,M.createElement)("path",{key:"b",d:"M2 4h4"}),(0,M.createElement)("circle",{key:"c",cx:4,cy:12,r:1.6}),(0,M.createElement)("circle",{key:"d",cx:12,cy:4,r:1.6}),(0,M.createElement)("path",{key:"e",d:"M12 6v4"}),(0,M.createElement)("path",{key:"f",d:"M10 12h4"})],e)}function je({size:e}){return ee([(0,M.createElement)("circle",{key:"a",cx:4,cy:3,r:1.6}),(0,M.createElement)("circle",{key:"b",cx:4,cy:13,r:1.6}),(0,M.createElement)("circle",{key:"c",cx:12,cy:5,r:1.6}),(0,M.createElement)("path",{key:"d",d:"M4 4.6v6.8"}),(0,M.createElement)("path",{key:"e",d:"M12 6.6c0 3-4 2.4-8 4"})],e)}function vt({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M2 7V3h4l8 8-4 4z"}),(0,M.createElement)("circle",{key:"b",cx:4.5,cy:5.5,r:.8,fill:"currentColor"})],e)}function le({size:e,open:t}){return ee([(0,M.createElement)("path",{key:"a",d:t?"M3 6l5 5 5-5":"M6 3l5 5-5 5"})],e)}function wt({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M4 4l8 8M12 4l-8 8"})],e)}function Ee({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M13 8a5 5 0 1 1-1.5-3.5"}),(0,M.createElement)("path",{key:"b",d:"M13 2v3h-3"})],e)}function xt({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M4 2h5l3 3v9H4z"}),(0,M.createElement)("path",{key:"b",d:"M9 2v3h3"})],e)}function kt({size:e}){return ee([(0,M.createElement)("path",{key:"a",d:"M5 2.5h4l2.5 2.5v7.5h-6.5z"}),(0,M.createElement)("path",{key:"b",d:"M9 2.5V5h2.5"}),(0,M.createElement)("path",{key:"c",d:"M11 12.5v1.5h-6.5V6"})],e)}function _t({size:e=15}){return(0,M.createElement)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"currentColor"},(0,M.createElement)("path",{"fill-rule":"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"}))}function St(e){let t=0;for(let r of e){t=Math.max(t,r.lane+1);for(let i of r.edges)t=Math.max(t,i.fromLane+1,i.toLane+1)}return t}function Ct(e){let t=[],r=[],i=new Map,n=0,a=s=>{let o=i.get(s);return o===void 0&&(o=n++,i.set(s,o)),o};for(let s of e){let o=f=>{let u=r.findIndex(T=>T===f);return u===-1&&(u=r.findIndex(T=>T===null),u===-1&&(u=r.length,r.push(null)),r[u]=f),u},l=o(s.hash),c=a(s.hash),g=[...r],p=s.parents,y=p.length>=2;for(let f=0;f<r.length;f++)f!==l&&r[f]===s.hash&&(r[f]=null);if(p.length===0)r[l]=null;else{r[l]=p[0],a(p[0]);for(let f=1;f<p.length;f++){let u=p[f];o(u),a(u)}}let h=[],v=r;for(let f=0;f<g.length;f++){let u=g[f];if(u!==null)if(u===s.hash)h.push({fromLane:f,toLane:l,color:a(s.hash)});else{let T=v.findIndex(E=>E===u);T!==-1&&h.push({fromLane:f,toLane:T,color:a(u)})}}for(let f of p){let u=v.findIndex(T=>T===f);u!==-1&&h.push({fromLane:l,toLane:u,color:a(f)})}for(t.push({commit:s,lane:l,color:c,edges:h,merge:y});r.length>0&&r[r.length-1]===null;)r=r.slice(0,-1)}return t}function Nt(e){let t={name:"",path:"",dir:!0,children:[]};for(let r of e){let i=r.path.split("/").filter(s=>s!==""),n=t,a="";for(let s=0;s<i.length;s++){let o=i[s];a=a===""?o:`${a}/${o}`;let l=s===i.length-1,c=n.children.find(g=>g.name===o&&g.dir===!l);c===void 0&&(c={name:o,path:a,dir:!l,children:[],...l?{meta:r.meta}:{}},n.children.push(c)),n=c}}return Gt(t),Tt(t.children)}function Gt(e){e.children.sort((t,r)=>t.dir!==r.dir?t.dir?-1:1:t.name.localeCompare(r.name));for(let t of e.children)Gt(t)}function Tt(e){return e.map(t=>{if(!t.dir)return t;let r=t;for(;r.children.length===1&&r.children[0].dir;){let i=r.children[0];r={name:`${r.name}/${i.name}`,path:i.path,dir:!0,children:i.children}}return{...r,children:Tt(r.children)}})}function ge(e,t,r){if(e===null)return"";let i=typeof e=="number"?e:Date.parse(e);if(!Number.isFinite(i))return"";let n=Math.max(0,t-i),a=Math.floor(n/6e4);if(a<1)return r("time.justNow");if(a<60)return r("time.minutesAgo",{n:a});let s=Math.floor(a/60);if(s<24)return r("time.hoursAgo",{n:s});let o=Math.floor(s/24);return r("time.daysAgo",{n:o})}function ue(e){if(e===null)return"";let t=new Date(typeof e=="number"?e:Date.parse(e));if(Number.isNaN(t.getTime()))return"";let r=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())} ${r(t.getHours())}:${r(t.getMinutes())}`}var De={added:"A",modified:"M",deleted:"D",renamed:"R",untracked:"U",conflicted:"!",typechange:"T"};function Me(e){return e==="added"||e==="untracked"?"gp-status--added":e==="deleted"?"gp-status--deleted":e==="renamed"?"gp-status--renamed":"gp-status--modified"}var C=require("react");var ur={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",svg:"image/svg+xml",ico:"image/x-icon",tif:"image/tiff",tiff:"image/tiff"};function Ue(e){let t=e.lastIndexOf(".");return t<0?null:ur[e.slice(t+1).toLowerCase()]??null}function Rt(e){return/^Binary files .* differ$/m.test(e)||/^GIT binary patch$/m.test(e)}function Et(e){return Ue(e)!==null}function mr(e){let t=Qe(e);return t.length===0?!1:t.every(r=>r.startsWith("+")||r.startsWith(" "))&&t.some(r=>r.startsWith("+"))&&/^\+\+\+ /m.test(e)&&/--- \/dev\/null/m.test(e)}function hr(e){let t=Qe(e);return t.length===0?!1:t.every(r=>r.startsWith("-")||r.startsWith(" "))&&t.some(r=>r.startsWith("-"))&&/^\+\+\+ \/dev\/null/m.test(e)}function Qe(e){let t=e.split(`
|
|
304
|
+
`),r=[],i=!1;for(let n of t){if(n.startsWith("@@")){i=!0;continue}if(i){if(n.startsWith("diff ")||n.startsWith("index ")){i=!1;continue}n!==""&&r.push(n)}}return r}function Dt(e){let t=0,r=0;for(let i of Qe(e))i.startsWith("+")?t++:i.startsWith("-")&&r++;return{add:t,del:r}}var yr=/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function Mt(e){let t=[],r=e.split(`
|
|
305
|
+
`),i=0,n=0,a=!0,s=!1,o=0;for(;o<r.length&&!r[o].startsWith("@@");o++);for(;o<r.length;o++){let l=r[o];if(l.startsWith("@@")){let p=yr.exec(l);if(p){let y=Number(p[1]),h=Number(p[3]),v=y-h;if(a)h>1&&t.push(me({rightStart:1,count:h-1,delta:v,atStart:!0,atEnd:!1}));else{let f=h-n;f>0&&t.push(me({rightStart:n,count:f,delta:v,atStart:!1,atEnd:!1}))}i=y,n=h,a=!1}t.push({kind:"hunk",leftNo:null,rightNo:null,leftText:null,rightText:null,text:l});continue}if(l.startsWith("\\"))continue;let c=l[0],g=l.slice(1);c==="+"?(t.push({kind:"add",leftNo:null,rightNo:n,leftText:null,rightText:g}),n++,s=!0):c==="-"?(t.push({kind:"del",leftNo:i,rightNo:null,leftText:g,rightText:null}),i++,s=!0):c===" "&&(t.push({kind:"context",leftNo:i,rightNo:n,leftText:g,rightText:g}),i++,n++,s=!0)}return s&&!a&&!mr(e)&&!hr(e)&&t.push(me({rightStart:n,count:null,delta:i-n,atStart:!1,atEnd:!0})),br(t)}function me(e){return{kind:"gap",leftNo:null,rightNo:null,leftText:null,rightText:null,gap:e}}function br(e){let t=[],r=0;for(;r<e.length;){let i=e[r];if(i.kind==="del"){let n=[],a=r;for(;a<e.length&&e[a].kind==="del";)n.push(e[a]),a++;let s=[];for(;a<e.length&&e[a].kind==="add";)s.push(e[a]),a++;let o=Math.max(n.length,s.length);for(let l=0;l<o;l++){let c=n[l],g=s[l];if(c&&g){let p=vr(c.leftText??"",g.rightText??"");t.push({kind:"mod",leftNo:c.leftNo,rightNo:g.rightNo,leftText:c.leftText,rightText:g.rightText,...p!==null?{leftWord:p.left,rightWord:p.right}:{}})}else c?t.push({kind:"del",leftNo:c.leftNo,rightNo:null,leftText:c.leftText,rightText:null}):g&&t.push({kind:"add",leftNo:null,rightNo:g.rightNo,leftText:null,rightText:g.rightText})}r=a}else t.push(i),r++}return t}function vr(e,t){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let n=0;for(;n<r-i&&e[e.length-1-n]===t[t.length-1-n];)n++;return i===0&&n===0?null:{left:[i,e.length-n],right:[i,t.length-n]}}function wr(e,t,r){return r.map((i,n)=>{let a=t+n;return{kind:"context",leftNo:a+e,rightNo:a,leftText:i,rightText:i}})}var Z=20;function Pt(e){let t=[];for(let r of e)r.kind==="mod"?(t.push({kind:"del",leftNo:r.leftNo,rightNo:null,leftText:r.leftText,rightText:null,...r.leftWord!==void 0?{leftWord:r.leftWord}:{}}),t.push({kind:"add",leftNo:null,rightNo:r.rightNo,leftText:null,rightText:r.rightText,...r.rightWord!==void 0?{rightWord:r.rightWord}:{}})):t.push(r);return t}function Ft(e,t,r,i,n,a){let s=e.findIndex(p=>p.kind==="gap"&&p.gap?.rightStart===t);if(s<0)return e.slice();let o=e[s].gap,l=wr(o.delta,i,n),c=[];if(o.atEnd)return c.push(...l),!a&&n.length>0&&c.push(me({rightStart:i+n.length,count:null,delta:o.delta,atStart:!1,atEnd:!0})),[...e.slice(0,s),...c,...e.slice(s+1)];let g=o.count??n.length;if(r==="all"||n.length>=g)c.push(...l);else if(r==="down"){c.push(...l);let p=g-n.length;c.push(me({rightStart:o.rightStart+n.length,count:p,delta:o.delta,atStart:!1,atEnd:!1}))}else{let p=g-n.length;c.push(me({rightStart:o.rightStart,count:p,delta:o.delta,atStart:o.atStart,atEnd:!1})),c.push(...l)}return[...e.slice(0,s),...c,...e.slice(s+1)]}var Ae=require("@deepseek-ai/dsh-client-ui-primitives");function Lt(e,t){let r=[[],[],[]],i=0;for(let n of e){let a=i+n.text.length,s=[i,Math.max(i,Math.min(a,t[0])),Math.max(i,Math.min(a,t[1])),a];for(let o=0;o<3;o++){let l=n.text.slice(s[o]-i,s[o+1]-i);l!==""&&r[o].push({text:l,style:n.style})}i=a}return r}var te=require("react");function Pe(e,t,r){let i=r(`diff.${e}`);return(0,te.createElement)("div",{className:`gp-imgcmp__pane gp-imgcmp__pane--${e}`},[(0,te.createElement)("div",{key:"head",className:"gp-imgcmp__head"},i),t===void 0?(0,te.createElement)("div",{key:"missing",className:"gp-imgcmp__missing"},r("diff.imageMissing")):(0,te.createElement)("div",{key:"img",className:"gp-imgcmp__img"},(0,te.createElement)("img",{src:t,alt:i}))])}function At({oldUrl:e,newUrl:t,mode:r,t:i}){return r==="before"?(0,te.createElement)("div",{className:"gp-imgcmp gp-imgcmp--single"},Pe("before",e,i)):r==="after"?(0,te.createElement)("div",{className:"gp-imgcmp gp-imgcmp--single"},Pe("after",t,i)):(0,te.createElement)("div",{className:"gp-imgcmp"},[Pe("before",e,i),Pe("after",t,i)])}var ze=(0,C.memo)(function({text:t,mode:r,path:i,remote:n,sessionId:a,imageSpec:s,t:o}){let l=(0,C.useMemo)(()=>Mt(t),[t]),c=Rt(t),g=(0,Ae.useCodeHighlighter)(i===void 0?void 0:(0,Ae.languageForPath)(i)),[p,y]=(0,C.useState)(l);(0,C.useEffect)(()=>{y(l)},[l]);let h=xr(p,y,n,a,i,s),v=c&&i!==void 0&&Et(i)&&n!==void 0&&a!==void 0&&s!==void 0,f=_r(v?n:void 0,v?a:void 0,v?i:void 0,v?s:void 0);if(c){if(v){if(f.kind==="idle"||f.kind==="loading")return(0,C.createElement)("div",{className:"gp-empty"},o("common.loading"));if(f.kind==="ready"){let u=f.res;if(u.tooLarge===!0)return(0,C.createElement)("div",{className:"gp-empty"},o("diff.tooLarge"));if(u.mime!==null&&(u.old!==void 0||u.new!==void 0))return(0,C.createElement)(At,{oldUrl:u.old,newUrl:u.new,mode:r,t:o})}}return(0,C.createElement)("div",{className:"gp-empty"},o("diff.binary"))}if(t.trim()==="")return(0,C.createElement)("div",{className:"gp-empty"},o("diff.empty"));if(r==="before")return zt(Sr(p),g);if(r==="after")return zt(Cr(p),g);if(r==="unified"){let u=Pt(p);return(0,C.createElement)("div",{className:"gp-diff__unified"},u.flatMap((T,E)=>Gr(T,E,g,h,o)))}return(0,C.createElement)("div",{className:"gp-diff__side"},p.flatMap((u,T)=>Nr(u,T,g,h,o)))});function xr(e,t,r,i,n,a){let[s,o]=(0,C.useState)(null),l=(0,C.useRef)(0);(0,C.useEffect)(()=>{l.current+=1,o(null)},[e]);let c=(0,C.useCallback)((g,p)=>{if(r===void 0||i===void 0||n===void 0||a===void 0)return;let y=`${g.rightStart}:${p}`;o(y);let h=++l.current,{start:v,end:f}=kr(g,p),u=a.base==="commit"&&a.commit!==void 0?{kind:"file-lines",path:n,base:"commit",commit:a.commit,start:v,end:f}:a.base==="staged"?{kind:"file-lines",path:n,base:"staged",start:v,end:f}:{kind:"file-lines",path:n,base:"worktree",start:v,end:f};r.query({sessionId:i,query:u}).then(T=>{if(h!==l.current)return;let E=I(T,"file-lines");o(null),E!==null&&t(w=>Ft(w,g.rightStart,p,E.start,E.lines,E.eof))}).catch(()=>{h===l.current&&o(null)})},[r,i,n,a,t]);return{busy:s,run:c}}function kr(e,t){if(e.atEnd)return{start:e.rightStart,end:e.rightStart+Z-1};let r=e.count??Z;return t==="all"||r<=Z?{start:e.rightStart,end:e.rightStart+r-1}:t==="down"?{start:e.rightStart,end:e.rightStart+Z-1}:{start:e.rightStart+r-Z,end:e.rightStart+r-1}}function _r(e,t,r,i){let[n,a]=(0,C.useState)({kind:"idle"}),s=i?.base,o=i?.commit;return(0,C.useEffect)(()=>{if(e===void 0||t===void 0||r===void 0||s===void 0)return;let l=!0;a({kind:"loading"});let c=s==="commit"&&o!==void 0?{kind:"image-diff",path:r,base:"commit",commit:o}:s==="staged"?{kind:"image-diff",path:r,base:"staged"}:{kind:"image-diff",path:r,base:"worktree"};return e.query({sessionId:t,query:c}).then(g=>{if(!l)return;let p=I(g,"image-diff");a(p!==null?{kind:"ready",res:p}:{kind:"failed"})}).catch(()=>{l&&a({kind:"failed"})}),()=>{l=!1}},[e,t,r,s,o]),n}function Fe(e,t=""){return e.map((r,i)=>(0,C.createElement)("span",{key:`${t}${i}`,style:r.style},r.text))}function Le(e,t,r,i){if(r==="")return(0,C.createElement)("div",{key:t,className:e},"\xA0");let n=i(r)?.[0];return(0,C.createElement)("div",{key:t,className:e},n===void 0?r:Fe(n))}function Ye(e,t,r,i,n,a){let s=a(r)?.[0]??[{text:r,style:{}}],[o,l,c]=Lt(s,i);return(0,C.createElement)("div",{key:t,className:e},[...Fe(o,"p"),(0,C.createElement)("span",{key:"w",className:n},l.length===0?"\xA0":Fe(l)),...Fe(c,"s")])}function Sr(e){return e.filter(t=>t.leftText!==null).map(t=>({no:t.leftNo,text:t.leftText}))}function Cr(e){return e.filter(t=>t.rightText!==null).map(t=>({no:t.rightNo,text:t.rightText}))}function zt(e,t){return(0,C.createElement)("div",{className:"gp-diff__single"},e.flatMap((r,i)=>[(0,C.createElement)("div",{key:`n${i}`,className:"gp-diff-no"},r.no??""),Le("gp-diff-cell",`c${i}`,r.text,t)]))}function Nr(e,t,r,i,n){if(e.kind==="hunk")return[(0,C.createElement)("div",{key:`h${t}`,className:"gp-diff-row--hunk gp-diff-cell",style:{gridColumn:"1 / -1"}},e.text??"")];if(e.kind==="gap")return[$t(e.gap,t,i,n)];let a=e.kind==="del"||e.kind==="mod"?"gp-diff-row--del":"",s=e.kind==="add"||e.kind==="mod"?"gp-diff-row--add":"",o=e.leftText===null?(0,C.createElement)("div",{key:`l${t}`,className:`gp-diff-cell ${a}`}):e.kind==="mod"&&e.leftWord!==void 0?Ye(`gp-diff-cell ${a}`,`l${t}`,e.leftText,e.leftWord,"gp-diff-word gp-diff-word--del",r):Le(`gp-diff-cell ${a}`,`l${t}`,e.leftText,r),l=e.rightText===null?(0,C.createElement)("div",{key:`r${t}`,className:`gp-diff-cell ${s}`}):e.kind==="mod"&&e.rightWord!==void 0?Ye(`gp-diff-cell ${s}`,`r${t}`,e.rightText,e.rightWord,"gp-diff-word gp-diff-word--add",r):Le(`gp-diff-cell ${s}`,`r${t}`,e.rightText,r);return[(0,C.createElement)("div",{key:`ln${t}`,className:"gp-diff-no"},e.leftNo??""),o,(0,C.createElement)("div",{key:`rn${t}`,className:"gp-diff-no"},e.rightNo??""),l]}function Gr(e,t,r,i,n){if(e.kind==="hunk")return[(0,C.createElement)("div",{key:`h${t}`,className:"gp-diff-row--hunk gp-diff-cell",style:{gridColumn:"1 / -1"}},e.text??"")];if(e.kind==="gap")return[$t(e.gap,t,i,n)];let a=e.kind==="del",s=e.kind==="add",o=s?"gp-diff-row--add":a?"gp-diff-row--del":"",l=s?"+":a?"\u2212":"\xA0",c=e.rightText??e.leftText??"",g=s?e.rightWord:a?e.leftWord:void 0,p=s?"gp-diff-word gp-diff-word--add":"gp-diff-word gp-diff-word--del",y=`gp-diff-cell gp-diff-uni__code ${o}`,h=g!==void 0?Ye(y,`c${t}`,c,g,p,r):Le(y,`c${t}`,c,r);return[(0,C.createElement)("div",{key:`ol${t}`,className:"gp-diff-no"},e.leftNo??""),(0,C.createElement)("div",{key:`nl${t}`,className:"gp-diff-no"},e.rightNo??""),(0,C.createElement)("div",{key:`sg${t}`,className:`gp-diff-uni__sign ${o}`},l),h]}function $t(e,t,r,i){let n=r.busy===`${e.rightStart}:all`,a=r.busy===`${e.rightStart}:up`,s=r.busy===`${e.rightStart}:down`,o=(c,g,p)=>(0,C.createElement)("button",{key:c,type:"button",className:"gp-gap__btn",disabled:r.busy!==null,onClick:y=>{y.stopPropagation(),r.run(e,c)}},p?i("common.loading"):g),l=[];if(e.atEnd)l.push(o("down",i("diff.expandDown",{n:Z}),s));else{let c=e.count??0;c>0&&c<=Z?l.push(o("all",i("diff.expandGap",{n:c}),n)):(e.atStart||l.push(o("up",i("diff.expandUp",{n:Z}),a)),l.push(o("all",i("diff.expandGap",{n:c}),n)),l.push(o("down",i("diff.expandDown",{n:Z}),s)))}return(0,C.createElement)("div",{key:`g${t}`,className:"gp-diff-row--gap",style:{gridColumn:"1 / -1"}},l)}function $e(e){return Dt(e)}var S=require("react");var Tr=100;function Ht(e,t,r){let[i,n]=(0,S.useState)(null),[a,s]=(0,S.useState)(!1),[o,l]=(0,S.useState)([]),c=(0,S.useCallback)(()=>{s(!1),(async()=>{let[g,p]=await Promise.all([e.query({sessionId:t,query:{kind:"branches"}}),e.query({sessionId:t,query:{kind:"tags"}})]),y=I(g,"branches");if(y===null){s(!0);return}let h=I(p,"tags");n({current:y.current,defaultBranch:y.defaultBranch,local:y.local,remote:y.remote,tags:h?.tags??[]}),e.query({sessionId:t,query:{kind:"authors"}}).then(v=>{l(I(v,"authors")?.authors??[])})})()},[e,t]);return(0,S.useEffect)(()=>{c()},[r]),{tree:i,treeError:a,authors:o,reload:c}}function Vt(e,t,r,i,n){let[a,s]=(0,S.useState)([]),[o,l]=(0,S.useState)(0),[c,g]=(0,S.useState)(!1),[p,y]=(0,S.useState)(!1),h=(0,S.useRef)(0),v=(0,S.useRef)(!1),f=(0,S.useRef)(null),u=(0,S.useCallback)(async(V,F)=>{if(v.current)return;v.current=!0;let $=h.current;g(!0),y(!1);let N=await e.query({sessionId:t,query:{kind:"history",limit:Tr,skip:V,...F.ref?{ref:F.ref}:{},...F.search?{search:F.search}:{},...F.author?{author:F.author}:{},...F.since?{since:F.since}:{}}});if(v.current=!1,$!==h.current)return;g(!1);let L=I(N,"history");if(L===null){y(!0);return}let k=L.commits;s(A=>V===0?k:[...A,...k]),l(L.total)},[e,t]),T=(0,S.useRef)(r);(0,S.useEffect)(()=>{h.current+=1,v.current=!1,T.current!==r&&(T.current=r,n(),f.current&&(f.current.scrollTop=0)),u(0,r)},[r,i]);let E=o<0?!0:a.length<o,w=(0,S.useCallback)(()=>{v.current||!E||u(a.length,r)},[u,a.length,r,E]);return{commits:a,total:o,loading:c,listError:p,hasMore:E,listRef:f,loadMore:w}}function Xt(e,t,r){let[i,n]=(0,S.useState)(null),[a,s]=(0,S.useState)(null),[o,l]=(0,S.useState)(!1),[c,g]=(0,S.useState)(null),[p,y]=(0,S.useState)(null),[h,v]=(0,S.useState)(!1),[f,u]=(0,S.useState)(r),[T,E]=(0,S.useState)(!1),w=(0,S.useRef)(0),V=(0,S.useRef)(null),F=(0,S.useRef)(new Map),$=(0,S.useCallback)((D,B)=>{let q=F.current;for(q.set(D,B);q.size>50;){let K=q.keys().next().value;if(K===void 0)break;q.delete(K)}},[]),N=(0,S.useCallback)(()=>{n(null),s(null),V.current=null},[]),L=(0,S.useCallback)(async D=>{V.current=D.hash,n(D),l(!1),w.current+=1,g(null),y(null),v(!1);let B=F.current.get(D.hash);if(B!==void 0){s(B);return}s(null);let q=await e.query({sessionId:t,query:{kind:"show",ref:D.hash}});if(V.current!==D.hash)return;let K=I(q,"show");if(K!==null){let ie={commit:K.commit,body:K.body,stats:K.stats};$(D.hash,ie),s(ie)}else l(!0)},[e,t,$]),k=(0,S.useCallback)(async(D,B,q,K=!1)=>{let ie=++w.current;g({path:D,hash:B,shortHash:q}),y(null),v(!1),E(K);let j=await e.query({sessionId:t,query:{kind:"diff",path:D,base:"commit",commit:B,...K?{context:1e5}:{}}});if(ie!==w.current)return;let ve=I(j,"diff");ve!==null?y(ve.text):v(!0)},[e,t]),A=(0,S.useCallback)(()=>{w.current+=1,g(null),y(null),v(!1),E(!1)},[]);(0,S.useEffect)(()=>{if(c===null)return;let D=B=>{B.key==="Escape"&&A()};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[c,A]);let[W,Q]=(0,S.useState)(null),[ce,X]=(0,S.useState)(null),O=(0,S.useRef)(void 0),ne=(0,S.useRef)(null),G=(0,S.useCallback)((D,B,q)=>{O.current!==void 0&&clearTimeout(O.current),O.current=setTimeout(()=>{ne.current=D.hash,Q({commit:D,x:B,y:q});let K=F.current.get(D.hash);if(K!==void 0){X(K.body);return}X(null),e.query({sessionId:t,query:{kind:"show",ref:D.hash}}).then(ie=>{if(ne.current!==D.hash)return;let j=I(ie,"show");j!==null?($(D.hash,{commit:j.commit,body:j.body,stats:j.stats}),X(j.body)):X("")})},260)},[e,t,$]),J=(0,S.useCallback)(()=>{O.current!==void 0&&clearTimeout(O.current),ne.current=null,Q(null),X(null)},[]);return(0,S.useEffect)(()=>()=>{O.current!==void 0&&clearTimeout(O.current)},[]),{selected:i,detail:a,detailError:o,select:L,clearSelection:N,fileDiff:c,fileDiffText:p,fileDiffError:h,fileDiffMode:f,setFileDiffMode:u,fileDiffExpanded:T,openFileDiff:k,closeFileDiff:A,hover:W,hoverBody:ce,onHoverEnter:G,onHoverLeave:J}}var Y=require("react"),Rr=(e,t,r)=>Math.max(t,Math.min(r,e));function Er(e,t){try{let r=typeof localStorage<"u"?localStorage.getItem(e):null,i=r===null?NaN:Number(r);return Number.isFinite(i)?i:t}catch{return t}}function Dr(e,t){try{typeof localStorage<"u"&&localStorage.setItem(e,String(Math.round(t)))}catch{}}function de(e){let{storageKey:t,initial:r,min:i,reserve:n,edge:a}=e,[s,o]=(0,Y.useState)(()=>Er(t,r)),l=(0,Y.useRef)(null),c=(0,Y.useRef)(null),g=(0,Y.useCallback)(y=>{let v=l.current?.parentElement?.clientWidth??Number.MAX_SAFE_INTEGER;c.current={x:y.clientX,w:s,max:Math.max(i,v-n)},y.preventDefault(),typeof document<"u"&&(document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[s,i,n]);(0,Y.useEffect)(()=>{if(typeof window>"u")return;let y=v=>{let f=c.current;if(f===null)return;let u=v.clientX-f.x;o(Rr(f.w+(a==="end"?u:-u),i,f.max))},h=()=>{c.current!==null&&(c.current=null,typeof document<"u"&&(document.body.style.cursor="",document.body.style.userSelect=""),o(v=>(Dr(t,v),v)))};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",h),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",h)}},[a,i,t]);let p=(0,Y.createElement)("div",{key:`rz-${t}`,ref:l,className:"gp-resizer",role:"separator","aria-orientation":"vertical",onPointerDown:g});return{width:s,divider:p}}var It=require("react");function he(e,t,r,i,n=!1){return e.map(a=>(0,It.createElement)("button",{key:a,type:"button",className:`gp-seg__btn${t===a?" gp-seg__btn--active":""}`,...n?{disabled:!0}:{},onClick:()=>r(a)},i(a)))}var ye=14,_e=30;function qt({remote:e,sessionId:t,refreshKey:r,defaultDiffView:i,t:n}){let[a,s]=(0,d.useState)({ref:null,search:"",author:"",since:""}),[o,l]=(0,d.useState)(""),[c,g]=(0,d.useState)(new Set(["tags","remote"])),{tree:p,treeError:y,authors:h,reload:v}=Ht(e,t,r),f=Xt(e,t,i),{commits:u,loading:T,listError:E,hasMore:w,listRef:V,loadMore:F}=Vt(e,t,a,r,f.clearSelection);(0,d.useEffect)(()=>{let G=setTimeout(()=>s(J=>J.search===o?J:{...J,search:o}),300);return()=>clearTimeout(G)},[o]);let $=a.search!=="",N=(0,d.useMemo)(()=>$?u.map(G=>({commit:G,lane:0,color:0,edges:[],merge:!1})):Ct(u),[u,$]),L=(0,d.useMemo)(()=>$?0:St(N),[N,$]),k=$?12:Math.max(ye,L*ye),A=`${k}px minmax(120px,1fr) 72px 120px 96px`,W=()=>{let G=V.current;G===null||!w||G.scrollTop+G.clientHeight>=G.scrollHeight-240&&F()},Q=(0,d.useMemo)(()=>Date.now(),[u]),ce=(0,d.useMemo)(()=>f.detail===null?[]:Nt(f.detail.stats.map(G=>({path:G.path,meta:G.status}))),[f.detail]),X=f.selected,O=de({storageKey:"gp.overview.left",initial:200,min:130,reserve:360,edge:"end"}),ne=de({storageKey:"gp.overview.right",initial:340,min:190,reserve:360,edge:"start"});return(0,d.createElement)("div",{className:"gp-overview"},[zr(f.fileDiff,{text:f.fileDiffText,error:f.fileDiffError,mode:f.fileDiffMode,onMode:f.setFileDiffMode,expanded:f.fileDiffExpanded,onExpand:G=>{f.fileDiff!==null&&f.openFileDiff(f.fileDiff.path,f.fileDiff.hash,f.fileDiff.shortHash,G)},onClose:f.closeFileDiff,remote:e,sessionId:t,t:n}),(0,d.createElement)("div",{key:"left",className:"gp-col gp-col--left",style:{flex:`0 0 ${O.width}px`}},Pr(p,y,a.ref,c,{onFilter:G=>s(J=>({...J,ref:G})),onToggle:G=>g(J=>{let D=new Set(J);return D.has(G)?D.delete(G):D.add(G),D}),onRetry:v,t:n})),O.divider,(0,d.createElement)("div",{key:"mid",className:"gp-col gp-col--mid gp-history"},[(0,d.createElement)("div",{key:"tb",className:"gp-toolbar"},[(0,d.createElement)("input",{key:"search",className:"gp-search",placeholder:n("overview.search"),value:o,onChange:G=>l(G.target.value)}),(0,d.createElement)("select",{key:"author",className:"gp-select",value:a.author,onChange:G=>s(J=>({...J,author:G.target.value}))},[(0,d.createElement)("option",{key:"",value:""},n("overview.allUsers")),...h.map(G=>(0,d.createElement)("option",{key:G,value:G},G))]),(0,d.createElement)("select",{key:"since",className:"gp-select",value:a.since,onChange:G=>s(J=>({...J,since:G.target.value}))},[(0,d.createElement)("option",{key:"",value:""},n("overview.allTime")),(0,d.createElement)("option",{key:"today",value:"1 day ago"},n("overview.today")),(0,d.createElement)("option",{key:"7d",value:"7 days ago"},n("overview.last7d")),(0,d.createElement)("option",{key:"30d",value:"30 days ago"},n("overview.last30d"))]),(0,d.createElement)("button",{key:"fetch",type:"button",className:"gp-icon-btn",title:n("overview.fetch"),onClick:()=>{e.run({sessionId:t,action:{kind:"fetch"}}).then(()=>v())}},(0,d.createElement)(Ee,{size:14}))]),(0,d.createElement)("div",{key:"list",className:"gp-history__list",ref:V,onScroll:W},u.length===0?(0,d.createElement)("div",{className:"gp-empty"},n(T?"common.loading":E?"overview.loadFailed":"overview.noResults")):N.map(G=>Fr(G,{selected:X?.hash===G.commit.hash,gridTpl:A,graphW:k,laneCount:L,searching:$,now:Q,onSelect:()=>void f.select(G.commit),onHoverEnter:f.onHoverEnter,onHoverLeave:f.onHoverLeave,t:n})))]),ne.divider,(0,d.createElement)("div",{key:"right",className:"gp-col gp-col--right gp-detail",style:{flex:`0 0 ${ne.width}px`}},X===null?(0,d.createElement)("div",{className:"gp-empty"},[(0,d.createElement)(Re,{key:"i",size:20}),n("overview.selectCommit")]):[(0,d.createElement)("div",{key:"files",className:"gp-detail__files"},f.detail===null?(0,d.createElement)("div",{className:"gp-empty"},f.detailError?n("overview.detailFailed"):n("common.loading")):Ar(ce,{activePath:f.fileDiff?.path??null,openTitle:n("overview.openFileDiff"),onOpen:G=>{X!==null&&f.openFileDiff(G,X.hash,X.shortHash)}})),(0,d.createElement)("div",{key:"msg",className:"gp-detail__msg"},[(0,d.createElement)("div",{key:"subj",className:"gp-detail__subject"},X.subject),(0,d.createElement)("div",{key:"meta",className:"gp-detail__meta"},[(0,d.createElement)("span",{key:"h",className:"gp-commit-hash"},X.shortHash),(0,d.createElement)("span",{key:"a"},X.author),(0,d.createElement)("span",{key:"t",title:ue(X.dateIso)},ge(X.dateIso,Q,n))]),f.detail!==null&&f.detail.body!==""?(0,d.createElement)("pre",{key:"body",className:"gp-detail__body"},f.detail.body):(0,d.createElement)("div",{key:"nb",className:"gp-empty"},n("overview.noMessage"))])]),Mr(f.hover,f.hoverBody,n)])}function Mr(e,t,r){if(e===null||typeof document>"u")return null;let i=460,n=Math.min(e.x+16,(typeof window<"u"?window.innerWidth:1200)-i-12),a=e.y+14,s=(0,d.createElement)("div",{className:"gp-hovercard",style:{left:n,top:a,maxWidth:i}},[(0,d.createElement)("div",{key:"subj",className:"gp-hovercard__subject"},e.commit.subject),(0,d.createElement)("div",{key:"meta",className:"gp-hovercard__meta"},[(0,d.createElement)("span",{key:"h",className:"gp-commit-hash"},e.commit.shortHash),(0,d.createElement)("span",{key:"a"},e.commit.author)]),t===null?(0,d.createElement)("div",{key:"l",className:"gp-hovercard__loading"},r("common.loading")):t===""?(0,d.createElement)("div",{key:"e",className:"gp-hovercard__loading"},r("overview.noMessage")):(0,d.createElement)("pre",{key:"body",className:"gp-hovercard__body"},t)]);return(0,Ze.createPortal)(s,document.body,"commit-hovercard")}function Pr(e,t,r,i,n){if(t)return(0,d.createElement)("div",{className:"gp-empty"},[(0,d.createElement)("span",{key:"m"},n.t("overview.branchesError")),(0,d.createElement)("button",{key:"r",type:"button",className:"gp-btn",style:{marginTop:8},onClick:n.onRetry},n.t("common.retry"))]);if(e===null)return(0,d.createElement)("div",{className:"gp-empty"},n.t("common.loading"));let a=(s,o,l,c,g="")=>(0,d.createElement)("div",{key:s,className:"gp-branch-group"},[(0,d.createElement)("div",{key:"head",className:"gp-branch-group__head",onClick:()=>n.onToggle(s)},[(0,d.createElement)(le,{key:"c",size:11,open:!i.has(s)}),`${n.t(o)} (${l.length})`]),i.has(s)?null:l.map(p=>{let y=g+p.name,h=e.current===p.name,v=`gp-branch-row${r===y?" gp-branch-row--active":""}${h?" gp-branch-row--current":""}`;return(0,d.createElement)("div",{key:p.name,className:v,title:p.name,onClick:()=>n.onFilter(r===y?null:y)},[(0,d.createElement)("span",{key:"i",style:{display:"inline-flex",width:14}},c),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},p.name),p.ahead||p.behind?(0,d.createElement)("span",{key:"t",className:"gp-branch-row__track"},`${p.ahead?`\u2191${p.ahead}`:""}${p.behind?`\u2193${p.behind}`:""}`):null])})]);return(0,d.createElement)("div",{},[(0,d.createElement)("div",{key:"head-row",className:"gp-branch-row",style:{fontWeight:600,paddingLeft:10},onClick:()=>n.onFilter(null)},n.t("overview.head")),a("local","overview.local",e.local,(0,d.createElement)(je,{size:13})),a("remote","overview.remote",e.remote,(0,d.createElement)(je,{size:13})),a("tags","overview.tags",e.tags,(0,d.createElement)(vt,{size:13}))])}function Fr(e,t){let r=e.commit;return(0,d.createElement)("div",{key:r.hash,className:`gp-commit-row${t.selected?" gp-commit-row--active":""}`,style:{gridTemplateColumns:t.gridTpl},onClick:t.onSelect,onMouseEnter:i=>t.onHoverEnter(r,i.clientX,i.clientY),onMouseLeave:t.onHoverLeave},[(0,d.createElement)("div",{key:"g",className:"gp-graph-cell"},t.searching?null:Lr(e,t.laneCount)),(0,d.createElement)("div",{key:"s",className:"gp-commit-subject"},[...r.refs.map(i=>(0,d.createElement)("span",{key:i.name,className:`gp-ref-chip${i.head?" gp-ref-chip--head":""}${i.kind==="remote"?" gp-ref-chip--remote":""}${i.kind==="tag"?" gp-ref-chip--tag":""}`},i.name)),r.subject]),(0,d.createElement)("div",{key:"h",className:"gp-commit-hash"},r.shortHash),(0,d.createElement)("div",{key:"a",className:"gp-commit-author"},r.author),(0,d.createElement)("div",{key:"d",className:"gp-commit-date",title:ue(r.dateIso)},ge(r.dateIso,t.now,t.t))])}var He=["#4e9bff","#3fb950","#e0982e","#d05ce3","#e5534b","#2dc6c6","#d29922","#8b949e"];function Lr(e,t){let r=Math.max(ye,t*ye),i=a=>a*ye+ye/2,n=[];for(let a of e.edges){let s=He[a.color%He.length];n.push((0,d.createElement)("path",{key:`e${a.fromLane}-${a.toLane}-${a.color}`,d:`M ${i(a.fromLane)} 0 C ${i(a.fromLane)} ${_e/2}, ${i(a.toLane)} ${_e/2}, ${i(a.toLane)} ${_e}`,stroke:s,strokeWidth:1.6,fill:"none"}))}return n.push((0,d.createElement)("circle",{key:"node",cx:i(e.lane),cy:_e/2,r:e.merge?4:3.2,fill:He[e.color%He.length],stroke:"var(--dsw-alias-bg-layer-1)",strokeWidth:1})),(0,d.createElement)("svg",{className:"gp-graph-svg",width:r,height:_e},n)}function Ar(e,t){let r=[],i=(n,a)=>{for(let s of n)if(s.dir)r.push((0,d.createElement)("div",{key:s.path,className:"gp-tree-row",style:{paddingLeft:10+a*14}},[(0,d.createElement)(le,{key:"c",size:11,open:!0}),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},s.name)])),i(s.children,a+1);else{let o=String(s.meta??"modified"),l=t.activePath===s.path;r.push((0,d.createElement)("div",{key:s.path,className:`gp-tree-row${l?" gp-tree-row--active":""}`,style:{paddingLeft:10+a*14},title:t.openTitle,onClick:()=>t.onOpen(s.path)},[(0,d.createElement)("span",{key:"st",className:`gp-status-badge ${Me(o)}`},(De[o]??o[0]??"M").toUpperCase()),(0,d.createElement)("span",{key:"n",className:"gp-tree-name"},s.name)]))}};return i(e,0),(0,d.createElement)("div",{},r)}function zr(e,t){if(e===null||typeof document>"u")return null;let{text:r,error:i,mode:n,onMode:a,expanded:s,onExpand:o,onClose:l,remote:c,sessionId:g,t:p}=t,y=(0,d.createElement)("div",{className:"gp-modal-backdrop",onClick:h=>{h.target===h.currentTarget&&l()}},(0,d.createElement)("div",{className:"gp-modal",role:"dialog","aria-modal":!0},[(0,d.createElement)("div",{key:"bar",className:"gp-modal__bar"},[(0,d.createElement)("span",{key:"fileicon",className:"gp-modal__fileicon"},(0,d.createElement)(xt,{size:15})),(0,d.createElement)("span",{key:"path",className:"gp-modal__path",title:e.path},$r(e.path)),(0,d.createElement)("span",{key:"hash",className:"gp-modal__hash"},e.shortHash),r!==null&&r!==""?(()=>{let h=$e(r);return(0,d.createElement)("span",{key:"sum",className:"gp-modal__sum"},[(0,d.createElement)("span",{key:"a",className:"gp-stats__add"},`+${h.add}`),(0,d.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${h.del}`)])})():null,(0,d.createElement)("button",{key:"expand",type:"button",className:`gp-seg__btn gp-diff__expand${s?" gp-seg__btn--active":""}`,disabled:n!=="split"&&n!=="unified",title:p(s?"diff.collapse":"diff.expandAll"),onClick:()=>o(!s)},p(s?"diff.collapse":"diff.expandAll")),(0,d.createElement)("div",{key:"seg",className:"gp-seg"},he(["unified","split","before","after"],n,a,h=>p(`diff.${h}`))),(0,d.createElement)("button",{key:"close",type:"button",className:"gp-icon-btn gp-modal__close",title:p("common.close"),onClick:l},(0,d.createElement)(wt,{size:15}))]),(0,d.createElement)("div",{key:"scroll",className:"gp-modal__scroll"},r===null?(0,d.createElement)("div",{className:"gp-empty"},p(i?"overview.diffFailed":"common.loading")):(0,d.createElement)(ze,{text:r,mode:n,path:e.path,remote:c,sessionId:g,imageSpec:{base:"commit",commit:e.hash},t:p}))]));return(0,Ze.createPortal)(y,document.body,"file-diff-modal")}function $r(e){let t=e.lastIndexOf("/");return t<0?[(0,d.createElement)("span",{key:"n",className:"gp-modal__name"},e)]:[(0,d.createElement)("span",{key:"d",className:"gp-modal__dir"},e.slice(0,t+1)),(0,d.createElement)("span",{key:"n",className:"gp-modal__name"},e.slice(t+1))]}var m=require("react");var U=require("react");function Jt({stats:e,t}){let r=Date.now(),i=[(0,U.createElement)("span",{key:"files",className:"gp-stats__item"},t("stats.files",{n:e.fileCount})),(0,U.createElement)("span",{key:"lines",className:"gp-stats__item"},[(0,U.createElement)("span",{key:"a",className:"gp-stats__add"},`+${e.insertions}`)," ",(0,U.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${e.deletions}`)])];e.staged>0&&i.push((0,U.createElement)("span",{key:"st",className:"gp-stats__item"},t("stats.staged",{n:e.staged}))),e.modified>0&&i.push((0,U.createElement)("span",{key:"mo",className:"gp-stats__item"},t("stats.modified",{n:e.modified}))),e.untracked>0&&i.push((0,U.createElement)("span",{key:"un",className:"gp-stats__item"},t("stats.untracked",{n:e.untracked})));let n=[];return e.lastChangeAt!==null&&n.push((0,U.createElement)("span",{key:"lc",className:"gp-stats__item",title:ue(e.lastChangeAt)},t("stats.lastChange",{time:ge(e.lastChangeAt,r,t)}))),e.headCommittedAt!==null&&n.push((0,U.createElement)("span",{key:"hc",className:"gp-stats__item",title:ue(e.headCommittedAt)},t("stats.lastCommit",{time:ge(e.headCommittedAt,r,t)}))),n.length>0&&i.push((0,U.createElement)("span",{key:"times",className:"gp-stats__times"},n)),(0,U.createElement)("div",{className:"gp-stats"},i)}function Kt({remote:e,sessionId:t,snapshot:r,onAction:i,t:n}){let[a,s]=(0,m.useState)(new Set),[o,l]=(0,m.useState)(""),[c,g]=(0,m.useState)(!1),[p,y]=(0,m.useState)(!1),[h,v]=(0,m.useState)(null),[f,u]=(0,m.useState)(new Set),[T,E]=(0,m.useState)(null),[w,V]=(0,m.useState)(null),[F,$]=(0,m.useState)(null),[N,L]=(0,m.useState)(()=>r.defaultDiffView),[k,A]=(0,m.useState)(!1),[W,Q]=(0,m.useState)(!1),ce=(0,m.useRef)(0),X=(0,m.useMemo)(()=>r.changes.filter(_=>_.staged).sort(et),[r]),O=(0,m.useMemo)(()=>r.changes.filter(_=>!_.staged&&_.status!=="untracked").sort(et),[r]),ne=(0,m.useMemo)(()=>r.changes.filter(_=>_.status==="untracked").sort(et),[r]),J=[{key:"staged",labelKey:"changes.groupStaged",items:X},{key:"unstaged",labelKey:"changes.groupUnstaged",items:O},{key:"untracked",labelKey:"changes.groupUntracked",items:ne}].filter(_=>_.items.length>0);(0,m.useEffect)(()=>{s(_=>{if(_.size===0)return _;let R=new Set(r.changes.map(oe=>oe.path+(oe.staged?":s":":w"))),z=new Set,pe=!1;for(let oe of _)R.has(oe)?z.add(oe):pe=!0;return pe?z:_})},[r]),(0,m.useEffect)(()=>{if(!c||W||o.trim()!=="")return;let _=!0;return e.query({sessionId:t,query:{kind:"last-commit-message"}}).then(R=>{let z=I(R,"last-commit-message");_&&z!==null&&(l(z.message),Q(!0))}),()=>{_=!1}},[c,W,o,e,t]);let D=(0,m.useCallback)(async(_,R,z=!1,pe=!1)=>{let oe=++ce.current;V({path:_,base:R}),pe||$(null),A(z);let rr=await e.query({sessionId:t,query:{kind:"diff",path:_,base:R,...z?{context:1e5}:{}}});if(oe!==ce.current)return;let at=I(rr,"diff");$(at!==null?at.text:"")},[e,t]);(0,m.useEffect)(()=>{if(w===null)return;if(!r.changes.some(R=>R.path===w.path)){V(null),$(null);return}D(w.path,w.base,k,!0)},[r]),(0,m.useEffect)(()=>{E(null)},[r]);let B=_=>{s(R=>{let z=new Set(R);return z.has(_)?z.delete(_):z.add(_),z})},q=async _=>{if(p)return!1;y(!0),v(null);try{let R=await i(_);return R.ok?!0:(v(R.error??n("error.generic")),!1)}catch(R){return v(R instanceof Error?R.message:n("error.generic")),!1}finally{y(!1)}},K=async()=>{let _=o.trim();if(_===""&&!c){v(n("error.emptyMessage"));return}let R=a.size>0?[...new Set([...a].map(pe=>pe.replace(/:[sw]$/,"")))]:void 0;await q({kind:"commit",message:_,...R?{paths:R}:{},...c?{amend:!0}:{}})&&(l(""),s(new Set),g(!1),Q(!1))},ie=_=>{u(R=>{let z=new Set(R);return z.has(_)?z.delete(_):z.add(_),z})},j=F!==null&&F!==""?$e(F):null,ve=de({storageKey:"gp.changes.left",initial:380,min:220,reserve:200,edge:"end"});return(0,m.createElement)("div",{className:"gp-changes"},[(0,m.createElement)("div",{key:"left",className:"gp-changes__left",style:{flex:`0 0 ${ve.width}px`}},[(0,m.createElement)(Jt,{key:"stats",stats:r.stats,t:n}),(0,m.createElement)("div",{key:"toolbar",className:"gp-toolbar"},[(0,m.createElement)("button",{key:"sa",type:"button",className:"gp-btn",disabled:p||r.changes.length===0,onClick:()=>void q({kind:"stage-all"})},n("changes.stageAll")),(0,m.createElement)("button",{key:"ua",type:"button",className:"gp-btn",disabled:p||r.staged===0,onClick:()=>void q({kind:"unstage-all"})},n("changes.unstageAll"))]),h!==null?(0,m.createElement)("div",{key:"err",className:"gp-feedback"},h):null,(0,m.createElement)("div",{key:"list",className:"gp-changes__list"},r.changes.length===0?(0,m.createElement)("div",{className:"gp-empty"},n("changes.noChanges")):J.map(_=>(0,m.createElement)("div",{key:_.key},[(0,m.createElement)("div",{key:"head",className:"gp-group-head",onClick:()=>ie(_.key)},[(0,m.createElement)(le,{key:"chev",size:12,open:!f.has(_.key)}),`${n(_.labelKey)} (${_.items.length})`]),f.has(_.key)?null:_.items.map(R=>{let z=R.path+(R.staged?":s":":w");return Hr(R,{selected:a.has(z),active:w?.path===R.path&&w.base===(R.staged?"staged":"worktree"),busy:p,armed:T===z,onToggle:()=>B(z),onOpen:()=>void D(R.path,R.staged?"staged":"worktree"),onStage:()=>void q(R.staged?{kind:"unstage",paths:[R.path]}:{kind:"stage",paths:[R.path]}),onDiscard:()=>{T===z?(q({kind:"discard",paths:[R.path]}),E(null)):E(z)},t:n})})]))),(0,m.createElement)("div",{key:"box",className:"gp-commitbox"},[(0,m.createElement)("textarea",{key:"msg",className:"gp-commitbox__msg",placeholder:n("commit.placeholder"),value:o,onChange:_=>l(_.target.value)}),(0,m.createElement)("div",{key:"row",className:"gp-commitbox__row"},[(0,m.createElement)("label",{key:"amend",className:"gp-commitbox__amend"},[(0,m.createElement)("input",{key:"cb",type:"checkbox",className:"gp-check",checked:c,onChange:()=>{g(_=>!_),Q(!1)}}),n("commit.amend")]),(0,m.createElement)("div",{key:"actions",className:"gp-commitbox__actions"},[(0,m.createElement)("button",{key:"commit",type:"button",className:"gp-btn gp-btn--primary",disabled:p||o.trim()==="",onClick:()=>void K()},n("commit.commit"))])])])]),ve.divider,(0,m.createElement)("div",{key:"right",className:"gp-changes__right"},w===null?(0,m.createElement)("div",{className:"gp-empty"},n("changes.selectFile")):(0,m.createElement)("div",{className:"gp-diff"},[(0,m.createElement)("div",{key:"tb",className:"gp-diff__toolbar"},[(0,m.createElement)("span",{key:"path",className:"gp-diff__path"},w.path),j?(0,m.createElement)("span",{key:"sum",className:"gp-stats__item",style:{marginLeft:"auto"}},[(0,m.createElement)("span",{key:"a",className:"gp-stats__add"},`+${j.add}`)," ",(0,m.createElement)("span",{key:"d",className:"gp-stats__del"},`\u2212${j.del}`)]):null,(0,m.createElement)("button",{key:"expand",type:"button",className:`gp-seg__btn gp-diff__expand${k?" gp-seg__btn--active":""}`,style:j?{}:{marginLeft:"auto"},disabled:N!=="split"&&N!=="unified",title:n(k?"diff.collapse":"diff.expandAll"),onClick:()=>void D(w.path,w.base,!k)},n(k?"diff.collapse":"diff.expandAll")),(0,m.createElement)("div",{key:"seg",className:"gp-seg"},he(["unified","split","before","after"],N,L,_=>n(`diff.${_}`)))]),(0,m.createElement)("div",{key:"scroll",className:"gp-diff__scroll"},F===null?(0,m.createElement)("div",{className:"gp-empty"},n("common.loading")):(0,m.createElement)(ze,{text:F,mode:N,path:w.path,remote:e,sessionId:t,imageSpec:{base:w.base},t:n}))]))])}function et(e,t){return e.path.localeCompare(t.path)}function Hr(e,t){let r=e.path.split("/").pop()??e.path,i=e.path.includes("/")?e.path.slice(0,e.path.lastIndexOf("/")):"";return(0,m.createElement)("div",{key:e.path+(e.staged?":s":":w"),className:`gp-file-row${t.active?" gp-file-row--active":""}`,onClick:t.onOpen},[(0,m.createElement)("input",{key:"cb",type:"checkbox",className:"gp-check",checked:t.selected,onClick:n=>n.stopPropagation(),onChange:t.onToggle}),(0,m.createElement)("span",{key:"st",className:`gp-status-badge ${Me(e.status)}`},De[e.status]??"?"),(0,m.createElement)("span",{key:"nm",className:"gp-tree-name",title:e.path},[r,i?(0,m.createElement)("span",{key:"d",style:{color:"var(--dsw-alias-label-tertiary)",marginLeft:6,fontSize:11}},i):null]),(0,m.createElement)("span",{key:"act",className:"gp-file-row__actions"},[(0,m.createElement)("button",{key:"stg",type:"button",className:"gp-icon-btn",title:e.staged?t.t("changes.unstage"):t.t("changes.stage"),disabled:t.busy,onClick:n=>{n.stopPropagation(),t.onStage()}},e.staged?"\u2212":"+"),(0,m.createElement)("button",{key:"dis",type:"button",className:"gp-icon-btn",title:t.armed?t.t("changes.discardConfirm"):t.t("changes.discard"),style:t.armed?{color:"var(--dsw-alias-state-error-primary)"}:{},disabled:t.busy,onClick:n=>{n.stopPropagation(),t.onDiscard()}},"\u21BA")])])}var b=require("react");var re=require("@deepseek-ai/dsh-client-ui-primitives");function Bt(e){return/\.(?:md|markdown)$/i.test(e)}function tt({remote:e,sessionId:t,t:r}){let[i,n]=(0,b.useState)(new Map),[a,s]=(0,b.useState)(new Set([""])),[o,l]=(0,b.useState)(null),[c,g]=(0,b.useState)({kind:"idle"}),[p,y]=(0,b.useState)(!1),[h,v]=(0,b.useState)("idle"),f=(0,b.useMemo)(()=>({code:{copyLabel:r("files.copy"),copiedLabel:r("files.copied")},footnotes:r("files.footnotes")}),[r]),u=(0,b.useRef)(0),T=de({storageKey:"gp.files.left",initial:300,min:180,reserve:220,edge:"end"}),E=(0,b.useCallback)(N=>{n(L=>{let k=L.get(N);if(k!==void 0&&k.status!=="error")return L;let A=new Map(L);return A.set(N,{status:"loading"}),A}),e.query({sessionId:t,query:{kind:"dir-list",path:N}}).then(L=>{let k=I(L,"dir-list");n(A=>{let W=new Map(A);return W.set(N,k===null?{status:"error"}:{status:"ready",entries:k.entries,truncated:k.truncated}),W})}).catch(()=>{n(L=>{let k=new Map(L);return k.set(N,{status:"error"}),k})})},[e,t]);(0,b.useEffect)(()=>{E("")},[E]);let w=(0,b.useCallback)(N=>{s(L=>{let k=new Set(L);return k.has(N)?(k.delete(N),k):(k.add(N),i.get(N)===void 0&&E(N),k)})},[i,E]),V=(0,b.useCallback)(N=>{l(N),y(!1),v("idle");let L=++u.current;g({kind:"loading",path:N}),e.query({sessionId:t,query:{kind:"file-content",path:N}}).then(k=>{if(L!==u.current)return;let A=I(k,"file-content");if(A===null){g({kind:"error",path:N});return}if(A.tooLarge===!0){g({kind:"tooLarge",path:N});return}if(A.variant==="image"&&A.dataUrl!==void 0){g({kind:"image",path:N,dataUrl:A.dataUrl});return}if(A.variant==="text"){g({kind:"text",path:N,content:A.content??"",lines:A.lines??0});return}g({kind:"binary",path:N})}).catch(()=>{L===u.current&&g({kind:"error",path:N})})},[e,t]),F=(0,b.useMemo)(()=>Wt("",0,{dirs:i,open:a,selected:o,toggleDir:w,selectFile:V,t:r}),[i,a,o,w,V,r]),$=async()=>{if(o===null)return;let N=u.current;try{await navigator.clipboard.writeText(o),N===u.current&&v("copied")}catch{N===u.current&&v("error")}};return(0,b.createElement)("div",{className:"gp-files"},[(0,b.createElement)("div",{key:"left",className:"gp-files__tree",style:{flex:`0 0 ${T.width}px`}},F),T.divider,(0,b.createElement)("div",{key:"right",className:"gp-files__preview"},[o!==null?(0,b.createElement)("div",{key:"bar",className:"gp-files__bar"},[(0,b.createElement)("code",{key:"path",className:"gp-files__path",title:o},o),c.kind==="text"&&Bt(c.path)?(0,b.createElement)("div",{key:"mode",className:"gp-files__mode",role:"group","aria-label":r("files.previewMode")},[(0,b.createElement)("button",{key:"source",type:"button",className:`gp-files__mode-btn${p?"":" gp-files__mode-btn--active"}`,"aria-pressed":!p,onClick:()=>y(!1)},r("files.source")),(0,b.createElement)("button",{key:"render",type:"button",className:`gp-files__mode-btn${p?" gp-files__mode-btn--active":""}`,"aria-pressed":p,onClick:()=>y(!0)},r("files.render"))]):null,(0,b.createElement)("button",{key:"copy",type:"button",className:`gp-files__copy-path${h==="error"?" gp-files__copy-path--error":""}`,"aria-live":"polite",onClick:()=>{$()}},r(h==="copied"?"files.pathCopied":h==="error"?"files.pathCopyFailed":"files.copyPath"))]):null,(0,b.createElement)("div",{key:"content",className:"gp-files__preview-content"},c.kind==="text"&&p&&Bt(c.path)?(0,b.createElement)("div",{className:"gp-files__markdown"},(0,b.createElement)(re.MarkdownText,{text:c.content,labels:f,variant:"body"})):Vr(c,r))])])}function Wt(e,t,r){let i=r.dirs.get(e);if(i===void 0||i.status==="loading")return t===0?[(0,b.createElement)("div",{key:"l",className:"gp-empty"},r.t("common.loading"))]:[(0,b.createElement)("div",{key:`l${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},r.t("common.loading"))];if(i.status==="error")return[(0,b.createElement)("div",{key:`e${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},r.t("files.loadFailed"))];let n=[];for(let a of i.entries){let s=e===""?a.name:`${e}/${a.name}`;if(a.dir){let o=r.open.has(s);n.push((0,b.createElement)("button",{key:s,type:"button",className:`gp-tree-row gp-files__entry gp-files__entry--dir${a.ignored?" gp-tree-row--ignored":""}`,style:{paddingLeft:10+t*14},"aria-expanded":o,"aria-label":a.ignored?`${a.name} (${r.t("files.ignored")})`:a.name,onClick:()=>r.toggleDir(s)},[(0,b.createElement)("span",{key:"c",className:"gp-tree-chev"},(0,b.createElement)(le,{size:11,open:o})),(0,b.createElement)("span",{key:"i",className:"gp-tree-ic"},(0,b.createElement)(re.FileTypeIcon,{kind:"folder",size:18})),(0,b.createElement)("span",{key:"n",className:"gp-tree-name"},a.name)])),o&&n.push(...Wt(s,t+1,r))}else{let o=r.selected===s;n.push((0,b.createElement)("button",{key:s,type:"button",className:`gp-tree-row gp-files__entry${o?" gp-tree-row--active":""}${a.ignored?" gp-tree-row--ignored":""}`,style:{paddingLeft:10+t*14},"aria-current":o?"true":void 0,"aria-label":a.ignored?`${a.name} (${r.t("files.ignored")})`:a.name,onClick:()=>r.selectFile(s)},[(0,b.createElement)("span",{key:"c",className:"gp-tree-chev"}),(0,b.createElement)("span",{key:"i",className:"gp-tree-ic"},(0,b.createElement)(re.FileTypeIcon,{path:s,size:18})),(0,b.createElement)("span",{key:"n",className:"gp-tree-name"},a.name)]))}}return i.truncated&&n.push((0,b.createElement)("div",{key:`t${e}`,className:"gp-tree-row gp-tree-row--muted",style:{paddingLeft:10+t*14}},r.t("files.truncated"))),n}function Vr(e,t){switch(e.kind){case"idle":return(0,b.createElement)("div",{className:"gp-empty"},t("files.selectFile"));case"loading":return(0,b.createElement)("div",{className:"gp-empty"},t("common.loading"));case"error":return(0,b.createElement)("div",{className:"gp-empty"},t("files.loadFailed"));case"tooLarge":return(0,b.createElement)("div",{className:"gp-empty"},t("files.tooLarge"));case"binary":return(0,b.createElement)("div",{className:"gp-empty"},t("files.binary"));case"image":return(0,b.createElement)("div",{className:"gp-files__image"},(0,b.createElement)("img",{src:e.dataUrl,alt:e.path}));case"text":return(0,b.createElement)("div",{className:"gp-files__code gp-diff__scroll"},(0,b.createElement)(Xr,{content:e.content,path:e.path}))}}function Xr({content:e,path:t}){let r=(0,re.languageForPath)(t),i=(0,re.useCodeHighlighter)(r),n=(0,b.useMemo)(()=>{let s=e.split(`
|
|
306
|
+
`);return s.length>0&&s[s.length-1]===""&&s.pop(),s},[e]),a=(0,b.useMemo)(()=>i(n.join(`
|
|
307
|
+
`)),[i,n]);return(0,b.createElement)("div",{className:"gp-files__single"},n.flatMap((s,o)=>[(0,b.createElement)("div",{key:`n${o}`,className:"gp-diff-no"},o+1),(0,b.createElement)("div",{key:`c${o}`,className:"gp-diff-cell"},s===""?"\xA0":a?.[o]!==void 0?a[o].map((l,c)=>(0,b.createElement)("span",{key:c,style:l.style},l.text)):s)]))}var Ot="gp.panel.fontDelta";function Ir(){if(typeof localStorage>"u")return 0;let e=Number(localStorage.getItem(Ot));return e===-1||e===1?e:0}function jt({ctx:e,sessionId:t,t:r}){let[i,n]=(0,x.useState)(Ir),[a,s]=(0,x.useState)(null),o=Te(t),l=we(e),c=o.state==="error"&&o.error.code==="not-a-git-repo",g=c?"files":a!==null&&a.sessionId===t?a.tab:null,p=(0,x.useRef)({tabs:new Set});p.current.sessionId!==t&&(p.current={sessionId:t,tabs:new Set}),g!==null&&p.current.tabs.add(g);let y=p.current.tabs.has("files");(0,x.useEffect)(()=>{if(!ae(t))return;if(c){s(null);return}if(a?.sessionId===t)return;let w=mt(t);if(w!==null){s({sessionId:t,tab:w});return}o.state==="ready"&&s({sessionId:t,tab:o.snapshot.dirty?"changes":"overview"})},[t,o,c,a?.sessionId]),(0,x.useEffect)(()=>{if(ae(t))return ht(t,w=>s({sessionId:t,tab:w}))},[t]);let h=o.state==="ready"?o.snapshot.checkedAt:0,v=async w=>{if(!ae(t))return{ok:!1,error:r("error.noCwd")};let V=await l.run({sessionId:t,action:w});return V.ok?(Be(t).accept(V.snapshot),{ok:!0}):{ok:!1,error:qr(V.error.code,V.error.message,r)}},f=w=>{n(w),typeof localStorage<"u"&&localStorage.setItem(Ot,String(w))},u=[{key:"overview",label:r("tab.overview"),icon:(0,x.createElement)(Re,{size:14})},{key:"changes",label:r("tab.changes"),icon:(0,x.createElement)(bt,{size:14})},{key:"files",label:r("tab.files"),icon:(0,x.createElement)(kt,{size:14})}],T=c?u.filter(w=>w.key==="files"):u,E=(()=>{if(!ae(t))return(0,x.createElement)("div",{className:"gp-empty"},r("error.noCwd"));if(o.state==="no-cwd")return(0,x.createElement)("div",{className:"gp-empty"},r("error.noCwd"));if(c)return(0,x.createElement)("div",{style:{display:"contents"}},y?(0,x.createElement)(tt,{key:t,remote:l,sessionId:t,t:r}):null);if(o.state==="error")return(0,x.createElement)("div",{className:"gp-empty"},r("pill.unavailable"));if(o.state==="cold"||o.state==="loading"||g===null)return(0,x.createElement)("div",{className:"gp-empty"},r("common.loading"));let w=o.snapshot;return(0,x.createElement)("div",{style:{display:"contents"}},[p.current.tabs.has("overview")?(0,x.createElement)("div",{key:"overview",style:g==="overview"?{display:"contents"}:{display:"none"}},(0,x.createElement)(qt,{key:t,remote:l,sessionId:t,refreshKey:h,defaultDiffView:w.defaultDiffView,t:r})):null,p.current.tabs.has("changes")?(0,x.createElement)("div",{key:"changes",style:g==="changes"?{display:"contents"}:{display:"none"}},(0,x.createElement)(Kt,{key:t,remote:l,sessionId:t,snapshot:w,onAction:v,t:r})):null,y?(0,x.createElement)("div",{key:"files",style:g==="files"?{display:"contents"}:{display:"none"}},(0,x.createElement)(tt,{key:t,remote:l,sessionId:t,t:r})):null])})();return(0,x.createElement)("div",{className:"gp-panel","data-conversation-composer-overlay":"","data-font-delta":i},[(0,x.createElement)("div",{key:"tabs",className:"gp-tabbar",role:"tablist"},[...T.map(w=>(0,x.createElement)("button",{key:w.key,type:"button",role:"tab","aria-selected":g===w.key,className:`gp-tab${g===w.key?" gp-tab--active":""}`,onClick:()=>{ae(t)&&s({sessionId:t,tab:w.key})}},[(0,x.createElement)("span",{key:"i",className:"gp-tab__icon"},w.icon),w.label])),(0,x.createElement)("div",{key:"font",className:"gp-font"},[(0,x.createElement)("button",{key:"dec",type:"button",className:"gp-font__decrease",onClick:()=>f(-1),"aria-label":r("panel.fontDecrease")},"A\u2212"),(0,x.createElement)("button",{key:"reset",type:"button",className:"gp-font__reset",onClick:()=>f(0),"aria-label":r("panel.fontReset")},"A"),(0,x.createElement)("button",{key:"inc",type:"button",className:"gp-font__increase",onClick:()=>f(1),"aria-label":r("panel.fontIncrease")},"A+")]),(0,x.createElement)(Jr,{key:"ver",remote:l,t:r})]),(0,x.createElement)("div",{key:"body",className:"gp-body"},E)])}function qr(e,t,r){switch(e){case"empty-message":return r("error.emptyMessage");case"not-a-git-repo":return r("error.notARepo");case"cwd-unavailable":return r("error.noCwd");case"local-changes-block":return r("error.localChangesBlock");default:return t??r("error.generic")}}function Jr({remote:e,t}){let[r,i]=(0,x.useState)({kind:"idle"});(0,x.useEffect)(()=>{let o=!0;return e.version({}).then(l=>{o&&"current"in l&&i(c=>({...c,info:l}))}),()=>{o=!1}},[e]);let n=async()=>{i(l=>({kind:"checking",info:l.info}));let o=await e.version({check:!0});i({kind:"idle",info:"current"in o?o:void 0})},a=r.info,s=r.kind==="checking"?(0,x.createElement)("span",{className:"gp-verbar__status"},t("version.checking")):a===void 0||!a.checkedRemote?null:a.error!==void 0?(0,x.createElement)("span",{className:"gp-verbar__status gp-verbar__status--err",title:a.error},a.error==="repository is not configured"?t("version.noRepo"):t("version.error")):a.updateAvailable&&a.latest!==void 0?(0,x.createElement)("span",{},[(0,x.createElement)("span",{key:"s",className:"gp-verbar__status gp-verbar__status--new"},t("version.updateAvailable",{latest:a.latest,current:a.current})),a.releaseUrl!==void 0?(0,x.createElement)("a",{key:"l",className:"gp-verbar__link",href:a.releaseUrl,target:"_blank",rel:"noreferrer",style:{marginLeft:8}},t("version.viewRelease")):null]):(0,x.createElement)("span",{className:"gp-verbar__status gp-verbar__status--ok"},t("version.upToDate",{current:a.current}));return(0,x.createElement)("div",{className:"gp-verbar"},[a!==void 0?(0,x.createElement)("span",{key:"tag",className:"gp-verbar__tag"},`v${a.current}`):null,s,(0,x.createElement)("button",{key:"btn",type:"button",className:"gp-verbar__btn",disabled:r.kind==="checking",onClick:()=>void n()},[(0,x.createElement)("span",{key:"i",className:"gp-tab__icon"},(0,x.createElement)(Ee,{size:12})),t("version.check")]),a?.repositoryUrl!==void 0?(0,x.createElement)("a",{key:"gh",className:"gp-icon-btn gp-verbar__gh",href:a.repositoryUrl,target:"_blank",rel:"noreferrer",title:t("version.openRepo"),"aria-label":t("version.openRepo")},(0,x.createElement)(_t,{size:15})):null])}var H=require("react"),Zt=require("react-dom");var Ut="data-gp-tab-dot",be,rt=null,Qt="",Xe=null,Ve;function Kr(e){if(typeof document>"u")return null;let t=document.querySelectorAll(Oe);for(let r of t)if((r.textContent??"").trim()===e)return r;return null}function nt(){let e=Kr(Qt);if(e===null)return;let t=e.querySelector(`[${Ut}]`);if(Xe===null){t?.remove();return}let r=`gp-tab-dot gp-tab-dot--${Xe}`;if(t!==null){t.className!==r&&(t.className=r);return}let i=document.createElement("span");i.className=r,i.setAttribute(Ut,""),i.setAttribute("aria-hidden","true"),e.appendChild(i)}function Br(){if(typeof document>"u"||typeof MutationObserver>"u")return;let e=document.querySelector(gt);if(e!==rt){if(be?.disconnect(),rt=e,e===null){be=void 0;return}be=new MutationObserver(()=>nt()),be.observe(e,{childList:!0,subtree:!0})}}function Wr(){be?.disconnect(),be=void 0,rt=null}function Yt(e,t,r){if(!(typeof document>"u")){if(r===null){it(e);return}Ve=e,Qt=t,Xe=r,Br(),nt()}}function it(e){Ve!==void 0&&Ve!==e||(Ve=void 0,Xe=null,nt(),Wr())}function Or(e){let t=e.replace(/[/\\]+$/,"").split(/[/\\]/);return t[t.length-1]||e}function jr(){let[e,t]=(0,H.useState)(!1),[r,i]=(0,H.useState)(null),n=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{if(!e||n.current===null){i(null);return}let o=n.current.getBoundingClientRect();i({left:o.left,bottom:window.innerHeight-o.top+8})},[e]),{bind:{ref:o=>{n.current=o},onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1)},render:o=>!e||r===null||typeof document>"u"?null:(0,Zt.createPortal)((0,H.createElement)("div",{className:"gp-tip",style:{left:r.left,bottom:r.bottom}},o.map((l,c)=>(0,H.createElement)("div",{key:c,className:c===0?"gp-tip__path":"gp-tip__note"},l))),document.body)}}function Ur(e){let[t,r]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{if(e===null||typeof ResizeObserver>"u")return;let n=e.closest("[data-conversation-region]")??document.body,a=()=>r(n.clientWidth>0&&n.clientWidth<Qr);a();let s=new ResizeObserver(a);return s.observe(n),()=>s.disconnect()},[e]),t}var Qr=620;function er({sessionId:e,t}){let r=Te(e),i=jr(),[n,a]=(0,H.useState)(null),s=Ur(n),o=(0,H.useRef)(Symbol("gp-tab-dot")),l=r.state==="ready"&&r.snapshot.showInputPill===!1?r.snapshot.dirty?"dirty":"synced":null,c=t("panel.tab");if((0,H.useEffect)(()=>{Yt(o.current,c,l);let u=o.current;return()=>{it(u)}},[c,l]),r.state==="cold"||r.state==="loading"||r.state==="no-cwd")return null;if(r.state==="error")return r.error.code==="not-a-git-repo"||r.error.showInputPill===!1?null:(0,H.createElement)("span",{className:"gp-pill gp-pill--degraded",title:r.error.detail??t("pill.unavailable")},t("pill.unavailable"));let g=r.snapshot;if(g.showInputPill===!1)return null;let p=Or(g.root),y=g.branch??`(${t("pill.detached")})`,h=g.dirty,v=h?"gp-pill--dirty":"gp-pill--synced",f=()=>{ae(e)&&ut(e,h?"changes":"overview"),yt(t("panel.tab"))};return(0,H.createElement)("span",{className:"gp-pill-wrap",ref:a},[(0,H.createElement)("button",{key:"btn",type:"button",className:`gp-pill ${v}${s?" gp-pill--compact":""}`,onClick:f,ref:i.bind.ref,onMouseEnter:i.bind.onMouseEnter,onMouseLeave:i.bind.onMouseLeave},[(0,H.createElement)("span",{key:"dot",className:"gp-pill__dot","aria-hidden":"true"}),(0,H.createElement)("span",{key:"repo",className:"gp-pill__repo"},p),(0,H.createElement)("span",{key:"git",className:"gp-pill__git"},["(",(0,H.createElement)("span",{key:"b",className:"gp-pill__branch"},y),")"])]),i.render([g.root,t(h?"pill.dirty":"pill.synced")])])}var P=require("react");function Yr(e){for(let t of e){let r=t.schema?.dict;if(r!==void 0&&"showInputPill"in r||JSON.stringify(t.schema).includes("showInputPill"))return t.ns}}function tr({ctx:e,t}){let[,r]=(0,P.useState)(0),[i,n]=(0,P.useState)(!1),[a,s]=(0,P.useState)(!1),[o,l]=(0,P.useState)(null),[c,g]=(0,P.useState)(null),p=()=>{r(k=>k+1)},y=e.get("configForms"),h=(0,P.useMemo)(()=>y?.describe(),[y]);(0,P.useEffect)(()=>{if(h!==void 0)return h.ensure(),h.subscribe(p)},[h]);let v=h?.getSnapshot().view,f=(0,P.useMemo)(()=>v===void 0?void 0:Yr(v.namespaces),[v]),u=(0,P.useMemo)(()=>y!==void 0&&f!==void 0?y.get(f):void 0,[y,f]);(0,P.useEffect)(()=>{if(u!==void 0)return u.subscribe(p)},[u]);let T=u?.getSnapshot(),E=u!==void 0&&T!==void 0&&T.status==="ready",w=h?.getSnapshot().status,V=o??(typeof T?.value?.showInputPill=="boolean"?T.value.showInputPill:!0),F=c??(T?.value?.defaultDiffView==="split"?"split":"unified"),$=async(k,A,W)=>{if(u!==void 0){s(!1),n(!0);try{let Q=await u.set(k,A);W(),Q?(xe(),setTimeout(()=>xe(),1e3)):s(!0)}catch{W(),s(!0)}finally{n(!1)}}},N=k=>(l(k),$("showInputPill",k,()=>l(null))),L=k=>k===F?Promise.resolve():(g(k),$("defaultDiffView",k,()=>g(null)));return y===void 0?(0,P.createElement)("p",{className:"gp-cfg__hint"},t("cfg.notLoaded")):E?(0,P.createElement)("div",{className:"gp-cfg"},[(0,P.createElement)("h3",{key:"title",className:"gp-cfg__title"},t("cfg.title")),(0,P.createElement)("label",{key:"row",className:"gp-cfg__row"},[(0,P.createElement)("input",{key:"switch",type:"checkbox",role:"switch",className:"gp-cfg__switch",checked:V,disabled:i||T?.writable===!1,onChange:k=>{N(k.currentTarget.checked)}}),(0,P.createElement)("span",{key:"text",className:"gp-cfg__text"},t("cfg.toggle"))]),(0,P.createElement)("p",{key:"hint",className:"gp-cfg__hint"},t("cfg.hint")),(0,P.createElement)("h3",{key:"difftitle",className:"gp-cfg__title",style:{marginTop:6}},t("cfg.diffTitle")),(0,P.createElement)("div",{key:"diffseg",className:"gp-seg gp-cfg__seg"},he(["unified","split"],F,k=>{L(k)},k=>t(k==="unified"?"cfg.diffUnified":"cfg.diffSplit"),i||T?.writable===!1)),(0,P.createElement)("p",{key:"diffhint",className:"gp-cfg__hint"},t("cfg.diffHint")),a?(0,P.createElement)("p",{key:"error",className:"gp-cfg__err",role:"alert"},t("cfg.saveFailed")):null]):w==="idle"||w==="loading"?(0,P.createElement)("p",{className:"gp-cfg__hint"},t("common.loading")):(0,P.createElement)("p",{className:"gp-cfg__hint"},t("cfg.notLoaded"))}var Se="gitPanel",Zr=["dsh-git-panel","@xbzbing/dsh-git-panel"],en=["slots","locale","connection"],tn="dsh-git-panel";function rn(e){ot(),pt(e),e.effect(()=>e.locale.register(Se,{zh:st,en:lt})??void 0,"dsh-git-panel: dictionaries");let t=e.locale.bind(Se),r=[],i=n=>{typeof n=="function"&&r.push(n)};i(e.slots.inject("conversation.view",()=>e.slots.register({name:"conversation.view",id:"git-panel",order:30,locale:Se,label:()=>t("panel.tab")},n=>(0,Ie.createElement)(jt,{ctx:e,sessionId:n.sessionId,t})))),i(e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"git-panel-pill",order:100,locale:Se},n=>(0,Ie.createElement)(er,{sessionId:n.sessionId,t}))));for(let n of Zr)i(e.slots.inject("plugins.bundle.config",()=>e.slots.register({name:"plugins.bundle.config",key:n,locale:Se},a=>a.view==="summary"?t("cfg.title"):(0,Ie.createElement)(tr,{ctx:e,t}))));e.effect(()=>{let n=e.on("connection/reset",()=>xe());return()=>{typeof n=="function"&&n();for(let a of r.splice(0))try{a()}catch{}ft()}},"dsh-git-panel: lifecycle")}module.exports={name:tn,inject:en,apply:rn};
|
|
309
308
|
return module.exports;
|
|
310
309
|
} });
|
package/lib/host/index.js
CHANGED
|
@@ -423,7 +423,7 @@ async function snapshotForSession(deps, config, sessionId) {
|
|
|
423
423
|
]);
|
|
424
424
|
const branch = "run" in branchRes && branchRes.run.exitCode === 0 ? branchRes.run.stdout.trim() || null : null;
|
|
425
425
|
const unborn = "run" in headRes && headRes.run.exitCode !== 0;
|
|
426
|
-
const head =
|
|
426
|
+
const head = "run" in headRes && headRes.run.exitCode === 0 ? headRes.run.stdout.trim() || null : null;
|
|
427
427
|
let allChanges = [];
|
|
428
428
|
let statusLossy = false;
|
|
429
429
|
if ("run" in statusRes && !statusRes.run.timedOut && statusRes.run.exitCode === 0) {
|
|
@@ -721,26 +721,18 @@ async function queryHistory(deps, root, q) {
|
|
|
721
721
|
const hexJump = search !== "" && isHexLike(search);
|
|
722
722
|
const countArgs = ["git", "rev-list", "--count"];
|
|
723
723
|
if (!hexJump) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
if (q.author !== void 0 && q.author !== "") {
|
|
729
|
-
args.push(`--author=${q.author}`);
|
|
730
|
-
countArgs.push(`--author=${q.author}`);
|
|
731
|
-
}
|
|
732
|
-
if (q.since !== void 0 && q.since !== "") {
|
|
733
|
-
args.push(`--since=${q.since}`);
|
|
734
|
-
countArgs.push(`--since=${q.since}`);
|
|
735
|
-
}
|
|
724
|
+
const filters = [];
|
|
725
|
+
if (search !== "") filters.push("-i", "-E", `--grep=${search}`);
|
|
726
|
+
if (q.author !== void 0 && q.author !== "") filters.push(`--author=${q.author}`);
|
|
727
|
+
if (q.since !== void 0 && q.since !== "") filters.push(`--since=${q.since}`);
|
|
736
728
|
if (q.ref !== void 0 && q.ref !== "") {
|
|
737
729
|
if (!isSafeRev(q.ref)) return { ok: false, error: { code: "invalid-name", message: `unsafe ref: ${q.ref}` } };
|
|
738
|
-
|
|
739
|
-
countArgs.push("--end-of-options", q.ref);
|
|
730
|
+
filters.push("--end-of-options", q.ref);
|
|
740
731
|
} else {
|
|
741
|
-
|
|
742
|
-
countArgs.push("--all");
|
|
732
|
+
filters.push("--all");
|
|
743
733
|
}
|
|
734
|
+
args.push(...filters);
|
|
735
|
+
countArgs.push(...filters);
|
|
744
736
|
} else {
|
|
745
737
|
args.push("--end-of-options", search);
|
|
746
738
|
}
|
|
@@ -760,9 +752,7 @@ async function queryHistory(deps, root, q) {
|
|
|
760
752
|
}
|
|
761
753
|
const commits = parseGraphLog(res.run.stdout);
|
|
762
754
|
let total = -1;
|
|
763
|
-
if (hexJump) {
|
|
764
|
-
total = -1;
|
|
765
|
-
} else if (countRes !== null && "run" in countRes && countRes.run.exitCode === 0) {
|
|
755
|
+
if (!hexJump && countRes !== null && "run" in countRes && countRes.run.exitCode === 0) {
|
|
766
756
|
const n = Number(countRes.run.stdout.trim());
|
|
767
757
|
if (Number.isFinite(n)) total = n;
|
|
768
758
|
}
|
|
@@ -990,14 +980,15 @@ async function queryFileContent(deps, config, root, q) {
|
|
|
990
980
|
return { ok: false, error: { code: "git-error", message: error instanceof Error ? error.message : "stat failed" } };
|
|
991
981
|
}
|
|
992
982
|
const mime = imageMimeFor(q.path);
|
|
993
|
-
|
|
983
|
+
const tooLarge = { ok: true, value: { kind: "file-content", path: q.path, variant: mime !== null ? "image" : "text", tooLarge: true } };
|
|
984
|
+
if (info.size > cap) return tooLarge;
|
|
994
985
|
let buf;
|
|
995
986
|
try {
|
|
996
987
|
buf = await deps.fs.readFile(file);
|
|
997
988
|
} catch (error) {
|
|
998
989
|
return { ok: false, error: { code: "git-error", message: error instanceof Error ? error.message : "read failed" } };
|
|
999
990
|
}
|
|
1000
|
-
if (buf.length > cap) return
|
|
991
|
+
if (buf.length > cap) return tooLarge;
|
|
1001
992
|
if (mime !== null) {
|
|
1002
993
|
return { ok: true, value: { kind: "file-content", path: q.path, variant: "image", dataUrl: `data:${mime};base64,${buf.toString("base64")}` } };
|
|
1003
994
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbzbing/dsh-git-panel",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "DeepSeek Harness (dsh) plugin: an IDE-style Git panel in the Web GUI — branch/history overview, uncommitted changes with commit & amend, diff stats, and a zsh-style branch marker in the input bar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
],
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
74
|
+
"@deepseek-ai/dsh": ">=0.1.7-rc.2",
|
|
74
75
|
"@deepseek-ai/dsh-session": ">=0.1.2-rc.1",
|
|
75
76
|
"@deepseek-ai/dsh-subprocess": ">=0.1.2-rc.1",
|
|
76
77
|
"@deepseek-ai/dsh-typert-protocol": ">=0.1.2-rc.1",
|