tmex-cli 0.12.4 → 0.13.0
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/CHANGELOG.md +16 -6
- package/dist/runtime/server.js +1639 -102
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-Cj9jwadE.js +19 -0
- package/resources/fe-dist/assets/DevicesPage-BbypaGC7.js +1 -0
- package/resources/fe-dist/assets/{FilePage-D1t8_zlX.js → FilePage-CbHZVJbn.js} +3 -4
- package/resources/fe-dist/assets/SettingsPage-CCV0NSQF.js +39 -0
- package/resources/fe-dist/assets/agent-tab-DPwxh08T.js +38 -0
- package/resources/fe-dist/assets/api-DlcFE5in.js +10 -0
- package/resources/fe-dist/assets/{arc-Cv0H1Phu.js → arc-Bzmm6y8F.js} +1 -2
- package/resources/fe-dist/assets/{architectureDiagram-3BPJPVTR-DG7npZeK.js → architectureDiagram-3BPJPVTR-BdsN6XRe.js} +1 -2
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-weB7PKUK.js → blockDiagram-GPEHLZMM-CXdQhkqo.js} +1 -2
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-C0sEabtp.js → c4Diagram-AAUBKEIU-CE_W2_pV.js} +1 -2
- package/resources/fe-dist/assets/{card-Spfb5xRZ.js → card-B_sl9KIo.js} +1 -2
- package/resources/fe-dist/assets/channel-CuapxAWT.js +1 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-BxOp2sIC.js → chunk-2J33WTMH-BAdEIJQO.js} +1 -2
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-bhg4hxVT.js → chunk-4BX2VUAB-BZ0yj21c.js} +1 -2
- package/resources/fe-dist/assets/{chunk-55IACEB6-v6jayOak.js → chunk-55IACEB6-BknLtkSo.js} +1 -2
- package/resources/fe-dist/assets/{chunk-727SXJPM-IY0KVws8.js → chunk-727SXJPM-CxVON9n5.js} +1 -2
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-CgwymoWa.js → chunk-AQP2D5EJ-CLqOK2pR.js} +1 -2
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-DN35690f.js → chunk-FMBD7UC4-Dt5Vot-R.js} +1 -2
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-lJmtxdhS.js → chunk-ND2GUHAM-t9HYlb8C.js} +1 -2
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-DFeaB8rn.js → chunk-QZHKN3VN-DZReNtLB.js} +1 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-C0k136Ud.js +1 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-C0k136Ud.js +1 -0
- package/resources/fe-dist/assets/copy-Z9Fsj1r-.js +6 -0
- package/resources/fe-dist/assets/{cose-bilkent-S5V4N54A-Dw2yYQz4.js → cose-bilkent-S5V4N54A-BCTtGF2n.js} +1 -2
- package/resources/fe-dist/assets/cytoscape.esm-DTSO7Bv0.js +0 -1
- package/resources/fe-dist/assets/{dagre-BM42HDAG-BeMjJ7ln.js → dagre-BM42HDAG-BQ48EqSj.js} +1 -2
- package/resources/fe-dist/assets/defaultLocale-DX6XiGOO.js +0 -1
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-Dur8_CuN.js → diagram-2AECGRRQ-BXjt2moR.js} +1 -2
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-GJc7gVa_.js → diagram-5GNKFQAL-B2bvNTQO.js} +1 -2
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-pxckXfjw.js → diagram-KO2AKTUF-DLHWfbBH.js} +1 -2
- package/resources/fe-dist/assets/{diagram-LMA3HP47-B9E8-X7C.js → diagram-LMA3HP47-BCFT3Bur.js} +1 -2
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-DrhHw5wy.js → diagram-OG6HWLK6-bNZtxUJ2.js} +1 -2
- package/resources/fe-dist/assets/en_US-B07wSHDj.js +1 -0
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-DY9Wg1A1.js → erDiagram-TEJ5UH35-KoAzrx4j.js} +1 -2
- package/resources/fe-dist/assets/files-tab-DdBDTjfs.js +70 -0
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-eq3WE9d6.js → flowDiagram-I6XJVG4X-C6wGExWt.js} +1 -2
- package/resources/fe-dist/assets/{ganttDiagram-6RSMTGT7-BlXISXe1.js → ganttDiagram-6RSMTGT7-BIWybjes.js} +1 -2
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-Bg-xHeIY.js → gitGraphDiagram-PVQCEYII-CD6tz24l.js} +1 -2
- package/resources/fe-dist/assets/graph-CAnANduQ.js +0 -1
- package/resources/fe-dist/assets/index-CUCrFB_J.js +29 -0
- package/resources/fe-dist/assets/index-CwH-l50P.js +299 -0
- package/resources/fe-dist/assets/index-D-q7dOhH.css +1 -0
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-CW2drAHG.js → infoDiagram-5YYISTIA-CrI-qlYw.js} +1 -2
- package/resources/fe-dist/assets/init-Gi6I4Gst.js +0 -1
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-Qchz0nqR.js → ishikawaDiagram-YF4QCWOH-D9v5anxN.js} +1 -2
- package/resources/fe-dist/assets/ja_JP-DjF6Lrmx.js +1 -0
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-Dk-UsexE.js → journeyDiagram-JHISSGLW-BH38CiJ0.js} +1 -2
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-DKeGp7b5.js → kanban-definition-UN3LZRKU-CKZ3_oXD.js} +1 -2
- package/resources/fe-dist/assets/layout-DGIYPm2g.js +0 -1
- package/resources/fe-dist/assets/{linear-Bt4f_qDW.js → linear-C_oE01xA.js} +1 -2
- package/resources/fe-dist/assets/{markdown-preview-DXv9GzaA.js → markdown-preview-BtNbNwlP.js} +6 -7
- package/resources/fe-dist/assets/{mermaid.core-B-wSkmMd.js → mermaid.core-4dbvlhht.js} +5 -6
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-DXBwCMXu.js → mindmap-definition-RKZ34NQL-C5o4mnnX.js} +1 -2
- package/resources/fe-dist/assets/ordinal-BENe2yWM.js +0 -1
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5--KxRgbWG.js → pieDiagram-4H26LBE5-2ss3HotB.js} +1 -2
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-DqXsCI9E.js → quadrantDiagram-W4KKPZXB-Bolcfx55.js} +1 -2
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-C2KeTWqB.js → requirementDiagram-4Y6WPE33-B-atSHRR.js} +1 -2
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-CC5tcr7d.js → sankeyDiagram-5OEKKPKP-ByynRcAV.js} +1 -2
- package/resources/fe-dist/assets/selection-clipboard-Dq6Zemfd.js +1 -0
- package/resources/fe-dist/assets/send-D0P5wgcD.js +11 -0
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-CqlMDtOG.js → sequenceDiagram-3UESZ5HK-CNC9IxV4.js} +1 -2
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-CVcrlBiw.js → stateDiagram-AJRCARHV-CqzYDImp.js} +1 -2
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-C3azxyWE.js +1 -0
- package/resources/fe-dist/assets/{terminal-settings-panel-CYV9svzz.js → terminal-settings-panel-cjw9P_wY.js} +6 -7
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-CEBskfkL.js → timeline-definition-PNZ67QCA-C38KIECs.js} +1 -2
- package/resources/fe-dist/assets/transfer-toast-5tb-zYhi.js +6 -0
- package/resources/fe-dist/assets/triangle-alert-CQzql6mY.js +6 -0
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-CrxyVTtu.js → vennDiagram-CIIHVFJN-BJudKfzJ.js} +1 -2
- package/resources/fe-dist/assets/{wardley-L42UT6IY-CSmsRb8z.js → wardley-L42UT6IY-B6p_luMy.js} +1 -2
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-DoDzNeOA.js → wardleyDiagram-YWT4CUSO-DZJeOiWQ.js} +1 -2
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-Dbq_OKsv.js → xychartDiagram-2RQKCTM6-DOMCute2.js} +1 -2
- package/resources/fe-dist/assets/zap-DWNtdoic.js +6 -0
- package/resources/fe-dist/assets/zh_CN-D10j4J8Y.js +1 -0
- package/resources/fe-dist/index.html +2 -2
- package/resources/gateway-drizzle/0010_lucky_kabuki.sql +32 -0
- package/resources/gateway-drizzle/meta/_journal.json +7 -0
- package/resources/fe-dist/assets/DevicePage-C4JS6baR.js +0 -15
- package/resources/fe-dist/assets/DevicesPage-p0CfWP1T.js +0 -2
- package/resources/fe-dist/assets/SettingsPage-Cq6n8Xjc.js +0 -27
- package/resources/fe-dist/assets/channel-DDiDKfY0.js +0 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-CXFjdzka.js +0 -2
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-CXFjdzka.js +0 -2
- package/resources/fe-dist/assets/index-CXIj7HZi.css +0 -1
- package/resources/fe-dist/assets/index-CYmVLCAD.js +0 -488
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-B0BDuZBM.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var oe=Object.defineProperty;var re=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var h=(e,t,n)=>re(e,typeof t!="symbol"?t+"":t,n);import{
|
|
1
|
+
var oe=Object.defineProperty;var re=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var h=(e,t,n)=>re(e,typeof t!="symbol"?t+"":t,n);import{Y as P,u as N,j as a,ap as st,B as M,X as A,a as le,c as ae,r as w,ar as ce,as as V,e as de,o as mt,am as he,at as ue,au as me,av as fe,aw as pe,K as _,P as ge,ax as ye,ay as xe,az as Se,aA as be,aB as Ce,aC as we,aD as Te,T as Ee,aE as Re,a5 as E,a8 as ve,a7 as ft,a6 as pt,a9 as Me,N as _e,O as Ae,Q as De,aF as He,R as ke,aG as Ne,U as Ie,aH as Be}from"./index-CwH-l50P.js";import{g as Le,h as gt,i as Oe,a as Fe,b as $e,c as Ke,d as yt,e as je,k as Ft}from"./selection-clipboard-Dq6Zemfd.js";import{K as $t}from"./send-D0P5wgcD.js";const Ye=[{id:"paste",type:"action",action:"paste",label:""},{id:"enter",type:"send",label:"Enter",payload:"\r"},{id:"shift-tab",type:"send",label:"SHIFT-TAB",payload:"\x1B[Z"},{id:"esc",type:"send",label:"ESC",payload:"\x1B"},{id:"ctrl-c",type:"send",label:"CTRL-C",payload:""},{id:"ctrl-d",type:"send",label:"CTRL-D",payload:""},{id:"arrow-up",type:"send",label:"↑",payload:"\x1B[A"},{id:"arrow-down",type:"send",label:"↓",payload:"\x1B[B"},{id:"arrow-left",type:"send",label:"←",payload:"\x1B[D"},{id:"arrow-right",type:"send",label:"→",payload:"\x1B[C"},{id:"shift-enter",type:"send",label:"SHIFT-Enter",payload:"\x1B[13;2u"},{id:"backspace",type:"send",label:"Backspace",payload:"\b"}];/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,14 +13,13 @@ var oe=Object.defineProperty;var re=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,config
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ge=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],
|
|
16
|
+
*/const Ge=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],_i=P("refresh-cw",Ge);/**
|
|
17
17
|
* @license lucide-react v0.564.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Ve=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ze=P("rotate-ccw",Ve);function We(e){return`rgb(${e.r} ${e.g} ${e.b})`}const Xe=new Map([[9622,4],[9623,8],[9624,1],[9625,13],[9626,9],[9627,7],[9628,11],[9629,2],[9630,6],[9631,14]]),qe=new Map([[9617,.25],[9618,.5],[9619,.75]]);function Qe(e){return e>=9600&&e<=9631}function z(e){const t=e.getContext("2d");if(!t)throw new Error("2d canvas context unavailable");return t}class Ze{constructor(t){h(this,"kind","canvas");h(this,"mainCanvas");h(this,"selectionCanvas");h(this,"cursorCanvas");h(this,"mainContext");h(this,"selectionContext");h(this,"cursorContext");h(this,"theme");h(this,"fontFamily");h(this,"fontSize");h(this,"cellDimensions",{width:9,height:17});h(this,"deviceCellWidth",9);h(this,"deviceCellHeight",17);h(this,"deviceFontSize",13);h(this,"textTopGap",0);h(this,"textBaselineY",0);h(this,"glyphBoxHeight",0);h(this,"dpr",1);h(this,"cols",0);h(this,"rows",0);h(this,"lastCursor",null);h(this,"frameCount",0);h(this,"lastDrawnRows",[]);h(this,"colorCache",new Map);h(this,"fontCache",new Map);h(this,"cursorBlinkVisible",!0);h(this,"cursorBlinkTimer",null);this.theme=t.theme,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,t.screenElement.style.position="relative",t.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[n,i]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])n.dataset.layer=i,n.style.position="absolute",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",t.screenElement.appendChild(n);this.mainContext=z(this.mainCanvas),this.selectionContext=z(this.selectionCanvas),this.cursorContext=z(this.cursorCanvas)}setTheme(t){this.theme=t,this.colorCache.clear()}render(t){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=t.cellDimensions,this.resize(t.meta.cols,t.meta.rows),this.drawSelection(t.selectionRects??[],t.selectionColor??this.theme.selectionBackground),t.meta.dirty==="clean"){this.drawCursor(t.meta);return}const n=t.meta.dirty==="full",i=n?t.rows:t.rows.filter(s=>s.dirty);let o;if(n)o=t.rows;else{const s=new Set;for(const r of i)s.add(r.y-1),s.add(r.y),s.add(r.y+1);o=t.rows.filter(r=>s.has(r.y))}for(const s of o)this.drawRowBackground(s,t.meta.colors);for(const s of o)this.drawRowForeground(s,t.meta.colors);for(const s of i)this.lastDrawnRows.push(s.y);this.drawCursor(t.meta)}getDebugState(){return{kind:this.kind,frameCount:this.frameCount,lastDrawnRows:[...this.lastDrawnRows]}}dispose(){this.mainCanvas.remove(),this.selectionCanvas.remove(),this.cursorCanvas.remove(),this.colorCache.clear(),this.fontCache.clear(),this.lastCursor=null,this.stopCursorBlink()}startCursorBlink(){this.cursorBlinkTimer||(this.cursorBlinkTimer=setInterval(()=>{this.cursorBlinkVisible=!this.cursorBlinkVisible,this.cursorCanvas.style.opacity=this.cursorBlinkVisible?"1":"0"},1e3))}stopCursorBlink(){this.cursorBlinkTimer&&(clearInterval(this.cursorBlinkTimer),this.cursorBlinkTimer=null),this.cursorBlinkVisible=!0,this.cursorCanvas.style.opacity="1"}resize(t,n){const i=Math.max(1,t),o=Math.max(1,n),s=Math.max(1,globalThis.devicePixelRatio??1),r=Math.max(1,Math.round(this.cellDimensions.width*s)),l=Math.max(1,Math.round(this.cellDimensions.height*s));if(this.cols===i&&this.rows===o&&this.dpr===s&&this.deviceCellWidth===r&&this.deviceCellHeight===l)return;this.cols=i,this.rows=o,this.dpr=s,this.deviceCellWidth=r,this.deviceCellHeight=l,this.deviceFontSize=this.fontSize*s,this.mainContext.font=`${this.deviceFontSize}px ${this.fontFamily}`;const c=this.mainContext.measureText("Mg|qyÅ");let d=c.fontBoundingBoxAscent,m=c.fontBoundingBoxDescent;Number.isFinite(d)&&Number.isFinite(m)&&d>0||(d=this.deviceFontSize*.8,m=this.deviceFontSize*.2),this.glyphBoxHeight=d+m,this.textTopGap=Math.round((l-this.glyphBoxHeight)/2),this.textBaselineY=Math.round(this.textTopGap+d);const g=i*r,S=o*l;for(const y of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])y.width=g,y.height=S,y.style.width=`${g/s}px`,y.style.height=`${S/s}px`;for(const y of[this.mainContext,this.selectionContext,this.cursorContext])y.setTransform(1,0,0,1,0,0),y.textBaseline="alphabetic",y.imageSmoothingEnabled=!1}drawSelection(t,n){if(this.selectionContext.clearRect(0,0,this.selectionCanvas.width,this.selectionCanvas.height),t.length!==0){this.selectionContext.fillStyle=n;for(const i of t)this.selectionContext.fillRect(i.x*this.deviceCellWidth,i.row*this.deviceCellHeight,i.width*this.deviceCellWidth,this.deviceCellHeight)}}drawRowBackground(t,n){const i=t.y*this.deviceCellHeight,o=this.cols*this.deviceCellWidth,s=this.toCss(n.background);this.mainContext.clearRect(0,i,o,this.deviceCellHeight),this.mainContext.fillStyle=s,this.mainContext.fillRect(0,i,o,this.deviceCellHeight);for(const r of t.cells){if(r.widthKind==="spacer-tail"||r.widthKind==="spacer-head")continue;const l=r.style.inverse?r.fgColor??n.foreground:r.bgColor??n.background;if(l.r!==n.background.r||l.g!==n.background.g||l.b!==n.background.b){const c=r.x*this.deviceCellWidth,d=r.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l),this.mainContext.fillRect(c,i,d,this.deviceCellHeight)}}}drawRowForeground(t,n){const i=t.y*this.deviceCellHeight,o=Math.max(1,Math.round(this.dpr));for(const s of t.cells){if(s.widthKind==="spacer-tail"||s.widthKind==="spacer-head"||!s.text||s.style.invisible)continue;const r=s.x*this.deviceCellWidth,l=s.style.inverse?s.bgColor??n.background:s.fgColor??n.foreground,c=s.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l);const d=s.codepoints.length===1&&Qe(s.codepoints[0])?s.codepoints[0]:null;d!==null?this.drawBlockElement(d,r,i,c,this.deviceCellHeight):(this.mainContext.font=this.resolveFont(s.style),this.mainContext.fillText(s.text,r,i+this.textBaselineY));const m=i+this.textTopGap,g=i+this.textTopGap+this.glyphBoxHeight;s.style.underline>0&&this.mainContext.fillRect(r,Math.min(Math.round(g-o),i+this.deviceCellHeight-o),Math.max(c-o,o),o),s.style.strikethrough&&this.mainContext.fillRect(r,Math.round(i+this.textTopGap+this.glyphBoxHeight/2),Math.max(c-o,o),o),s.style.overline&&this.mainContext.fillRect(r,Math.max(i,Math.round(m)),Math.max(c-o,o),o)}}drawBlockElement(t,n,i,o,s){const r=this.mainContext,l=C=>Math.round(o*C/8),c=C=>Math.round(s*C/8),d=(C,p,x,I)=>{r.fillRect(n+C,i+p,x-C,I-p)};if(t===9600){d(0,0,o,c(4));return}if(t>=9601&&t<=9608){d(0,c(8-(t-9600)),o,s);return}if(t>=9609&&t<=9615){d(0,0,l(9616-t),s);return}if(t===9616){d(l(4),0,o,s);return}const m=qe.get(t);if(m!==void 0){const C=r.globalAlpha;r.globalAlpha=C*m,d(0,0,o,s),r.globalAlpha=C;return}if(t===9620){d(0,0,o,c(1));return}if(t===9621){d(l(7),0,o,s);return}const g=Xe.get(t)??0,S=l(4),y=c(4);g&1&&d(0,0,S,y),g&2&&d(S,0,o,y),g&4&&d(0,y,S,s),g&8&&d(S,y,o,s)}drawCursor(t){const n=t.colors,i=t.cursor,o=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cursorCanvas.width,this.cursorCanvas.height),!i.visible||i.x===null||i.y===null){this.lastCursor=null,this.stopCursorBlink();return}const s=i.x*this.deviceCellWidth,r=i.y*this.deviceCellHeight,l=i.wideTail?this.deviceCellWidth*2:this.deviceCellWidth,c=Math.max(1,Math.round(this.dpr)),d=n.cursor??n.foreground,m=this.toCss(d);this.cursorContext.fillStyle=m,this.cursorContext.strokeStyle=m,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(s,r+this.deviceCellHeight-2*c,Math.max(l-c,c),2*c),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:i.x,y:i.y,style:i.style},o&&(o.x!==this.lastCursor.x||o.y!==this.lastCursor.y||o.style!==this.lastCursor.style)&&this.lastDrawnRows.push(o.y)}resolveFont(t){const n=this.deviceFontSize,i=[t.italic?"italic":"normal",t.bold?"700":"400",`${n}px`,this.fontFamily].join("|"),o=this.fontCache.get(i);if(o)return o;const s=`${t.italic?"italic ":""}${t.bold?"700 ":""}${n}px ${this.fontFamily}`;return this.fontCache.set(i,s),s}toCss(t){const n=`${t.r},${t.g},${t.b}`,i=this.colorCache.get(n);if(i)return i;const o=We(t);return this.colorCache.set(n,o),o}}const W=/https?:\/\/[^\s"'`<>()[\]{}]+/g,Je=/[.,;:!?]+$/;function tn(e){let t="";const n=[],i=e.colChars.length;for(let o=0;o<i;o+=1){const s=e.colChars[o];if(!(s===null||s===""))for(let r=0;r<s.length;r+=1)t+=s[r],n.push(o)}return{text:t,colOf:n}}function en(e){let t="";const n=[],i=[];for(let r=0;r<e.length;r+=1){const l=tn(e[r]);for(let c=0;c<l.text.length;c+=1)t+=l.text[c],n.push(r),i.push(l.colOf[c])}const o=[];W.lastIndex=0;let s=W.exec(t);for(;s!==null;){const r=s[0].replace(Je,"");if(r.length>0){const l=s.index,c=l+r.length-1;let d=l;for(let m=l;m<=c;m+=1)(m===c||n[m+1]!==n[m])&&(o.push({lineIndex:n[d],startCol:i[d],endCol:i[m],url:r}),d=m+1)}s=W.exec(t)}return o}const D=0,nn=-2,sn=1,on=2,rn=3,ln=10,an=11,cn=12,dn=13,hn=14,un=15,mn=16,fn=17,pn=1,gn=2,yn=1,xn=2,Sn=3,bn=4,Cn=5,wn=6,Tn=1,En=2,Rn=3,vn=4;function ot(e){if(e.disposed||e.renderStateHandle===0)throw new Error("render state resources already disposed")}function Mn(e){switch(e){case 2:return"full";case 1:return"partial";default:return"clean"}}function _n(e){switch(e){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function An(e){switch(e){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function H(e,t){return{r:e.view().getUint8(t),g:e.view().getUint8(t+1),b:e.view().getUint8(t+2)}}function xt(e,t){const n=e.bindings.allocStruct("GhosttyColorRgb");try{const i=t(n.ptr);if(i===nn)return null;if(i!==D)throw new Error(`ghostty optional color read failed with result ${i}`);return H(e.bindings,n.ptr)}finally{n.free()}}function v(e,t){const n=e.bindings.allocU8();try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty bool read failed with result ${i}`);return e.bindings.readU8(n)!==0}finally{e.bindings.freeU8(n)}}function B(e,t){const n=e.bindings.allocBytes(2);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u16 read failed with result ${i}`);return e.bindings.view().getUint16(n,!0)}finally{e.bindings.freeBytes(n,2)}}function Dn(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u32 read failed with result ${i}`);return e.bindings.view().getUint32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function et(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty enum read failed with result ${i}`);return e.bindings.view().getInt32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function St(e,t){const n=e.bindings.allocBytes(8);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u64 read failed with result ${i}`);return e.bindings.readU64(n)}finally{e.bindings.freeBytes(n,8)}}function Hn(e){const t=e.bindings.allocStruct("GhosttyStyle");try{e.bindings.setField(t.view,"GhosttyStyle","size",e.bindings.typeSize("GhosttyStyle")),e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,xn,t.ptr);const n=i=>e.bindings.field("GhosttyStyle",i).offset;return{bold:t.view.getUint8(n("bold"))!==0,italic:t.view.getUint8(n("italic"))!==0,faint:t.view.getUint8(n("faint"))!==0,blink:t.view.getUint8(n("blink"))!==0,inverse:t.view.getUint8(n("inverse"))!==0,invisible:t.view.getUint8(n("invisible"))!==0,strikethrough:t.view.getUint8(n("strikethrough"))!==0,overline:t.view.getUint8(n("overline"))!==0,underline:t.view.getInt32(n("underline"),!0)}}finally{t.free()}}function Nn(e){const t=Dn(e,i=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Sn,i));if(t===0)return[];const n=e.bindings.allocBytes(t*4);try{e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,bn,n);const i=[];for(let o=0;o<t;o+=1)i.push(e.bindings.view().getUint32(n+o*4,!0));return i}finally{e.bindings.freeBytes(n,t*4)}}function kn(e){if(e.length===0)return"";try{return String.fromCodePoint(...e)}catch{return""}}function In(e){let t="";for(const n of e)if(!(n.widthKind==="spacer-tail"||n.widthKind==="spacer-head")){if(n.text){t+=n.text;continue}n.widthKind==="narrow"&&(t+=" ")}return t}function Bn(e){const t=e.bindings.allocStruct("GhosttyRenderStateColors");try{e.bindings.setField(t.view,"GhosttyRenderStateColors","size",e.bindings.typeSize("GhosttyRenderStateColors")),e.bindings.getRenderStateColors(e.renderStateHandle,t.ptr);const n=e.bindings.field("GhosttyRenderStateColors","palette").offset,i=[];for(let r=0;r<256;r+=1){const l=t.ptr+n+r*3;i.push(H(e.bindings,l))}const o=t.view.getUint8(e.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,s=v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,hn,r));return{cols:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,sn,r)),rows:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,on,r)),dirty:Mn(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,rn,r))),colors:{background:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","background").offset),foreground:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:o?H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:i},cursor:{style:_n(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,ln,r))),visible:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,an,r)),blinking:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,cn,r)),passwordInput:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,dn,r)),x:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,un,r)):null,y:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,mn,r)):null,wideTail:s?v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,fn,r)):!1}}}finally{t.free()}}function Ln(e,t){const n=St(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,gn,s));e.bindings.bindRenderStateRowCells(e.rowIteratorHandle,e.rowCellsHandle);const i=[];let o=0;for(;e.bindings.nextRenderStateRowCell(e.rowCellsHandle);){const s=St(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,yn,d)),r=Nn(e),l=An(et(e,d=>e.bindings.getRawCellValueResult(s,Rn,d))),c={x:o,text:kn(r),codepoints:r,widthKind:l,hasText:v(e,d=>e.bindings.getRawCellValueResult(s,vn,d)),style:Hn(e),fgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,wn,d)),bgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Cn,d))};i.push(c),o+=1}return{y:t,dirty:v(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,pn,s)),wrap:v(e,s=>e.bindings.getRawRowValueResult(n,Tn,s)),wrapContinuation:v(e,s=>e.bindings.getRawRowValueResult(n,En,s)),text:In(i),cells:i}}function bt(e){return{bindings:e,renderStateHandle:e.createRenderState(),rowIteratorHandle:e.createRenderStateRowIterator(),rowCellsHandle:e.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function Ct(e,t){ot(e),e.bindings.updateRenderState(e.renderStateHandle,t),e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle),e.snapshotVersion+=1,e.cachedMeta=null}function nt(e){return ot(e),e.cachedMeta||(e.cachedMeta=Bn(e)),e.cachedMeta}function*On(e){ot(e);const t=nt(e);e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle);let n=0;for(;n<t.rows&&e.bindings.nextRenderStateRowIterator(e.rowIteratorHandle);)yield Ln(e,n),n+=1}function X(e){e.disposed||(e.disposed=!0,e.rowCellsHandle!==0&&(e.bindings.freeRenderStateRowCells(e.rowCellsHandle),e.rowCellsHandle=0),e.rowIteratorHandle!==0&&(e.bindings.freeRenderStateRowIterator(e.rowIteratorHandle),e.rowIteratorHandle=0),e.renderStateHandle!==0&&(e.bindings.freeRenderState(e.renderStateHandle),e.renderStateHandle=0),e.cachedMeta=null)}const Fn={colChars:[],contentCols:0,wrappedToNext:!1};function $n(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n!==null&&n!==""&&n!==" ")return t+1}return 0}function wt(e,t=!1){const n=[];for(const i of e){if(i.widthKind==="spacer-tail"){n.push(null);continue}if(i.widthKind==="spacer-head"){n.push("");continue}n.push(i.text||" ")}return{colChars:n,contentCols:$n(n),wrappedToNext:t}}function Kn(e,t){return Math.max(0,Math.min(Math.max(e.colChars.length-1,0),Math.floor(t)))}function rt(e,t){let n=Kn(e,t);for(;n>0&&e.colChars[n]===null;)n-=1;return n}function q(e,t){let n=t;for(;n>0&&e.colChars[n]===null;)n-=1;return e.colChars[n]||""}function Tt(e,t){let n=t;for(;n+1<e.colChars.length&&e.colChars[n+1]===null;)n+=1;return n}function jn(e,t){return e.line<t.line?{start:e,end:t}:e.line>t.line?{start:t,end:e}:e.col<=t.col?{start:e,end:t}:{start:t,end:e}}function Yn(e,t,n){if(n.colChars.length===0)return{start:{line:e,col:0},end:{line:e,col:0}};const i=rt(n,t),o=l=>/[\p{L}\p{N}_-]/u.test(l);if(!o(q(n,i)))return{start:{line:e,col:i},end:{line:e,col:i}};let s=i,r=i;for(;s>0&&o(q(n,s-1));)s-=1;for(;r+1<n.colChars.length&&o(q(n,r+1));)r+=1;return{start:{line:e,col:s},end:{line:e,col:r}}}function Yt(e,t){const n=Math.max(t.contentCols-1,0);return{start:{line:e,col:0},end:{line:e,col:n}}}function Pt(e,t,n){const i=n(e.line);switch(t){case"word":return Yn(e.line,e.col,i);case"line":return Yt(e.line,i);default:{const o=rt(i,e.col);return{start:{line:e.line,col:o},end:{line:e.line,col:o}}}}}function Ut(){return{anchor:null,focus:null,mode:"character"}}function Et(e){return!!(e.anchor&&e.focus)}function Pn(){return Ut()}function Un(e,t,n){const i=Pt(t,t.mode,n);return{anchor:i.start,focus:i.end,mode:t.mode}}function Rt(e,t,n){return e.anchor?e.mode==="line"?{...e,focus:Yt(t.line,n(t.line)).end}:e.mode==="word"?{...e,focus:Pt(t,"word",n).end}:{...e,focus:{line:t.line,col:rt(n(t.line),t.col)}}:e}function Gt(e){return!e.anchor||!e.focus?null:jn(e.anchor,e.focus)}function Gn(e,t,n){const i=e.wrappedToNext?e.colChars.length-1:e.contentCols-1,o=Math.min(n,i);let s=Math.max(0,t);for(;s>0&&e.colChars[s]===null;)s-=1;if(s>o)return"";let r="";for(let l=s;l<=o;l+=1)r+=e.colChars[l]??"";return r}function Vn(e,t){const n=Gt(e);if(!n)return null;let i="";for(let o=n.start.line;o<=n.end.line;o+=1){const s=t(o),r=o===n.start.line?n.start.col:0,l=o===n.end.line?n.end.col:s.colChars.length-1;i+=Gn(s,r,l),o<n.end.line&&!s.wrappedToNext&&(i+=`
|
|
22
|
-
`)}return i}function zn(e,t,n,i){const o=Gt(e);if(!o)return[];const s=t+n-1,r=[];for(let l=Math.max(o.start.line,t);l<=Math.min(o.end.line,s);l+=1){const c=l-t;if(l===o.start.line&&l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:o.start.col,width:g-o.start.col+1});continue}if(l===o.start.line){const m=i?Math.max(i(l).colChars.length-o.start.col,0):Number.MAX_SAFE_INTEGER;r.push({row:c,x:o.start.col,width:m});continue}if(l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:0,width:g+1});continue}const d=i?i(l).colChars.length:Number.MAX_SAFE_INTEGER;r.push({row:c,x:0,width:d})}return r}const vt=80,N=24,Q=9,Z=17,Mt=1.2,Wn=48,Mi="ghostty-official",$=9,K=1e3,j=1002,Y=1003,J=1007,L=1047,O=1049,Xn=[$,K,j,Y],_t=1,At=3,Dt=2,qn=4,Qn=5;class Zn{constructor(t){this.content=t}translateToString(t){return t?this.content.replace(/\s+$/u,""):this.content}}class Jn{constructor(){h(this,"active",{baseY:0,viewportY:0,length:N,getLine:t=>{const n=t-this.active.viewportY,i=this.visibleLines[n];return typeof i=="string"?new Zn(i):null}});h(this,"visibleLines",Array.from({length:N},()=>""))}setViewport(t,n,i,o){this.active.viewportY=t,this.active.baseY=n,this.active.length=i,this.visibleLines=o}}const ti={deleteContentBackward:"Backspace",deleteContentForward:"Delete",insertLineBreak:"Enter",insertParagraph:"Enter"};function ei(e){return!(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey)}function ni(e,t){const n=e.slice(0,t).map(i=>i.text);for(;n.length<t;)n.push("");return n}function F(e){return Ft({shiftKey:!!e.shiftKey,ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,metaKey:!!e.metaKey,getModifierState:()=>!1})}class ii{constructor(){h(this,"terminal",null)}activate(t){this.terminal=t instanceof U?t:null}fit(){const t=this.proposeDimensions();!this.terminal||!t||this.terminal.resize(t.cols,t.rows)}proposeDimensions(){var t;return((t=this.terminal)==null?void 0:t.measureSizeFromElement())??null}dispose(){this.terminal=null}}class U{constructor(t,n,i,o,s,r){h(this,"buffer",new Jn);h(this,"_core",{_renderService:{dimensions:{css:{cell:{width:Q,height:Z}}}}});h(this,"options");h(this,"element",null);h(this,"textarea",null);h(this,"cols",vt);h(this,"rows",N);h(this,"bindings");h(this,"terminalHandle");h(this,"keyEncoderHandle");h(this,"mouseEncoderHandle");h(this,"renderState");h(this,"dataListeners",new Set);h(this,"selectionListeners",new Set);h(this,"linkListeners",new Set);h(this,"linkCursorActive",!1);h(this,"lastNotifiedSelectionText",null);h(this,"addons",new Set);h(this,"screenElement",null);h(this,"renderer",null);h(this,"renderRaf",null);h(this,"lastCursor",null);h(this,"disposed",!1);h(this,"disableStdin");h(this,"customKeyEventHandler",()=>!0);h(this,"imeIsComposing",!1);h(this,"lastCompositionCommit",null);h(this,"selectionState",Ut());h(this,"lineCache",new Map);h(this,"lastViewportOffset",0);h(this,"lastViewportRows",N);h(this,"lastRenderedRows",[]);h(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});h(this,"autoScrollTimer",null);h(this,"domEventDisposers",[]);h(this,"copyShortcutSuppressed",!1);h(this,"scrollbarThumb",null);h(this,"scrollbarFadeTimer",null);h(this,"pressedMouseButtons",new Set);h(this,"wheelPixelDelta",0);h(this,"mouseDragActive",!1);this.bindings=t,this.terminalHandle=n,this.keyEncoderHandle=i,this.mouseEncoderHandle=o,this.renderState=s,this.options=r,this.disableStdin=!!r.disableStdin}static async create(t){const n=await le(),i=n.createTerminal(vt,N,t.scrollback);let o=0,s=0,r=null;try{return n.setTerminalTheme(i,t.theme),o=n.createKeyEncoder(),s=n.createMouseEncoder(),r=bt(n),new U(n,i,o,s,r,t)}catch(l){throw r&&X(r),o!==0&&n.freeKeyEncoder(o),s!==0&&n.freeMouseEncoder(s),n.freeTerminal(i),l}}open(t){if(this.disposed||this.element)return;const n=document.createElement("div");n.className="xterm",n.style.position="absolute",n.style.inset="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.backgroundColor=this.options.theme.background,n.style.color=this.options.theme.foreground,n.style.fontFamily=this.options.fontFamily,n.style.fontSize=`${this.options.fontSize}px`,n.style.lineHeight=String(this.options.lineHeight??Mt);const i=document.createElement("div");i.className="xterm-viewport",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",i.style.position="relative";const o=document.createElement("div");o.className="xterm-screen",o.style.width="100%",o.style.height="100%",o.style.position="relative",o.style.userSelect="none",o.style.webkitUserSelect="none",o.style.backgroundColor=this.options.theme.background;const s=document.createElement("div");s.className="xterm-helper-textarea",s.setAttribute("aria-label","Terminal Input"),s.setAttribute("role","textbox"),s.setAttribute("contenteditable","true"),s.setAttribute("autocorrect","off"),s.setAttribute("autocapitalize","off"),s.setAttribute("spellcheck","false"),s.style.position="absolute",s.style.opacity="1",s.style.pointerEvents="none",s.style.left="0",s.style.top="0",s.style.minWidth="1px",s.style.minHeight="1px",s.style.whiteSpace="pre",s.style.border="0",s.style.padding="0",s.style.margin="0",s.style.color=this.options.theme.foreground,s.style.backgroundColor="transparent",s.style.caretColor="transparent",s.style.overflow="visible",s.style.outline="none",s.style.boxShadow="none",s.style.fontFamily=this.options.fontFamily,s.style.fontSize=`${this.options.fontSize}px`,s.style.userSelect="text",s.style.webkitUserSelect="text";const r=document.createElement("div");r.className="xterm-scrollbar-track",r.style.position="absolute",r.style.top="0",r.style.right="0",r.style.width="8px",r.style.height="100%",r.style.backgroundColor="transparent",r.style.pointerEvents="none";const l=document.createElement("div");l.className="xterm-scrollbar-thumb",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.width="6px",l.style.marginRight="1px",l.style.borderRadius="3px",l.style.backgroundColor="rgba(128, 128, 128, 0.5)",l.style.pointerEvents="none",l.style.transition="opacity 0.15s ease",l.style.opacity="0",r.appendChild(l),i.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(r),t.appendChild(n),this.element=n,this.screenElement=o,this.textarea=s,this.scrollbarThumb=l,this.renderer=new Ze({screenElement:o,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const c=this.measureSizeFromElement();c?this.resize(c.cols,c.rows):this.render()}loadAddon(t){t.activate(this),this.addons.add(t)}onData(t){return this.dataListeners.add(t),{dispose:()=>{this.dataListeners.delete(t)}}}attachCustomKeyEventHandler(t){this.customKeyEventHandler=t}onSelectionChange(t){return this.selectionListeners.add(t),{dispose:()=>{this.selectionListeners.delete(t)}}}onLinkActivated(t){return this.linkListeners.add(t),{dispose:()=>{this.linkListeners.delete(t)}}}hasSelection(){return Et(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(t,n,i="word"){return this.disposed?!1:this.beginSelectionAt(t,n,i)}updateTouchSelection(t,n){this.disposed||this.updateSelectionDrag(t,n)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(t){if(this.disposed)return;const n=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,t);const i=this.isAltScreenActive();n&&!i&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const t of Xn)this.bindings.setTerminalMode(this.terminalHandle,t,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(L)||this.isModeEnabled(O)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(t,n){if(this.disposed)return;const i=Math.max(2,Math.floor(t)),o=Math.max(2,Math.floor(n));this.cols=i,this.rows=o,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,i,o,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(t){this.disposed||t===0||(this.bindings.scrollViewportDelta(this.terminalHandle,t),this.render())}scrollToTop(){this.disposed||(this.bindings.scrollViewportTop(this.terminalHandle),this.render())}scrollToBottom(){this.disposed||(this.bindings.scrollViewportBottom(this.terminalHandle),this.render())}exportModeSnapshot(){return{mouseX10:this.isModeEnabled($),mouseNormal:this.isModeEnabled(K),mouseButton:this.isModeEnabled(j),mouseAny:this.isModeEnabled(Y),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(J),altScreen1047:this.isModeEnabled(L),altScreen1049:this.isModeEnabled(O)}}restoreModeSnapshot(t){this.bindings.setTerminalMode(this.terminalHandle,$,t.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,K,t.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,j,t.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Y,t.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,t.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,t.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,t.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,t.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,J,t.altScroll),this.bindings.setTerminalMode(this.terminalHandle,L,t.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,O,t.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(t){if(this.disposed||t.deltaY===0)return!1;const n=this.gestureToLines(t);if(n===0)return!1;const i=this.getInputRoutingState();if(i.mouseReporting){const o=n<0?qn:Qn;let s=!1;for(let r=0;r<Math.abs(n);r+=1)s=this.emitMouseInput({action:"press",button:o,clientX:t.clientX,clientY:t.clientY,mods:F(t),anyButtonPressed:this.pressedMouseButtons.size>0})||s;return s}return i.altScroll?this.emitAltScrollInput(n):(this.scrollLines(n),!0)}paste(t){if(this.disposed||this.disableStdin||!t)return;const n=this.bindings.encodePaste(this.terminalHandle,t);n&&this.emitData(n)}focus(){var t;(t=this.textarea)==null||t.focus({preventScroll:!0})}getCursorViewportRect(){if(this.disposed)return null;const t=this.screenElement,n=this.lastCursor;if(!t||!n||!n.visible||n.y===null||this.textarea===null||document.activeElement!==this.textarea)return null;const{height:i}=this.cellDimensions();if(i<=0)return null;const o=t.getBoundingClientRect().top+n.y*i;return{top:o,bottom:o+i}}getRendererKind(){var t;return((t=this.renderer)==null?void 0:t.kind)??"unknown"}setTheme(t){var n;this.bindings.setTerminalTheme(this.terminalHandle,t),this.options.theme=t,this.element&&(this.element.style.backgroundColor=t.background,this.element.style.color=t.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=t.background),(n=this.renderer)==null||n.setTheme(t),this.scheduleRender()}setDisableStdin(t){this.disableStdin=t,this.syncInputState()}measureSizeFromElement(){const t=this.element;if(!t)return null;const n=t.getBoundingClientRect(),{width:i,height:o}=this.cellDimensions();return n.width===0||n.height===0||i<=0||o<=0?null:{cols:Math.max(2,Math.floor(n.width/i)),rows:Math.max(2,Math.floor(n.height/o))}}dispose(){var t,n;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const i of this.addons)i.dispose();this.addons.clear(),(t=this.renderer)==null||t.dispose(),this.renderer=null,(n=this.element)==null||n.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,X(this.renderState),this.bindings.freeMouseEncoder(this.mouseEncoderHandle),this.bindings.freeKeyEncoder(this.keyEncoderHandle),this.bindings.freeTerminal(this.terminalHandle)}}cellDimensions(){return this._core._renderService.dimensions.css.cell}syncInputState(){this.textarea&&(this.textarea.readOnly=this.disableStdin,this.textarea.tabIndex=this.disableStdin?-1:0,this.disableStdin&&document.activeElement===this.textarea&&this.textarea.blur())}bindDomEvents(){const t=this.element,n=this.textarea;if(!t||!n)return;t.addEventListener("click",()=>{this.disableStdin||this.focus()});const i=this.screenElement??t;i.addEventListener("mousedown",s=>{if(s instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const r=this.mouseButtonFromEvent(s);if(r===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(r),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:r,clientX:s.clientX,clientY:s.clientY,mods:F(s),anyButtonPressed:!0}),s.preventDefault();return}if(s.button===0&&mt(s)){const r=this.linkAtClient(s.clientX,s.clientY);if(r){this.emitLinkActivated(r),s.preventDefault();return}}s.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(s),s.preventDefault())}}),i.addEventListener("mousemove",s=>{if(!(!(s instanceof MouseEvent)||this.mouseDragActive)){if(this.getInputRoutingState().mouseReporting){this.setLinkCursor(!1);return}this.setLinkCursor(mt(s)&&this.linkAtClient(s.clientX,s.clientY)!==null)}}),i.addEventListener("mouseleave",()=>{this.setLinkCursor(!1)}),t.addEventListener("wheel",s=>{this.handleViewportGesture({source:"wheel",deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,shiftKey:s.shiftKey,ctrlKey:s.ctrlKey,altKey:s.altKey,metaKey:s.metaKey})&&s.preventDefault()},{passive:!1});const o=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(o){const s=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},r=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const c=this.mouseButtonFromEvent(l);c!==null&&this.pressedMouseButtons.delete(c),this.emitMouseInput({action:"release",button:c,clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};o.addEventListener("mousemove",s),o.addEventListener("mouseup",r),this.domEventDisposers.push(()=>{o.removeEventListener("mousemove",s),o.removeEventListener("mouseup",r)})}n.addEventListener("keydown",s=>{const r=this.getSelectionText();if(r&&ae(s)){s.preventDefault(),ce(r).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(s)||this.disableStdin||this.imeIsComposing||s.keyCode===229||de(s)||!ei(s))return;const l=this.encodeKeyboardEvent(s,s.repeat?"repeat":"press");l&&(s.preventDefault(),this.emitData(l),this.clearTextarea())}),n.addEventListener("keyup",s=>{if(this.copyShortcutSuppressed){const l=s.key.toLowerCase();if(l==="c"){s.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,s.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const r=this.encodeKeyboardEvent(s,"release");r&&(s.preventDefault(),this.emitData(r),this.clearTextarea())}),n.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),n.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),n.addEventListener("compositionend",s=>{this.imeIsComposing=!1;const r=s.data??"";r&&(this.lastCompositionCommit={data:r,at:Date.now()},this.emitData(r),this.clearTextarea())}),n.addEventListener("beforeinput",s=>{if(this.disableStdin||s.inputType==="insertFromPaste"||s.isComposing||this.imeIsComposing)return;const r=ti[s.inputType??""];if(r){s.preventDefault();const d=this.encodeSyntheticKey(r);d&&this.emitData(d),this.clearTextarea();return}const l=s.data??"";if(!l)return;const c=this.lastCompositionCommit;if(c&&c.data===l&&Date.now()-c.at<40){this.lastCompositionCommit=null,s.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,s.preventDefault(),this.emitData(l),this.clearTextarea()}),n.addEventListener("paste",s=>{var l;if(this.disableStdin)return;const r=((l=s.clipboardData)==null?void 0:l.getData("text/plain"))??"";r&&(s.preventDefault(),this.paste(r),this.clearTextarea())}),n.addEventListener("copy",s=>{const r=this.getSelectionText();r&&he(s,r)}),n.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const s=n.textContent??"";if(!s){this.clearTextarea();return}const r=this.lastCompositionCommit;if(r&&r.data===s&&Date.now()-r.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(s),this.clearTextarea()})}encodeKeyboardEvent(t,n){const i=ft(t.code);if(i===0)return null;const o=t.key.length===1&&!t.ctrlKey&&!t.metaKey?t.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:n,keyCode:i,mods:Ft(t),composing:t.isComposing,utf8:o,unshiftedCodepoint:ue(t.code)})}encodeSyntheticKey(t){const n={code:t,key:t,shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1,repeat:!1,isComposing:!1,getModifierState:()=>!1};return this.encodeKeyboardEvent(n,"press")}getInputRoutingState(){const t=this.isModeEnabled($)||this.isModeEnabled(K)||this.isModeEnabled(j)||this.isModeEnabled(Y),n=this.isModeEnabled(L)||this.isModeEnabled(O);return{mouseReporting:t,altScroll:!t&&n&&this.isModeEnabled(J)}}gestureToLines(t){const n=this.cellDimensions().height||Z;if(t.source==="wheel"){if(t.deltaMode===1)return this.wheelPixelDelta=0,t.deltaY>0?Math.ceil(t.deltaY):Math.floor(t.deltaY);if(t.deltaMode===2){this.wheelPixelDelta=0;const o=Math.max(1,this.rows),s=t.deltaY*o;return s>0?Math.ceil(s):Math.floor(s)}this.wheelPixelDelta+=t.deltaY;const i=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/n):Math.ceil(this.wheelPixelDelta/n);return i!==0&&(this.wheelPixelDelta-=i*n),i}return t.deltaY>0?Math.ceil(t.deltaY/n):Math.floor(t.deltaY/n)}isModeEnabled(t){return this.bindings.isTerminalModeEnabled(this.terminalHandle,t)}mouseButtonFromEvent(t){switch(t.button){case 0:return _t;case 1:return At;case 2:return Dt;default:return null}}mouseButtonFromButtons(t){return t&1?_t:t&4?At:t&2?Dt:null}pointerPositionFromClient(t,n){var r;const i=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!i)return null;const o=Math.max(1,i.width),s=Math.max(1,i.height);return{x:Math.max(0,Math.min(o-1,t-i.left)),y:Math.max(0,Math.min(s-1,n-i.top))}}emitMouseInput(t){var r;if(this.disableStdin)return!1;const n=this.pointerPositionFromClient(t.clientX,t.clientY);if(!n)return!1;const i=this.cellDimensions(),o=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!o)return!1;const s=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:t.action,button:t.button,mods:t.mods,x:n.x,y:n.y,anyButtonPressed:t.anyButtonPressed,screenWidth:Math.max(1,Math.round(o.width)),screenHeight:Math.max(1,Math.round(o.height)),cellWidth:Math.max(1,Math.round(i.width||Q)),cellHeight:Math.max(1,Math.round(i.height||Z))});return s?(this.emitData(s),!0):!1}emitAltScrollInput(t){const n=ft(t<0?"ArrowUp":"ArrowDown");if(n===0)return!1;let i=!1;for(let o=0;o<Math.abs(t);o+=1){const s=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:n,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});s&&(this.emitData(s),i=!0)}return i}emitData(t){for(const n of this.dataListeners)n(t)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const t=this.textarea,n=this.screenElement;if(!t||!n)return;const{width:i,height:o}=this.cellDimensions();if(i<=0||o<=0)return;const s=bt(this.bindings);let r=0,l=0;try{Ct(s,this.terminalHandle);const m=nt(s);m.cursor.x!==null&&m.cursor.y!==null&&(r=m.cursor.x,l=m.cursor.y)}finally{X(s)}const c=r*i,d=l*o;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.width=`${Math.max(1,i)}px`,t.style.height=`${Math.max(1,o)}px`,t.style.lineHeight=`${o}px`,t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`}scheduleRender(){this.renderRaf===null&&(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=null,this.render()}))}render(){if(this.disposed||!this.screenElement||!this.renderer)return;const t=this.bindings.readScrollbar(this.terminalHandle),n=Math.max(1,t.len||this.rows);Ct(this.renderState,this.terminalHandle);const i=nt(this.renderState),o=Array.from(On(this.renderState));this.lastCursor=i.cursor,this.cols=Math.max(2,i.cols),this.rows=Math.max(2,i.rows||n),this.lastViewportOffset=t.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=o;for(const d of o)this.lineCache.set(t.offset+d.y,wt(d.cells,d.wrap));const s=zn(this.selectionState,this.lastViewportOffset,this.lastViewportRows,d=>this.getLineModel(d)),r=this.getSelectionText();this.renderer.render({meta:i,rows:o,cellDimensions:this.cellDimensions(),selectionRects:s,selectionColor:this.options.theme.selectionBackground});const l=ni(o,this.rows),c=Math.max(0,t.total-t.len);this.buffer.setViewport(t.offset,c,t.total,l),this.updateSelectionTextProbe(r),this.updateScrollbar(t)}updateScrollbar(t){var c;const n=this.scrollbarThumb;if(!n)return;const i=((c=this.screenElement)==null?void 0:c.clientHeight)??0;if(i===0||t.total<=t.len){n.style.opacity="0";return}const o=t.len/t.total,s=Math.max(20,o*i),l=t.offset/Math.max(1,t.total-t.len)*(i-s);n.style.height=`${s}px`,n.style.transform=`translateY(${l}px)`,n.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{n.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const t=document.createElement("span");t.textContent="WWWWWWWWWW",t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="pre",t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,this.element.appendChild(t);const n=t.getBoundingClientRect();t.remove();const i=Math.max(1,globalThis.devicePixelRatio??1),o=n.width>0?n.width/10:Q,s=this.options.fontSize*(this.options.lineHeight??Mt);this._core._renderService.dimensions.css.cell.width=Math.max(1,Math.round(o*i))/i,this._core._renderService.dimensions.css.cell.height=Math.max(1,Math.round(s*i))/i}clearSelectionState(t=!0){this.selectionState=Pn(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),t&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(t,n,i){const o=this.hitTest(t,n);return o?(this.pointerDrag={active:!0,moved:!1,mode:i,lastClientX:t,lastClientY:n},this.selectionState=Un(this.selectionState,{...o,mode:i},s=>this.getLineModel(s)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(t,n){if(!this.pointerDrag.active)return;const i=this.hitTest(t,n);this.pointerDrag.lastClientX=t,this.pointerDrag.lastClientY=n,i&&(this.pointerDrag.moved=!0,this.selectionState=Rt(this.selectionState,i,o=>this.getLineModel(o)),this.render()),this.updateAutoScroll()}beginPointerSelection(t){this.beginSelectionAt(t.clientX,t.clientY,this.selectionModeFromClickDetail(t.detail))}updatePointerSelection(t){this.updateSelectionDrag(t.clientX,t.clientY)}finishPointerSelection(t){var i,o,s,r;if(!this.pointerDrag.active||t.button!==0)return;this.pointerDrag.lastClientX=t.clientX,this.pointerDrag.lastClientY=t.clientY,this.stopAutoScroll();const n=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((i=this.selectionState.anchor)==null?void 0:i.line)===((o=this.selectionState.focus)==null?void 0:o.line)&&((s=this.selectionState.anchor)==null?void 0:s.col)===((r=this.selectionState.focus)==null?void 0:r.col);if(this.pointerDrag.active=!1,n){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(t){return t>=3?"line":t===2?"word":"character"}hitTest(t,n){var S;const i=(S=this.screenElement)==null?void 0:S.getBoundingClientRect();if(!i)return null;const{width:o,height:s}=this.cellDimensions();if(o<=0||s<=0)return null;const r=t-i.left,l=n-i.top,c=Math.max(this.cols-1,0),d=Math.max(this.lastViewportRows-1,0),m=Math.max(0,Math.min(c,Math.floor(r/o))),g=Math.max(0,Math.min(d,Math.floor(l/s)));return{line:this.lastViewportOffset+g,col:m}}getLineModel(t){const n=this.lineCache.get(t);if(n)return n;const i=t-this.lastViewportOffset,o=this.lastRenderedRows[i];return o?wt(o.cells,o.wrap):Fn}emitLinkActivated(t){for(const n of this.linkListeners)n(t)}setLinkCursor(t){this.linkCursorActive!==t&&(this.linkCursorActive=t,this.screenElement&&(this.screenElement.style.cursor=t?"pointer":""))}linkAtClient(t,n){const i=this.hitTest(t,n);return i?this.linkAtPoint(i.line,i.col):null}linkAtPoint(t,n){if(this.getLineModel(t).colChars.length===0)return null;let i=t;for(;this.getLineModel(i-1).wrappedToNext;)i-=1;let o=t;for(;this.getLineModel(o).wrappedToNext;)o+=1;const s=[];for(let l=i;l<=o;l+=1)s.push(this.getLineModel(l));const r=t-i;for(const l of en(s))if(l.lineIndex===r&&n>=l.startCol&&n<=l.endCol)return l.url;return null}getSelectionText(){return Et(this.selectionState)?Vn(this.selectionState,t=>this.getLineModel(t)):null}updateSelectionTextProbe(t){if(globalThis.__tmexE2eTerminalSelectionText=t,t!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=t;for(const n of this.selectionListeners)n(t)}}updateAutoScroll(){var i;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(i=this.screenElement)==null?void 0:i.getBoundingClientRect();if(!t){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<t.top||this.pointerDrag.lastClientY>t.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Wn))}stepAutoScroll(){var o;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!t){this.stopAutoScroll();return}let n=0;if(this.pointerDrag.lastClientY<t.top?n=-1:this.pointerDrag.lastClientY>t.bottom&&(n=1),n===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,n),this.render();const i=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);i&&(this.selectionState=Rt(this.selectionState,i,s=>this.getLineModel(s)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const t=this.domEventDisposers.pop();t==null||t()}}}async function si(e){return U.create(e)}const oi=new Set(["Control","Shift","Alt","Meta","CapsLock","NumLock","ScrollLock","Dead","Unidentified","OS","ContextMenu","Fn","FnLock","Hyper","Super"]),ri={Enter:{label:"Enter",raw:"\r"},Tab:{label:"Tab",raw:" "},Escape:{label:"ESC",raw:"\x1B"},Backspace:{label:"Backspace",raw:"\b"}," ":{label:"Space",raw:" "},ArrowUp:{label:"↑",csiFinal:"A"},ArrowDown:{label:"↓",csiFinal:"B"},ArrowRight:{label:"→",csiFinal:"C"},ArrowLeft:{label:"←",csiFinal:"D"},Home:{label:"Home",csiFinal:"H"},End:{label:"End",csiFinal:"F"},Delete:{label:"Delete",csiNum:3},Insert:{label:"Insert",csiNum:2},PageUp:{label:"PgUp",csiNum:5},PageDown:{label:"PgDn",csiNum:6}},li={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"},ai={"[":"\x1B","\\":"","]":"","^":"",_:"","@":"\0","?":""};function ci(e){return 1+(e.shiftKey?1:0)+(e.altKey?2:0)+(e.ctrlKey?4:0)+(e.metaKey?8:0)}function di(e){const t=[];return e.ctrlKey&&t.push("CTRL"),e.altKey&&t.push("ALT"),e.metaKey&&t.push("CMD"),e.shiftKey&&t.push("SHIFT"),t.length?`${t.join("-")}-`:""}function hi(e){const t=e.key;if(!t||oi.has(t))return null;const n=ci(e),i=n!==1,o=di(e);if(t==="Tab"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Tab",payload:"\x1B[Z"};if(t==="Enter"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Enter",payload:"\x1B[13;2u"};if(e.ctrlKey&&!e.altKey&&!e.metaKey&&/^[a-zA-Z]$/.test(t)){const l=t.toUpperCase();return{label:`CTRL-${l}`,payload:String.fromCharCode(l.charCodeAt(0)-64)}}const s=li[t];if(s)return{label:o+t,payload:s};const r=ri[t];if(r){if("raw"in r){const c=e.altKey?`\x1B${r.raw}`:r.raw;return{label:o+r.label,payload:c}}if("csiFinal"in r){const c=i?`\x1B[1;${n}${r.csiFinal}`:`\x1B[${r.csiFinal}`;return{label:o+r.label,payload:c}}const l=i?`\x1B[${r.csiNum};${n}~`:`\x1B[${r.csiNum}~`;return{label:o+r.label,payload:l}}if(t.length===1){if(e.altKey&&!e.ctrlKey&&!e.metaKey)return{label:`ALT-${t.toUpperCase()}`,payload:`\x1B${t}`};if(e.ctrlKey){const l=ai[t];return l!==void 0?{label:o+t,payload:l}:null}return{label:t,payload:t}}return null}function Vt(e){return e.replace(/\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)/g,(t,n)=>{if(n[0]==="x"&&n.length===3||n[0]==="u"&&n.length===5)return String.fromCharCode(Number.parseInt(n.slice(1),16));switch(n){case"r":return"\r";case"n":return`
|
|
21
|
+
*/const Ve=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ze=P("rotate-ccw",Ve);function We(e){return`rgb(${e.r} ${e.g} ${e.b})`}const Xe=new Map([[9622,4],[9623,8],[9624,1],[9625,13],[9626,9],[9627,7],[9628,11],[9629,2],[9630,6],[9631,14]]),qe=new Map([[9617,.25],[9618,.5],[9619,.75]]);function Qe(e){return e>=9600&&e<=9631}function z(e){const t=e.getContext("2d");if(!t)throw new Error("2d canvas context unavailable");return t}class Ze{constructor(t){h(this,"kind","canvas");h(this,"mainCanvas");h(this,"selectionCanvas");h(this,"cursorCanvas");h(this,"mainContext");h(this,"selectionContext");h(this,"cursorContext");h(this,"theme");h(this,"fontFamily");h(this,"fontSize");h(this,"cellDimensions",{width:9,height:17});h(this,"deviceCellWidth",9);h(this,"deviceCellHeight",17);h(this,"deviceFontSize",13);h(this,"textTopGap",0);h(this,"textBaselineY",0);h(this,"glyphBoxHeight",0);h(this,"dpr",1);h(this,"cols",0);h(this,"rows",0);h(this,"lastCursor",null);h(this,"frameCount",0);h(this,"lastDrawnRows",[]);h(this,"colorCache",new Map);h(this,"fontCache",new Map);h(this,"cursorBlinkVisible",!0);h(this,"cursorBlinkTimer",null);this.theme=t.theme,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,t.screenElement.style.position="relative",t.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[n,i]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])n.dataset.layer=i,n.style.position="absolute",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",t.screenElement.appendChild(n);this.mainContext=z(this.mainCanvas),this.selectionContext=z(this.selectionCanvas),this.cursorContext=z(this.cursorCanvas)}setTheme(t){this.theme=t,this.colorCache.clear()}render(t){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=t.cellDimensions,this.resize(t.meta.cols,t.meta.rows),this.drawSelection(t.selectionRects??[],t.selectionColor??this.theme.selectionBackground),t.meta.dirty==="clean"){this.drawCursor(t.meta);return}const n=t.meta.dirty==="full",i=n?t.rows:t.rows.filter(s=>s.dirty);let o;if(n)o=t.rows;else{const s=new Set;for(const r of i)s.add(r.y-1),s.add(r.y),s.add(r.y+1);o=t.rows.filter(r=>s.has(r.y))}for(const s of o)this.drawRowBackground(s,t.meta.colors);for(const s of o)this.drawRowForeground(s,t.meta.colors);for(const s of i)this.lastDrawnRows.push(s.y);this.drawCursor(t.meta)}getDebugState(){return{kind:this.kind,frameCount:this.frameCount,lastDrawnRows:[...this.lastDrawnRows]}}dispose(){this.mainCanvas.remove(),this.selectionCanvas.remove(),this.cursorCanvas.remove(),this.colorCache.clear(),this.fontCache.clear(),this.lastCursor=null,this.stopCursorBlink()}startCursorBlink(){this.cursorBlinkTimer||(this.cursorBlinkTimer=setInterval(()=>{this.cursorBlinkVisible=!this.cursorBlinkVisible,this.cursorCanvas.style.opacity=this.cursorBlinkVisible?"1":"0"},1e3))}stopCursorBlink(){this.cursorBlinkTimer&&(clearInterval(this.cursorBlinkTimer),this.cursorBlinkTimer=null),this.cursorBlinkVisible=!0,this.cursorCanvas.style.opacity="1"}resize(t,n){const i=Math.max(1,t),o=Math.max(1,n),s=Math.max(1,globalThis.devicePixelRatio??1),r=Math.max(1,Math.round(this.cellDimensions.width*s)),l=Math.max(1,Math.round(this.cellDimensions.height*s));if(this.cols===i&&this.rows===o&&this.dpr===s&&this.deviceCellWidth===r&&this.deviceCellHeight===l)return;this.cols=i,this.rows=o,this.dpr=s,this.deviceCellWidth=r,this.deviceCellHeight=l,this.deviceFontSize=this.fontSize*s,this.mainContext.font=`${this.deviceFontSize}px ${this.fontFamily}`;const c=this.mainContext.measureText("Mg|qyÅ");let d=c.fontBoundingBoxAscent,m=c.fontBoundingBoxDescent;Number.isFinite(d)&&Number.isFinite(m)&&d>0||(d=this.deviceFontSize*.8,m=this.deviceFontSize*.2),this.glyphBoxHeight=d+m,this.textTopGap=Math.round((l-this.glyphBoxHeight)/2),this.textBaselineY=Math.round(this.textTopGap+d);const g=i*r,S=o*l;for(const y of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])y.width=g,y.height=S,y.style.width=`${g/s}px`,y.style.height=`${S/s}px`;for(const y of[this.mainContext,this.selectionContext,this.cursorContext])y.setTransform(1,0,0,1,0,0),y.textBaseline="alphabetic",y.imageSmoothingEnabled=!1}drawSelection(t,n){if(this.selectionContext.clearRect(0,0,this.selectionCanvas.width,this.selectionCanvas.height),t.length!==0){this.selectionContext.fillStyle=n;for(const i of t)this.selectionContext.fillRect(i.x*this.deviceCellWidth,i.row*this.deviceCellHeight,i.width*this.deviceCellWidth,this.deviceCellHeight)}}drawRowBackground(t,n){const i=t.y*this.deviceCellHeight,o=this.cols*this.deviceCellWidth,s=this.toCss(n.background);this.mainContext.clearRect(0,i,o,this.deviceCellHeight),this.mainContext.fillStyle=s,this.mainContext.fillRect(0,i,o,this.deviceCellHeight);for(const r of t.cells){if(r.widthKind==="spacer-tail"||r.widthKind==="spacer-head")continue;const l=r.style.inverse?r.fgColor??n.foreground:r.bgColor??n.background;if(l.r!==n.background.r||l.g!==n.background.g||l.b!==n.background.b){const c=r.x*this.deviceCellWidth,d=r.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l),this.mainContext.fillRect(c,i,d,this.deviceCellHeight)}}}drawRowForeground(t,n){const i=t.y*this.deviceCellHeight,o=Math.max(1,Math.round(this.dpr));for(const s of t.cells){if(s.widthKind==="spacer-tail"||s.widthKind==="spacer-head"||!s.text||s.style.invisible)continue;const r=s.x*this.deviceCellWidth,l=s.style.inverse?s.bgColor??n.background:s.fgColor??n.foreground,c=s.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l);const d=s.codepoints.length===1&&Qe(s.codepoints[0])?s.codepoints[0]:null;d!==null?this.drawBlockElement(d,r,i,c,this.deviceCellHeight):(this.mainContext.font=this.resolveFont(s.style),this.mainContext.fillText(s.text,r,i+this.textBaselineY));const m=i+this.textTopGap,g=i+this.textTopGap+this.glyphBoxHeight;s.style.underline>0&&this.mainContext.fillRect(r,Math.min(Math.round(g-o),i+this.deviceCellHeight-o),Math.max(c-o,o),o),s.style.strikethrough&&this.mainContext.fillRect(r,Math.round(i+this.textTopGap+this.glyphBoxHeight/2),Math.max(c-o,o),o),s.style.overline&&this.mainContext.fillRect(r,Math.max(i,Math.round(m)),Math.max(c-o,o),o)}}drawBlockElement(t,n,i,o,s){const r=this.mainContext,l=C=>Math.round(o*C/8),c=C=>Math.round(s*C/8),d=(C,p,x,I)=>{r.fillRect(n+C,i+p,x-C,I-p)};if(t===9600){d(0,0,o,c(4));return}if(t>=9601&&t<=9608){d(0,c(8-(t-9600)),o,s);return}if(t>=9609&&t<=9615){d(0,0,l(9616-t),s);return}if(t===9616){d(l(4),0,o,s);return}const m=qe.get(t);if(m!==void 0){const C=r.globalAlpha;r.globalAlpha=C*m,d(0,0,o,s),r.globalAlpha=C;return}if(t===9620){d(0,0,o,c(1));return}if(t===9621){d(l(7),0,o,s);return}const g=Xe.get(t)??0,S=l(4),y=c(4);g&1&&d(0,0,S,y),g&2&&d(S,0,o,y),g&4&&d(0,y,S,s),g&8&&d(S,y,o,s)}drawCursor(t){const n=t.colors,i=t.cursor,o=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cursorCanvas.width,this.cursorCanvas.height),!i.visible||i.x===null||i.y===null){this.lastCursor=null,this.stopCursorBlink();return}const s=i.x*this.deviceCellWidth,r=i.y*this.deviceCellHeight,l=i.wideTail?this.deviceCellWidth*2:this.deviceCellWidth,c=Math.max(1,Math.round(this.dpr)),d=n.cursor??n.foreground,m=this.toCss(d);this.cursorContext.fillStyle=m,this.cursorContext.strokeStyle=m,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(s,r+this.deviceCellHeight-2*c,Math.max(l-c,c),2*c),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:i.x,y:i.y,style:i.style},o&&(o.x!==this.lastCursor.x||o.y!==this.lastCursor.y||o.style!==this.lastCursor.style)&&this.lastDrawnRows.push(o.y)}resolveFont(t){const n=this.deviceFontSize,i=[t.italic?"italic":"normal",t.bold?"700":"400",`${n}px`,this.fontFamily].join("|"),o=this.fontCache.get(i);if(o)return o;const s=`${t.italic?"italic ":""}${t.bold?"700 ":""}${n}px ${this.fontFamily}`;return this.fontCache.set(i,s),s}toCss(t){const n=`${t.r},${t.g},${t.b}`,i=this.colorCache.get(n);if(i)return i;const o=We(t);return this.colorCache.set(n,o),o}}const W=/https?:\/\/[^\s"'`<>()[\]{}]+/g,Je=/[.,;:!?]+$/;function tn(e){let t="";const n=[],i=e.colChars.length;for(let o=0;o<i;o+=1){const s=e.colChars[o];if(!(s===null||s===""))for(let r=0;r<s.length;r+=1)t+=s[r],n.push(o)}return{text:t,colOf:n}}function en(e){let t="";const n=[],i=[];for(let r=0;r<e.length;r+=1){const l=tn(e[r]);for(let c=0;c<l.text.length;c+=1)t+=l.text[c],n.push(r),i.push(l.colOf[c])}const o=[];W.lastIndex=0;let s=W.exec(t);for(;s!==null;){const r=s[0].replace(Je,"");if(r.length>0){const l=s.index,c=l+r.length-1;let d=l;for(let m=l;m<=c;m+=1)(m===c||n[m+1]!==n[m])&&(o.push({lineIndex:n[d],startCol:i[d],endCol:i[m],url:r}),d=m+1)}s=W.exec(t)}return o}const D=0,nn=-2,sn=1,on=2,rn=3,ln=10,an=11,cn=12,dn=13,hn=14,un=15,mn=16,fn=17,pn=1,gn=2,yn=1,xn=2,Sn=3,bn=4,Cn=5,wn=6,Tn=1,En=2,Rn=3,vn=4;function ot(e){if(e.disposed||e.renderStateHandle===0)throw new Error("render state resources already disposed")}function Mn(e){switch(e){case 2:return"full";case 1:return"partial";default:return"clean"}}function _n(e){switch(e){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function An(e){switch(e){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function H(e,t){return{r:e.view().getUint8(t),g:e.view().getUint8(t+1),b:e.view().getUint8(t+2)}}function xt(e,t){const n=e.bindings.allocStruct("GhosttyColorRgb");try{const i=t(n.ptr);if(i===nn)return null;if(i!==D)throw new Error(`ghostty optional color read failed with result ${i}`);return H(e.bindings,n.ptr)}finally{n.free()}}function v(e,t){const n=e.bindings.allocU8();try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty bool read failed with result ${i}`);return e.bindings.readU8(n)!==0}finally{e.bindings.freeU8(n)}}function B(e,t){const n=e.bindings.allocBytes(2);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u16 read failed with result ${i}`);return e.bindings.view().getUint16(n,!0)}finally{e.bindings.freeBytes(n,2)}}function Dn(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u32 read failed with result ${i}`);return e.bindings.view().getUint32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function et(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty enum read failed with result ${i}`);return e.bindings.view().getInt32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function St(e,t){const n=e.bindings.allocBytes(8);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u64 read failed with result ${i}`);return e.bindings.readU64(n)}finally{e.bindings.freeBytes(n,8)}}function Hn(e){const t=e.bindings.allocStruct("GhosttyStyle");try{e.bindings.setField(t.view,"GhosttyStyle","size",e.bindings.typeSize("GhosttyStyle")),e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,xn,t.ptr);const n=i=>e.bindings.field("GhosttyStyle",i).offset;return{bold:t.view.getUint8(n("bold"))!==0,italic:t.view.getUint8(n("italic"))!==0,faint:t.view.getUint8(n("faint"))!==0,blink:t.view.getUint8(n("blink"))!==0,inverse:t.view.getUint8(n("inverse"))!==0,invisible:t.view.getUint8(n("invisible"))!==0,strikethrough:t.view.getUint8(n("strikethrough"))!==0,overline:t.view.getUint8(n("overline"))!==0,underline:t.view.getInt32(n("underline"),!0)}}finally{t.free()}}function kn(e){const t=Dn(e,i=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Sn,i));if(t===0)return[];const n=e.bindings.allocBytes(t*4);try{e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,bn,n);const i=[];for(let o=0;o<t;o+=1)i.push(e.bindings.view().getUint32(n+o*4,!0));return i}finally{e.bindings.freeBytes(n,t*4)}}function Nn(e){if(e.length===0)return"";try{return String.fromCodePoint(...e)}catch{return""}}function In(e){let t="";for(const n of e)if(!(n.widthKind==="spacer-tail"||n.widthKind==="spacer-head")){if(n.text){t+=n.text;continue}n.widthKind==="narrow"&&(t+=" ")}return t}function Bn(e){const t=e.bindings.allocStruct("GhosttyRenderStateColors");try{e.bindings.setField(t.view,"GhosttyRenderStateColors","size",e.bindings.typeSize("GhosttyRenderStateColors")),e.bindings.getRenderStateColors(e.renderStateHandle,t.ptr);const n=e.bindings.field("GhosttyRenderStateColors","palette").offset,i=[];for(let r=0;r<256;r+=1){const l=t.ptr+n+r*3;i.push(H(e.bindings,l))}const o=t.view.getUint8(e.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,s=v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,hn,r));return{cols:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,sn,r)),rows:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,on,r)),dirty:Mn(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,rn,r))),colors:{background:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","background").offset),foreground:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:o?H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:i},cursor:{style:_n(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,ln,r))),visible:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,an,r)),blinking:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,cn,r)),passwordInput:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,dn,r)),x:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,un,r)):null,y:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,mn,r)):null,wideTail:s?v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,fn,r)):!1}}}finally{t.free()}}function Ln(e,t){const n=St(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,gn,s));e.bindings.bindRenderStateRowCells(e.rowIteratorHandle,e.rowCellsHandle);const i=[];let o=0;for(;e.bindings.nextRenderStateRowCell(e.rowCellsHandle);){const s=St(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,yn,d)),r=kn(e),l=An(et(e,d=>e.bindings.getRawCellValueResult(s,Rn,d))),c={x:o,text:Nn(r),codepoints:r,widthKind:l,hasText:v(e,d=>e.bindings.getRawCellValueResult(s,vn,d)),style:Hn(e),fgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,wn,d)),bgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Cn,d))};i.push(c),o+=1}return{y:t,dirty:v(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,pn,s)),wrap:v(e,s=>e.bindings.getRawRowValueResult(n,Tn,s)),wrapContinuation:v(e,s=>e.bindings.getRawRowValueResult(n,En,s)),text:In(i),cells:i}}function bt(e){return{bindings:e,renderStateHandle:e.createRenderState(),rowIteratorHandle:e.createRenderStateRowIterator(),rowCellsHandle:e.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function Ct(e,t){ot(e),e.bindings.updateRenderState(e.renderStateHandle,t),e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle),e.snapshotVersion+=1,e.cachedMeta=null}function nt(e){return ot(e),e.cachedMeta||(e.cachedMeta=Bn(e)),e.cachedMeta}function*On(e){ot(e);const t=nt(e);e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle);let n=0;for(;n<t.rows&&e.bindings.nextRenderStateRowIterator(e.rowIteratorHandle);)yield Ln(e,n),n+=1}function X(e){e.disposed||(e.disposed=!0,e.rowCellsHandle!==0&&(e.bindings.freeRenderStateRowCells(e.rowCellsHandle),e.rowCellsHandle=0),e.rowIteratorHandle!==0&&(e.bindings.freeRenderStateRowIterator(e.rowIteratorHandle),e.rowIteratorHandle=0),e.renderStateHandle!==0&&(e.bindings.freeRenderState(e.renderStateHandle),e.renderStateHandle=0),e.cachedMeta=null)}const Fn={colChars:[],contentCols:0,wrappedToNext:!1};function $n(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n!==null&&n!==""&&n!==" ")return t+1}return 0}function wt(e,t=!1){const n=[];for(const i of e){if(i.widthKind==="spacer-tail"){n.push(null);continue}if(i.widthKind==="spacer-head"){n.push("");continue}n.push(i.text||" ")}return{colChars:n,contentCols:$n(n),wrappedToNext:t}}function Kn(e,t){return Math.max(0,Math.min(Math.max(e.colChars.length-1,0),Math.floor(t)))}function rt(e,t){let n=Kn(e,t);for(;n>0&&e.colChars[n]===null;)n-=1;return n}function q(e,t){let n=t;for(;n>0&&e.colChars[n]===null;)n-=1;return e.colChars[n]||""}function Tt(e,t){let n=t;for(;n+1<e.colChars.length&&e.colChars[n+1]===null;)n+=1;return n}function jn(e,t){return e.line<t.line?{start:e,end:t}:e.line>t.line?{start:t,end:e}:e.col<=t.col?{start:e,end:t}:{start:t,end:e}}function Yn(e,t,n){if(n.colChars.length===0)return{start:{line:e,col:0},end:{line:e,col:0}};const i=rt(n,t),o=l=>/[\p{L}\p{N}_-]/u.test(l);if(!o(q(n,i)))return{start:{line:e,col:i},end:{line:e,col:i}};let s=i,r=i;for(;s>0&&o(q(n,s-1));)s-=1;for(;r+1<n.colChars.length&&o(q(n,r+1));)r+=1;return{start:{line:e,col:s},end:{line:e,col:r}}}function Yt(e,t){const n=Math.max(t.contentCols-1,0);return{start:{line:e,col:0},end:{line:e,col:n}}}function Pt(e,t,n){const i=n(e.line);switch(t){case"word":return Yn(e.line,e.col,i);case"line":return Yt(e.line,i);default:{const o=rt(i,e.col);return{start:{line:e.line,col:o},end:{line:e.line,col:o}}}}}function Ut(){return{anchor:null,focus:null,mode:"character"}}function Et(e){return!!(e.anchor&&e.focus)}function Pn(){return Ut()}function Un(e,t,n){const i=Pt(t,t.mode,n);return{anchor:i.start,focus:i.end,mode:t.mode}}function Rt(e,t,n){return e.anchor?e.mode==="line"?{...e,focus:Yt(t.line,n(t.line)).end}:e.mode==="word"?{...e,focus:Pt(t,"word",n).end}:{...e,focus:{line:t.line,col:rt(n(t.line),t.col)}}:e}function Gt(e){return!e.anchor||!e.focus?null:jn(e.anchor,e.focus)}function Gn(e,t,n){const i=e.wrappedToNext?e.colChars.length-1:e.contentCols-1,o=Math.min(n,i);let s=Math.max(0,t);for(;s>0&&e.colChars[s]===null;)s-=1;if(s>o)return"";let r="";for(let l=s;l<=o;l+=1)r+=e.colChars[l]??"";return r}function Vn(e,t){const n=Gt(e);if(!n)return null;let i="";for(let o=n.start.line;o<=n.end.line;o+=1){const s=t(o),r=o===n.start.line?n.start.col:0,l=o===n.end.line?n.end.col:s.colChars.length-1;i+=Gn(s,r,l),o<n.end.line&&!s.wrappedToNext&&(i+=`
|
|
22
|
+
`)}return i}function zn(e,t,n,i){const o=Gt(e);if(!o)return[];const s=t+n-1,r=[];for(let l=Math.max(o.start.line,t);l<=Math.min(o.end.line,s);l+=1){const c=l-t;if(l===o.start.line&&l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:o.start.col,width:g-o.start.col+1});continue}if(l===o.start.line){const m=i?Math.max(i(l).colChars.length-o.start.col,0):Number.MAX_SAFE_INTEGER;r.push({row:c,x:o.start.col,width:m});continue}if(l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:0,width:g+1});continue}const d=i?i(l).colChars.length:Number.MAX_SAFE_INTEGER;r.push({row:c,x:0,width:d})}return r}const vt=80,k=24,Q=9,Z=17,Mt=1.2,Wn=48,Ai="ghostty-official",$=9,K=1e3,j=1002,Y=1003,J=1007,L=1047,O=1049,Xn=[$,K,j,Y],_t=1,At=3,Dt=2,qn=4,Qn=5;class Zn{constructor(t){this.content=t}translateToString(t){return t?this.content.replace(/\s+$/u,""):this.content}}class Jn{constructor(){h(this,"active",{baseY:0,viewportY:0,length:k,getLine:t=>{const n=t-this.active.viewportY,i=this.visibleLines[n];return typeof i=="string"?new Zn(i):null}});h(this,"visibleLines",Array.from({length:k},()=>""))}setViewport(t,n,i,o){this.active.viewportY=t,this.active.baseY=n,this.active.length=i,this.visibleLines=o}}const ti={deleteContentBackward:"Backspace",deleteContentForward:"Delete",insertLineBreak:"Enter",insertParagraph:"Enter"};function ei(e){return!(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey)}function ni(e,t){const n=e.slice(0,t).map(i=>i.text);for(;n.length<t;)n.push("");return n}function F(e){return Ft({shiftKey:!!e.shiftKey,ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,metaKey:!!e.metaKey,getModifierState:()=>!1})}class ii{constructor(){h(this,"terminal",null)}activate(t){this.terminal=t instanceof U?t:null}fit(){const t=this.proposeDimensions();!this.terminal||!t||this.terminal.resize(t.cols,t.rows)}proposeDimensions(){var t;return((t=this.terminal)==null?void 0:t.measureSizeFromElement())??null}dispose(){this.terminal=null}}class U{constructor(t,n,i,o,s,r){h(this,"buffer",new Jn);h(this,"_core",{_renderService:{dimensions:{css:{cell:{width:Q,height:Z}}}}});h(this,"options");h(this,"element",null);h(this,"textarea",null);h(this,"cols",vt);h(this,"rows",k);h(this,"bindings");h(this,"terminalHandle");h(this,"keyEncoderHandle");h(this,"mouseEncoderHandle");h(this,"renderState");h(this,"dataListeners",new Set);h(this,"selectionListeners",new Set);h(this,"linkListeners",new Set);h(this,"linkCursorActive",!1);h(this,"lastNotifiedSelectionText",null);h(this,"addons",new Set);h(this,"screenElement",null);h(this,"renderer",null);h(this,"renderRaf",null);h(this,"lastCursor",null);h(this,"disposed",!1);h(this,"disableStdin");h(this,"customKeyEventHandler",()=>!0);h(this,"imeIsComposing",!1);h(this,"lastCompositionCommit",null);h(this,"selectionState",Ut());h(this,"lineCache",new Map);h(this,"lastViewportOffset",0);h(this,"lastViewportRows",k);h(this,"lastRenderedRows",[]);h(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});h(this,"autoScrollTimer",null);h(this,"domEventDisposers",[]);h(this,"copyShortcutSuppressed",!1);h(this,"scrollbarThumb",null);h(this,"scrollbarFadeTimer",null);h(this,"pressedMouseButtons",new Set);h(this,"wheelPixelDelta",0);h(this,"mouseDragActive",!1);this.bindings=t,this.terminalHandle=n,this.keyEncoderHandle=i,this.mouseEncoderHandle=o,this.renderState=s,this.options=r,this.disableStdin=!!r.disableStdin}static async create(t){const n=await Le(),i=n.createTerminal(vt,k,t.scrollback);let o=0,s=0,r=null;try{return n.setTerminalTheme(i,t.theme),o=n.createKeyEncoder(),s=n.createMouseEncoder(),r=bt(n),new U(n,i,o,s,r,t)}catch(l){throw r&&X(r),o!==0&&n.freeKeyEncoder(o),s!==0&&n.freeMouseEncoder(s),n.freeTerminal(i),l}}open(t){if(this.disposed||this.element)return;const n=document.createElement("div");n.className="xterm",n.style.position="absolute",n.style.inset="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.backgroundColor=this.options.theme.background,n.style.color=this.options.theme.foreground,n.style.fontFamily=this.options.fontFamily,n.style.fontSize=`${this.options.fontSize}px`,n.style.lineHeight=String(this.options.lineHeight??Mt);const i=document.createElement("div");i.className="xterm-viewport",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",i.style.position="relative";const o=document.createElement("div");o.className="xterm-screen",o.style.width="100%",o.style.height="100%",o.style.position="relative",o.style.userSelect="none",o.style.webkitUserSelect="none",o.style.backgroundColor=this.options.theme.background;const s=document.createElement("div");s.className="xterm-helper-textarea",s.setAttribute("aria-label","Terminal Input"),s.setAttribute("role","textbox"),s.setAttribute("contenteditable","true"),s.setAttribute("autocorrect","off"),s.setAttribute("autocapitalize","off"),s.setAttribute("spellcheck","false"),s.style.position="absolute",s.style.opacity="1",s.style.pointerEvents="none",s.style.left="0",s.style.top="0",s.style.minWidth="1px",s.style.minHeight="1px",s.style.whiteSpace="pre",s.style.border="0",s.style.padding="0",s.style.margin="0",s.style.color=this.options.theme.foreground,s.style.backgroundColor="transparent",s.style.caretColor="transparent",s.style.overflow="visible",s.style.outline="none",s.style.boxShadow="none",s.style.fontFamily=this.options.fontFamily,s.style.fontSize=`${this.options.fontSize}px`,s.style.userSelect="text",s.style.webkitUserSelect="text";const r=document.createElement("div");r.className="xterm-scrollbar-track",r.style.position="absolute",r.style.top="0",r.style.right="0",r.style.width="8px",r.style.height="100%",r.style.backgroundColor="transparent",r.style.pointerEvents="none";const l=document.createElement("div");l.className="xterm-scrollbar-thumb",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.width="6px",l.style.marginRight="1px",l.style.borderRadius="3px",l.style.backgroundColor="rgba(128, 128, 128, 0.5)",l.style.pointerEvents="none",l.style.transition="opacity 0.15s ease",l.style.opacity="0",r.appendChild(l),i.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(r),t.appendChild(n),this.element=n,this.screenElement=o,this.textarea=s,this.scrollbarThumb=l,this.renderer=new Ze({screenElement:o,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const c=this.measureSizeFromElement();c?this.resize(c.cols,c.rows):this.render()}loadAddon(t){t.activate(this),this.addons.add(t)}onData(t){return this.dataListeners.add(t),{dispose:()=>{this.dataListeners.delete(t)}}}attachCustomKeyEventHandler(t){this.customKeyEventHandler=t}onSelectionChange(t){return this.selectionListeners.add(t),{dispose:()=>{this.selectionListeners.delete(t)}}}onLinkActivated(t){return this.linkListeners.add(t),{dispose:()=>{this.linkListeners.delete(t)}}}hasSelection(){return Et(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(t,n,i="word"){return this.disposed?!1:this.beginSelectionAt(t,n,i)}updateTouchSelection(t,n){this.disposed||this.updateSelectionDrag(t,n)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(t){if(this.disposed)return;const n=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,t);const i=this.isAltScreenActive();n&&!i&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const t of Xn)this.bindings.setTerminalMode(this.terminalHandle,t,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(L)||this.isModeEnabled(O)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(t,n){if(this.disposed)return;const i=Math.max(2,Math.floor(t)),o=Math.max(2,Math.floor(n));this.cols=i,this.rows=o,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,i,o,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(t){this.disposed||t===0||(this.bindings.scrollViewportDelta(this.terminalHandle,t),this.render())}scrollToTop(){this.disposed||(this.bindings.scrollViewportTop(this.terminalHandle),this.render())}scrollToBottom(){this.disposed||(this.bindings.scrollViewportBottom(this.terminalHandle),this.render())}exportModeSnapshot(){return{mouseX10:this.isModeEnabled($),mouseNormal:this.isModeEnabled(K),mouseButton:this.isModeEnabled(j),mouseAny:this.isModeEnabled(Y),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(J),altScreen1047:this.isModeEnabled(L),altScreen1049:this.isModeEnabled(O)}}restoreModeSnapshot(t){this.bindings.setTerminalMode(this.terminalHandle,$,t.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,K,t.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,j,t.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Y,t.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,t.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,t.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,t.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,t.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,J,t.altScroll),this.bindings.setTerminalMode(this.terminalHandle,L,t.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,O,t.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(t){if(this.disposed||t.deltaY===0)return!1;const n=this.gestureToLines(t);if(n===0)return!1;const i=this.getInputRoutingState();if(i.mouseReporting){const o=n<0?qn:Qn;let s=!1;for(let r=0;r<Math.abs(n);r+=1)s=this.emitMouseInput({action:"press",button:o,clientX:t.clientX,clientY:t.clientY,mods:F(t),anyButtonPressed:this.pressedMouseButtons.size>0})||s;return s}return i.altScroll?this.emitAltScrollInput(n):(this.scrollLines(n),!0)}paste(t){if(this.disposed||this.disableStdin||!t)return;const n=this.bindings.encodePaste(this.terminalHandle,t);n&&this.emitData(n)}focus(){var t;(t=this.textarea)==null||t.focus({preventScroll:!0})}getCursorViewportRect(){if(this.disposed)return null;const t=this.screenElement,n=this.lastCursor;if(!t||!n||!n.visible||n.y===null||this.textarea===null||document.activeElement!==this.textarea)return null;const{height:i}=this.cellDimensions();if(i<=0)return null;const o=t.getBoundingClientRect().top+n.y*i;return{top:o,bottom:o+i}}getRendererKind(){var t;return((t=this.renderer)==null?void 0:t.kind)??"unknown"}setTheme(t){var n;this.bindings.setTerminalTheme(this.terminalHandle,t),this.options.theme=t,this.element&&(this.element.style.backgroundColor=t.background,this.element.style.color=t.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=t.background),(n=this.renderer)==null||n.setTheme(t),this.scheduleRender()}setDisableStdin(t){this.disableStdin=t,this.syncInputState()}measureSizeFromElement(){const t=this.element;if(!t)return null;const n=t.getBoundingClientRect(),{width:i,height:o}=this.cellDimensions();return n.width===0||n.height===0||i<=0||o<=0?null:{cols:Math.max(2,Math.floor(n.width/i)),rows:Math.max(2,Math.floor(n.height/o))}}dispose(){var t,n;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const i of this.addons)i.dispose();this.addons.clear(),(t=this.renderer)==null||t.dispose(),this.renderer=null,(n=this.element)==null||n.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,X(this.renderState),this.bindings.freeMouseEncoder(this.mouseEncoderHandle),this.bindings.freeKeyEncoder(this.keyEncoderHandle),this.bindings.freeTerminal(this.terminalHandle)}}cellDimensions(){return this._core._renderService.dimensions.css.cell}syncInputState(){this.textarea&&(this.textarea.readOnly=this.disableStdin,this.textarea.tabIndex=this.disableStdin?-1:0,this.disableStdin&&document.activeElement===this.textarea&&this.textarea.blur())}bindDomEvents(){const t=this.element,n=this.textarea;if(!t||!n)return;t.addEventListener("click",()=>{this.disableStdin||this.focus()});const i=this.screenElement??t;i.addEventListener("mousedown",s=>{if(s instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const r=this.mouseButtonFromEvent(s);if(r===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(r),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:r,clientX:s.clientX,clientY:s.clientY,mods:F(s),anyButtonPressed:!0}),s.preventDefault();return}if(s.button===0&>(s)){const r=this.linkAtClient(s.clientX,s.clientY);if(r){this.emitLinkActivated(r),s.preventDefault();return}}s.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(s),s.preventDefault())}}),i.addEventListener("mousemove",s=>{if(!(!(s instanceof MouseEvent)||this.mouseDragActive)){if(this.getInputRoutingState().mouseReporting){this.setLinkCursor(!1);return}this.setLinkCursor(gt(s)&&this.linkAtClient(s.clientX,s.clientY)!==null)}}),i.addEventListener("mouseleave",()=>{this.setLinkCursor(!1)}),t.addEventListener("wheel",s=>{this.handleViewportGesture({source:"wheel",deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,shiftKey:s.shiftKey,ctrlKey:s.ctrlKey,altKey:s.altKey,metaKey:s.metaKey})&&s.preventDefault()},{passive:!1});const o=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(o){const s=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},r=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const c=this.mouseButtonFromEvent(l);c!==null&&this.pressedMouseButtons.delete(c),this.emitMouseInput({action:"release",button:c,clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};o.addEventListener("mousemove",s),o.addEventListener("mouseup",r),this.domEventDisposers.push(()=>{o.removeEventListener("mousemove",s),o.removeEventListener("mouseup",r)})}n.addEventListener("keydown",s=>{const r=this.getSelectionText();if(r&&Oe(s)){s.preventDefault(),Fe(r).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(s)||this.disableStdin||this.imeIsComposing||s.keyCode===229||$e(s)||!ei(s))return;const l=this.encodeKeyboardEvent(s,s.repeat?"repeat":"press");l&&(s.preventDefault(),this.emitData(l),this.clearTextarea())}),n.addEventListener("keyup",s=>{if(this.copyShortcutSuppressed){const l=s.key.toLowerCase();if(l==="c"){s.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,s.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const r=this.encodeKeyboardEvent(s,"release");r&&(s.preventDefault(),this.emitData(r),this.clearTextarea())}),n.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),n.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),n.addEventListener("compositionend",s=>{this.imeIsComposing=!1;const r=s.data??"";r&&(this.lastCompositionCommit={data:r,at:Date.now()},this.emitData(r),this.clearTextarea())}),n.addEventListener("beforeinput",s=>{if(this.disableStdin||s.inputType==="insertFromPaste"||s.isComposing||this.imeIsComposing)return;const r=ti[s.inputType??""];if(r){s.preventDefault();const d=this.encodeSyntheticKey(r);d&&this.emitData(d),this.clearTextarea();return}const l=s.data??"";if(!l)return;const c=this.lastCompositionCommit;if(c&&c.data===l&&Date.now()-c.at<40){this.lastCompositionCommit=null,s.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,s.preventDefault(),this.emitData(l),this.clearTextarea()}),n.addEventListener("paste",s=>{var l;if(this.disableStdin)return;const r=((l=s.clipboardData)==null?void 0:l.getData("text/plain"))??"";r&&(s.preventDefault(),this.paste(r),this.clearTextarea())}),n.addEventListener("copy",s=>{const r=this.getSelectionText();r&&Ke(s,r)}),n.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const s=n.textContent??"";if(!s){this.clearTextarea();return}const r=this.lastCompositionCommit;if(r&&r.data===s&&Date.now()-r.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(s),this.clearTextarea()})}encodeKeyboardEvent(t,n){const i=yt(t.code);if(i===0)return null;const o=t.key.length===1&&!t.ctrlKey&&!t.metaKey?t.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:n,keyCode:i,mods:Ft(t),composing:t.isComposing,utf8:o,unshiftedCodepoint:je(t.code)})}encodeSyntheticKey(t){const n={code:t,key:t,shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1,repeat:!1,isComposing:!1,getModifierState:()=>!1};return this.encodeKeyboardEvent(n,"press")}getInputRoutingState(){const t=this.isModeEnabled($)||this.isModeEnabled(K)||this.isModeEnabled(j)||this.isModeEnabled(Y),n=this.isModeEnabled(L)||this.isModeEnabled(O);return{mouseReporting:t,altScroll:!t&&n&&this.isModeEnabled(J)}}gestureToLines(t){const n=this.cellDimensions().height||Z;if(t.source==="wheel"){if(t.deltaMode===1)return this.wheelPixelDelta=0,t.deltaY>0?Math.ceil(t.deltaY):Math.floor(t.deltaY);if(t.deltaMode===2){this.wheelPixelDelta=0;const o=Math.max(1,this.rows),s=t.deltaY*o;return s>0?Math.ceil(s):Math.floor(s)}this.wheelPixelDelta+=t.deltaY;const i=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/n):Math.ceil(this.wheelPixelDelta/n);return i!==0&&(this.wheelPixelDelta-=i*n),i}return t.deltaY>0?Math.ceil(t.deltaY/n):Math.floor(t.deltaY/n)}isModeEnabled(t){return this.bindings.isTerminalModeEnabled(this.terminalHandle,t)}mouseButtonFromEvent(t){switch(t.button){case 0:return _t;case 1:return At;case 2:return Dt;default:return null}}mouseButtonFromButtons(t){return t&1?_t:t&4?At:t&2?Dt:null}pointerPositionFromClient(t,n){var r;const i=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!i)return null;const o=Math.max(1,i.width),s=Math.max(1,i.height);return{x:Math.max(0,Math.min(o-1,t-i.left)),y:Math.max(0,Math.min(s-1,n-i.top))}}emitMouseInput(t){var r;if(this.disableStdin)return!1;const n=this.pointerPositionFromClient(t.clientX,t.clientY);if(!n)return!1;const i=this.cellDimensions(),o=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!o)return!1;const s=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:t.action,button:t.button,mods:t.mods,x:n.x,y:n.y,anyButtonPressed:t.anyButtonPressed,screenWidth:Math.max(1,Math.round(o.width)),screenHeight:Math.max(1,Math.round(o.height)),cellWidth:Math.max(1,Math.round(i.width||Q)),cellHeight:Math.max(1,Math.round(i.height||Z))});return s?(this.emitData(s),!0):!1}emitAltScrollInput(t){const n=yt(t<0?"ArrowUp":"ArrowDown");if(n===0)return!1;let i=!1;for(let o=0;o<Math.abs(t);o+=1){const s=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:n,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});s&&(this.emitData(s),i=!0)}return i}emitData(t){for(const n of this.dataListeners)n(t)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const t=this.textarea,n=this.screenElement;if(!t||!n)return;const{width:i,height:o}=this.cellDimensions();if(i<=0||o<=0)return;const s=bt(this.bindings);let r=0,l=0;try{Ct(s,this.terminalHandle);const m=nt(s);m.cursor.x!==null&&m.cursor.y!==null&&(r=m.cursor.x,l=m.cursor.y)}finally{X(s)}const c=r*i,d=l*o;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.width=`${Math.max(1,i)}px`,t.style.height=`${Math.max(1,o)}px`,t.style.lineHeight=`${o}px`,t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`}scheduleRender(){this.renderRaf===null&&(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=null,this.render()}))}render(){if(this.disposed||!this.screenElement||!this.renderer)return;const t=this.bindings.readScrollbar(this.terminalHandle),n=Math.max(1,t.len||this.rows);Ct(this.renderState,this.terminalHandle);const i=nt(this.renderState),o=Array.from(On(this.renderState));this.lastCursor=i.cursor,this.cols=Math.max(2,i.cols),this.rows=Math.max(2,i.rows||n),this.lastViewportOffset=t.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=o;for(const d of o)this.lineCache.set(t.offset+d.y,wt(d.cells,d.wrap));const s=zn(this.selectionState,this.lastViewportOffset,this.lastViewportRows,d=>this.getLineModel(d)),r=this.getSelectionText();this.renderer.render({meta:i,rows:o,cellDimensions:this.cellDimensions(),selectionRects:s,selectionColor:this.options.theme.selectionBackground});const l=ni(o,this.rows),c=Math.max(0,t.total-t.len);this.buffer.setViewport(t.offset,c,t.total,l),this.updateSelectionTextProbe(r),this.updateScrollbar(t)}updateScrollbar(t){var c;const n=this.scrollbarThumb;if(!n)return;const i=((c=this.screenElement)==null?void 0:c.clientHeight)??0;if(i===0||t.total<=t.len){n.style.opacity="0";return}const o=t.len/t.total,s=Math.max(20,o*i),l=t.offset/Math.max(1,t.total-t.len)*(i-s);n.style.height=`${s}px`,n.style.transform=`translateY(${l}px)`,n.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{n.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const t=document.createElement("span");t.textContent="WWWWWWWWWW",t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="pre",t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,this.element.appendChild(t);const n=t.getBoundingClientRect();t.remove();const i=Math.max(1,globalThis.devicePixelRatio??1),o=n.width>0?n.width/10:Q,s=this.options.fontSize*(this.options.lineHeight??Mt);this._core._renderService.dimensions.css.cell.width=Math.max(1,Math.round(o*i))/i,this._core._renderService.dimensions.css.cell.height=Math.max(1,Math.round(s*i))/i}clearSelectionState(t=!0){this.selectionState=Pn(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),t&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(t,n,i){const o=this.hitTest(t,n);return o?(this.pointerDrag={active:!0,moved:!1,mode:i,lastClientX:t,lastClientY:n},this.selectionState=Un(this.selectionState,{...o,mode:i},s=>this.getLineModel(s)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(t,n){if(!this.pointerDrag.active)return;const i=this.hitTest(t,n);this.pointerDrag.lastClientX=t,this.pointerDrag.lastClientY=n,i&&(this.pointerDrag.moved=!0,this.selectionState=Rt(this.selectionState,i,o=>this.getLineModel(o)),this.render()),this.updateAutoScroll()}beginPointerSelection(t){this.beginSelectionAt(t.clientX,t.clientY,this.selectionModeFromClickDetail(t.detail))}updatePointerSelection(t){this.updateSelectionDrag(t.clientX,t.clientY)}finishPointerSelection(t){var i,o,s,r;if(!this.pointerDrag.active||t.button!==0)return;this.pointerDrag.lastClientX=t.clientX,this.pointerDrag.lastClientY=t.clientY,this.stopAutoScroll();const n=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((i=this.selectionState.anchor)==null?void 0:i.line)===((o=this.selectionState.focus)==null?void 0:o.line)&&((s=this.selectionState.anchor)==null?void 0:s.col)===((r=this.selectionState.focus)==null?void 0:r.col);if(this.pointerDrag.active=!1,n){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(t){return t>=3?"line":t===2?"word":"character"}hitTest(t,n){var S;const i=(S=this.screenElement)==null?void 0:S.getBoundingClientRect();if(!i)return null;const{width:o,height:s}=this.cellDimensions();if(o<=0||s<=0)return null;const r=t-i.left,l=n-i.top,c=Math.max(this.cols-1,0),d=Math.max(this.lastViewportRows-1,0),m=Math.max(0,Math.min(c,Math.floor(r/o))),g=Math.max(0,Math.min(d,Math.floor(l/s)));return{line:this.lastViewportOffset+g,col:m}}getLineModel(t){const n=this.lineCache.get(t);if(n)return n;const i=t-this.lastViewportOffset,o=this.lastRenderedRows[i];return o?wt(o.cells,o.wrap):Fn}emitLinkActivated(t){for(const n of this.linkListeners)n(t)}setLinkCursor(t){this.linkCursorActive!==t&&(this.linkCursorActive=t,this.screenElement&&(this.screenElement.style.cursor=t?"pointer":""))}linkAtClient(t,n){const i=this.hitTest(t,n);return i?this.linkAtPoint(i.line,i.col):null}linkAtPoint(t,n){if(this.getLineModel(t).colChars.length===0)return null;let i=t;for(;this.getLineModel(i-1).wrappedToNext;)i-=1;let o=t;for(;this.getLineModel(o).wrappedToNext;)o+=1;const s=[];for(let l=i;l<=o;l+=1)s.push(this.getLineModel(l));const r=t-i;for(const l of en(s))if(l.lineIndex===r&&n>=l.startCol&&n<=l.endCol)return l.url;return null}getSelectionText(){return Et(this.selectionState)?Vn(this.selectionState,t=>this.getLineModel(t)):null}updateSelectionTextProbe(t){if(globalThis.__tmexE2eTerminalSelectionText=t,t!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=t;for(const n of this.selectionListeners)n(t)}}updateAutoScroll(){var i;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(i=this.screenElement)==null?void 0:i.getBoundingClientRect();if(!t){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<t.top||this.pointerDrag.lastClientY>t.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Wn))}stepAutoScroll(){var o;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!t){this.stopAutoScroll();return}let n=0;if(this.pointerDrag.lastClientY<t.top?n=-1:this.pointerDrag.lastClientY>t.bottom&&(n=1),n===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,n),this.render();const i=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);i&&(this.selectionState=Rt(this.selectionState,i,s=>this.getLineModel(s)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const t=this.domEventDisposers.pop();t==null||t()}}}async function si(e){return U.create(e)}const oi=new Set(["Control","Shift","Alt","Meta","CapsLock","NumLock","ScrollLock","Dead","Unidentified","OS","ContextMenu","Fn","FnLock","Hyper","Super"]),ri={Enter:{label:"Enter",raw:"\r"},Tab:{label:"Tab",raw:" "},Escape:{label:"ESC",raw:"\x1B"},Backspace:{label:"Backspace",raw:"\b"}," ":{label:"Space",raw:" "},ArrowUp:{label:"↑",csiFinal:"A"},ArrowDown:{label:"↓",csiFinal:"B"},ArrowRight:{label:"→",csiFinal:"C"},ArrowLeft:{label:"←",csiFinal:"D"},Home:{label:"Home",csiFinal:"H"},End:{label:"End",csiFinal:"F"},Delete:{label:"Delete",csiNum:3},Insert:{label:"Insert",csiNum:2},PageUp:{label:"PgUp",csiNum:5},PageDown:{label:"PgDn",csiNum:6}},li={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"},ai={"[":"\x1B","\\":"","]":"","^":"",_:"","@":"\0","?":""};function ci(e){return 1+(e.shiftKey?1:0)+(e.altKey?2:0)+(e.ctrlKey?4:0)+(e.metaKey?8:0)}function di(e){const t=[];return e.ctrlKey&&t.push("CTRL"),e.altKey&&t.push("ALT"),e.metaKey&&t.push("CMD"),e.shiftKey&&t.push("SHIFT"),t.length?`${t.join("-")}-`:""}function hi(e){const t=e.key;if(!t||oi.has(t))return null;const n=ci(e),i=n!==1,o=di(e);if(t==="Tab"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Tab",payload:"\x1B[Z"};if(t==="Enter"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Enter",payload:"\x1B[13;2u"};if(e.ctrlKey&&!e.altKey&&!e.metaKey&&/^[a-zA-Z]$/.test(t)){const l=t.toUpperCase();return{label:`CTRL-${l}`,payload:String.fromCharCode(l.charCodeAt(0)-64)}}const s=li[t];if(s)return{label:o+t,payload:s};const r=ri[t];if(r){if("raw"in r){const c=e.altKey?`\x1B${r.raw}`:r.raw;return{label:o+r.label,payload:c}}if("csiFinal"in r){const c=i?`\x1B[1;${n}${r.csiFinal}`:`\x1B[${r.csiFinal}`;return{label:o+r.label,payload:c}}const l=i?`\x1B[${r.csiNum};${n}~`:`\x1B[${r.csiNum}~`;return{label:o+r.label,payload:l}}if(t.length===1){if(e.altKey&&!e.ctrlKey&&!e.metaKey)return{label:`ALT-${t.toUpperCase()}`,payload:`\x1B${t}`};if(e.ctrlKey){const l=ai[t];return l!==void 0?{label:o+t,payload:l}:null}return{label:t,payload:t}}return null}function Vt(e){return e.replace(/\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)/g,(t,n)=>{if(n[0]==="x"&&n.length===3||n[0]==="u"&&n.length===5)return String.fromCharCode(Number.parseInt(n.slice(1),16));switch(n){case"r":return"\r";case"n":return`
|
|
23
23
|
`;case"t":return" ";case"e":return"\x1B";case"0":return"\0";case"a":return"\x07";case"b":return"\b";case"f":return"\f";case"v":return"\v";case"\\":return"\\";default:return n}})}function it(e){let t="";for(const n of e){const i=n.codePointAt(0)??0;n==="\\"?t+="\\\\":n==="\r"?t+="\\r":n===`
|
|
24
|
-
`?t+="\\n":n===" "?t+="\\t":n==="\x1B"?t+="\\e":i<32||i>=127&&i<=159?t+=`\\x${i.toString(16).padStart(2,"0")}`:t+=n}return t}const ui={CTRL:"⌃",CONTROL:"⌃",SHIFT:"⇧",ALT:"⌥",OPTION:"⌥",OPT:"⌥",CMD:"⌘",META:"⌘",SUPER:"⌘",WIN:"⌘",ENTER:"⏎",RETURN:"⏎",CR:"⏎",ESC:"⎋",ESCAPE:"⎋",TAB:"⇥",BACKSPACE:"⌫",BS:"⌫",DELETE:"⌦",DEL:"⌦",SPACE:"␣",UP:"↑",DOWN:"↓",LEFT:"←",RIGHT:"→"};function mi(e){return e&&e.split(/[-+]/).map(n=>{const i=n.trim().toUpperCase();return ui[i]??n}).join("")}const fi={paste:jt,toggleKeyboard:$t,newAgentSession:st,scrollToBottom:Kt};function pi({items:e,useIcons:t,onActivate:n,disabled:i=!1,preventFocusSteal:o=!1,className:s,rowTestId:r="editor-shortcuts-row",idPrefix:l="editor-shortcut"}){const{t:c}=k();return a.jsx("div",{className:A("shortcut-row flex items-center gap-1.5 py-2 overflow-x-auto scrollbar-thin",s),"data-testid":r,children:e.map(d=>{const m=d.type==="action",g=m&&d.action?fi[d.action]:null,S=m&&d.action?c(`settings.terminal.shortcuts.action.${d.action}`):"",y=d.label||it(d.payload??""),C=t?mi(y):y,p=m?d.label.trim()||S:y;return a.jsx(M,{type:"button",variant:"ghost",size:"sm",className:"terminal-shortcut-btn h-8 min-w-9 px-2.5 rounded-full font-mono text-[13px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:p,"aria-label":p,"data-testid":`${l}-${d.id}`,onMouseDown:o?x=>x.preventDefault():void 0,onClick:n?()=>n(d):void 0,disabled:i,children:g?a.jsx(g,{className:"h-4 w-4"}):a.jsx("span",{children:C})},d.id)})})}const Ht=["terminal-shortcuts"];async function zt(e,t){try{return(await e.json()).error??t}catch{return t}}async function gi(){const e=await fetch("/api/settings/terminal-shortcuts");if(!e.ok)throw new Error(await zt(e,"Failed to load terminal shortcuts"));return(await e.json()).settings}async function yi(e){const t=await fetch("/api/settings/terminal-shortcuts",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await zt(t,"Failed to save terminal shortcuts"));return(await t.json()).settings}const Wt=[{action:"paste",icon:jt},{action:"toggleKeyboard",icon:$t},{action:"newAgentSession",icon:st},{action:"scrollToBottom",icon:Kt}];function Nt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`sc-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function kt(e){return JSON.stringify([e.id,e.type,e.label,e.payload??null,e.action??null])}function tt(e,t){return e.length!==t.length?!1:e.every((n,i)=>kt(n)===kt(t[i]))}function xi({action:e}){var i;const{t}=k(),n=((i=Wt.find(o=>o.action===e))==null?void 0:i.icon)??st;return a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-muted px-1.5 py-0.5 text-muted-foreground text-xs",children:[a.jsx(n,{className:"h-3.5 w-3.5"}),t(`settings.terminal.shortcuts.action.${e}`)]})}function Si({item:e,onLabelChange:t,onPayloadChange:n,onRemove:i}){const{t:o}=k(),{attributes:s,listeners:r,setNodeRef:l,setActivatorNodeRef:c,transform:d,transition:m,isDragging:g}=_e({id:e.id}),S=e.type==="action",[y,C]=w.useState(()=>it(e.payload??""));return w.useEffect(()=>{C(it(e.payload??""))},[e.payload]),a.jsxs("div",{ref:l,style:{transform:He.Translate.toString(d),transition:m},className:A("flex items-center gap-2 rounded-lg border border-border bg-background p-2.5",g&&"opacity-60 shadow-sm"),"data-testid":`shortcut-editor-row-${e.id}`,children:[a.jsx("button",{type:"button",ref:c,...s,...r,"aria-label":o("settings.terminal.shortcuts.dragHandle"),className:"shrink-0 cursor-grab touch-none text-muted-foreground hover:text-foreground",children:a.jsx(Ae,{className:"h-4 w-4"})}),S&&e.action?a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(xi,{action:e.action}),a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o(`settings.terminal.shortcuts.action.${e.action}`),className:"h-9 min-w-0 flex-1","data-testid":`shortcut-editor-label-${e.id}`})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":`shortcut-editor-label-${e.id}`}),a.jsx(_,{value:y,onChange:p=>C(p.target.value),onBlur:()=>n(e.id,Vt(y)),placeholder:o("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":`shortcut-editor-payload-${e.id}`})]}),a.jsx(M,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>i(e.id),"aria-label":o("settings.terminal.shortcuts.delete"),"data-testid":`shortcut-editor-remove-${e.id}`,children:a.jsx(De,{className:"h-4 w-4"})})]})}function bi(){const{t:e}=k(),t=me(),{data:n,isLoading:i,isError:o,refetch:s}=fe({queryKey:Ht,queryFn:gi}),[r,l]=w.useState([]),[c,d]=w.useState(!1),[m,g]=w.useState(null),[S,y]=w.useState(!1),[C,p]=w.useState(!1),[x,I]=w.useState(""),[lt,at]=w.useState("");w.useEffect(()=>{if(!n)return;if(m===null){l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons});return}if(tt(m.items,n.items)&&m.useIcons===n.useIcons)return;tt(r,m.items)&&c===m.useIcons&&(l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons}))},[n,m,r,c]);const Xt=w.useMemo(()=>m?!tt(r,m.items)||c!==m.useIcons:!1,[r,c,m]),qt=pe(V(Me,{activationConstraint:{distance:8}}),V(ve,{activationConstraint:{delay:250,tolerance:5}}),V(Re,{coordinateGetter:Ee})),ct=ge({mutationFn:()=>yi({items:r,useIcons:c}),onSuccess:f=>{t.setQueryData(Ht,f),l(f.items),d(f.useIcons),g({items:f.items,useIcons:f.useIcons}),pt.success(e("settings.terminal.shortcuts.saved"))},onError:f=>{pt.error(f instanceof Error?f.message:e("settings.terminal.shortcuts.saveFailed"))}}),Qt=f=>{const{active:b,over:R}=f;!R||b.id===R.id||l(T=>{const ht=T.findIndex(G=>G.id===b.id),ut=T.findIndex(G=>G.id===R.id);return ht<0||ut<0?T:Te(T,ht,ut)})},Zt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,label:b}:T)),Jt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,payload:b}:T)),te=f=>l(b=>b.filter(R=>R.id!==f)),dt=(f,b)=>{b&&l(R=>[...R,{id:Nt(),type:"send",label:f||b,payload:b}])},ee=f=>l(b=>[...b,{id:Nt(),type:"action",action:f,label:""}]),ne=()=>{l(Ye.map(f=>({...f}))),d(!1)},ie=f=>{f.preventDefault(),f.stopPropagation();const b=hi({key:f.key,ctrlKey:f.ctrlKey,shiftKey:f.shiftKey,altKey:f.altKey,metaKey:f.metaKey});b&&(dt(b.label,b.payload),y(!1))},se=()=>{const f=Vt(lt);f&&(dt(x.trim(),f),I(""),at(""))};return o&&!m?a.jsxs("div",{className:"space-y-2","data-testid":"terminal-shortcuts-error",children:[a.jsx("p",{className:"text-destructive text-sm",children:e("settings.terminal.shortcuts.loadFailed")}),a.jsx(M,{type:"button",variant:"outline",size:"sm",onClick:()=>s(),children:e("settings.terminal.shortcuts.retry")})]}):i&&!m?a.jsx("p",{className:"text-muted-foreground text-sm",children:e("settings.terminal.shortcuts.loading")}):a.jsxs("div",{className:"space-y-5","data-testid":"terminal-shortcuts-editor",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.preview")}),a.jsx("div",{className:"rounded-lg border border-border bg-muted/30 px-3","data-testid":"shortcut-preview",children:a.jsx(pi,{items:r,useIcons:c})})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border p-3",children:[a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"font-medium text-sm",children:e("settings.terminal.shortcuts.useIcons")}),a.jsx("span",{className:"text-muted-foreground text-xs",children:e("settings.terminal.shortcuts.useIconsDesc")})]}),a.jsx(ye,{checked:c,onCheckedChange:f=>d(f),"aria-label":e("settings.terminal.shortcuts.useIcons"),"data-testid":"shortcut-use-icons"})]}),a.jsx(xe,{sensors:qt,collisionDetection:Se,onDragEnd:Qt,children:a.jsx(be,{items:r.map(f=>f.id),strategy:Ce,children:a.jsx("div",{className:"space-y-2","data-testid":"shortcut-editor-list",children:r.map(f=>a.jsx(Si,{item:f,onLabelChange:Zt,onPayloadChange:Jt,onRemove:te},f.id))})})}),a.jsxs("div",{className:"space-y-3 rounded-lg border border-dashed border-border p-4",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.addShortcut")}),a.jsx("button",{type:"button",onKeyDown:ie,onFocus:()=>y(!0),onBlur:()=>y(!1),className:A("w-full rounded-lg border px-3 py-2.5 text-center text-sm outline-none transition-colors",S?"border-primary bg-primary/5 text-foreground":"border-border text-muted-foreground"),"data-testid":"shortcut-capture-input",children:e(S?"settings.terminal.shortcuts.capturePrompt":"settings.terminal.shortcuts.captureHint")}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:Wt.map(({action:f,icon:b})=>a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>ee(f),"data-testid":`shortcut-add-action-${f}`,children:[a.jsx(b,{className:"h-3.5 w-3.5"}),e(`settings.terminal.shortcuts.action.${f}`)]},f))}),a.jsx("button",{type:"button",className:"text-muted-foreground text-xs underline underline-offset-2",onClick:()=>p(f=>!f),children:e("settings.terminal.shortcuts.advanced")}),C&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx(_,{value:x,onChange:f=>I(f.target.value),placeholder:e("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":"shortcut-manual-label"}),a.jsx(_,{value:lt,onChange:f=>at(f.target.value),placeholder:e("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":"shortcut-manual-payload"}),a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:se,"data-testid":"shortcut-manual-add",children:[a.jsx(we,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.add")]})]})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[a.jsxs(M,{type:"button",variant:"ghost",size:"sm",onClick:ne,"data-testid":"shortcut-reset",children:[a.jsx(ze,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.reset")]}),a.jsx(M,{type:"button",variant:"default",size:"default",onClick:()=>ct.mutate(),disabled:!Xt||ct.isPending,"data-testid":"shortcut-save",children:e("settings.terminal.shortcuts.save")})]})]})}const u="\x1B",Ci=[`${u}[1;32m feat/terminal-font${u}[0m ${u}[39m~/projects/tmex${u}[0m`,`${u}[39m// 渲染中文与彩色代码块:字号 / 字体 / 行高 实时预览${u}[0m`,`${u}[35mexport const${u}[0m ${u}[36mgreeting${u}[0m = ${u}[33m"你好,世界 🌏"${u}[0m;`,`${u}[35mfunction${u}[0m ${u}[34mfib${u}[0m(${u}[36mn${u}[0m: ${u}[32mnumber${u}[0m) {`,` ${u}[35mreturn${u}[0m n ${u}[31m<${u}[0m ${u}[33m2${u}[0m ${u}[31m?${u}[0m n ${u}[31m:${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m1${u}[0m) ${u}[31m+${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m2${u}[0m);`,"}",`${u}[32m+ 新增${u}[0m ${u}[31m- 删除${u}[0m ${u}[33m~ 修改${u}[0m ${u}[36m通过测试 ✓${u}[0m`,`${u}[1;34m dir/${u}[0m ${u}[32m file.ts${u}[0m ${u}[33m README.md${u}[0m ${u}[35m config${u}[0m`,`${u}[39m$${u}[0m bun run ${u}[36mbuild:fonts${u}[0m ${u}[32m✓${u}[0m ${u}[39m14MB${u}[0m`,`${u}[7m NORMAL ${u}[0m ${u}[39m UTF-8 LF TypeScript${u}[0m`].join(`\r
|
|
25
|
-
`);function wi({className:e}){const t=E(c=>c.terminalFontId),n=E(c=>c.terminalFontSize),i=E(c=>c.terminalLineHeight),o=E(c=>c.theme),s=w.useRef(null),r=w.useRef(null);w.useEffect(()=>{let c=!1,d=null;return(async()=>{await
|
|
26
|
-
//# sourceMappingURL=terminal-settings-panel-CYV9svzz.js.map
|
|
24
|
+
`?t+="\\n":n===" "?t+="\\t":n==="\x1B"?t+="\\e":i<32||i>=127&&i<=159?t+=`\\x${i.toString(16).padStart(2,"0")}`:t+=n}return t}const ui={CTRL:"⌃",CONTROL:"⌃",SHIFT:"⇧",ALT:"⌥",OPTION:"⌥",OPT:"⌥",CMD:"⌘",META:"⌘",SUPER:"⌘",WIN:"⌘",ENTER:"⏎",RETURN:"⏎",CR:"⏎",ESC:"⎋",ESCAPE:"⎋",TAB:"⇥",BACKSPACE:"⌫",BS:"⌫",DELETE:"⌦",DEL:"⌦",SPACE:"␣",UP:"↑",DOWN:"↓",LEFT:"←",RIGHT:"→"};function mi(e){return e&&e.split(/[-+]/).map(n=>{const i=n.trim().toUpperCase();return ui[i]??n}).join("")}const fi={paste:jt,toggleKeyboard:$t,newAgentSession:st,scrollToBottom:Kt};function pi({items:e,useIcons:t,onActivate:n,disabled:i=!1,preventFocusSteal:o=!1,className:s,rowTestId:r="editor-shortcuts-row",idPrefix:l="editor-shortcut"}){const{t:c}=N();return a.jsx("div",{className:A("shortcut-row flex items-center gap-1.5 py-2 overflow-x-auto scrollbar-thin",s),"data-testid":r,children:e.map(d=>{const m=d.type==="action",g=m&&d.action?fi[d.action]:null,S=m&&d.action?c(`settings.terminal.shortcuts.action.${d.action}`):"",y=d.label||it(d.payload??""),C=t?mi(y):y,p=m?d.label.trim()||S:y;return a.jsx(M,{type:"button",variant:"ghost",size:"sm",className:"terminal-shortcut-btn h-8 min-w-9 px-2.5 rounded-full font-mono text-[13px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:p,"aria-label":p,"data-testid":`${l}-${d.id}`,onMouseDown:o?x=>x.preventDefault():void 0,onClick:n?()=>n(d):void 0,disabled:i,children:g?a.jsx(g,{className:"h-4 w-4"}):a.jsx("span",{children:C})},d.id)})})}const Ht=["terminal-shortcuts"];async function zt(e,t){try{return(await e.json()).error??t}catch{return t}}async function gi(){const e=await fetch("/api/settings/terminal-shortcuts");if(!e.ok)throw new Error(await zt(e,"Failed to load terminal shortcuts"));return(await e.json()).settings}async function yi(e){const t=await fetch("/api/settings/terminal-shortcuts",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await zt(t,"Failed to save terminal shortcuts"));return(await t.json()).settings}const Wt=[{action:"paste",icon:jt},{action:"toggleKeyboard",icon:$t},{action:"newAgentSession",icon:st},{action:"scrollToBottom",icon:Kt}];function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`sc-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function Nt(e){return JSON.stringify([e.id,e.type,e.label,e.payload??null,e.action??null])}function tt(e,t){return e.length!==t.length?!1:e.every((n,i)=>Nt(n)===Nt(t[i]))}function xi({action:e}){var i;const{t}=N(),n=((i=Wt.find(o=>o.action===e))==null?void 0:i.icon)??st;return a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-muted px-1.5 py-0.5 text-muted-foreground text-xs",children:[a.jsx(n,{className:"h-3.5 w-3.5"}),t(`settings.terminal.shortcuts.action.${e}`)]})}function Si({item:e,onLabelChange:t,onPayloadChange:n,onRemove:i}){const{t:o}=N(),{attributes:s,listeners:r,setNodeRef:l,setActivatorNodeRef:c,transform:d,transition:m,isDragging:g}=we({id:e.id}),S=e.type==="action",[y,C]=w.useState(()=>it(e.payload??""));return w.useEffect(()=>{C(it(e.payload??""))},[e.payload]),a.jsxs("div",{ref:l,style:{transform:Re.Translate.toString(d),transition:m},className:A("flex items-center gap-2 rounded-lg border border-border bg-background p-2.5",g&&"opacity-60 shadow-sm"),"data-testid":`shortcut-editor-row-${e.id}`,children:[a.jsx("button",{type:"button",ref:c,...s,...r,"aria-label":o("settings.terminal.shortcuts.dragHandle"),className:"shrink-0 cursor-grab touch-none text-muted-foreground hover:text-foreground",children:a.jsx(Te,{className:"h-4 w-4"})}),S&&e.action?a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(xi,{action:e.action}),a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o(`settings.terminal.shortcuts.action.${e.action}`),className:"h-9 min-w-0 flex-1","data-testid":`shortcut-editor-label-${e.id}`})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":`shortcut-editor-label-${e.id}`}),a.jsx(_,{value:y,onChange:p=>C(p.target.value),onBlur:()=>n(e.id,Vt(y)),placeholder:o("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":`shortcut-editor-payload-${e.id}`})]}),a.jsx(M,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>i(e.id),"aria-label":o("settings.terminal.shortcuts.delete"),"data-testid":`shortcut-editor-remove-${e.id}`,children:a.jsx(Ee,{className:"h-4 w-4"})})]})}function bi(){const{t:e}=N(),t=le(),{data:n,isLoading:i,isError:o,refetch:s}=ae({queryKey:Ht,queryFn:gi}),[r,l]=w.useState([]),[c,d]=w.useState(!1),[m,g]=w.useState(null),[S,y]=w.useState(!1),[C,p]=w.useState(!1),[x,I]=w.useState(""),[lt,at]=w.useState("");w.useEffect(()=>{if(!n)return;if(m===null){l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons});return}if(tt(m.items,n.items)&&m.useIcons===n.useIcons)return;tt(r,m.items)&&c===m.useIcons&&(l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons}))},[n,m,r,c]);const Xt=w.useMemo(()=>m?!tt(r,m.items)||c!==m.useIcons:!1,[r,c,m]),qt=ce(V(Ce,{activationConstraint:{distance:8}}),V(be,{activationConstraint:{delay:250,tolerance:5}}),V(Se,{coordinateGetter:xe})),ct=de({mutationFn:()=>yi({items:r,useIcons:c}),onSuccess:f=>{t.setQueryData(Ht,f),l(f.items),d(f.useIcons),g({items:f.items,useIcons:f.useIcons}),mt.success(e("settings.terminal.shortcuts.saved"))},onError:f=>{mt.error(f instanceof Error?f.message:e("settings.terminal.shortcuts.saveFailed"))}}),Qt=f=>{const{active:b,over:R}=f;!R||b.id===R.id||l(T=>{const ht=T.findIndex(G=>G.id===b.id),ut=T.findIndex(G=>G.id===R.id);return ht<0||ut<0?T:ye(T,ht,ut)})},Zt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,label:b}:T)),Jt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,payload:b}:T)),te=f=>l(b=>b.filter(R=>R.id!==f)),dt=(f,b)=>{b&&l(R=>[...R,{id:kt(),type:"send",label:f||b,payload:b}])},ee=f=>l(b=>[...b,{id:kt(),type:"action",action:f,label:""}]),ne=()=>{l(Ye.map(f=>({...f}))),d(!1)},ie=f=>{f.preventDefault(),f.stopPropagation();const b=hi({key:f.key,ctrlKey:f.ctrlKey,shiftKey:f.shiftKey,altKey:f.altKey,metaKey:f.metaKey});b&&(dt(b.label,b.payload),y(!1))},se=()=>{const f=Vt(lt);f&&(dt(x.trim(),f),I(""),at(""))};return o&&!m?a.jsxs("div",{className:"space-y-2","data-testid":"terminal-shortcuts-error",children:[a.jsx("p",{className:"text-destructive text-sm",children:e("settings.terminal.shortcuts.loadFailed")}),a.jsx(M,{type:"button",variant:"outline",size:"sm",onClick:()=>s(),children:e("settings.terminal.shortcuts.retry")})]}):i&&!m?a.jsx("p",{className:"text-muted-foreground text-sm",children:e("settings.terminal.shortcuts.loading")}):a.jsxs("div",{className:"space-y-5","data-testid":"terminal-shortcuts-editor",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.preview")}),a.jsx("div",{className:"rounded-lg border border-border bg-muted/30 px-3","data-testid":"shortcut-preview",children:a.jsx(pi,{items:r,useIcons:c})})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border p-3",children:[a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"font-medium text-sm",children:e("settings.terminal.shortcuts.useIcons")}),a.jsx("span",{className:"text-muted-foreground text-xs",children:e("settings.terminal.shortcuts.useIconsDesc")})]}),a.jsx(he,{checked:c,onCheckedChange:f=>d(f),"aria-label":e("settings.terminal.shortcuts.useIcons"),"data-testid":"shortcut-use-icons"})]}),a.jsx(ue,{sensors:qt,collisionDetection:me,onDragEnd:Qt,children:a.jsx(fe,{items:r.map(f=>f.id),strategy:pe,children:a.jsx("div",{className:"space-y-2","data-testid":"shortcut-editor-list",children:r.map(f=>a.jsx(Si,{item:f,onLabelChange:Zt,onPayloadChange:Jt,onRemove:te},f.id))})})}),a.jsxs("div",{className:"space-y-3 rounded-lg border border-dashed border-border p-4",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.addShortcut")}),a.jsx("button",{type:"button",onKeyDown:ie,onFocus:()=>y(!0),onBlur:()=>y(!1),className:A("w-full rounded-lg border px-3 py-2.5 text-center text-sm outline-none transition-colors",S?"border-primary bg-primary/5 text-foreground":"border-border text-muted-foreground"),"data-testid":"shortcut-capture-input",children:e(S?"settings.terminal.shortcuts.capturePrompt":"settings.terminal.shortcuts.captureHint")}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:Wt.map(({action:f,icon:b})=>a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>ee(f),"data-testid":`shortcut-add-action-${f}`,children:[a.jsx(b,{className:"h-3.5 w-3.5"}),e(`settings.terminal.shortcuts.action.${f}`)]},f))}),a.jsx("button",{type:"button",className:"text-muted-foreground text-xs underline underline-offset-2",onClick:()=>p(f=>!f),children:e("settings.terminal.shortcuts.advanced")}),C&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx(_,{value:x,onChange:f=>I(f.target.value),placeholder:e("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":"shortcut-manual-label"}),a.jsx(_,{value:lt,onChange:f=>at(f.target.value),placeholder:e("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":"shortcut-manual-payload"}),a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:se,"data-testid":"shortcut-manual-add",children:[a.jsx(ge,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.add")]})]})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[a.jsxs(M,{type:"button",variant:"ghost",size:"sm",onClick:ne,"data-testid":"shortcut-reset",children:[a.jsx(ze,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.reset")]}),a.jsx(M,{type:"button",variant:"default",size:"default",onClick:()=>ct.mutate(),disabled:!Xt||ct.isPending,"data-testid":"shortcut-save",children:e("settings.terminal.shortcuts.save")})]})]})}const u="\x1B",Ci=[`${u}[1;32m feat/terminal-font${u}[0m ${u}[39m~/projects/tmex${u}[0m`,`${u}[39m// 渲染中文与彩色代码块:字号 / 字体 / 行高 实时预览${u}[0m`,`${u}[35mexport const${u}[0m ${u}[36mgreeting${u}[0m = ${u}[33m"你好,世界 🌏"${u}[0m;`,`${u}[35mfunction${u}[0m ${u}[34mfib${u}[0m(${u}[36mn${u}[0m: ${u}[32mnumber${u}[0m) {`,` ${u}[35mreturn${u}[0m n ${u}[31m<${u}[0m ${u}[33m2${u}[0m ${u}[31m?${u}[0m n ${u}[31m:${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m1${u}[0m) ${u}[31m+${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m2${u}[0m);`,"}",`${u}[32m+ 新增${u}[0m ${u}[31m- 删除${u}[0m ${u}[33m~ 修改${u}[0m ${u}[36m通过测试 ✓${u}[0m`,`${u}[1;34m dir/${u}[0m ${u}[32m file.ts${u}[0m ${u}[33m README.md${u}[0m ${u}[35m config${u}[0m`,`${u}[39m$${u}[0m bun run ${u}[36mbuild:fonts${u}[0m ${u}[32m✓${u}[0m ${u}[39m14MB${u}[0m`,`${u}[7m NORMAL ${u}[0m ${u}[39m UTF-8 LF TypeScript${u}[0m`].join(`\r
|
|
25
|
+
`);function wi({className:e}){const t=E(c=>c.terminalFontId),n=E(c=>c.terminalFontSize),i=E(c=>c.terminalLineHeight),o=E(c=>c.theme),s=w.useRef(null),r=w.useRef(null);w.useEffect(()=>{let c=!1,d=null;return(async()=>{await ve(t,n);const m=s.current;if(c||!m)return;if(d=await si({fontFamily:Me(t),fontSize:n,lineHeight:i,scrollback:100,theme:o==="light"?ft:pt,disableStdin:!0}),c){d.dispose();return}d.open(m);const g=new ii;d.loadAddon(g),r.current=g,g.fit(),d.write(Ci)})(),()=>{c=!0,r.current=null,d==null||d.dispose()}},[t,n,i,o]),w.useEffect(()=>{const c=s.current;if(!c)return;const d=new ResizeObserver(()=>{var m;return(m=r.current)==null?void 0:m.fit()});return d.observe(c),()=>d.disconnect()},[]);const l=Math.ceil(n*i*12);return a.jsx("div",{className:A("relative w-full overflow-hidden rounded-md border",e),style:{height:`${l}px`,backgroundColor:o==="light"?ft.background:pt.background},children:a.jsx("div",{ref:s,className:"absolute inset-0"})})}const It=8,Bt=28,Lt=1,Ot=2,Ti=[{value:"lift",labelKey:"terminal.keyboardBehavior.modeLift",descKey:"terminal.keyboardBehavior.modeLiftDesc"},{value:"resize",labelKey:"terminal.keyboardBehavior.modeResize",descKey:"terminal.keyboardBehavior.modeResizeDesc"},{value:"follow",labelKey:"terminal.keyboardBehavior.modeFollow",descKey:"terminal.keyboardBehavior.modeFollowDesc"}];function Di({showPreview:e=!0,showShortcuts:t=!0}){const{t:n}=N(),i=E(p=>p.terminalFontSize),o=E(p=>p.setTerminalFontSize),s=E(p=>p.terminalLineHeight),r=E(p=>p.setTerminalLineHeight),l=E(p=>p.terminalFontId),c=E(p=>p.setTerminalFontId),d=E(p=>p.keyboardBehaviorMode),m=E(p=>p.setKeyboardBehaviorMode),[g,S]=w.useState(String(i)),[y,C]=w.useState(String(s));return w.useEffect(()=>{S(String(i))},[i]),w.useEffect(()=>{C(String(s))},[s]),a.jsxs("div",{className:"space-y-6",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:n("settings.terminal.description")}),e&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("settings.terminal.preview")}),a.jsx(wi,{})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-font-size",children:n("settings.terminal.fontSize")}),a.jsx(_,{id:"terminal-font-size","data-testid":"terminal-font-size",type:"number",min:It,max:Bt,step:1,value:g,onChange:p=>{S(p.target.value);const x=Number(p.target.value);Number.isFinite(x)&&x>=It&&x<=Bt&&o(x)},className:"min-h-10"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-line-height",children:n("settings.terminal.lineHeight")}),a.jsx(_,{id:"terminal-line-height","data-testid":"terminal-line-height",type:"number",min:Lt,max:Ot,step:.1,value:y,onChange:p=>{C(p.target.value);const x=Number(p.target.value);Number.isFinite(x)&&x>=Lt&&x<=Ot&&r(x)},className:"min-h-10"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-font-family",children:n("settings.terminal.fontFamily")}),a.jsxs(_e,{value:l,onValueChange:p=>{p&&c(p)},children:[a.jsx(Ae,{id:"terminal-font-family","data-testid":"terminal-font-family",className:"min-h-10 w-full",children:a.jsx(De,{children:He(l).displayName})}),a.jsx(ke,{children:Ne.map(p=>a.jsx(Ie,{value:p.id,children:p.displayName},p.id))})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("terminal.keyboardBehavior.title")}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("terminal.keyboardBehavior.description")}),a.jsx("div",{className:"flex flex-col gap-2",children:Ti.map(p=>{const x=d===p.value;return a.jsxs("button",{type:"button",onClick:()=>m(p.value),"aria-pressed":x,"data-testid":`keyboard-behavior-option-${p.value}`,className:A("flex items-start gap-3 rounded-lg border p-3 text-left transition-colors",x?"border-primary bg-primary/5":"border-border hover:bg-muted/50"),children:[a.jsx("span",{className:A("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",x?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/40"),children:x&&a.jsx(Be,{className:"h-3.5 w-3.5"})}),a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"text-sm font-medium",children:n(p.labelKey)}),a.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:n(p.descKey)})]})]},p.value)})})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("settings.terminal.savedInBrowser")}),t&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"h-px bg-border"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block font-medium text-sm",children:n("settings.terminal.shortcuts.title")}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("settings.terminal.shortcuts.savedOnServer")}),a.jsx(bi,{})]})]})]})}export{Kt as A,jt as C,ii as F,_i as R,pi as S,Di as T,Ai as a,bi as b,si as c,ze as d,gi as f,Ht as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as l,D as pt,V as Wt,W as Pt,X as Bt,c as gt,l as S,I as Vt,N as Ft,Y as ft,d as J,C as zt,$ as Gt,z as Ot}from"./mermaid.core-
|
|
1
|
+
import{_ as l,D as pt,V as Wt,W as Pt,X as Bt,c as gt,l as S,I as Vt,N as Ft,Y as ft,d as J,C as zt,$ as Gt,z as Ot}from"./mermaid.core-4dbvlhht.js";import{d as ot}from"./arc-Bzmm6y8F.js";import"./index-CwH-l50P.js";var tt=(function(){var e=l(function(k,s,d,h){for(d=d||{},h=k.length;h--;d[k[h]]=s);return d},"o"),t=[6,11,13,14,15,17,19,20,23,24],n=[1,12],i=[1,13],r=[1,14],o=[1,15],c=[1,16],a=[1,19],p=[1,20],y={trace:l(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:l(function(s,d,h,g,m,u,w){var v=u.length-1;switch(m){case 1:return u[v-1];case 3:g.setDirection("LR");break;case 4:g.setDirection("TD");break;case 5:this.$=[];break;case 6:u[v-1].push(u[v]),this.$=u[v-1];break;case 7:case 8:this.$=u[v];break;case 9:case 10:this.$=[];break;case 11:g.getCommonDb().setDiagramTitle(u[v].substr(6)),this.$=u[v].substr(6);break;case 12:this.$=u[v].trim(),g.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=u[v].trim(),g.getCommonDb().setAccDescription(this.$);break;case 15:g.addSection(u[v].substr(8)),this.$=u[v].substr(8);break;case 18:g.addTask(u[v],0,""),this.$=u[v];break;case 19:g.addEvent(u[v].substr(2)),this.$=u[v];break}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(t,[2,5],{5:6}),e(t,[2,2]),e(t,[2,3]),e(t,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:n,15:i,17:r,19:o,20:c,21:17,22:18,23:a,24:p},e(t,[2,10],{1:[2,1]}),e(t,[2,6]),{12:21,14:n,15:i,17:r,19:o,20:c,21:17,22:18,23:a,24:p},e(t,[2,8]),e(t,[2,9]),e(t,[2,11]),{16:[1,22]},{18:[1,23]},e(t,[2,14]),e(t,[2,15]),e(t,[2,16]),e(t,[2,17]),e(t,[2,18]),e(t,[2,19]),e(t,[2,7]),e(t,[2,12]),e(t,[2,13])],defaultActions:{},parseError:l(function(s,d){if(d.recoverable)this.trace(s);else{var h=new Error(s);throw h.hash=d,h}},"parseError"),parse:l(function(s){var d=this,h=[0],g=[],m=[null],u=[],w=this.table,v="",M=0,R=0,P=2,V=1,L=u.slice.call(arguments,1),_=Object.create(this.lexer),C={yy:{}};for(var F in this.yy)Object.prototype.hasOwnProperty.call(this.yy,F)&&(C.yy[F]=this.yy[F]);_.setInput(s,C.yy),C.yy.lexer=_,C.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var z=_.yylloc;u.push(z);var q=_.options&&_.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function X(A){h.length=h.length-2*A,m.length=m.length-A,u.length=u.length-A}l(X,"popStack");function O(){var A;return A=g.pop()||_.lex()||V,typeof A!="number"&&(A instanceof Array&&(g=A,A=g.pop()),A=d.symbols_[A]||A),A}l(O,"lex");for(var $,N,b,T,E={},H,I,B,D;;){if(N=h[h.length-1],this.defaultActions[N]?b=this.defaultActions[N]:(($===null||typeof $>"u")&&($=O()),b=w[N]&&w[N][$]),typeof b>"u"||!b.length||!b[0]){var K="";D=[];for(H in w[N])this.terminals_[H]&&H>P&&D.push("'"+this.terminals_[H]+"'");_.showPosition?K="Parse error on line "+(M+1)+`:
|
|
2
2
|
`+_.showPosition()+`
|
|
3
3
|
Expecting `+D.join(", ")+", got '"+(this.terminals_[$]||$)+"'":K="Parse error on line "+(M+1)+": Unexpected "+($==V?"end of input":"'"+(this.terminals_[$]||$)+"'"),this.parseError(K,{text:_.match,token:this.terminals_[$]||$,line:_.yylineno,loc:z,expected:D})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+N+", token: "+$);switch(b[0]){case 1:h.push($),m.push(_.yytext),u.push(_.yylloc),h.push(b[1]),$=null,R=_.yyleng,v=_.yytext,M=_.yylineno,z=_.yylloc;break;case 2:if(I=this.productions_[b[1]][1],E.$=m[m.length-I],E._$={first_line:u[u.length-(I||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(I||1)].first_column,last_column:u[u.length-1].last_column},q&&(E._$.range=[u[u.length-(I||1)].range[0],u[u.length-1].range[1]]),T=this.performAction.apply(E,[v,R,M,C.yy,b[1],m,u].concat(L)),typeof T<"u")return T;I&&(h=h.slice(0,-1*I*2),m=m.slice(0,-1*I),u=u.slice(0,-1*I)),h.push(this.productions_[b[1]][0]),m.push(E.$),u.push(E._$),B=w[h[h.length-2]][h[h.length-1]],h.push(B);break;case 3:return!0}}return!0},"parse")},x=(function(){var k={EOF:1,parseError:l(function(d,h){if(this.yy.parser)this.yy.parser.parseError(d,h);else throw new Error(d)},"parseError"),setInput:l(function(s,d){return this.yy=d||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:l(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var d=s.match(/(?:\r\n?|\n).*/g);return d?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:l(function(s){var d=s.length,h=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-d),this.offset-=d;var g=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),h.length-1&&(this.yylineno-=h.length-1);var m=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:h?(h.length===g.length?this.yylloc.first_column:0)+g[g.length-h.length].length-h[0].length:this.yylloc.first_column-d},this.options.ranges&&(this.yylloc.range=[m[0],m[0]+this.yyleng-d]),this.yyleng=this.yytext.length,this},"unput"),more:l(function(){return this._more=!0,this},"more"),reject:l(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:l(function(s){this.unput(this.match.slice(s))},"less"),pastInput:l(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:l(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:l(function(){var s=this.pastInput(),d=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
|
|
@@ -118,4 +118,3 @@ Expecting `+D.join(", ")+", got '"+(this.terminals_[$]||$)+"'":K="Parse error on
|
|
|
118
118
|
filter: brightness(120%);
|
|
119
119
|
}
|
|
120
120
|
`},"getStyles"),fe=ge,ye={setConf:l(()=>{},"setConf"),draw:l((e,t,n,i)=>{var o,c;return(((c=(o=i==null?void 0:i.db)==null?void 0:o.getDirection)==null?void 0:c.call(o))??"LR")==="TD"?de.draw(e,t,n,i):ie.draw(e,t,n,i)},"draw")},ve={db:yt,renderer:ye,parser:Dt,styles:fe};export{ve as diagram};
|
|
121
|
-
//# sourceMappingURL=timeline-definition-PNZ67QCA-CEBskfkL.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Y as p,j as s,X as g,o as i,Z as a}from"./index-CwH-l50P.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const h=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],b=p("rotate-cw",h);function j({value:e=0,className:t}){const r=Math.max(0,Math.min(100,e));return s.jsx("div",{className:g("bg-secondary relative h-1.5 w-full overflow-hidden rounded-full",t),children:s.jsx("div",{className:"bg-primary h-full rounded-full transition-[width] duration-150",style:{width:`${r}%`}})})}function m(e,t){return e==="upload"?t===1?a.t("files.transfer.legUserToTmex"):a.t("files.transfer.legTmexToServer"):t===1?a.t("files.transfer.legServerToTmex"):a.t("files.transfer.legTmexToUser")}function x({label:e,leg:t}){const r=[t.rate,t.detail].filter(Boolean).join(" · ");return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e}),s.jsx("span",{className:"shrink-0 tabular-nums",children:r})]}),s.jsx(j,{value:t.pct})]})}function N({m:e}){return s.jsxs("div",{className:"flex w-full flex-col gap-2","data-testid":"transfer-toast",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:e.fileName}),s.jsx(x,{label:m(e.direction,1),leg:e.legs[0]}),s.jsx(x,{label:m(e.direction,2),leg:e.legs[1]})]})}function w(e,t,r){const l=`transfer-${e}-${performance.now()}`,o={fileName:e,direction:t,legs:[{pct:0},{pct:0}]};let c=0;const d=()=>{const n={...o,legs:[{...o.legs[0]},{...o.legs[1]}]};i(s.jsx(N,{m:n}),{id:l,duration:Number.POSITIVE_INFINITY,dismissible:!1,closeButton:!1,action:{label:a.t("files.transfer.cancel"),onClick:()=>r()},classNames:{content:"flex-1"}})};return d(),{leg(n,u){o.legs[n-1]=u;const f=performance.now();u.pct<100&&f-c<100||(c=f,d())},success(n){i.success(s.jsx("span",{"data-testid":"transfer-toast",children:n}),{id:l,duration:4e3,dismissible:!0,closeButton:!0})},fail(n){i.error(s.jsx("span",{"data-testid":"transfer-toast",children:n}),{id:l,duration:Number.POSITIVE_INFINITY,dismissible:!0,closeButton:!0})},cancel(){i.dismiss(l)}}}export{b as R,w as s};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Y as e}from"./index-CwH-l50P.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const a=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],o=e("triangle-alert",a);export{o as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aU as Gt,s as Wt,g as Kt,q as Ht,p as Xt,a as Yt,b as Zt,_ as S,D as St,I as Jt,d as rt,al as Qt,V as $t,W as te,X as ee,e as ne,z as se,F as ie,G as re}from"./mermaid.core-B-wSkmMd.js";import"./index-CYmVLCAD.js";const kt=(t,n)=>Gt(t,"a",-n),_t=1e-10;function st(t,n){const s=ae(t),e=s.filter(c=>oe(c,t));let i=0,r=0;const o=[];if(e.length>1){const c=Et(e);for(let u=0;u<e.length;++u){const a=e[u];a.angle=Math.atan2(a.x-c.x,a.y-c.y)}e.sort((u,a)=>a.angle-u.angle);let f=e[e.length-1];for(let u=0;u<e.length;++u){const a=e[u];r+=(f.x+a.x)*(a.y-f.y);const y={x:(a.x+f.x)/2,y:(a.y+f.y)/2};let d=null;for(let m=0;m<a.parentIndex.length;++m)if(f.parentIndex.includes(a.parentIndex[m])){const x=t[a.parentIndex[m]],M=Math.atan2(a.x-x.x,a.y-x.y),E=Math.atan2(f.x-x.x,f.y-x.y);let _=E-M;_<0&&(_+=2*Math.PI);const w=E-_/2;let g=W(y,{x:x.x+x.radius*Math.sin(w),y:x.y+x.radius*Math.cos(w)});g>x.radius*2&&(g=x.radius*2),(d==null||d.width>g)&&(d={circle:x,width:g,p1:a,p2:f,large:g>x.radius,sweep:!0})}d!=null&&(o.push(d),i+=lt(d.circle.radius,d.width),f=a)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let f=!1;for(let u=0;u<t.length;++u)if(W(t[u],c)>Math.abs(c.radius-t[u].radius)){f=!0;break}f?i=r=0:(i=c.radius*c.radius*Math.PI,o.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-_t,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return r/=2,n&&(n.area=i+r,n.arcArea=i,n.polygonArea=r,n.arcs=o,n.innerPoints=e,n.intersectionPoints=s),i+r}function oe(t,n){return n.every(s=>W(t,s)<s.radius+_t)}function ae(t){const n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){const i=Tt(t[s],t[e]);for(const r of i)r.parentIndex=[s,e],n.push(r)}return n}function lt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function W(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function xt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);const e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return lt(t,e)+lt(n,i)}function Tt(t,n){const s=W(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];const r=(e*e-i*i+s*s)/(2*s),o=Math.sqrt(e*e-r*r),c=t.x+r*(n.x-t.x)/s,f=t.y+r*(n.y-t.y)/s,u=-(n.y-t.y)*(o/s),a=-(n.x-t.x)*(o/s);return[{x:c+u,y:f-a},{x:c-u,y:f+a}]}function Et(t){const n={x:0,y:0};for(const s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}function le(t,n,s,e){e=e||{};const i=e.maxIterations||100,r=e.tolerance||1e-10,o=t(n),c=t(s);let f=s-n;if(o*c>0)throw"Initial bisect points must have opposite signs";if(o===0)return n;if(c===0)return s;for(let u=0;u<i;++u){f/=2;const a=n+f,y=t(a);if(y*o>=0&&(n=a),Math.abs(f)<r||y===0)return a}return n+f}function ct(t){const n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}function Mt(t,n){return ct(t).map(()=>ct(n))}function tt(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}function ut(t){return Math.sqrt(tt(t,t))}function ht(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}function Q(t,n,s,e,i){for(let r=0;r<t.length;++r)t[r]=n*s[r]+e*i[r]}function zt(t,n,s){s=s||{};const e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,r=s.zeroDelta||.001,o=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,f=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,a=s.psi!==void 0?s.psi:-.5,y=s.sigma!==void 0?s.sigma:.5;let d;const m=n.length,x=new Array(m+1);x[0]=n,x[0].fx=t(n),x[0].id=0;for(let v=0;v<m;++v){const l=n.slice();l[v]=l[v]?l[v]*i:r,x[v+1]=l,x[v+1].fx=t(l),x[v+1].id=v+1}function M(v){for(let l=0;l<v.length;l++)x[m][l]=v[l];x[m].fx=v.fx}const E=(v,l)=>v.fx-l.fx,_=n.slice(),w=n.slice(),g=n.slice(),b=n.slice();for(let v=0;v<e;++v){if(x.sort(E),s.history){const p=x.map(h=>{const j=h.slice();return j.fx=h.fx,j.id=h.id,j});p.sort((h,j)=>h.id-j.id),s.history.push({x:x[0].slice(),fx:x[0].fx,simplex:p})}d=0;for(let p=0;p<m;++p)d=Math.max(d,Math.abs(x[0][p]-x[1][p]));if(Math.abs(x[0].fx-x[m].fx)<o&&d<c)break;for(let p=0;p<m;++p){_[p]=0;for(let h=0;h<m;++h)_[p]+=x[h][p];_[p]/=m}const l=x[m];if(Q(w,1+f,_,-f,l),w.fx=t(w),w.fx<x[0].fx)Q(b,1+u,_,-u,l),b.fx=t(b),b.fx<w.fx?M(b):M(w);else if(w.fx>=x[m-1].fx){let p=!1;if(w.fx>l.fx?(Q(g,1+a,_,-a,l),g.fx=t(g),g.fx<l.fx?M(g):p=!0):(Q(g,1-a*f,_,a*f,l),g.fx=t(g),g.fx<w.fx?M(g):p=!0),p){if(y>=1)break;for(let h=1;h<x.length;++h)Q(x[h],1-y,x[0],y,x[h]),x[h].fx=t(x[h])}}else M(w)}return x.sort(E),{fx:x[0].fx,x:x[0]}}function ce(t,n,s,e,i,r,o){const c=s.fx,f=tt(s.fxprime,n);let u=c,a=c,y=f,d=0;i=i||1,r=r||1e-6,o=o||.1;function m(x,M,E){for(let _=0;_<16;++_)if(i=(x+M)/2,Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||u>=E)M=i;else{if(Math.abs(y)<=-o*f)return i;y*(M-x)>=0&&(M=x),x=i,E=u}return 0}for(let x=0;x<10;++x){if(Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||x&&u>=a)return m(d,i,a);if(Math.abs(y)<=-o*f)return i;if(y>=0)return m(i,d,u);a=u,d=i,i*=2}return i}function ue(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()};const r=n.slice();let o,c,f=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),o=e.fxprime.slice(),ht(o,e.fxprime,-1);for(let a=0;a<u;++a){if(f=ce(t,o,e,i,f),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),!f)ht(o,e.fxprime,-1);else{Q(r,1,i.fxprime,-1,e.fxprime);const y=tt(e.fxprime,e.fxprime),d=Math.max(0,tt(r,i.fxprime)/y);Q(o,d,o,-1,i.fxprime),c=e,e=i,i=c}if(ut(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),e}function At(t,n={}){n.maxIterations=n.maxIterations||500;const s=n.initialLayout||ge,e=n.lossFunction||et,i=he(t,n),r=s(i,n),o=Object.keys(r),c=[];for(const a of o)c.push(r[a].x),c.push(r[a].y);const u=zt(a=>{const y={};for(let d=0;d<o.length;++d){const m=o[d];y[m]={x:a[2*d],y:a[2*d+1],radius:r[m].radius}}return e(y,i)},c,n).x;for(let a=0;a<o.length;++a){const y=o[a];r[y].x=u[2*a],r[y].y=u[2*a+1]}return r}const Rt=1e-10;function ft(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Rt?Math.abs(t-n):le(e=>xt(t,n,e)-s,0,t+n)}function he(t,n={}){const s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(s){const c=new Map;for(const f of e)for(let u=0;u<f.sets.length;u++){const a=String(f.sets[u]);c.set(a,f.size+(c.get(a)||0));for(let y=u+1;y<f.sets.length;y++){const d=String(f.sets[y]),m=`${a};${d}`,x=`${d};${a}`;c.set(m,f.size+(c.get(m)||0)),c.set(x,f.size+(c.get(x)||0))}}for(const f of e)f.sets.length<3&&(f.size=c.get(i(f.sets)))}const r=[],o=new Set;for(const c of e)if(c.sets.length===1)r.push(c.sets[0]);else if(c.sets.length===2){const f=c.sets[0],u=c.sets[1];o.add(i(c.sets)),o.add(i([u,f]))}r.sort((c,f)=>c===f?0:c<f?-1:1);for(let c=0;c<r.length;++c){const f=r[c];for(let u=c+1;u<r.length;++u){const a=r[u];o.has(i([f,a]))||e.push({sets:[f,a],size:0})}}return e}function fe(t,n,s){const e=Mt(n.length,n.length),i=Mt(n.length,n.length);return t.filter(r=>r.sets.length===2).forEach(r=>{const o=s[r.sets[0]],c=s[r.sets[1]],f=Math.sqrt(n[o].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),a=ft(f,u,r.size);e[o][c]=e[c][o]=a;let y=0;r.size+1e-10>=Math.min(n[o].size,n[c].size)?y=1:r.size<=1e-10&&(y=-1),i[o][c]=i[c][o]=y}),{distances:e,constraints:i}}function de(t,n,s,e){for(let r=0;r<n.length;++r)n[r]=0;let i=0;for(let r=0;r<s.length;++r){const o=t[2*r],c=t[2*r+1];for(let f=r+1;f<s.length;++f){const u=t[2*f],a=t[2*f+1],y=s[r][f],d=e[r][f],m=(u-o)*(u-o)+(a-c)*(a-c),x=Math.sqrt(m),M=m-y*y;d>0&&x<=y||d<0&&x>=y||(i+=2*M*M,n[2*r]+=4*M*(o-u),n[2*r+1]+=4*M*(c-a),n[2*f]+=4*M*(u-o),n[2*f+1]+=4*M*(a-c))}}return i}function ge(t,n={}){let s=ye(t,n);const e=n.lossFunction||et;if(t.length>=8){const i=xe(t,n),r=e(i,t),o=e(s,t);r+1e-8<o&&(s=i)}return s}function xe(t,n={}){const s=n.restarts||10,e=[],i={};for(const d of t)d.sets.length===1&&(i[d.sets[0]]=e.length,e.push(d));let{distances:r,constraints:o}=fe(t,e,i);const c=ut(r.map(ut))/r.length;r=r.map(d=>d.map(m=>m/c));const f=(d,m)=>de(d,m,r,o);let u=null;for(let d=0;d<s;++d){const m=ct(r.length*2).map(Math.random),x=ue(f,m,n);(!u||x.fx<u.fx)&&(u=x)}const a=u.x,y={};for(let d=0;d<e.length;++d){const m=e[d];y[m.sets[0]]={x:a[2*d]*c,y:a[2*d+1]*c,radius:Math.sqrt(m.size/Math.PI)}}if(n.history)for(const d of n.history)ht(d.x,c);return y}function ye(t,n){const s=n&&n.lossFunction?n.lossFunction:et,e={},i={};for(const y of t)if(y.sets.length===1){const d=y.sets[0];e[d]={x:1e10,y:1e10,rowid:e.length,size:y.size,radius:Math.sqrt(y.size/Math.PI)},i[d]=[]}t=t.filter(y=>y.sets.length===2);for(const y of t){let d=y.weight!=null?y.weight:1;const m=y.sets[0],x=y.sets[1];y.size+Rt>=Math.min(e[m].size,e[x].size)&&(d=0),i[m].push({set:x,size:y.size,weight:d}),i[x].push({set:m,size:y.size,weight:d})}const r=[];Object.keys(i).forEach(y=>{let d=0;for(let m=0;m<i[y].length;++m)d+=i[y][m].size*i[y][m].weight;r.push({set:y,size:d})});function o(y,d){return d.size-y.size}r.sort(o);const c={};function f(y){return y.set in c}function u(y,d){e[d].x=y.x,e[d].y=y.y,c[d]=!0}u({x:0,y:0},r[0].set);for(let y=1;y<r.length;++y){const d=r[y].set,m=i[d].filter(f),x=e[d];if(m.sort(o),m.length===0)throw"ERROR: missing pairwise overlap information";const M=[];for(var a=0;a<m.length;++a){const w=e[m[a].set],g=ft(x.radius,w.radius,m[a].size);M.push({x:w.x+g,y:w.y}),M.push({x:w.x-g,y:w.y}),M.push({y:w.y+g,x:w.x}),M.push({y:w.y-g,x:w.x});for(let b=a+1;b<m.length;++b){const v=e[m[b].set],l=ft(x.radius,v.radius,m[b].size),p=Tt({x:w.x,y:w.y,radius:g},{x:v.x,y:v.y,radius:l});M.push(...p)}}let E=1e50,_=M[0];for(const w of M){e[d].x=w.x,e[d].y=w.y;const g=s(e,t);g<E&&(E=g,_=w)}u(_,d)}return e}function et(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const o=t[e.sets[0]],c=t[e.sets[1]];i=xt(o.radius,c.radius,W(o,c))}else i=st(e.sets.map(o=>t[o]));const r=e.weight!=null?e.weight:1;s+=r*(i-e.size)*(i-e.size)}return s}function Dt(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const c=t[e.sets[0]],f=t[e.sets[1]];i=xt(c.radius,f.radius,W(c,f))}else i=st(e.sets.map(c=>t[c]));const r=e.weight!=null?e.weight:1,o=Math.log((i+1)/(e.size+1));s+=r*o*o}return s}function pe(t,n,s){if(s==null?t.sort((i,r)=>r.radius-i.radius):t.sort(s),t.length>0){const i=t[0].x,r=t[0].y;for(const o of t)o.x-=i,o.y-=r}if(t.length===2&&W(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const i=Math.atan2(t[1].x,t[1].y)-n,r=Math.cos(i),o=Math.sin(i);for(const c of t){const f=c.x,u=c.y;c.x=r*f-o*u,c.y=o*f+r*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){const r=t[1].y/(1e-10+t[1].x);for(const o of t){var e=(o.x+r*o.y)/(1+r*r);o.x=2*e-o.x,o.y=2*e*r-o.y}}}}function me(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}function s(i,r){const o=n(i),c=n(r);o.parent=c}for(let i=0;i<t.length;++i)for(let r=i+1;r<t.length;++r){const o=t[i].radius+t[r].radius;W(t[i],t[r])+1e-10<o&&s(t[r],t[i])}const e=new Map;for(let i=0;i<t.length;++i){const r=n(t[i]).parent.setid;e.has(r)||e.set(r,[]),e.get(r).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}function dt(t){const n=s=>{const e=t.reduce((r,o)=>Math.max(r,o[s]+o.radius),Number.NEGATIVE_INFINITY),i=t.reduce((r,o)=>Math.min(r,o[s]-o.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}};return{xRange:n("x"),yRange:n("y")}}function Ct(t,n,s){n==null&&(n=Math.PI/2);let e=Ft(t).map(u=>Object.assign({},u));const i=me(e);for(const u of i){pe(u,n,s);const a=dt(u);u.size=(a.xRange.max-a.xRange.min)*(a.yRange.max-a.yRange.min),u.bounds=a}i.sort((u,a)=>a.size-u.size),e=i[0];let r=e.bounds;const o=(r.xRange.max-r.xRange.min)/50;function c(u,a,y){if(!u)return;const d=u.bounds;let m,x;if(a)m=r.xRange.max-d.xRange.min+o;else{m=r.xRange.max-d.xRange.max;const M=(d.xRange.max-d.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;M<0&&(m+=M)}if(y)x=r.yRange.max-d.yRange.min+o;else{x=r.yRange.max-d.yRange.max;const M=(d.yRange.max-d.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;M<0&&(x+=M)}for(const M of u)M.x+=m,M.y+=x,e.push(M)}let f=1;for(;f<i.length;)c(i[f],!0,!1),c(i[f+1],!1,!0),c(i[f+2],!0,!0),f+=3,r=dt(e);return Ot(e)}function Nt(t,n,s,e,i){const r=Ft(t);n-=2*e,s-=2*e;const{xRange:o,yRange:c}=dt(r);if(o.max===o.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let f,u;if(i){const m=Math.sqrt(i/Math.PI)*2;f=n/m,u=s/m}else f=n/(o.max-o.min),u=s/(c.max-c.min);const a=Math.min(u,f),y=(n-(o.max-o.min)*a)/2,d=(s-(c.max-c.min)*a)/2;return Ot(r.map(m=>({radius:a*m.radius,x:e+y+(m.x-o.min)*a,y:e+d+(m.y-c.min)*a,setid:m.setid})))}function Ot(t){const n={};for(const s of t)n[s.setid]=s;return n}function Ft(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}function be(t={}){let n=!1,s=600,e=350,i=15,r=1e3,o=Math.PI/2,c=!0,f=null,u=!0,a=!0,y=null,d=null,m=!1,x=null,M=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,E={},_=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],w=0,g=function(p){if(p in E)return E[p];var h=E[p]=_[w];return w+=1,w>=_.length&&(w=0),h},b=At,v=et;function l(p){let h=p.datum();const j=new Set;h.forEach(I=>{I.size==0&&I.sets.length==1&&j.add(I.sets[0])}),h=h.filter(I=>!I.sets.some(L=>j.has(L)));let k={},N={};if(h.length>0){let I=b(h,{lossFunction:v,distinct:m});c&&(I=Ct(I,o,d)),k=Nt(I,s,e,i,f),N=jt(k,h,M)}const X={};h.forEach(I=>{I.label&&(X[I.sets]=I.label)});function B(I){if(I.sets in X)return X[I.sets];if(I.sets.length==1)return""+I.sets[0]}p.selectAll("svg").data([k]).enter().append("svg");const U=p.select("svg");n?U.attr("viewBox",`0 0 ${s} ${e}`):U.attr("width",s).attr("height",e);const q={};let z=!1;U.selectAll(".venn-area path").each(function(I){const L=this.getAttribute("d");I.sets.length==1&&L&&!m&&(z=!0,q[I.sets[0]]=ke(L))});function A(I){return L=>{const G=I.sets.map(Z=>{let H=q[Z],J=k[Z];return H||(H={x:s/2,y:e/2,radius:1}),J||(J={x:s/2,y:e/2,radius:1}),{x:H.x*(1-L)+J.x*L,y:H.y*(1-L)+J.y*L,radius:H.radius*(1-L)+J.radius*L}});return wt(G,x)}}const D=U.selectAll(".venn-area").data(h,I=>I.sets),O=D.enter().append("g").attr("class",I=>`venn-area venn-${I.sets.length==1?"circle":"intersection"}${I.colour||I.color?" venn-coloured":""}`).attr("data-venn-sets",I=>I.sets.join("_")),P=O.append("path"),V=O.append("text").attr("class","label").text(I=>B(I)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);a&&(P.style("fill-opacity","0").filter(I=>I.sets.length==1).style("fill",I=>I.colour?I.colour:I.color?I.color:g(I.sets)).style("fill-opacity",".25"),V.style("fill",I=>I.colour||I.color?"#FFF":t.textFill?t.textFill:I.sets.length==1?g(I.sets):"#444"));function R(I){return typeof I.transition=="function"?I.transition("venn").duration(r):I}let T=p;z&&typeof T.transition=="function"?(T=R(p),T.selectAll("path").attrTween("d",A)):T.selectAll("path").attr("d",I=>wt(I.sets.map(L=>k[L])),x);const F=T.selectAll("text").filter(I=>I.sets in N).text(I=>B(I)).attr("x",I=>Math.floor(N[I.sets].x)).attr("y",I=>Math.floor(N[I.sets].y));u&&(z?"on"in F?F.on("end",ot(k,B)):F.each("end",ot(k,B)):F.each(ot(k,B)));const C=R(D.exit()).remove();typeof D.transition=="function"&&C.selectAll("path").attrTween("d",A);const Y=C.selectAll("text").attr("x",s/2).attr("y",e/2);return y!==null&&(V.style("font-size","0px"),F.style("font-size",y),Y.style("font-size","0px")),{circles:k,textCentres:N,nodes:D,enter:O,update:T,exit:C}}return l.wrap=function(p){return arguments.length?(u=p,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(p){return arguments.length?(s=p,l):s},l.height=function(p){return arguments.length?(e=p,l):e},l.padding=function(p){return arguments.length?(i=p,l):i},l.distinct=function(p){return arguments.length?(m=p,l):m},l.colours=function(p){return arguments.length?(g=p,l):g},l.colors=function(p){return arguments.length?(g=p,l):g},l.fontSize=function(p){return arguments.length?(y=p,l):y},l.round=function(p){return arguments.length?(x=p,l):x},l.duration=function(p){return arguments.length?(r=p,l):r},l.layoutFunction=function(p){return arguments.length?(b=p,l):b},l.normalize=function(p){return arguments.length?(c=p,l):c},l.scaleToFit=function(p){return arguments.length?(f=p,l):f},l.styled=function(p){return arguments.length?(a=p,l):a},l.orientation=function(p){return arguments.length?(o=p,l):o},l.orientationOrder=function(p){return arguments.length?(d=p,l):d},l.lossFunction=function(p){return arguments.length?(v=p==="default"?et:p==="logRatio"?Dt:p,l):v},l}function ot(t,n){return function(s){const e=this,i=t[s.sets[0]].radius||50,r=n(s)||"",o=r.split(/\s+/).reverse(),f=(r.length+o.length)/3;let u=o.pop(),a=[u],y=0;const d=1.1;e.textContent=null;const m=[];function x(g){const b=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return b.textContent=g,m.push(b),e.append(b),b}let M=x(u);for(;u=o.pop(),!!u;){a.push(u);const g=a.join(" ");M.textContent=g,g.length>f&&M.getComputedTextLength()>i&&(a.pop(),M.textContent=a.join(" "),a=[u],M=x(u),y++)}const E=.35-y*d/2,_=e.getAttribute("x"),w=e.getAttribute("y");m.forEach((g,b)=>{g.setAttribute("x",_),g.setAttribute("y",w),g.setAttribute("dy",`${E+b*d}em`)})}}function at(t,n,s){let e=n[0].radius-W(n[0],t);for(let i=1;i<n.length;++i){const r=n[i].radius-W(n[i],t);r<=e&&(e=r)}for(let i=0;i<s.length;++i){const r=W(s[i],t)-s[i].radius;r<=e&&(e=r)}return e}function Lt(t,n,s){const e=[];for(const a of t)e.push({x:a.x,y:a.y}),e.push({x:a.x+a.radius/2,y:a.y}),e.push({x:a.x-a.radius/2,y:a.y}),e.push({x:a.x,y:a.y+a.radius/2}),e.push({x:a.x,y:a.y-a.radius/2});let i=e[0],r=at(e[0],t,n);for(let a=1;a<e.length;++a){const y=at(e[a],t,n);y>=r&&(i=e[a],r=y)}const o=zt(a=>-1*at({x:a[0],y:a[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:o[0],y:o[1]};let f=!0;for(const a of t)if(W(c,a)>a.radius){f=!1;break}for(const a of n)if(W(c,a)<a.radius){f=!1;break}if(f)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};const u={};return st(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?Lt(t,[]):Et(u.arcs.map(a=>a.p1))}function ve(t){const n={},s=Object.keys(t);for(const e of s)n[e]=[];for(let e=0;e<s.length;e++){const i=s[e],r=t[i];for(let o=e+1;o<s.length;++o){const c=s[o],f=t[c],u=W(r,f);u+f.radius<=r.radius+1e-10?n[c].push(i):u+r.radius<=f.radius+1e-10&&n[i].push(c)}}return n}function jt(t,n,s){const e={},i=ve(t);for(let r=0;r<n.length;++r){const o=n[r].sets,c={},f={};for(let d=0;d<o.length;++d){c[o[d]]=!0;const m=i[o[d]];for(let x=0;x<m.length;++x)f[m[x]]=!0}const u=[],a=[];for(let d in t)d in c?u.push(t[d]):d in f||a.push(t[d]);const y=Lt(u,a,s);e[o]=y,y.disjoint&&n[r].size>0&&console.log("WARNING: area "+o+" not represented on screen")}return e}function Ie(t,n,s){const e=[];return e.push(`
|
|
1
|
+
import{aU as Gt,s as Wt,g as Kt,q as Ht,p as Xt,a as Yt,b as Zt,_ as S,D as St,I as Jt,d as rt,al as Qt,V as $t,W as te,X as ee,e as ne,z as se,F as ie,G as re}from"./mermaid.core-4dbvlhht.js";import"./index-CwH-l50P.js";const kt=(t,n)=>Gt(t,"a",-n),_t=1e-10;function st(t,n){const s=ae(t),e=s.filter(c=>oe(c,t));let i=0,r=0;const o=[];if(e.length>1){const c=Et(e);for(let u=0;u<e.length;++u){const a=e[u];a.angle=Math.atan2(a.x-c.x,a.y-c.y)}e.sort((u,a)=>a.angle-u.angle);let f=e[e.length-1];for(let u=0;u<e.length;++u){const a=e[u];r+=(f.x+a.x)*(a.y-f.y);const y={x:(a.x+f.x)/2,y:(a.y+f.y)/2};let d=null;for(let m=0;m<a.parentIndex.length;++m)if(f.parentIndex.includes(a.parentIndex[m])){const x=t[a.parentIndex[m]],M=Math.atan2(a.x-x.x,a.y-x.y),E=Math.atan2(f.x-x.x,f.y-x.y);let _=E-M;_<0&&(_+=2*Math.PI);const w=E-_/2;let g=W(y,{x:x.x+x.radius*Math.sin(w),y:x.y+x.radius*Math.cos(w)});g>x.radius*2&&(g=x.radius*2),(d==null||d.width>g)&&(d={circle:x,width:g,p1:a,p2:f,large:g>x.radius,sweep:!0})}d!=null&&(o.push(d),i+=lt(d.circle.radius,d.width),f=a)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let f=!1;for(let u=0;u<t.length;++u)if(W(t[u],c)>Math.abs(c.radius-t[u].radius)){f=!0;break}f?i=r=0:(i=c.radius*c.radius*Math.PI,o.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-_t,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return r/=2,n&&(n.area=i+r,n.arcArea=i,n.polygonArea=r,n.arcs=o,n.innerPoints=e,n.intersectionPoints=s),i+r}function oe(t,n){return n.every(s=>W(t,s)<s.radius+_t)}function ae(t){const n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){const i=Tt(t[s],t[e]);for(const r of i)r.parentIndex=[s,e],n.push(r)}return n}function lt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function W(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function xt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);const e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return lt(t,e)+lt(n,i)}function Tt(t,n){const s=W(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];const r=(e*e-i*i+s*s)/(2*s),o=Math.sqrt(e*e-r*r),c=t.x+r*(n.x-t.x)/s,f=t.y+r*(n.y-t.y)/s,u=-(n.y-t.y)*(o/s),a=-(n.x-t.x)*(o/s);return[{x:c+u,y:f-a},{x:c-u,y:f+a}]}function Et(t){const n={x:0,y:0};for(const s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}function le(t,n,s,e){e=e||{};const i=e.maxIterations||100,r=e.tolerance||1e-10,o=t(n),c=t(s);let f=s-n;if(o*c>0)throw"Initial bisect points must have opposite signs";if(o===0)return n;if(c===0)return s;for(let u=0;u<i;++u){f/=2;const a=n+f,y=t(a);if(y*o>=0&&(n=a),Math.abs(f)<r||y===0)return a}return n+f}function ct(t){const n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}function Mt(t,n){return ct(t).map(()=>ct(n))}function tt(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}function ut(t){return Math.sqrt(tt(t,t))}function ht(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}function Q(t,n,s,e,i){for(let r=0;r<t.length;++r)t[r]=n*s[r]+e*i[r]}function zt(t,n,s){s=s||{};const e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,r=s.zeroDelta||.001,o=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,f=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,a=s.psi!==void 0?s.psi:-.5,y=s.sigma!==void 0?s.sigma:.5;let d;const m=n.length,x=new Array(m+1);x[0]=n,x[0].fx=t(n),x[0].id=0;for(let v=0;v<m;++v){const l=n.slice();l[v]=l[v]?l[v]*i:r,x[v+1]=l,x[v+1].fx=t(l),x[v+1].id=v+1}function M(v){for(let l=0;l<v.length;l++)x[m][l]=v[l];x[m].fx=v.fx}const E=(v,l)=>v.fx-l.fx,_=n.slice(),w=n.slice(),g=n.slice(),b=n.slice();for(let v=0;v<e;++v){if(x.sort(E),s.history){const p=x.map(h=>{const j=h.slice();return j.fx=h.fx,j.id=h.id,j});p.sort((h,j)=>h.id-j.id),s.history.push({x:x[0].slice(),fx:x[0].fx,simplex:p})}d=0;for(let p=0;p<m;++p)d=Math.max(d,Math.abs(x[0][p]-x[1][p]));if(Math.abs(x[0].fx-x[m].fx)<o&&d<c)break;for(let p=0;p<m;++p){_[p]=0;for(let h=0;h<m;++h)_[p]+=x[h][p];_[p]/=m}const l=x[m];if(Q(w,1+f,_,-f,l),w.fx=t(w),w.fx<x[0].fx)Q(b,1+u,_,-u,l),b.fx=t(b),b.fx<w.fx?M(b):M(w);else if(w.fx>=x[m-1].fx){let p=!1;if(w.fx>l.fx?(Q(g,1+a,_,-a,l),g.fx=t(g),g.fx<l.fx?M(g):p=!0):(Q(g,1-a*f,_,a*f,l),g.fx=t(g),g.fx<w.fx?M(g):p=!0),p){if(y>=1)break;for(let h=1;h<x.length;++h)Q(x[h],1-y,x[0],y,x[h]),x[h].fx=t(x[h])}}else M(w)}return x.sort(E),{fx:x[0].fx,x:x[0]}}function ce(t,n,s,e,i,r,o){const c=s.fx,f=tt(s.fxprime,n);let u=c,a=c,y=f,d=0;i=i||1,r=r||1e-6,o=o||.1;function m(x,M,E){for(let _=0;_<16;++_)if(i=(x+M)/2,Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||u>=E)M=i;else{if(Math.abs(y)<=-o*f)return i;y*(M-x)>=0&&(M=x),x=i,E=u}return 0}for(let x=0;x<10;++x){if(Q(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=tt(e.fxprime,n),u>c+r*i*f||x&&u>=a)return m(d,i,a);if(Math.abs(y)<=-o*f)return i;if(y>=0)return m(i,d,u);a=u,d=i,i*=2}return i}function ue(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()};const r=n.slice();let o,c,f=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),o=e.fxprime.slice(),ht(o,e.fxprime,-1);for(let a=0;a<u;++a){if(f=ce(t,o,e,i,f),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),!f)ht(o,e.fxprime,-1);else{Q(r,1,i.fxprime,-1,e.fxprime);const y=tt(e.fxprime,e.fxprime),d=Math.max(0,tt(r,i.fxprime)/y);Q(o,d,o,-1,i.fxprime),c=e,e=i,i=c}if(ut(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),e}function At(t,n={}){n.maxIterations=n.maxIterations||500;const s=n.initialLayout||ge,e=n.lossFunction||et,i=he(t,n),r=s(i,n),o=Object.keys(r),c=[];for(const a of o)c.push(r[a].x),c.push(r[a].y);const u=zt(a=>{const y={};for(let d=0;d<o.length;++d){const m=o[d];y[m]={x:a[2*d],y:a[2*d+1],radius:r[m].radius}}return e(y,i)},c,n).x;for(let a=0;a<o.length;++a){const y=o[a];r[y].x=u[2*a],r[y].y=u[2*a+1]}return r}const Rt=1e-10;function ft(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Rt?Math.abs(t-n):le(e=>xt(t,n,e)-s,0,t+n)}function he(t,n={}){const s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(s){const c=new Map;for(const f of e)for(let u=0;u<f.sets.length;u++){const a=String(f.sets[u]);c.set(a,f.size+(c.get(a)||0));for(let y=u+1;y<f.sets.length;y++){const d=String(f.sets[y]),m=`${a};${d}`,x=`${d};${a}`;c.set(m,f.size+(c.get(m)||0)),c.set(x,f.size+(c.get(x)||0))}}for(const f of e)f.sets.length<3&&(f.size=c.get(i(f.sets)))}const r=[],o=new Set;for(const c of e)if(c.sets.length===1)r.push(c.sets[0]);else if(c.sets.length===2){const f=c.sets[0],u=c.sets[1];o.add(i(c.sets)),o.add(i([u,f]))}r.sort((c,f)=>c===f?0:c<f?-1:1);for(let c=0;c<r.length;++c){const f=r[c];for(let u=c+1;u<r.length;++u){const a=r[u];o.has(i([f,a]))||e.push({sets:[f,a],size:0})}}return e}function fe(t,n,s){const e=Mt(n.length,n.length),i=Mt(n.length,n.length);return t.filter(r=>r.sets.length===2).forEach(r=>{const o=s[r.sets[0]],c=s[r.sets[1]],f=Math.sqrt(n[o].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),a=ft(f,u,r.size);e[o][c]=e[c][o]=a;let y=0;r.size+1e-10>=Math.min(n[o].size,n[c].size)?y=1:r.size<=1e-10&&(y=-1),i[o][c]=i[c][o]=y}),{distances:e,constraints:i}}function de(t,n,s,e){for(let r=0;r<n.length;++r)n[r]=0;let i=0;for(let r=0;r<s.length;++r){const o=t[2*r],c=t[2*r+1];for(let f=r+1;f<s.length;++f){const u=t[2*f],a=t[2*f+1],y=s[r][f],d=e[r][f],m=(u-o)*(u-o)+(a-c)*(a-c),x=Math.sqrt(m),M=m-y*y;d>0&&x<=y||d<0&&x>=y||(i+=2*M*M,n[2*r]+=4*M*(o-u),n[2*r+1]+=4*M*(c-a),n[2*f]+=4*M*(u-o),n[2*f+1]+=4*M*(a-c))}}return i}function ge(t,n={}){let s=ye(t,n);const e=n.lossFunction||et;if(t.length>=8){const i=xe(t,n),r=e(i,t),o=e(s,t);r+1e-8<o&&(s=i)}return s}function xe(t,n={}){const s=n.restarts||10,e=[],i={};for(const d of t)d.sets.length===1&&(i[d.sets[0]]=e.length,e.push(d));let{distances:r,constraints:o}=fe(t,e,i);const c=ut(r.map(ut))/r.length;r=r.map(d=>d.map(m=>m/c));const f=(d,m)=>de(d,m,r,o);let u=null;for(let d=0;d<s;++d){const m=ct(r.length*2).map(Math.random),x=ue(f,m,n);(!u||x.fx<u.fx)&&(u=x)}const a=u.x,y={};for(let d=0;d<e.length;++d){const m=e[d];y[m.sets[0]]={x:a[2*d]*c,y:a[2*d+1]*c,radius:Math.sqrt(m.size/Math.PI)}}if(n.history)for(const d of n.history)ht(d.x,c);return y}function ye(t,n){const s=n&&n.lossFunction?n.lossFunction:et,e={},i={};for(const y of t)if(y.sets.length===1){const d=y.sets[0];e[d]={x:1e10,y:1e10,rowid:e.length,size:y.size,radius:Math.sqrt(y.size/Math.PI)},i[d]=[]}t=t.filter(y=>y.sets.length===2);for(const y of t){let d=y.weight!=null?y.weight:1;const m=y.sets[0],x=y.sets[1];y.size+Rt>=Math.min(e[m].size,e[x].size)&&(d=0),i[m].push({set:x,size:y.size,weight:d}),i[x].push({set:m,size:y.size,weight:d})}const r=[];Object.keys(i).forEach(y=>{let d=0;for(let m=0;m<i[y].length;++m)d+=i[y][m].size*i[y][m].weight;r.push({set:y,size:d})});function o(y,d){return d.size-y.size}r.sort(o);const c={};function f(y){return y.set in c}function u(y,d){e[d].x=y.x,e[d].y=y.y,c[d]=!0}u({x:0,y:0},r[0].set);for(let y=1;y<r.length;++y){const d=r[y].set,m=i[d].filter(f),x=e[d];if(m.sort(o),m.length===0)throw"ERROR: missing pairwise overlap information";const M=[];for(var a=0;a<m.length;++a){const w=e[m[a].set],g=ft(x.radius,w.radius,m[a].size);M.push({x:w.x+g,y:w.y}),M.push({x:w.x-g,y:w.y}),M.push({y:w.y+g,x:w.x}),M.push({y:w.y-g,x:w.x});for(let b=a+1;b<m.length;++b){const v=e[m[b].set],l=ft(x.radius,v.radius,m[b].size),p=Tt({x:w.x,y:w.y,radius:g},{x:v.x,y:v.y,radius:l});M.push(...p)}}let E=1e50,_=M[0];for(const w of M){e[d].x=w.x,e[d].y=w.y;const g=s(e,t);g<E&&(E=g,_=w)}u(_,d)}return e}function et(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const o=t[e.sets[0]],c=t[e.sets[1]];i=xt(o.radius,c.radius,W(o,c))}else i=st(e.sets.map(o=>t[o]));const r=e.weight!=null?e.weight:1;s+=r*(i-e.size)*(i-e.size)}return s}function Dt(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const c=t[e.sets[0]],f=t[e.sets[1]];i=xt(c.radius,f.radius,W(c,f))}else i=st(e.sets.map(c=>t[c]));const r=e.weight!=null?e.weight:1,o=Math.log((i+1)/(e.size+1));s+=r*o*o}return s}function pe(t,n,s){if(s==null?t.sort((i,r)=>r.radius-i.radius):t.sort(s),t.length>0){const i=t[0].x,r=t[0].y;for(const o of t)o.x-=i,o.y-=r}if(t.length===2&&W(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const i=Math.atan2(t[1].x,t[1].y)-n,r=Math.cos(i),o=Math.sin(i);for(const c of t){const f=c.x,u=c.y;c.x=r*f-o*u,c.y=o*f+r*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){const r=t[1].y/(1e-10+t[1].x);for(const o of t){var e=(o.x+r*o.y)/(1+r*r);o.x=2*e-o.x,o.y=2*e*r-o.y}}}}function me(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}function s(i,r){const o=n(i),c=n(r);o.parent=c}for(let i=0;i<t.length;++i)for(let r=i+1;r<t.length;++r){const o=t[i].radius+t[r].radius;W(t[i],t[r])+1e-10<o&&s(t[r],t[i])}const e=new Map;for(let i=0;i<t.length;++i){const r=n(t[i]).parent.setid;e.has(r)||e.set(r,[]),e.get(r).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}function dt(t){const n=s=>{const e=t.reduce((r,o)=>Math.max(r,o[s]+o.radius),Number.NEGATIVE_INFINITY),i=t.reduce((r,o)=>Math.min(r,o[s]-o.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}};return{xRange:n("x"),yRange:n("y")}}function Ct(t,n,s){n==null&&(n=Math.PI/2);let e=Ft(t).map(u=>Object.assign({},u));const i=me(e);for(const u of i){pe(u,n,s);const a=dt(u);u.size=(a.xRange.max-a.xRange.min)*(a.yRange.max-a.yRange.min),u.bounds=a}i.sort((u,a)=>a.size-u.size),e=i[0];let r=e.bounds;const o=(r.xRange.max-r.xRange.min)/50;function c(u,a,y){if(!u)return;const d=u.bounds;let m,x;if(a)m=r.xRange.max-d.xRange.min+o;else{m=r.xRange.max-d.xRange.max;const M=(d.xRange.max-d.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;M<0&&(m+=M)}if(y)x=r.yRange.max-d.yRange.min+o;else{x=r.yRange.max-d.yRange.max;const M=(d.yRange.max-d.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;M<0&&(x+=M)}for(const M of u)M.x+=m,M.y+=x,e.push(M)}let f=1;for(;f<i.length;)c(i[f],!0,!1),c(i[f+1],!1,!0),c(i[f+2],!0,!0),f+=3,r=dt(e);return Ot(e)}function Nt(t,n,s,e,i){const r=Ft(t);n-=2*e,s-=2*e;const{xRange:o,yRange:c}=dt(r);if(o.max===o.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let f,u;if(i){const m=Math.sqrt(i/Math.PI)*2;f=n/m,u=s/m}else f=n/(o.max-o.min),u=s/(c.max-c.min);const a=Math.min(u,f),y=(n-(o.max-o.min)*a)/2,d=(s-(c.max-c.min)*a)/2;return Ot(r.map(m=>({radius:a*m.radius,x:e+y+(m.x-o.min)*a,y:e+d+(m.y-c.min)*a,setid:m.setid})))}function Ot(t){const n={};for(const s of t)n[s.setid]=s;return n}function Ft(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}function be(t={}){let n=!1,s=600,e=350,i=15,r=1e3,o=Math.PI/2,c=!0,f=null,u=!0,a=!0,y=null,d=null,m=!1,x=null,M=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,E={},_=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],w=0,g=function(p){if(p in E)return E[p];var h=E[p]=_[w];return w+=1,w>=_.length&&(w=0),h},b=At,v=et;function l(p){let h=p.datum();const j=new Set;h.forEach(I=>{I.size==0&&I.sets.length==1&&j.add(I.sets[0])}),h=h.filter(I=>!I.sets.some(L=>j.has(L)));let k={},N={};if(h.length>0){let I=b(h,{lossFunction:v,distinct:m});c&&(I=Ct(I,o,d)),k=Nt(I,s,e,i,f),N=jt(k,h,M)}const X={};h.forEach(I=>{I.label&&(X[I.sets]=I.label)});function B(I){if(I.sets in X)return X[I.sets];if(I.sets.length==1)return""+I.sets[0]}p.selectAll("svg").data([k]).enter().append("svg");const U=p.select("svg");n?U.attr("viewBox",`0 0 ${s} ${e}`):U.attr("width",s).attr("height",e);const q={};let z=!1;U.selectAll(".venn-area path").each(function(I){const L=this.getAttribute("d");I.sets.length==1&&L&&!m&&(z=!0,q[I.sets[0]]=ke(L))});function A(I){return L=>{const G=I.sets.map(Z=>{let H=q[Z],J=k[Z];return H||(H={x:s/2,y:e/2,radius:1}),J||(J={x:s/2,y:e/2,radius:1}),{x:H.x*(1-L)+J.x*L,y:H.y*(1-L)+J.y*L,radius:H.radius*(1-L)+J.radius*L}});return wt(G,x)}}const D=U.selectAll(".venn-area").data(h,I=>I.sets),O=D.enter().append("g").attr("class",I=>`venn-area venn-${I.sets.length==1?"circle":"intersection"}${I.colour||I.color?" venn-coloured":""}`).attr("data-venn-sets",I=>I.sets.join("_")),P=O.append("path"),V=O.append("text").attr("class","label").text(I=>B(I)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);a&&(P.style("fill-opacity","0").filter(I=>I.sets.length==1).style("fill",I=>I.colour?I.colour:I.color?I.color:g(I.sets)).style("fill-opacity",".25"),V.style("fill",I=>I.colour||I.color?"#FFF":t.textFill?t.textFill:I.sets.length==1?g(I.sets):"#444"));function R(I){return typeof I.transition=="function"?I.transition("venn").duration(r):I}let T=p;z&&typeof T.transition=="function"?(T=R(p),T.selectAll("path").attrTween("d",A)):T.selectAll("path").attr("d",I=>wt(I.sets.map(L=>k[L])),x);const F=T.selectAll("text").filter(I=>I.sets in N).text(I=>B(I)).attr("x",I=>Math.floor(N[I.sets].x)).attr("y",I=>Math.floor(N[I.sets].y));u&&(z?"on"in F?F.on("end",ot(k,B)):F.each("end",ot(k,B)):F.each(ot(k,B)));const C=R(D.exit()).remove();typeof D.transition=="function"&&C.selectAll("path").attrTween("d",A);const Y=C.selectAll("text").attr("x",s/2).attr("y",e/2);return y!==null&&(V.style("font-size","0px"),F.style("font-size",y),Y.style("font-size","0px")),{circles:k,textCentres:N,nodes:D,enter:O,update:T,exit:C}}return l.wrap=function(p){return arguments.length?(u=p,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(p){return arguments.length?(s=p,l):s},l.height=function(p){return arguments.length?(e=p,l):e},l.padding=function(p){return arguments.length?(i=p,l):i},l.distinct=function(p){return arguments.length?(m=p,l):m},l.colours=function(p){return arguments.length?(g=p,l):g},l.colors=function(p){return arguments.length?(g=p,l):g},l.fontSize=function(p){return arguments.length?(y=p,l):y},l.round=function(p){return arguments.length?(x=p,l):x},l.duration=function(p){return arguments.length?(r=p,l):r},l.layoutFunction=function(p){return arguments.length?(b=p,l):b},l.normalize=function(p){return arguments.length?(c=p,l):c},l.scaleToFit=function(p){return arguments.length?(f=p,l):f},l.styled=function(p){return arguments.length?(a=p,l):a},l.orientation=function(p){return arguments.length?(o=p,l):o},l.orientationOrder=function(p){return arguments.length?(d=p,l):d},l.lossFunction=function(p){return arguments.length?(v=p==="default"?et:p==="logRatio"?Dt:p,l):v},l}function ot(t,n){return function(s){const e=this,i=t[s.sets[0]].radius||50,r=n(s)||"",o=r.split(/\s+/).reverse(),f=(r.length+o.length)/3;let u=o.pop(),a=[u],y=0;const d=1.1;e.textContent=null;const m=[];function x(g){const b=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return b.textContent=g,m.push(b),e.append(b),b}let M=x(u);for(;u=o.pop(),!!u;){a.push(u);const g=a.join(" ");M.textContent=g,g.length>f&&M.getComputedTextLength()>i&&(a.pop(),M.textContent=a.join(" "),a=[u],M=x(u),y++)}const E=.35-y*d/2,_=e.getAttribute("x"),w=e.getAttribute("y");m.forEach((g,b)=>{g.setAttribute("x",_),g.setAttribute("y",w),g.setAttribute("dy",`${E+b*d}em`)})}}function at(t,n,s){let e=n[0].radius-W(n[0],t);for(let i=1;i<n.length;++i){const r=n[i].radius-W(n[i],t);r<=e&&(e=r)}for(let i=0;i<s.length;++i){const r=W(s[i],t)-s[i].radius;r<=e&&(e=r)}return e}function Lt(t,n,s){const e=[];for(const a of t)e.push({x:a.x,y:a.y}),e.push({x:a.x+a.radius/2,y:a.y}),e.push({x:a.x-a.radius/2,y:a.y}),e.push({x:a.x,y:a.y+a.radius/2}),e.push({x:a.x,y:a.y-a.radius/2});let i=e[0],r=at(e[0],t,n);for(let a=1;a<e.length;++a){const y=at(e[a],t,n);y>=r&&(i=e[a],r=y)}const o=zt(a=>-1*at({x:a[0],y:a[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:o[0],y:o[1]};let f=!0;for(const a of t)if(W(c,a)>a.radius){f=!1;break}for(const a of n)if(W(c,a)<a.radius){f=!1;break}if(f)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};const u={};return st(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?Lt(t,[]):Et(u.arcs.map(a=>a.p1))}function ve(t){const n={},s=Object.keys(t);for(const e of s)n[e]=[];for(let e=0;e<s.length;e++){const i=s[e],r=t[i];for(let o=e+1;o<s.length;++o){const c=s[o],f=t[c],u=W(r,f);u+f.radius<=r.radius+1e-10?n[c].push(i):u+r.radius<=f.radius+1e-10&&n[i].push(c)}}return n}function jt(t,n,s){const e={},i=ve(t);for(let r=0;r<n.length;++r){const o=n[r].sets,c={},f={};for(let d=0;d<o.length;++d){c[o[d]]=!0;const m=i[o[d]];for(let x=0;x<m.length;++x)f[m[x]]=!0}const u=[],a=[];for(let d in t)d in c?u.push(t[d]):d in f||a.push(t[d]);const y=Lt(u,a,s);e[o]=y,y.disjoint&&n[r].size>0&&console.log("WARNING: area "+o+" not represented on screen")}return e}function Ie(t,n,s){const e=[];return e.push(`
|
|
2
2
|
M`,t,n),e.push(`
|
|
3
3
|
m`,-s,0),e.push(`
|
|
4
4
|
a`,s,s,0,1,0,s*2,0),e.push(`
|
|
@@ -32,4 +32,3 @@ Expecting `+H.join(", ")+", got '"+(this.terminals_[T]||T)+"'":J="Parse error on
|
|
|
32
32
|
color: ${t.vennSetTextColor};
|
|
33
33
|
}
|
|
34
34
|
`,"getStyles"),Ve=Pe;function qt(t){const n=new Map;for(const s of t){const e=s.targets.join("|"),i=n.get(e);i?Object.assign(i,s.styles):n.set(e,{...s.styles})}return n}S(qt,"buildStyleByKey");var Be=S((t,n,s,e)=>{var U,q,z;const i=e.db,r=(U=i.getConfig)==null?void 0:U.call(i),{themeVariables:o,look:c,handDrawnSeed:f}=St(),u=c==="handDrawn",a=[o.venn1,o.venn2,o.venn3,o.venn4,o.venn5,o.venn6,o.venn7,o.venn8].filter(Boolean),y=(q=i.getDiagramTitle)==null?void 0:q.call(i),d=i.getSubsetData(),m=i.getTextData(),x=qt(i.getStyleData()),M=(r==null?void 0:r.width)??800,E=(r==null?void 0:r.height)??450,w=M/1600,g=y?48*w:0,b=o.primaryTextColor??o.textColor,v=Jt(n);v.attr("viewBox",`0 0 ${M} ${E}`),y&&v.append("text").text(y).attr("class","venn-title").attr("font-size",`${32*w}px`).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*w).style("fill",o.vennTitleTextColor||o.titleColor);const l=rt(document.createElement("div")),p=be().width(M).height(E-g);l.datum(d).call(p);const h=u?Qt.svg(l.select("svg").node()):void 0,j=Me(d,{width:M,height:E-g,padding:(r==null?void 0:r.padding)??15}),k=new Map;for(const A of j){const D=$([...A.data.sets].sort());k.set(D,A)}m.length>0&&Ut(r,k,l,m,w,x);const N=$t(o.background||"#f4f4f4");l.selectAll(".venn-circle").each(function(A,D){var L;const O=rt(this),V=$([...A.sets].sort()),R=x.get(V),T=(R==null?void 0:R.fill)||a[D%a.length]||o.primaryColor;O.classed(`venn-set-${D%8}`,!0);const F=(R==null?void 0:R["fill-opacity"])??.1,C=(R==null?void 0:R.stroke)||T,Y=(R==null?void 0:R["stroke-width"])||`${5*w}`;if(u&&h){const G=k.get(V);if(G&&G.circles.length>0){const Z=G.circles[0],H=h.circle(Z.x,Z.y,Z.radius*2,{roughness:.7,seed:f,fill:kt(T,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:-41+D*60,stroke:C,strokeWidth:parseFloat(String(Y))});O.select("path").remove(),(L=O.node())==null||L.insertBefore(H,O.select("text").node())}}else O.select("path").style("fill",T).style("fill-opacity",F).style("stroke",C).style("stroke-width",Y).style("stroke-opacity",.95);const I=(R==null?void 0:R.color)||(N?te(T,30):ee(T,30));O.select("text").style("font-size",`${48*w}px`).style("fill",I)}),u&&h?l.selectAll(".venn-intersection").each(function(A){var T;const D=rt(this),P=$([...A.sets].sort()),V=x.get(P),R=V==null?void 0:V.fill;if(R){const F=D.select("path"),C=F.attr("d");if(C){const Y=h.path(C,{roughness:.7,seed:f,fill:kt(R,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),I=F.node();(T=I==null?void 0:I.parentNode)==null||T.insertBefore(Y,I),F.remove()}}else D.select("path").style("fill-opacity",0);D.select("text").style("font-size",`${48*w}px`).style("fill",(V==null?void 0:V.color)??o.vennSetTextColor??b)}):(l.selectAll(".venn-intersection text").style("font-size",`${48*w}px`).style("fill",A=>{var P;const O=$([...A.sets].sort());return((P=x.get(O))==null?void 0:P.color)??o.vennSetTextColor??b}),l.selectAll(".venn-intersection path").style("fill-opacity",A=>{var P;const O=$([...A.sets].sort());return(P=x.get(O))!=null&&P.fill?1:0}).style("fill",A=>{var P;const O=$([...A.sets].sort());return((P=x.get(O))==null?void 0:P.fill)??"transparent"}));const X=v.append("g").attr("transform",`translate(0, ${g})`),B=l.select("svg").node();if(B&&"childNodes"in B)for(const A of[...B.childNodes])(z=X.node())==null||z.appendChild(A);ne(v,E,M,(r==null?void 0:r.useMaxWidth)??!0)},"draw");function $(t){return t.join("|")}S($,"stableSetsKey");function Ut(t,n,s,e,i,r){var a;const o=(t==null?void 0:t.useDebugLayout)??!1,f=s.select("svg").append("g").attr("class","venn-text-nodes"),u=new Map;for(const y of e){const d=$(y.sets),m=u.get(d);m?m.push(y):u.set(d,[y])}for(const[y,d]of u.entries()){const m=n.get(y);if(!(m!=null&&m.text))continue;const x=m.text.x,M=m.text.y,E=Math.min(...m.circles.map(q=>q.radius)),_=Math.min(...m.circles.map(q=>q.radius-Math.hypot(x-q.x,M-q.y)));let w=Number.isFinite(_)?Math.max(0,_):0;w===0&&Number.isFinite(E)&&(w=E*.6);const g=f.append("g").attr("class","venn-text-area").attr("font-size",`${40*i}px`);o&&g.append("circle").attr("class","venn-text-debug-circle").attr("cx",x).attr("cy",M).attr("r",w).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);const b=Math.max(80*i,w*2*.95),v=Math.max(60*i,w*2*.95),h=(m.data.label&&m.data.label.length>0?Math.min(32*i,w*.25):0)+(d.length<=2?30*i:0),j=x-b/2,k=M-v/2+h,N=Math.max(1,Math.ceil(Math.sqrt(d.length))),X=Math.max(1,Math.ceil(d.length/N)),B=b/N,U=v/X;for(const[q,z]of d.entries()){const A=q%N,D=Math.floor(q/N),O=j+B*(A+.5),P=k+U*(D+.5);o&&g.append("rect").attr("class","venn-text-debug-cell").attr("x",j+B*A).attr("y",k+U*D).attr("width",B).attr("height",U).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);const V=B*.9,R=U*.9,T=g.append("foreignObject").attr("class","venn-text-node-fo").attr("width",V).attr("height",R).attr("x",O-V/2).attr("y",P-R/2).attr("overflow","visible"),F=(a=r.get(z.id))==null?void 0:a.color,C=T.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(z.label??z.id);F&&C.style("color",F)}}}S(Ut,"renderTextNodes");var qe={draw:Be},We={parser:we,db:je,renderer:qe,styles:Ve};export{We as diagram};
|
|
35
|
-
//# sourceMappingURL=vennDiagram-CIIHVFJN-CrxyVTtu.js.map
|