diffs-pane 0.3.0 → 0.4.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/README.md +32 -4
- package/dist/cli/index.js +61 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/daemon/edits.js +179 -0
- package/dist/daemon/edits.js.map +1 -0
- package/dist/daemon/security.js +2 -2
- package/dist/daemon/security.js.map +1 -1
- package/dist/daemon/server.js +50 -2
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/session.js +24 -1
- package/dist/daemon/session.js.map +1 -1
- package/dist/shared/patch.js +94 -3
- package/dist/shared/patch.js.map +1 -1
- package/dist/shared/themes.js +62 -0
- package/dist/shared/themes.js.map +1 -0
- package/dist/ui/assets/index-C3xEfNP_.js +518 -0
- package/dist/ui/assets/index-DUH6QCUZ.css +1 -0
- package/dist/ui/assets/index-Dtx8mcCv.js +2832 -0
- package/dist/ui/assets/worker-O63gxiV6.js +156 -0
- package/dist/ui/index.html +2 -2
- package/dist/vcs/git.js +65 -1
- package/dist/vcs/git.js.map +1 -1
- package/dist/vcs/jj.js +12 -0
- package/dist/vcs/jj.js.map +1 -1
- package/dist/vcs/types.js +3 -1
- package/dist/vcs/types.js.map +1 -1
- package/package.json +12 -12
- package/skills/diffs-pane/SKILL.md +2 -0
- package/dist/ui/assets/index-BQk-ERmu.css +0 -1
- package/dist/ui/assets/index-jMRN-7du.js +0 -2904
- package/dist/ui/assets/worker-DLF4drjM.js +0 -155
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import{i as qe,s as Ze,r as Xe,p as Ye,a as Qe,h as Je,d as tn,c as en,b as nn,e as Te,f as sn,g as vt,j as rn,I as K,D as Qt,E as Jt,k as te,l as xt,q as at,m as ee,n as ne}from"./index-Dtx8mcCv.js";const on={compositeOverBg:nn,contrastRatio:en,deriveMutedFg:tn,hoverWouldEraseText:Je,isDarkSurface:Qe,isFullyTransparent:qe,pickReadableForeground:Ye,relativeLuminance:Xe,surfacesMatch:Ze},an=100,nt=1,Vt=2,$t=3;var Ee=class{#e=[];#t=[];#r;#n=!1;constructor(t){this.#r=Math.max(1,t?.maxEntries??an)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}clear(){this.#e.length=0,this.#t.length=0,this.#n=!1}clearRedo(){this.#t.length=0}push(t){this.#e.push(t),this.clearRedo(),this.#n=!0,this.#e.length>this.#r&&this.#e.shift()}setLastUndoSelectionsAfter(t){const e=this.#e[this.#e.length-1];e!==void 0&&(e.selectionsAfter=t.map(n=>({...n})))}setLastUndoLineAnnotations(t,e){const n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=t.slice(),n.lineAnnotationsAfter=e.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#n?this.peekUndo():void 0}replaceLastUndo(t){if(this.#e.length===0){this.push(t);return}this.#e[this.#e.length-1]=t,this.clearRedo(),this.#n=!0}popUndoToRedo(){const t=this.#e.pop();if(t!==void 0)return this.#t.push(t),this.#n=!1,t}popRedoToUndo(){const t=this.#t.pop();if(t!==void 0)return this.#e.push(t),this.#n=!1,t}};function cn(t,e,n,i,s,r,o,a){const c=[...e].sort((l,f)=>l.start-f.start),h=[];let d;if(s?.length===c.length){const l=[];for(const f of s){if(f.start.line!==f.end.line||f.start.character!==f.end.character)break;l.push(t.offsetAt(f.start))}if(l.length===c.length){l.sort((v,g)=>v-g);let f=!0,u=!0;for(let v=0;v<c.length;v++){const g=c[v];if(g.text.length>0||g.start===g.end){f=!1,u=!1;break}f&&=l[v]===g.end,u&&=l[v]===g.start}d=f?Vt:u?$t:void 0}}for(let l=0,f=0;l<c.length;l++){const u=c[l],v=t.getTextSlice(u.start,u.end),g=u.start+f;h.push({start:g,end:g+u.text.length,text:v}),f+=u.text.length-(u.end-u.start)}return{forwardEdits:c.map(l=>({...l})),inverseEdits:h,versionBefore:n,versionAfter:i,selectionsBefore:s?.map(l=>({...l})),selectionsAfter:r?.map(l=>({...l})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:a?.slice(),coalescingMode:d}}function ln(t,e){if(t===void 0||t.undoBoundary===!0||e.undoBoundary===!0||t.forwardEdits.length===0||t.forwardEdits.length!==t.inverseEdits.length||t.forwardEdits.length!==e.forwardEdits.length||e.forwardEdits.length!==e.inverseEdits.length)return!1;let n;for(let i=0;i<t.forwardEdits.length;i++){const s=t.forwardEdits[i],r=t.inverseEdits[i],o=e.forwardEdits[i],a=e.inverseEdits[i],c=Ae(o.start,t.forwardEdits),h=s.start<=s.end&&s.text.length>0&&!s.text.includes(`
|
|
2
|
+
`)&&!r.text.includes(`
|
|
3
|
+
`),d=o.start===o.end&&o.text.length>0&&!o.text.includes(`
|
|
4
|
+
`)&&a.text.length===0;if(h&&d){if(o.start!==r.end||(n??=nt,n!==nt||t.coalescingMode!==void 0&&t.coalescingMode!==nt||e.coalescingMode!==void 0&&e.coalescingMode!==nt))return!1;continue}const l=s.text.length===0&&s.end>s.start&&r.text.length>0,f=o.text.length===0&&o.end>o.start&&a.text.length>0;if(l&&f){let u;if(c===s.end)u=$t;else{if(c+(o.end-o.start)!==s.start)return!1;u=Vt}if(n??=u,n!==u||t.coalescingMode!==void 0&&t.coalescingMode!==u||e.coalescingMode!==void 0&&e.coalescingMode!==u)return!1;continue}return!1}return n!==void 0}function hn(t,e){const n=[],i=[];let s;for(let r=0;r<t.forwardEdits.length;r++){const o=t.forwardEdits[r],a=t.inverseEdits[r],c=e.forwardEdits[r],h=e.inverseEdits[r],d=Ae(c.start,t.forwardEdits);if(o.text.length>0){s??=nt,n.push({start:o.start,end:o.end,text:o.text+c.text}),i.push(a.text);continue}if(d===o.end){s??=$t,n.push({start:o.start,end:d+(c.end-c.start),text:""}),i.push(a.text+h.text);continue}s??=Vt,n.push({start:Math.min(o.start,d),end:o.end,text:""}),i.push(h.text+a.text)}return{forwardEdits:n,inverseEdits:dn(n,i),versionBefore:t.versionBefore,versionAfter:e.versionAfter,selectionsBefore:t.selectionsBefore?.slice(),selectionsAfter:e.selectionsAfter?.slice(),lineAnnotationsBefore:t.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice(),coalescingMode:s}}function dn(t,e){const n=[];for(let i=0,s=0;i<t.length;i++){const r=t[i],o=r.start+s;n.push({start:o,end:o+r.text.length,text:e[i]}),s+=r.text.length-(r.end-r.start)}return n}function Ae(t,e){let n=t;for(const i of e){const s=i.end-i.start,r=i.text.length,o=r-s;if(!(n<i.start)){if(n>=i.start+r){n-=o;continue}n=i.start+Math.min(n-i.start,s)}}return n}const fn=1e5,It=10,dt=13,un="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";var it=class{source;offset;length;lineOffsetStart;lineOffsetEnd;hasVirtualTrailingCRBreak;firstCharCode;lastCharCode;static Original=0;static Added=1;constructor(t,e,n,i,s,r,o,a){this.source=t,this.offset=e,this.length=n,this.lineOffsetStart=i,this.lineOffsetEnd=s,this.hasVirtualTrailingCRBreak=r,this.firstCharCode=o,this.lastCharCode=a}get lineBreakCount(){return this.lineOffsetEnd-this.lineOffsetStart+(this.hasVirtualTrailingCRBreak?1:0)}},ie=class{text;lineOffsets;constructor(t){this.text=t,this.lineOffsets=Te(t)}append(t){const e=this.text.length;for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);i!==It&&i!==dt||(i===dt&&t.charCodeAt(n+1)===It&&n++,this.lineOffsets.push(e+n+1))}return this.text+=t,e}},ct=class{piece;subtreeLength;subtreeLineBreakCount;subtreeFirstCharCode;subtreeLastCharCode;left=null;right=null;parent=null;priority=0;constructor(t,e=t.length,n=t.lineBreakCount,i=t.firstCharCode,s=t.lastCharCode){this.piece=t,this.subtreeLength=e,this.subtreeLineBreakCount=n,this.subtreeFirstCharCode=i,this.subtreeLastCharCode=s}updateSubtreeLength(){this.subtreeLength=(this.left?.subtreeLength??0)+this.piece.length+(this.right?.subtreeLength??0),this.subtreeLineBreakCount=(this.left?.subtreeLineBreakCount??0)+this.piece.lineBreakCount+(this.right?.subtreeLineBreakCount??0)-(V(this.left?.subtreeLastCharCode,this.piece.firstCharCode)?1:0)-(V(this.piece.lastCharCode,this.right?.subtreeFirstCharCode)?1:0),this.subtreeFirstCharCode=this.left?.subtreeFirstCharCode??this.piece.firstCharCode,this.subtreeLastCharCode=this.right?.subtreeLastCharCode??this.piece.lastCharCode}},gn=class{#e;#t=new ie("");#r=null;#n=0;#a=0;#l=null;#c=null;#v=null;#w=2654435769;constructor(t){this.#e=new ie(t);const e=this.#k(it.Original,0,t.length);this.#r=e.length>0?this.#q(e):null,this.#n=this.#r?.subtreeLength??0,this.#a=(this.#r?.subtreeLineBreakCount??0)+1}get lineCount(){return this.#a}getText(t){if(t===void 0)return this.#B();const e=this.offsetAt(t.start),n=this.offsetAt(t.end);return this.getTextSlice(e,n)}getLineText(t,e=!1){if(this.#l!==null&&this.#l[0]===t&&this.#l[1]===e)return this.#l[2];const n=this.#y(t);if(n===void 0)throw new Error(`Line index out of range: ${t}`);const i=this.getTextSlice(n[0],n[1],!e);return this.#l=[t,e,i],this.#c=[t,e,i.length],i}getLineLength(t,e=!1){const n=this.#c,i=this.#l;if(n!==null&&n[0]===t&&n[1]===e)return n[2];if(i!==null&&i[0]===t&&i[1]===e){const c=i[2].length;return this.#c=[t,e,c],c}const s=this.#y(t);if(s===void 0)throw new Error(`Line index out of range: ${t}`);const[r,o]=s;let a=o-r;if(!e)for(;a>0&&bt(this.charAt(r+a-1).charCodeAt(0));)a--;return this.#c=[t,e,a],a}getTextSlice(t,e,n=!1){if(t>=e)return"";const i=D(t,0,this.#n),s=D(e,i,this.#n);if(i>=s)return"";const r=this.#x(i);if(r===void 0)return"";const o=[];let[a,c]=r,h=s-i;for(;a!==null&&h>0;){const d=Math.min(a.piece.length-c,h),l=this.#m(a.piece.source),f=a.piece.offset+c;let u=f+d;if(n)for(;u>f&&bt(l.text.charCodeAt(u-1));)u--;o.push(l.text.slice(f,u)),h-=d,c=0,a=this.#u(a)}return o.join("")}charAt(t){const e=this.#x(t);if(e===void 0)return"";const[n,i]=e;return this.#m(n.piece.source).text.charAt(n.piece.offset+i)}includes(t){if(t.length===0)return!0;const e=se(t);let n=0,i=!1;return this.#L(s=>{for(let r=s.start;r<s.end;r++){const o=s.text.charCodeAt(r);for(;n>0&&o!==t.charCodeAt(n);)n=e[n-1];if(o===t.charCodeAt(n)&&n++,n===t.length)return i=!0,!1}return!0}),i}findNextNonOverlappingSubstring(t,e){if(t.length===0||t.length>this.#n)return;const n=pn(e,this.#n),i=n.reduce((h,[,d])=>Math.max(h,d),0),s=se(t);let r=0,o=0,a,c;return this.#L(h=>{for(let d=h.start;d<h.end;d++){const l=h.text.charCodeAt(d);for(;r>0&&l!==t.charCodeAt(r);)r=s[r-1];if(l===t.charCodeAt(r)&&r++,r===t.length){const f=o-t.length+1;if(!vn(n,f,f+t.length)){if(f>=i)return c=f,!1;a??=f}r=s[r-1]}o++}return!0}),c??a}search(t){if(t.text.length===0||this.#n===0)return[];if(t.text.includes(`
|
|
5
|
+
`)||t.text.includes("\r")||t.regex&&(t.text.includes("\\n")||t.text.includes("\\r")))return[];let e;try{e=Me(t.text,t.regex,t.caseSensitive)}catch{return[]}return this.#g(e,t.wholeWord,fn)}#g(t,e,n){const i=[],s=this.#B(),r=s.length,o=Te(s);for(let a=0;a<o.length;a++){const c=o[a];let h=o[a+1]??r;for(;h>c&&bt(s.charCodeAt(h-1));)h--;const d=s.slice(c,h);t.lastIndex=0;let l;for(;(l=t.exec(d))!==null;){const f=l.index,u=l[0];if(u.length===0){t.lastIndex=oe(d,f);continue}const v=c+f;if((!e||xn(s,v,u.length))&&(i.push([v,v+u.length]),i.length>=n))return i;f===t.lastIndex&&(t.lastIndex=oe(d,f))}}return i}insert(t,e){if(t.length===0)return;const n=D(e,0,this.#n);this.#p(n,n,t),this.#M()}delete(t,e){if(e<=0||this.#n===0)return;const n=D(t,0,this.#n),i=D(n+e,n,this.#n);n!==i&&(this.#p(n,i,""),this.#M())}applyEdits(t){if(t.length!==0){for(let e=t.length-1;e>=0;e--){const n=t[e],i=D(n.start,0,this.#n),s=D(n.end,i,this.#n);this.#p(i,s,n.text)}this.#M()}}positionAt(t){const e=D(t,0,this.#n);if(this.#n===0)return{line:0,character:0};const n=this.#A(e),i=e-(n===0?0:this.#W(n-1));return this.#v=[n,i,e],{line:n,character:i}}positionsAt(t){const e=Array.from({length:t.length});if(t.length===0)return e;if(this.#n===0)return e.fill({line:0,character:0});for(let n=0;n<t.length;n++)e[n]=this.positionAt(t[n]);return e}offsetAt(t){if(t.line<0||this.#n===0)return 0;if(t.line>=this.#a)throw new Error(`Line index out of range: ${t.line}`);const e=this.#v;if(e!==null&&e[0]===t.line&&e[1]===t.character)return e[2];const n=this.#y(t.line);if(n===void 0)throw new Error(`Line index out of range: ${t.line}`);const i=D(t.character,0,n[1]-n[0]);return n[0]+i}#x(t){if(t<0||t>=this.#n)return;let e=this.#r,n=t;for(;e!==null;){const i=e.left?.subtreeLength??0;if(n<i){e=e.left;continue}if(n-=i,n<e.piece.length)return[e,n];n-=e.piece.length,e=e.right}}#u(t){if(t.right!==null){let n=t.right;for(;n.left!==null;)n=n.left;return n}let e=t;for(;e.parent!==null&&e===e.parent.right;)e=e.parent;return e.parent}#y(t){if(t<0)throw new Error(`Line index out of range: ${t}`);if(this.#n===0){if(t===0)return[0,0];throw new Error(`Line index out of range: ${t}`)}if(t>=this.#a)throw new Error(`Line index out of range: ${t}`);return[t===0?0:this.#W(t-1),t<this.#a-1?this.#W(t):this.#n]}#A(t){let e=this.#r,n=D(t,0,this.#n),i=0;for(;e!==null;){const s=e.left?.subtreeLength??0;if(n<s){e=e.left;continue}if(i+=(e.left?.subtreeLineBreakCount??0)-(V(e.left?.subtreeLastCharCode,e.piece.firstCharCode)?1:0),n-=s,n<=e.piece.length){const r=this.#m(e.piece.source),o=Math.min(St(r.lineOffsets,e.piece.offset+n),e.piece.lineOffsetEnd);return i+=o-e.piece.lineOffsetStart,n===e.piece.length&&e.piece.hasVirtualTrailingCRBreak&&i++,n===e.piece.length&&V(e.piece.lastCharCode,this.#u(e)?.piece.firstCharCode)&&i--,i}i+=e.piece.lineBreakCount-(V(e.piece.lastCharCode,e.right?.subtreeFirstCharCode)?1:0),n-=e.piece.length,e=e.right}return this.#a-1}#W(t){let e=this.#r,n=t,i=0,s;for(;e!==null;){const r=(e.left?.subtreeLineBreakCount??0)-(V(e.left?.subtreeLastCharCode,e.piece.firstCharCode)?1:0);if(n<r){s=e.piece.firstCharCode,e=e.left;continue}const o=e.left?.subtreeLength??0;i+=o,n-=r;const a=e.right?.subtreeFirstCharCode??s,c=e.piece.lineBreakCount-(V(e.piece.lastCharCode,a)?1:0);if(n<c)return i+this.#o(e.piece,n);i+=e.piece.length,n-=c,e=e.right}return this.#n}#o(t,e){return e<t.lineOffsetEnd-t.lineOffsetStart?this.#m(t.source).lineOffsets[t.lineOffsetStart+e]-t.offset:t.length}#B(){const t=[];return this.#L(e=>{t.push(e.text.slice(e.start,e.end))}),t.join("")}#L(t){this.#F(this.#r,e=>{const n=this.#m(e.piece.source);return t({text:n.text,lineOffsets:n.lineOffsets,lineOffsetStart:e.piece.lineOffsetStart,lineOffsetEnd:e.piece.lineOffsetEnd,start:e.piece.offset,end:e.piece.offset+e.piece.length})})}#m(t){return t===it.Original?this.#e:this.#t}#k(t,e,n){const i=this.#m(t),s=e+n,r=St(i.lineOffsets,e),o=St(i.lineOffsets,s),a=i.text.charCodeAt(s-1);return new it(t,e,n,r,o,a===dt&&i.lineOffsets[o-1]!==s,i.text.charCodeAt(e),a)}#p(t,e,n){if(t===e&&n.length===0)return;const[i,s]=this.#U(this.#r,t),r=this.#S(s,e-t);let o;if(n.length>0){const a=this.#k(it.Added,this.#t.append(n),n.length);o=this.#R(this.#h(i,a),r)}else{const[a,c]=this.#V(r);o=a===void 0?i:this.#R(this.#h(i,a),c)}o!==null&&(o.parent=null),this.#r=o,this.#n=o?.subtreeLength??0,this.#a=(o?.subtreeLineBreakCount??0)+1}#M(){this.#l=null,this.#c=null,this.#v=null}#C(){return this.#w=Math.imul(this.#w,1664525)+1013904223>>>0,this.#w}#q(t){const e=new ct(t);return e.priority=this.#C(),e}#T(t,e){t.left=e,e!==null&&(e.parent=t)}#P(t,e){t.right=e,e!==null&&(e.parent=t)}#U(t,e){if(t===null)return[null,null];if(e<=0)return[null,t];if(e>=t.subtreeLength)return[t,null];const n=t.left?.subtreeLength??0;if(e<=n){const[a,c]=this.#U(t.left,e);return this.#T(t,c),t.updateSubtreeLength(),[a,t]}const i=t.piece.length;if(e>=n+i){const[a,c]=this.#U(t.right,e-n-i);return this.#P(t,a),t.updateSubtreeLength(),[t,c]}const s=e-n,r=new ct(this.#k(t.piece.source,t.piece.offset,s)),o=new ct(this.#k(t.piece.source,t.piece.offset+s,i-s));return r.priority=t.priority,o.priority=t.priority,this.#T(r,t.left),this.#P(o,t.right),r.updateSubtreeLength(),o.updateSubtreeLength(),[r,o]}#S(t,e){if(t===null||e>=t.subtreeLength)return null;if(e<=0)return t;const n=t.left?.subtreeLength??0;if(e<=n)return this.#T(t,this.#S(t.left,e)),t.updateSubtreeLength(),t;const i=n+t.piece.length;if(e>=i)return this.#S(t.right,e-i);const s=e-n,r=new ct(this.#k(t.piece.source,t.piece.offset+s,t.piece.length-s));return r.priority=t.priority,this.#P(r,t.right),r.updateSubtreeLength(),r}#R(t,e){return t===null?e:e===null?t:t.priority>=e.priority?(this.#P(t,this.#R(t.right,e)),t.updateSubtreeLength(),t):(this.#T(e,this.#R(t,e.left)),e.updateSubtreeLength(),e)}#h(t,e){if(t===null)return this.#q(e);let n=t;for(;n.right!==null;)n=n.right;if(mn(n.piece,e)){n.piece=Cn(n.piece,e);for(let i=n;i!==null&&(i.updateSubtreeLength(),i!==t);)i=i.parent;return t}return this.#R(t,this.#q(e))}#V(t){if(t===null)return[void 0,null];if(t.left===null)return[t.piece,t.right];const[e,n]=this.#V(t.left);return this.#T(t,n),t.updateSubtreeLength(),[e,t]}#F(t,e){return t===null?!0:!this.#F(t.left,e)||e(t)===!1?!1:this.#F(t.right,e)}};function bt(t){return t===10||t===13}function D(t,e,n){return Math.min(Math.max(t,e),n)}function se(t){const e=Array.from({length:t.length}).fill(0);let n=0;for(let i=1;i<t.length;i++){const s=t.charCodeAt(i);for(;n>0&&s!==t.charCodeAt(n);)n=e[n-1];s===t.charCodeAt(n)&&n++,e[i]=n}return e}function pn(t,e){const n=[];for(const[s,r]of t){const o=D(s,0,e),a=D(r,o,e);o<a&&n.push([o,a])}n.sort((s,r)=>s[0]-r[0]);const i=[];for(const s of n){const r=i[i.length-1];if(r!==void 0&&s[0]<=r[1]){r[1]=Math.max(r[1],s[1]);continue}i.push(s)}return i}function vn(t,e,n){let i=0,s=t.length;for(;i<s;){const o=i+Math.floor((s-i)/2);t[o][1]<=e?i=o+1:s=o}const r=t[i];return r!==void 0&&r[0]<n}function mn(t,e){return t.source===e.source&&t.offset+t.length===e.offset&&!V(t.lastCharCode,e.firstCharCode)}function Cn(t,e){return new it(t.source,t.offset,t.length+e.length,t.lineOffsetStart,e.lineOffsetEnd,e.hasVirtualTrailingCRBreak,t.firstCharCode,e.lastCharCode)}function V(t,e){return t===dt&&e===It}function St(t,e){let n=0,i=t.length;for(;n<i;){const s=n+Math.floor((i-n)/2);t[s]<=e?n=s+1:i=s}return n}function Ln(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function re(t){if(t<=32||t===127)return!0;const e=String.fromCharCode(t);return un.includes(e)}function xn(t,e,n){const i=e<=0||re(t.charCodeAt(e-1)),s=e+n>=t.length||re(t.charCodeAt(e+n));return i&&s}function Me(t,e,n){const i=e?t:Ln(t);return new RegExp(i,`g${n?"":"i"}${e?"m":""}`)}function bn(t,e){return t.replace(/\$([$&]|\d+)/g,(n,i)=>i==="$"?"$":i==="&"?e[0]??"":e[Number(i)]??"")}function Sn(t,e,n,i,s,r){if(!i.regex)return i.replaceText;const o=t(s),a=n(o.line),c=s-e({line:o.line,character:0});let h;try{h=Me(i.text,!0,i.caseSensitive)}catch{return i.replaceText}h.lastIndex=c;const d=h.exec(a);return d===null||d.index!==c||d[0].length!==r-s?i.replaceText:bn(i.replaceText,d)}function oe(t,e){if(e+1<t.length){const n=t.charCodeAt(e),i=t.charCodeAt(e+1);if(n>=55296&&n<=56319&&i>=56320&&i<=57343)return e+2}return e+1}var wn=class Pt{#e;#t;#r;#n;#a;#l;constructor(e,n,i="text",s=0,r=new Ee){this.#e=new URL(e,"file://").toString(),this.#t=i,this.#r=s,this.#n=new gn(n),this.#a=r;const o=this.#n.getLineText(0,!0);o.endsWith(`\r
|
|
6
|
+
`)?this.#l=`\r
|
|
7
|
+
`:o.endsWith("\r")?this.#l="\r":this.#l=`
|
|
8
|
+
`}get uri(){return this.#e}get languageId(){return this.#t}get version(){return this.#r}get lineCount(){return this.#n.lineCount}get eol(){return this.#l}get canUndo(){return this.#a.canUndo}get canRedo(){return this.#a.canRedo}positionAt(e){return this.normalizePosition(this.#n.positionAt(e))}positionsAt(e){const n=this.#n.positionsAt(e);for(let i=0;i<n.length;i++)n[i]=this.normalizePosition(n[i]);return n}offsetAt(e){return this.#n.offsetAt(this.normalizePosition(e))}getText(e){return e===void 0?this.#n.getText():this.#n.getText({start:this.normalizePosition(e.start),end:this.normalizePosition(e.end)})}getLineText(e,n){return this.#n.getLineText(e,n)}normalizeEol(e){return e.replace(/\r\n|\r|\n/g,this.eol)}getLineLength(e,n){return this.#n.getLineLength(e,n)}charAt(e){return typeof e=="number"?this.#n.charAt(e):this.#n.charAt(this.offsetAt(e))}getTextSlice(e,n){return this.#n.getTextSlice(e,n)}findNextNonOverlappingSubstring(e,n){return this.#n.findNextNonOverlappingSubstring(e,n)}search(e){return this.#n.search(e)}applyEdits(e,n=!0,i,s,r=!1){if(e.length!==0)return this.#c(this.#u(this.resolveEdits(e)),n,i,s,r)}resolveEdits(e){return e.map(n=>this.#w(n))}applyResolvedEdits(e,n=!0,i,s,r=!1){if(e.length!==0)return this.#c(this.#u(e.map(o=>this.#g(o))),n,i,s,r)}#c(e,n,i,s,r){const o=cn(this,e,this.#r,this.#r+1,n?i:void 0,n?s:void 0);n&&r&&(o.undoBoundary=!0);const a=this.#a.peekUndoForCoalescing(),c=this.#y(e);return this.#r++,c.lineDelta===0&&ln(a,o)?this.#a.replaceLastUndo(hn(a,o)):this.#a.push(o),c}setLastUndoSelectionsAfter(e){this.#a.setLastUndoSelectionsAfter(e)}setLastUndoLineAnnotations(e,n){this.#a.setLastUndoLineAnnotations(e,n)}undo(){const e=this.#a.popUndoToRedo();if(e===void 0)return;const n=this.#y(e.inverseEdits);if(n===void 0)return;this.#r=e.versionBefore;const i=e.selectionsBefore?.slice();return[n,i,e.lineAnnotationsBefore?.slice(),i===void 0?e.inverseEdits.map(s=>({...s})):void 0]}redo(){const e=this.#a.popRedoToUndo();if(e===void 0)return;const n=this.#y(e.forwardEdits);if(n===void 0)return;this.#r=e.versionAfter;const i=e.selectionsAfter?.slice();return[n,i,e.lineAnnotationsAfter?.slice(),i===void 0?e.forwardEdits.map(s=>({...s})):void 0]}normalizePosition(e){const n=Pt.#v(e.line,this.lineCount-1);return{line:n,character:Pt.#v(e.character,this.getLineLength(n))}}static#v(e,n){return Number.isNaN(e)?0:Math.max(0,Math.min(Math.floor(e),n))}#w(e){let n=this.offsetAt(e.range.start),i=this.offsetAt(e.range.end);if(n>i){const s=n;n=i,i=s}return this.#g({start:n,end:i,text:e.newText})}#g(e){let{start:n,end:i}=e;const s=n===i;return this.#x(n)&&n--,s?i=n:this.#x(i)&&i++,{start:n,end:i,text:e.text}}#x(e){const n=this.#n.charAt(e-1).charCodeAt(0),i=this.#n.charAt(e).charCodeAt(0);return n>=55296&&n<=56319&&i>=56320&&i<=57343}#u(e){const n=[...e].sort((i,s)=>{const r=i.start-s.start;return r===0?i.end-s.end:r});for(let i=0;i<n.length-1;i++)if(n[i].end>n[i+1].start)throw new Error("Overlapping text edits are not supported");return n}#y(e){const n=this.#n.lineCount,i=this.positionsAt(e.flatMap(h=>[h.start,h.end])),s=this.#A(e,i),r=i[0],o=i[i.length-1],a=o.line===n-1&&o.character===this.#n.getLineLength(o.line);this.#n.applyEdits(e);const c=this.#n.lineCount;return{changes:e.map((h,d)=>({...h,range:{start:i[d*2],end:i[d*2+1]}})),startLine:s.startLine,startCharacter:r.character,endCharacter:o.character,endLine:Math.min(s.endLine,Math.max(0,c-1)),endedAtDocumentEnd:a,previousLineCount:n,lineCount:c,lineDelta:c-n,changedLineRanges:s.ranges,changedLineChanges:s.changes}}#A(e,n){let i=1/0,s=0,r=0;const o=[],a=[],c=this.#n.lineCount-1,h=this.#n.getLineLength(c);for(let d=0;d<e.length;d++){const l=e[d],f=n[d*2],u=n[d*2+1],v=f.line,g=u.line,p=sn(l.text),m=v+r,C=m+p,x=p-(g-v);i=Math.min(i,v),s=Math.max(s,C);const L=o[o.length-1];L!==void 0&&m<=L[1]+1?o[o.length-1]=[L[0],Math.max(L[1],C)]:o.push([m,C]),a.push([m,C,x,f.character,u.character,g===c&&u.character===h]),r+=x}return i===1/0?{startLine:0,endLine:0,ranges:[[0,0]],changes:[[0,0,0,0,0,!1]]}:{startLine:i,endLine:s,ranges:o,changes:a}}};function rt({metaKey:t,ctrlKey:e},n=vt()){return n?t&&!e:e&&!t}function yn(t){if(vt()&&t.ctrlKey&&!t.altKey&&!t.metaKey)switch(t.key){case"a":return"start";case"e":return"end";case"p":return"up";case"n":return"down";case"f":return"right";case"b":return"left"}if(!t.altKey&&!t.ctrlKey&&!t.metaKey){if(t.key==="ArrowUp")return"up";if(t.key==="ArrowDown")return"down";if(t.key==="ArrowLeft")return"left";if(t.key==="ArrowRight")return"right";if(t.key==="Home")return"start";if(t.key==="End")return"end"}if(rt(t)){if(t.key==="ArrowLeft")return"textStart";if(t.key==="ArrowRight")return"end"}}const ae=new WeakMap,kn=Re([{bindings:{Tab:"indent","shift+Tab":"outdent","cmdOrCtrl+[":"indentLess","cmdOrCtrl+]":"indentMore","cmdOrCtrl+z":"undo","cmdOrCtrl+shift+z":"redo","cmdOrCtrl+a":"selectAll","cmdOrCtrl+d":"findNextMatch","cmdOrCtrl+f":"openSearchPanel","cmdOrCtrl+alt+f":"openSearchReplacePanel","alt+ArrowUp":"moveLineUp","alt+ArrowDown":"moveLineDown","shift+alt+ArrowUp":"copyLineUp","shift+alt+ArrowDown":"copyLineDown",Escape:"simplifySelection","cmdOrCtrl+Enter":"insertBlankLine","cmdOrCtrl+/":"toggleComment","shift+alt+a":"toggleBlockComment","cmdOrCtrl+Home":"moveCursorToDocStart","cmdOrCtrl+End":"moveCursorToDocEnd","cmdOrCtrl+shift+Home":"expandSelectionDocStart","cmdOrCtrl+shift+End":"expandSelectionDocEnd"}},{platform:"mac",bindings:{"ctrl+k":"deleteHardLineForward","ctrl+alt+p":"moveLineUp","ctrl+alt+n":"moveLineDown","cmd+ArrowUp":"moveCursorToDocStart","cmd+ArrowDown":"moveCursorToDocEnd","cmd+shift+ArrowUp":"expandSelectionDocStart","cmd+shift+ArrowDown":"expandSelectionDocEnd"}},{platform:"windows",bindings:{"ctrl+y":"redo"}},{platform:"linux",bindings:{"ctrl+y":"redo","ctrl+alt+p":"moveLineUp","ctrl+alt+n":"moveLineDown"}}]),Tn={Backquote:"`",Minus:"-",Equal:"=",Comma:",",Period:".",Slash:"/",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Space:"Space"};function Re(t){let e=ae.get(t);if(e===void 0){e={mac:new Map,windows:new Map,linux:new Map};for(const n of t)for(const i of Object.keys(n.bindings)){const s=n.bindings[i];if(s===void 0)continue;const r=i.split("+"),o=r.pop();for(const a of["mac","windows","linux"]){if(n.platform!==void 0&&n.platform!==a)continue;let c=0;for(const d of r)d==="alt"?c|=1:d==="ctrl"?c|=2:d==="cmd"?c|=4:d==="shift"?c|=8:d==="cmdOrCtrl"&&(c|=a==="mac"?4:2);let h=e[a].get(c);h===void 0&&(h=new Map,e[a].set(c,h)),h.set(o,s)}}ae.set(t,e)}return e}function En(t,e,n=vt()){const i=t.key===" "?"Space":t.key.length===1?t.key.toLowerCase():t.key,s=t.code??"",r=s.startsWith("Key")&&s.length===4?s.slice(3).toLowerCase():s.startsWith("Digit")&&s.length===6?s.slice(5):Tn[s],o=n?"mac":globalThis.navigator?.platform.includes("Linux")===!0?"linux":"windows",a=(t.altKey?1:0)|(t.ctrlKey?2:0)|(t.metaKey?4:0)|(t.shiftKey?8:0);if(e!==void 0){const h=Re(e)[o].get(a),d=h?.get(i)??(r===void 0?void 0:h?.get(r));if(d!==void 0)return d}const c=kn[o].get(a);return c?.get(i)??(r===void 0?void 0:c?.get(r))}function Bt(t,e=vt()){if(!t.altKey&&rt(t,e)&&((t.key.length===1?t.key.toLowerCase():t.key)==="g"||t.code==="KeyG"))return t.shiftKey?"previous":"next"}var An=`::selection {
|
|
9
|
+
background-color: #0000;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-deleted-text-selection] [data-deletions] ::selection, [data-deleted-text-selection] [data-line-type="change-deletion"] ::selection {
|
|
13
|
+
background-color: var(--diffs-editor-selection-bg);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@keyframes blinking {
|
|
17
|
+
0% {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
50% {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
100% {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host, [data-code], [data-content], [data-diff-type="split"][data-overflow="wrap"] {
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[data-code] {
|
|
35
|
+
container-type: inline-size;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-content] {
|
|
39
|
+
cursor: text;
|
|
40
|
+
caret-color: var(--diffs-bg-caret);
|
|
41
|
+
background-color: #0000;
|
|
42
|
+
outline: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-line] {
|
|
46
|
+
cursor: text;
|
|
47
|
+
background-color: #0000;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-line]:after {
|
|
51
|
+
content: "";
|
|
52
|
+
z-index: -20;
|
|
53
|
+
background-color: var(--diffs-line-bg);
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-line][data-editor-active-line]:after {
|
|
60
|
+
box-shadow: inset 0 0 0 1px var(--diffs-editor-line-highlight-border);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-editor-overlay] {
|
|
64
|
+
display: contents;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-caret], [data-selection-range], [data-match-range], [data-bracket-match-range], [data-marker-range] {
|
|
68
|
+
height: 1lh;
|
|
69
|
+
line-height: var(--diffs-line-height);
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[data-caret] {
|
|
77
|
+
background-color: var(--diffs-bg-caret-override, var(--diffs-editor-cursor-fg, light-dark(color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 75%, var(--diffs-bg)))));
|
|
78
|
+
visibility: hidden;
|
|
79
|
+
width: 2px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
83
|
+
[data-caret] {
|
|
84
|
+
animation: 1.2s .8s infinite blinking;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[data-selection-range] {
|
|
89
|
+
z-index: -10;
|
|
90
|
+
background-color: var(--diffs-editor-selection-bg);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-selection-corner] {
|
|
94
|
+
background-color: var(--diffs-selection-corner-bg, var(--diffs-bg));
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 100%;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-match-range] {
|
|
100
|
+
z-index: -10;
|
|
101
|
+
background-color: var(--diffs-editor-match-bg, var(--diffs-editor-selection-bg));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[data-match-range]:not([data-focus]) {
|
|
105
|
+
background-color: var(--diffs-editor-match-highlight-bg, light-dark(#ff963288, #ff963266));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-bracket-match-range] {
|
|
109
|
+
z-index: -9;
|
|
110
|
+
box-sizing: border-box;
|
|
111
|
+
border-bottom: 1px solid
|
|
112
|
+
var(--diffs-editor-bracket-match-border, color-mix(in lab, var(--diffs-fg) 60%, transparent));
|
|
113
|
+
background-color: var(--diffs-editor-bracket-match-bg, color-mix(in lab, var(--diffs-fg) 5%, transparent));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[data-rtl] {
|
|
117
|
+
border-top-left-radius: 3px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-rtr] {
|
|
121
|
+
border-top-right-radius: 3px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[data-rbl] {
|
|
125
|
+
border-bottom-left-radius: 3px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
[data-rbr] {
|
|
129
|
+
border-bottom-right-radius: 3px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[data-marker-range] {
|
|
133
|
+
z-index: 1;
|
|
134
|
+
background-color: var(--diffs-marker-bg);
|
|
135
|
+
mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjMiPjxwYXRoIGQ9Im0wIDIuNSBsMiAtMS41IGwxIDAgbDIgMS41IGwxIDAiIHN0cm9rZT0iI2ZmZiIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+");
|
|
136
|
+
mask-position: 0 100%;
|
|
137
|
+
mask-size: 6px 3px;
|
|
138
|
+
mask-repeat: repeat-x;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
[data-marker-error] {
|
|
142
|
+
--diffs-marker-contrast: light-dark(#fff, #000);
|
|
143
|
+
--diffs-marker-bg: var(--diffs-editor-error-fg, var(--diffs-deletion-base));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
[data-marker-warning] {
|
|
147
|
+
--diffs-marker-contrast: #000;
|
|
148
|
+
--diffs-marker-bg: var(--diffs-editor-warning-fg, light-dark(var(--diffs-warning-light), var(--diffs-warning-dark)));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[data-marker-info] {
|
|
152
|
+
--diffs-marker-contrast: #000;
|
|
153
|
+
--diffs-marker-bg: var(--diffs-editor-info-fg, var(--diffs-modified-base));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
[data-marker-hint] {
|
|
157
|
+
--diffs-marker-contrast: light-dark(#fff, #000);
|
|
158
|
+
--diffs-marker-bg: var(--diffs-editor-hint-fg, var(--diffs-fg-number));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (width >= 480px) {
|
|
162
|
+
[data-content] {
|
|
163
|
+
caret-color: #0000;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[data-content]:focus ~ [data-editor-overlay] [data-caret] {
|
|
167
|
+
visibility: visible;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[data-editor-widget] {
|
|
172
|
+
--diffs-widget-fg: var(--diffs-fg);
|
|
173
|
+
--diffs-widget-bg: color-mix(in lab, var(--diffs-fg) 4%, var(--diffs-bg));
|
|
174
|
+
--diffs-widget-border: color-mix(in lab, var(--diffs-fg) 20%, transparent);
|
|
175
|
+
--diffs-widget-shadow: inset 0 0 0 1px var(--diffs-bg), 0 4px 8px #00000013,
|
|
176
|
+
0 6px 18px #00000013;
|
|
177
|
+
z-index: 100;
|
|
178
|
+
width: fit-content;
|
|
179
|
+
max-width: calc(100% - 24px);
|
|
180
|
+
font: 14px/20px var(--diffs-header-font-fallback);
|
|
181
|
+
border: 1px solid var(--diffs-widget-border);
|
|
182
|
+
background-color: var(--diffs-widget-bg);
|
|
183
|
+
box-shadow: var(--diffs-widget-shadow);
|
|
184
|
+
background-clip: padding-box;
|
|
185
|
+
border-radius: 9px;
|
|
186
|
+
position: absolute;
|
|
187
|
+
top: 0;
|
|
188
|
+
left: 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
[data-marker-popover], [data-selection-action-popover] {
|
|
192
|
+
--popover-gap: var(--diffs-popover-gap, var(--diffs-gap-fallback, 8px));
|
|
193
|
+
--popover-viewport-left: 0px;
|
|
194
|
+
--popover-viewport-right: 100cqw;
|
|
195
|
+
--popover-viewport-top: -99999px;
|
|
196
|
+
--popover-viewport-bottom: 99999px;
|
|
197
|
+
--popover-min-left: calc(var(--popover-viewport-left) + var(--gutter-width, 0px) + var(--popover-gap));
|
|
198
|
+
--popover-available-width: max(0px,
|
|
199
|
+
calc(var(--popover-viewport-right) - var(--popover-min-left) -
|
|
200
|
+
var(--popover-gap)));
|
|
201
|
+
max-width: min(640px, var(--popover-available-width));
|
|
202
|
+
translate: clamp(var(--popover-min-left),
|
|
203
|
+
var(--popover-x, var(--popover-min-left)),
|
|
204
|
+
calc(var(--popover-viewport-right) - var(--popover-gap) - 100%))
|
|
205
|
+
/* Clamp into the scrollport so a popover with no fitting side stays in view. */
|
|
206
|
+
clamp(var(--popover-viewport-top),
|
|
207
|
+
calc(var(--popover-y, 0px) + var(--popover-y-shift, 0px)),
|
|
208
|
+
calc(var(--popover-viewport-bottom) - var(--popover-gap) - 100%));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[data-marker-popover] {
|
|
212
|
+
--diffs-widget-bg: var(--diffs-marker-bg);
|
|
213
|
+
--diffs-widget-shadow: 0 4px 8px #00000026, 0 6px 18px #00000026;
|
|
214
|
+
min-width: min(180px, var(--popover-available-width));
|
|
215
|
+
overflow-wrap: anywhere;
|
|
216
|
+
color: var(--diffs-marker-contrast);
|
|
217
|
+
white-space: normal;
|
|
218
|
+
pointer-events: auto;
|
|
219
|
+
border: 0;
|
|
220
|
+
padding: 8px 12px;
|
|
221
|
+
|
|
222
|
+
@supports (color: contrast-color(red)) {
|
|
223
|
+
color: contrast-color(var(--diffs-marker-bg, var(--diffs-bg)));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
& [data-marker-message] {
|
|
227
|
+
white-space: normal;
|
|
228
|
+
overflow-wrap: anywhere;
|
|
229
|
+
|
|
230
|
+
& code {
|
|
231
|
+
white-space: normal;
|
|
232
|
+
color: inherit;
|
|
233
|
+
background-color: #0000;
|
|
234
|
+
display: inline;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
[data-selection-action-popover] {
|
|
240
|
+
pointer-events: auto;
|
|
241
|
+
flex-wrap: wrap;
|
|
242
|
+
align-items: center;
|
|
243
|
+
gap: 4px;
|
|
244
|
+
width: max-content;
|
|
245
|
+
padding: 4px;
|
|
246
|
+
display: flex;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
[data-search-panel] {
|
|
250
|
+
z-index: 100;
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
justify-content: right;
|
|
253
|
+
width: 100%;
|
|
254
|
+
height: 0;
|
|
255
|
+
display: flex;
|
|
256
|
+
position: sticky;
|
|
257
|
+
top: 16px;
|
|
258
|
+
right: 16px;
|
|
259
|
+
container: search-panel / inline-size;
|
|
260
|
+
|
|
261
|
+
& [data-editor-widget] {
|
|
262
|
+
z-index: 100;
|
|
263
|
+
flex-shrink: 0;
|
|
264
|
+
align-items: stretch;
|
|
265
|
+
gap: 8px;
|
|
266
|
+
min-width: 260px;
|
|
267
|
+
max-width: 100%;
|
|
268
|
+
margin-inline: auto 16px;
|
|
269
|
+
padding: 4px;
|
|
270
|
+
display: flex;
|
|
271
|
+
position: relative;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
& svg {
|
|
275
|
+
fill: currentColor;
|
|
276
|
+
width: 12px;
|
|
277
|
+
height: 12px;
|
|
278
|
+
display: block;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
[data-search-grid] {
|
|
283
|
+
grid-template-columns: auto auto auto;
|
|
284
|
+
grid-template-areas: "find matches nav"
|
|
285
|
+
"replace actions .";
|
|
286
|
+
align-items: center;
|
|
287
|
+
gap: 4px 6px;
|
|
288
|
+
width: 100%;
|
|
289
|
+
display: grid;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
[data-input-box][data-find] {
|
|
293
|
+
grid-area: find;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
[data-search-nav] {
|
|
297
|
+
grid-area: nav;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
[data-input-box][data-replace] {
|
|
301
|
+
grid-area: replace;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
[data-replace-actions] {
|
|
305
|
+
grid-area: actions;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
[data-search-grid][data-mode="find"] {
|
|
309
|
+
grid-template-areas: "find matches nav";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
[data-search-grid][data-mode="find"] [data-replace-cell] {
|
|
313
|
+
display: none;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@container search-panel (width < 400px) {
|
|
317
|
+
[data-search-panel] [data-editor-widget] {
|
|
318
|
+
padding: 10px;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
[data-search-grid][data-mode="replace"] {
|
|
322
|
+
grid-template-columns: auto 1fr auto;
|
|
323
|
+
grid-template-areas: "find find find"
|
|
324
|
+
"replace replace replace"
|
|
325
|
+
"nav matches actions";
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
[data-search-grid][data-mode="find"] {
|
|
329
|
+
grid-template-columns: auto 1fr auto;
|
|
330
|
+
grid-template-areas: "find find find"
|
|
331
|
+
"nav matches matches";
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
[data-replace-actions] {
|
|
335
|
+
justify-self: end;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
[data-search-grid] [data-input-box] {
|
|
339
|
+
width: auto;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
[data-input-box] {
|
|
344
|
+
align-items: center;
|
|
345
|
+
width: 200px;
|
|
346
|
+
display: flex;
|
|
347
|
+
position: relative;
|
|
348
|
+
|
|
349
|
+
& input {
|
|
350
|
+
width: 100%;
|
|
351
|
+
min-width: 0;
|
|
352
|
+
color: var(--diffs-fg);
|
|
353
|
+
background-color: var(--diffs-bg);
|
|
354
|
+
border: 1px solid color-mix(in lab, var(--diffs-fg) 12%, var(--diffs-bg));
|
|
355
|
+
border-radius: 6px;
|
|
356
|
+
outline: none;
|
|
357
|
+
flex-grow: 1;
|
|
358
|
+
padding-inline: 6px;
|
|
359
|
+
font-size: 13px;
|
|
360
|
+
line-height: 24px;
|
|
361
|
+
|
|
362
|
+
&::selection {
|
|
363
|
+
background-color: color-mix(in lab, var(--diffs-fg) 8%, var(--diffs-bg));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
&:focus-visible {
|
|
367
|
+
outline: 1px solid var(--diffs-modified-base);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
&[data-find] input {
|
|
372
|
+
padding-inline-end: 72px;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
& [data-search-icon] {
|
|
376
|
+
--diffs-search-icon-size: 20px;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
[data-search-toggles] {
|
|
381
|
+
align-items: center;
|
|
382
|
+
gap: 1px;
|
|
383
|
+
display: flex;
|
|
384
|
+
position: absolute;
|
|
385
|
+
top: 50%;
|
|
386
|
+
right: 4px;
|
|
387
|
+
transform: translateY(-50%);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
[data-matches] {
|
|
391
|
+
white-space: nowrap;
|
|
392
|
+
min-width: 50px;
|
|
393
|
+
color: color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg));
|
|
394
|
+
flex-shrink: 0;
|
|
395
|
+
grid-area: matches;
|
|
396
|
+
font-size: 12px;
|
|
397
|
+
font-weight: 500;
|
|
398
|
+
line-height: 20px;
|
|
399
|
+
|
|
400
|
+
&[data-no-matches] {
|
|
401
|
+
color: color-mix(in lab, var(--diffs-fg) 35%, var(--diffs-bg));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
[data-replace-actions], [data-search-nav] {
|
|
406
|
+
align-items: center;
|
|
407
|
+
display: flex;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
[data-search-icon] {
|
|
411
|
+
appearance: none;
|
|
412
|
+
width: var(--diffs-search-icon-size, 24px);
|
|
413
|
+
height: var(--diffs-search-icon-size, 24px);
|
|
414
|
+
color: color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg));
|
|
415
|
+
border-radius: var(--diffs-search-icon-radius, 4px);
|
|
416
|
+
cursor: pointer;
|
|
417
|
+
background: none;
|
|
418
|
+
border: 0;
|
|
419
|
+
flex-shrink: 0;
|
|
420
|
+
justify-content: center;
|
|
421
|
+
align-items: center;
|
|
422
|
+
margin: 0;
|
|
423
|
+
padding: 0;
|
|
424
|
+
transition: background-color .1s ease-in-out, color .1s ease-in-out;
|
|
425
|
+
display: flex;
|
|
426
|
+
|
|
427
|
+
&:disabled {
|
|
428
|
+
opacity: .25;
|
|
429
|
+
cursor: default;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
&:not(:disabled):hover {
|
|
433
|
+
color: var(--diffs-fg);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
&:focus-visible {
|
|
437
|
+
outline: 1px solid var(--diffs-modified-base);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
&[aria-pressed="true"] {
|
|
441
|
+
color: var(--diffs-modified-base);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
[data-search-close] {
|
|
446
|
+
--diffs-search-icon-size: 20px;
|
|
447
|
+
--diffs-search-icon-radius: 50%;
|
|
448
|
+
color: var(--diffs-widget-bg);
|
|
449
|
+
background-color: color-mix(in lab,
|
|
450
|
+
var(--diffs-widget-fg) 50%,
|
|
451
|
+
var(--diffs-bg));
|
|
452
|
+
position: absolute;
|
|
453
|
+
top: 0;
|
|
454
|
+
right: 0;
|
|
455
|
+
transform: translate(50%, -50%);
|
|
456
|
+
|
|
457
|
+
&:not(:disabled):hover {
|
|
458
|
+
opacity: 1;
|
|
459
|
+
color: var(--diffs-widget-bg);
|
|
460
|
+
background-color: var(--diffs-widget-fg);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
`;const Mn="//",Rn=["/*","*/"],On={sql:{lineComment:"--"},ruby:{lineComment:"#",blockComment:["=begin","=end"]},rst:{lineComment:".."},coffeescript:{lineComment:"#",blockComment:["###","###"]},cmd:{lineComment:"@REM"},julia:{lineComment:"#",blockComment:["#=","=#"]},yaml:{lineComment:"#"},yml:{lineComment:"#"},markdown:{lineComment:null,blockComment:["<!--","-->"]},zsh:{lineComment:"#"},makefile:{lineComment:"#"},handlebars:{lineComment:null,blockComment:["{{!--","--}}"]},ini:{lineComment:";",blockComment:[";"," "]},powershell:{lineComment:"#",blockComment:["<#","#>"]},vb:{lineComment:"'"},xml:{lineComment:null,blockComment:["<!--","-->"]},lua:{lineComment:"--",blockComment:["--[[","]]"]},html:{lineComment:null,blockComment:["<!--","-->"]},diff:{lineComment:"#",blockComment:["#"," "]},r:{lineComment:"#"},fsharp:{blockComment:["(*","*)"]},pug:{lineComment:"//-"},perl:{lineComment:"#"},tex:{lineComment:"%"},clojure:{lineComment:";;"},css:{lineComment:null},python:{lineComment:"#",blockComment:['"""','"""']},dotenv:{lineComment:"#"},dockerfile:{lineComment:"#"},razor:{lineComment:null,blockComment:["<!--","-->"]},prompt:{lineComment:null,blockComment:["<!--","-->"]}};function In(t,e){const n={...On[t],...e?.[t]};return{lineComment:n.lineComment===void 0?Mn:n.lineComment,blockComment:n.blockComment??Rn}}function Pn(t,e,n){const i=[],s=new Set;for(const a of e){let c=a.end.line;a.start.line<c&&a.end.character===0&&c--;const h=i.length;let d=1/0;for(let l=a.start.line;l<=c;l++){if(s.has(l))continue;s.add(l);const f=t.getLineText(l),u=f.length-f.trimStart().length,v=u===f.length;v||(d=Math.min(d,u)),i.push({line:l,comment:f.slice(u,u+n.length)===n?u:-1,empty:v,indent:u,single:!1})}if(d!==1/0)for(let l=h;l<i.length;l++)i[l].empty||(i[l].indent=d);i.length===h+1&&(i[h].single=!0)}const r=i.some(a=>a.comment<0&&(!a.empty||a.single)),o=[];if(r){for(const a of i){if(a.empty&&!a.single)continue;const c={line:a.line,character:a.indent};o.push({range:{start:c,end:c},newText:n+" "})}return o}for(const a of i){if(a.comment<0)continue;const c=t.getLineText(a.line),h=a.comment,d=h+n.length+(c[h+n.length]===" "?1:0);o.push({range:{start:{line:a.line,character:h},end:{line:a.line,character:d}},newText:""})}return o}const tt=50;function Bn(t,e,n,i,s){const r=Math.max(0,i-tt),o=t.getTextSlice(r,i),a=t.getTextSlice(s,s+tt),c=o.length-o.trimEnd().length,h=a.length-a.trimStart().length,d=o.length-c;if(o.slice(d-e.length,d)===e&&a.slice(h,h+n.length)===n)return{open:{start:i-c-e.length,end:i-c+(c>0?1:0),text:""},close:{start:s+h-(h>0?1:0),end:s+h+n.length,text:""},contentStart:i,contentEnd:s};const l=s-i<=tt*2?t.getTextSlice(i,s):void 0,f=l??t.getTextSlice(i,i+tt),u=l??t.getTextSlice(s-tt,s),v=f.length-f.trimStart().length,g=s-(u.length-u.trimEnd().length)-n.length;if(f.slice(v,v+e.length)!==e||t.getTextSlice(g,g+n.length)!==n)return;const p=i+v,m=p+e.length+(/\s/.test(f[e.length+v]??"")?1:0),C=g-(/\s/.test(t.getTextSlice(g-1,g))?1:0);return{open:{start:p,end:m,text:""},close:{start:C,end:g+n.length,text:""},contentStart:m,contentEnd:C}}function ce(t,e,n,i){let s=0,r=e.length;for(;s<r;){const a=s+r>>>1;e[a].end<t?s=a+1:r=a}let o=n[s];for(let a=s;a<e.length;a++){const c=e[a];if(t<c.start)break;if(c.start===c.end&&t===c.start){if(i<0)break;o+=c.text.length;continue}if(t>c.end){o+=c.text.length-(c.end-c.start);continue}return t===c.end?c.start+o+c.text.length:c.start+o+(i>0?c.text.length:0)}return t+o}function Nn(t,e,[n,i],s=!1){const r=e.map(l=>{let{start:f,end:u}=l;if(s){let v=u.line;f.line<v&&u.character===0&&v--;const g=t.getLineText(f.line),p=g.length-g.trimStart().length;f={line:f.line,character:p},u={line:v,character:t.getLineLength(v)}}return{from:t.offsetAt(f),to:t.offsetAt(u),direction:l.direction,comment:void 0}});if(s&&r.length>1){r.sort((f,u)=>{const v=f.from-u.from;return v!==0?v:f.to-u.to});let l=0;for(let f=1;f<r.length;f++){const u=r[l],v=r[f];v.from<=u.to?u.to=Math.max(u.to,v.to):r[++l]=v}r.length=l+1}for(const l of r)l.comment=Bn(t,n,i,l.from,l.to);const o=r.every(l=>l.comment!==void 0),a=[];for(const l of r){const f=l.comment;if(o&&f!==void 0){a.push(f.open,f.close);continue}if(f===void 0){if(l.from===l.to){a.push({start:l.from,end:l.to,text:n+" "+i});continue}a.push({start:l.from,end:l.from,text:n+" "},{start:l.to,end:l.to,text:" "+i})}}if(a.length===0)return;a.sort((l,f)=>{const u=l.start-f.start;return u!==0?u:l.end-f.end});const c=a.map(l=>({range:{start:t.positionAt(l.start),end:t.positionAt(l.end)},newText:l.text}));if(s)return{edits:c,nextSelectionOffsets:[]};const h=r.map(l=>{const f=l.comment;return o&&f!==void 0?{start:f.contentStart,end:f.contentEnd,startAssociation:1,endAssociation:-1}:f!==void 0?{start:l.from,end:l.to,startAssociation:1,endAssociation:1}:l.from===l.to?{start:l.from,end:l.to,startAssociation:-1,endAssociation:-1,collapsedInset:n.length+1}:{start:l.from,end:l.to,startAssociation:1,endAssociation:-1}}),d=new Array(a.length+1);d[0]=0;for(let l=0;l<a.length;l++){const f=a[l];d[l+1]=d[l]+f.text.length-(f.end-f.start)}return{edits:c,nextSelectionOffsets:h.map((l,f)=>{const u=ce(l.start,a,d,l.startAssociation)+(l.collapsedInset??0);return[u,l.collapsedInset===void 0?ce(l.end,a,d,l.endAssociation):u,r[f].direction]})}}function k(t,e,n){const{style:i,dataset:s,children:r,...o}=e??{},a=document.createElement(t);return Object.assign(a,o),i!==void 0&&(typeof i=="string"?a.style.cssText=i:Object.assign(a.style,i)),s!==void 0&&(typeof s=="string"?a.dataset[s]="":Array.isArray(s)?s.forEach(c=>{a.dataset[c]=""}):Object.assign(a.dataset,s)),r!==void 0&&a.replaceChildren(...r),n!==void 0&&n.appendChild(a),a}function T(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function W(t,e="line"){const n=t.dataset[e];if(n===void 0)return;const i=parseInt(n,10);if(!Number.isNaN(i))return i}function le(t,e){if(t.nodeType===3){const n=t.textContent?.length??0;return Math.max(0,Math.min(e,n))}return t.nodeType===1?Math.max(0,Math.min(e,t.childNodes.length)):0}function zn(t,e){return Object.assign(t,e)}function Hn(t,e){let n;return function(...i){clearTimeout(n),n=setTimeout(()=>t.apply(this,i),e)}}function q(t,e=1e3){return Math.round(t*e)/e}function _n(t){return t.endsWith(`
|
|
464
|
+
`)||t.endsWith("\r")}function Oe(t){if(!(typeof Intl>"u"||typeof Intl.Segmenter!="function"))return new Intl.Segmenter(void 0,t)}let he,de=!1;function Y(){return de||(he=Oe({granularity:"grapheme"}),de=!0),he}function Wn(t){const e=t.ownerDocument;let n=t.parentElement;for(;n!=null&&n!==e.body&&n!==e.documentElement;){const i=n.ownerDocument.defaultView?.getComputedStyle(n).overflowY;if(i==="auto"||i==="scroll"||i==="overlay")return n;n=n.parentElement}return e}function mt(t,e){const n=Dn(t);if(n.length===0)return;const i=[];let s=!1;for(const r of e){if(r.side==="deletions"||r.lineNumber<=0){i.push(r);continue}let o=r.lineNumber-1,a=t.previousLineCount,c=!1;for(const d of n){const l=Math.max(1,a+d.lineDelta),f=Fn(o,d,l);if(f===void 0){c=!0,o=void 0;break}(f!==o||Vn(o,d))&&(c=!0),o=f,a=l}if(o===void 0){s=!0;continue}const h=o+1;if(c){i.push(h===r.lineNumber?r:{...r,lineNumber:h}),s=!0;continue}i.push(r)}return s?i:void 0}function Dn(t){if(t.changedLineChanges!==void 0)return t.changedLineChanges.flatMap(([i,s,r,o=0,a=0,c=!1])=>{if(r===0)return[];const h=Math.max(0,s-i);return[{startLine:i,startCharacter:o,endLine:i+Math.max(0,h-r),deletesEndLine:r<0&&c,insertedLineBreaks:h,lineDelta:r}]});if(t.lineDelta===0)return t.changedLineRanges.flatMap(([i,s])=>{const r=s-i;return r<=0?[]:[{startLine:i,startCharacter:0,endLine:i,deletesEndLine:!1,insertedLineBreaks:r,lineDelta:r}]});const e=Math.max(0,-t.lineDelta),n=t.endedAtDocumentEnd&&t.startLine+e===t.previousLineCount-1;return[{startLine:t.startLine,startCharacter:t.startCharacter,endLine:t.startLine+e,deletesEndLine:n,insertedLineBreaks:Math.max(0,t.lineDelta),lineDelta:t.lineDelta}]}function Fn(t,e,n){if(t<e.startLine)return t;if(t>e.endLine||e.endLine>e.startLine&&t===e.endLine&&!e.deletesEndLine)return t+e.lineDelta;if(e.startLine===e.endLine)return e.startCharacter===0?t+e.insertedLineBreaks:t;if(Un(t,e))return;const i=Math.min(Math.max(0,t-e.startLine),e.insertedLineBreaks);return $n(e.startLine+i,n)}function Un(t,e){return!(e.lineDelta>=0||t<e.startLine||t>e.endLine||t===e.startLine&&e.startCharacter>0||t===e.endLine&&!e.deletesEndLine)}function Vn(t,e){return e.lineDelta===0||t<e.startLine||t>e.endLine?!1:!(e.endLine>e.startLine&&t===e.endLine&&!e.deletesEndLine)}function $n(t,e){return Math.max(0,Math.min(t,Math.max(0,e-1)))}function Kn(t,e,n){const i=new Map,s=new Map;for(const d of t){const l=d.lineNumber;i.has(l)||i.set(l,[]),s.has(l)||s.set(l,[]),(d.side==="deletions"?s:i).get(l).push(rn(d))}const r=e.parentElement?.previousElementSibling;let o,a;if(r!=null&&r instanceof HTMLElement&&r.dataset.deletions!==void 0)for(const d of r.children){const l=d,{gutter:f,content:u}=l.dataset;f!==void 0?o=l:u!==void 0&&(a=l)}fe(e,n),a!==void 0&&fe(a,o);const c=ue(i,e,n);if(a===void 0)return;const h=ue(s,a,o);requestAnimationFrame(()=>{Gn(i,s,c,h)})}function fe(t,e){const n=[];for(let i=1;i<t.childElementCount;i++){const s=t.children[i];s.dataset.lineAnnotation!==void 0&&(n.push(s),e!==void 0&&n.push(e.children[i]))}for(const i of n)i.remove()}function ue(t,e,n){const i=new Map;for(const s of e.children){const r=W(s);if(r!==void 0){const o=t.get(r);if(o!==void 0){const a=k("div",{dataset:{lineAnnotation:"0,"+(r-1)},children:[k("div",{dataset:"annotationContent",children:o.map(c=>k("slot",{name:c}))})]});s.after(a),i.set(r,a)}}}if(n!==void 0)for(const s of n.children){const r=W(s,"columnNumber");if(r!==void 0&&t.has(r)){const o=k("div",{dataset:{gutterBuffer:"annotation",bufferSize:"1"},style:{gridRow:"span 1"}});s.after(o)}}return i}function Gn(t,e,n,i){const s=new Map;for(const[r,o]of t.entries()){const a=i.get(r);if(o.length===0&&a!==void 0){const c=ge(a);c>0&&s.set(r,c)}}for(const[r,o]of e.entries()){const a=n.get(r);if(o.length===0&&a!==void 0){const c=ge(a);c>0&&s.set(r,c)}}pe(t,n,s),pe(e,i,s)}function ge(t){const e=t.firstElementChild;return e instanceof HTMLElement?e.getBoundingClientRect().height:0}function pe(t,e,n){for(const[i,s]of e.entries()){const r=t.get(i),o=n.get(i);r?.length===0&&o!==void 0&&s.style.setProperty("--diffs-annotation-min-height",`${o}px`)}}var jn=class{#e;#t;#r;#n;#a;#l;#c=0;#v=0;#w=0;#g=!0;#x;#u=new Map;#y;#A;constructor(t){this.#y=t.hasActivePopover,this.#A=t.updateActivePopover}setViewportElements(t,e){const n=this.#e!==t||this.#t!==e;this.#e=t,n&&(this.#t=e,this.#g=!0,this.#x?.forEach(i=>i()),this.#x=void 0)}cleanUp(){this.#t=void 0,this.#e=void 0,this.#r=void 0,this.#n=void 0,this.#a=void 0,this.#l=void 0,this.#c=0,this.#v=0,this.#w=0,this.#g=!0,this.#x?.forEach(t=>t()),this.#x=void 0,this.#u.clear()}resetPlacement(t="default"){this.#u.delete(t)}setPlacement(t,e="default"){this.#u.set(e,t)}choosePlacement(t){const{preferred:e,fallback:n,viewport:i,popoverHeight:s,atDocumentEdge:r,placementKey:o="default"}=t,a=this.#u.get(o);let c;if(i!==void 0&&s>0){const h=(d,l=0)=>d.top>=i.top+l&&d.bottom<=i.bottom-l;a==="fallback"&&h(n)&&!h(e,4)||!h(e)&&h(n)?c="fallback":c="preferred"}else c=r?"fallback":"preferred";return this.#u.set(o,c),c}getPlacementBounds(){const t=this.#B();if(t===void 0)return;const e=this.#L();let n,i;if(e!==void 0?(n=e.top,i=e.bottom):(n=0,i=window.innerHeight),n=Math.max(n,t.top),i=Math.min(i,t.bottom),i<=n)return;const s=this.#c,r=this.#v,o=this.#w>0?this.#w:t.width,a=e!==void 0?e.left:0,c=e!==void 0?e.right:window.innerWidth,h=s,d=s+o,l=Math.max(h,a-t.left+s),f=Math.min(d,c-t.left+s);return{top:n-t.top+r,bottom:i-t.top+r,left:l,right:Math.max(l,f)}}#W(){const t=this.#e;if(t===void 0)return;if(this.#n===t&&(this.#r===void 0||this.#r.isConnected))return this.#r;let e=t.parentElement;for(;e!==null;){const n=getComputedStyle(e).overflowY;if(n==="auto"||n==="scroll"||n==="overlay")return this.#r=e,this.#n=t,e;e=e.parentElement}this.#r=void 0,this.#n=t}#o(){if(!this.#g)return;this.#m();const t=this.#t;this.#a=t?.getBoundingClientRect(),this.#c=t?.scrollLeft??0,this.#v=t?.scrollTop??0,this.#w=t?.clientWidth??0,this.#l=this.#W()?.getBoundingClientRect(),this.#g=!1}#B(){return this.#o(),this.#a}#L(){return this.#o(),this.#l}#m(){if(this.#x!==void 0)return;let t;const e=()=>{this.#g=!0,!(!this.#y()||t!==void 0)&&(t=requestAnimationFrame(()=>{t=void 0,this.#A()}))},n=this.#W(),i=this.#t;this.#x=[n!==void 0?T(n,"scroll",e,{passive:!0}):T(window,"scroll",e,{passive:!0}),...i!==void 0?[T(i,"scroll",e,{passive:!0})]:[],T(window,"resize",e,{passive:!0}),()=>{t!==void 0&&(cancelAnimationFrame(t),t=void 0)}]}};function Ie(t,{gutterWidth:e,placeAbove:n,viewport:i,x:s,y:r}){if(t.style.setProperty("--gutter-width",e+"px"),t.style.setProperty("--popover-x",s+"px"),t.style.setProperty("--popover-y",r+"px"),t.style.setProperty("--popover-y-shift",n?"-100%":"0px"),i===void 0){t.style.removeProperty("--popover-viewport-left"),t.style.removeProperty("--popover-viewport-right"),t.style.removeProperty("--popover-viewport-top"),t.style.removeProperty("--popover-viewport-bottom");return}t.style.setProperty("--popover-viewport-left",i.left+"px"),t.style.setProperty("--popover-viewport-right",i.right+"px"),t.style.setProperty("--popover-viewport-top",i.top+"px"),t.style.setProperty("--popover-viewport-bottom",i.bottom+"px")}const Pe=new Map([["'","'"],['"','"'],["`","`"],["{","}"],["[","]"],["<",">"],["(",")"]]),qn=new Set(["'",'"',"`"]),Zn=new Set(["{","[","(","<"]);function Xn(t,e=0){const n=be(t.startContainer,t.startOffset),i=be(t.endContainer,t.endOffset);if(!(n===null||i===null))return{start:n,end:i,direction:e}}function Yn(t,e,n,i){if(t===void 0)return[[],e];const{start:s,end:r}=e,o=[];let a={...e};const c=s.line!==r.line;let h=r.line;s.line<r.line&&r.character===0&&h--;for(let d=s.line;d<=h;d++){const l=t.getLineText(d);if(l===void 0||c&&l.trim().length===0)continue;const f=l.startsWith(" ")?" ":" ".repeat(n);let u=0,v=f;if(i){if(l.startsWith(" "))u=1;else if(l.startsWith(" ")){const p=l.length-l.trimStart().length;u=Math.min(f.length,p)}if(u===0)continue;v=""}o.push({range:{start:{line:d,character:0},end:{line:d,character:u}},newText:v});const g=v.length-u;d===s.line&&(a={...a,start:{...s,character:Math.max(0,s.character+g)}}),d===r.line&&(a={...a,end:{...r,character:Math.max(0,r.character+g)}})}return[o,a]}function Be(t,e,n,i={}){const s=t.lineCount;return e.map(r=>{let{line:o,character:a}=n==="up"||n==="left"?r.start:r.end;if(n==="textStart"||n==="start"||n==="end"){const h=B(r);o=h.line,a=h.character;const d=Ne(t,o,a,i);if(n==="textStart"){const l=t.getLineText(o).slice(d.start,d.end),f=d.start+De(l);a=a===f?d.start:f}else a=n==="start"?d.start:d.end}else if(n==="up"){const h=ve(t,o,a,-1,i);h!==void 0?(o=h.line,a=h.character):o>0&&(o=i.resolveRenderableLine==null?o-1:i.resolveRenderableLine(o-1,"up")??o)}else if(n==="down"){const h=ve(t,o,a,1,i);if(h!==void 0)o=h.line,a=h.character;else{const d=Math.max(s-1,0);o<d&&(o=i.resolveRenderableLine==null?o+1:Math.min(i.resolveRenderableLine(o+1,"down")??o,d))}}else if(I(r)){const h=t.getLineLength(o);if(a=Math.min(a,h),n==="left"){if(a>0)a=ut(t,o,a,!1);else if(o>0){const d=i.resolveRenderableLine==null?o-1:i.resolveRenderableLine(o-1,"up");d!==void 0&&(o=d,a=t.getLineLength(o))}}else if(a<h)a=ut(t,o,a,!0);else if(o<s-1){const d=i.resolveRenderableLine==null?o+1:i.resolveRenderableLine(o+1,"down");d!==void 0&&(o=Math.min(d,s-1),a=0)}}const c={line:o,character:a};return{start:c,end:c,direction:0}})}function ve(t,e,n,i,s){if(s.getSoftLineOffsets===void 0)return;const r=Ne(t,e,n,s),o=r.index+i;let a=e,c;if(o>=0&&o<r.count)c=ft(t,a,o,s);else{const u=e+i;if(u<0||u>=t.lineCount)return{line:e,character:n};const v=s.resolveRenderableLine==null?u:s.resolveRenderableLine(u,i<0?"up":"down");if(v===void 0)return{line:e,character:n};a=Math.min(v,t.lineCount-1);const g=Qn(t,a,s);c=ft(t,a,i<0?g-1:0,s)}const h=Math.max(0,n-r.start),d=c.start+h,l=c.index===c.count-1?d:Math.min(d,c.end),f=t.getLineText(a);return{line:a,character:l>f.length?l:Nt(f,l)}}function Nt(t,e){if(e<=0||e>=t.length)return e;const n=Y();if(n!==void 0){for(const s of n.segment(t)){if(e<=s.index)return e;const r=s.index+s.segment.length;if(e<r)return r}return e}let i=0;for(const s of t){if(e<=i)return e;const r=i+s.length;if(e<r)return r;i=r}return e}function Ne(t,e,n,i){const s=t.getLineLength(e),r=i.getSoftLineOffsets?.(e);if(r===void 0||r.length<2)return{start:0,end:s,index:0,count:1};for(let o=0;o+1<r.length;o++){const a=ft(t,e,o,i);if(n>=a.start&&n<=a.end)return a}return ft(t,e,n<(r[0]??0)?0:r.length-2,i)}function Qn(t,e,n){const i=n.getSoftLineOffsets?.(e);return i===void 0||i.length<2?1:i.length-1}function ft(t,e,n,i){const s=t.getLineLength(e),r=i.getSoftLineOffsets?.(e);if(r===void 0||r.length<2)return{start:0,end:s,index:0,count:1};const o=r.length-1,a=Math.max(0,Math.min(n,o-1)),c=Math.max(0,Math.min(s,r[a]??0));return{start:c,end:Math.max(c,Math.min(s,r[a+1]??s)),index:a,count:o}}function Jn(t,e,n,i={}){return e.map(s=>{const r=s.direction===-1?s.start:s.end,[o]=Be(t,[{start:r,end:r,direction:0}],n,i);return zt(s,o)})}function ti(t,e,n,i,s=2,r=!1){if(e[e.length-1]===void 0)return{nextSelections:[]};const o=[];for(const L of e)o.push(L.start,L.end);const a=o.map(L=>t.offsetAt(L)),c=a[(e.length-1)*2],h=a[(e.length-1)*2+1],d=[];let l=!0;for(let L=0;L<e.length;L++){const S={index:L,start:a[L*2],end:a[L*2+1]},w=d[d.length-1];w!==void 0&&(S.start<w.start||S.start===w.start&&S.end<w.end)&&(l=!1),d.push(S)}l||d.sort((L,S)=>{const w=L.start-S.start;if(w!==0)return w;const R=L.end-S.end;return R!==0?R:L.index-S.index});const f=Dt(t,n,s),u=[],v=Array.from({length:e.length});let g=0,p;const m=()=>{if(p===void 0)return;const L=Dt(t,{start:p.start,end:p.end,text:f.text},s),S=We(t,L.text,L.start);u.push({start:L.start,end:L.end,text:S});const w=[p.start+g+S.length,p.start+g+S.length];for(const R of p.indices)v[R]=w;g+=S.length-(L.end-L.start),p=void 0};for(const L of d){const S=Math.max(0,L.start+(f.start-c)),w=Math.max(S,L.end+(f.end-h));if(p!==void 0&&S<p.end){p.end=Math.max(p.end,w),p.indices.push(L.index);continue}m(),p={start:S,end:w,indices:[L.index]}}m();const C=t.applyResolvedEdits(u,!0,e,void 0,r),x=jt(t,v.map(L=>{if(L===void 0)throw new Error("Missing next selection offsets");return L}));if(t.setLastUndoSelectionsAfter(x),C!==void 0&&i!==void 0){const L=mt(C,i);L!==void 0&&t.setLastUndoLineAnnotations(i,L)}return{nextSelections:x,change:C}}function ei(t,e){if(e.length!==t.length+2)return;const n=Pe.get(e[0]);if(!(n===void 0||e[e.length-1]!==n||e.slice(1,-1)!==t))return 1}function ni(t,e,n,i){const s=e.start+n,r=s+i.length;if(e.end-e.start>0){const o=t.getTextSlice(e.start,e.end),a=ei(o,i)??i.indexOf(o);if(a!==-1&&a+o.length<=i.length){const c=s+a;return[c,c+o.length]}}return[r,r]}function ot(t,e,n,i,s=!1,r="selection"){if(e.length!==n.length)throw new Error("Selection text replacements must match the selection count");const o=[];for(const g of e)o.push(g.start,g.end);const a=o.map(g=>t.offsetAt(g)),c=[];let h=!0;for(let g=0;g<e.length;g++){const p={index:g,start:a[g*2],end:a[g*2+1]},m=c[c.length-1];m!==void 0&&(p.start<m.start||p.start===m.start&&p.end<m.end)&&(h=!1),c.push(p)}h||c.sort((g,p)=>{const m=g.start-p.start;if(m!==0)return m;const C=g.end-p.end;return C!==0?C:g.index-p.index});const d=n.every(g=>g==="");let l;const f=Array.from({length:e.length});if(d){l=[];let g=!1;for(const p of c){if(f[p.index]=[p.end,p.end],p.start>=p.end)continue;g=!0;const m=l[l.length-1];m!==void 0&&p.start<m.end?l[l.length-1]={start:m.start,end:Math.max(m.end,p.end),text:""}:l.push({start:p.start,end:p.end,text:""})}if(!g)return{nextSelections:e};for(const p of c){const m=p.end;let C=0,x=m;for(const L of l){if(m<=L.start)break;if(m>=L.end){C-=L.end-L.start;continue}x=L.start+C;break}x===m&&(x+=C),f[p.index]=[x,x]}}else{l=[];let g=0,p=-1;for(let m=0;m<c.length;m++){const C=c[m];if(C.start<p)throw new Error("Overlapping multi-selection edits are not supported");p=C.end;const x=We(t,n[r==="document"?m:C.index],C.start);l.push({start:C.start,end:C.end,text:x}),f[C.index]=ni(t,C,g,x),g+=x.length-(C.end-C.start)}}const u=t.applyResolvedEdits(l,!0,e,void 0,s),v=jt(t,f.map(g=>{if(g===void 0)throw new Error("Missing next selection offsets");return g}));if(t.setLastUndoSelectionsAfter(v),u!==void 0&&i!==void 0){const g=mt(u,i);g!==void 0&&t.setLastUndoLineAnnotations(i,g)}return{nextSelections:v,change:u}}function ii(t,e){return t==="never"?!1:t==="brackets"?Zn.has(e):t==="quotes"?qn.has(e):!0}function si(t,e,n,i){if(n.length!==1||e.length===0)return;const s=Pe.get(n);if(s===void 0||!ii(i,n))return;const r=[];for(const o of e){if(I(o))return;r.push(n+t.getText(o)+s)}return r}function ri(t,e,n){const i=[],s=[];for(const a of e){const[c,h]=yi(t,a);if(!I(a)){s.push([c,h]);continue}const{line:d,character:l}=a.start,f=c,u=t.getLineText(d),v=u.length,g=f-l,p=Wt(u);let m;if(l>0&&l<v){const C=st(u,l,!1,p),x=st(u,l,!0,p);m={start:g+C,end:g+x,text:u.slice(l,x)+u.slice(C,l)},s.push([g+x,g+x])}else if(l===v&&p.length>=2){const C=p[p.length-1],x=p[p.length-2];m={start:g+x,end:f,text:u.slice(C,v)+u.slice(x,C)},s.push([f,f])}else if(l===0&&d>0&&v>0){const C=d-1,x=t.getLineText(C),L=x.length,S=t.offsetAt({line:C,character:L}),w=L>0?st(x,L,!1,Wt(x)):L,R=st(u,0,!0,p),O=S-(L-w),y=u.slice(0,R)+t.getTextSlice(S,f)+x.slice(w,L);m={start:O,end:f+R,text:y};const E=O+y.length;s.push([E,E])}else{s.push([c,h]);continue}i.push(m)}if(i.length===0)return{nextSelections:e};i.sort((a,c)=>a.start-c.start);for(let a=1;a<i.length;a++)if(i[a].start<i[a-1].end)throw new Error("Overlapping multi-selection edits are not supported");const r=t.applyResolvedEdits(i,!0,e),o=jt(t,s);if(t.setLastUndoSelectionsAfter(o),r!==void 0&&n!==void 0){const a=mt(r,n);a!==void 0&&t.setLastUndoLineAnnotations(n,a)}return{nextSelections:o,change:r}}function oi(t,e,n){const i=e.map(s=>{const r=ki(t,s);return{start:r.start,end:r.end,direction:0}});return ot(t,i,i.map(()=>""),n)}function ai(t,e,n,i){const s=e.map(r=>{if(!I(r))return{start:r.start,end:r.end,direction:0};const o=B(r),{line:a,character:c}=o,h=n?.(a,c)??0;if(c>h)return{start:{line:a,character:h},end:{line:a,character:c},direction:0};if(a===0)return{start:o,end:o,direction:0};const d=t.getLineLength(a-1);return{start:{line:a-1,character:d},end:{line:a,character:0},direction:0}});return ot(t,s,s.map(()=>""),i)}function ci(t,e,n){const i=e.map(s=>{const[r,o]=wi(t,s);return{start:r,end:o,direction:0}});return ot(t,i,i.map(()=>""),n)}function li(t,e,n){if(!I(e))return[e.start,e.end];const i=B(e);let{line:s,character:r}=i;const o=t.getLineLength(s),a=t.lineCount;if(r=Math.min(r,o),n)return r<o?[{line:s,character:r},{line:s,character:ut(t,s,r,!0)}]:s<a-1?[{line:s,character:o},{line:s+1,character:0}]:[i,i];if(r>0)return[{line:s,character:ut(t,s,r,!1)},{line:s,character:r}];if(s>0){const c=t.getLineLength(s-1);return[{line:s-1,character:c},{line:s,character:0}]}return[i,i]}function hi(t,e,n,i,s=2){const r=e.map(o=>{let[a,c]=li(t,o,n);if(!n&&I(o)){const h=Dt(t,{start:t.offsetAt(a),end:t.offsetAt(c),text:""},s);a=t.positionAt(h.start),c=t.positionAt(h.end)}return{start:a,end:c,direction:0}});return ot(t,r,r.map(()=>""),i)}function I(t){return t.start.line===t.end.line&&t.start.character===t.end.character}function B(t){const{start:e,end:n,direction:i}=t;return i===-1?e:n}function et(t){return t==="context"||t==="context-expanded"||t==="change-addition"}function Kt(t,e){const n=I(t),i=I(e);return n&&i?A(t.start,e.start)===0:n?A(e.start,t.start)<=0&&A(t.start,e.end)<=0:i?A(t.start,e.start)<=0&&A(e.start,t.end)<=0:A(t.start,e.end)<0&&A(e.start,t.end)<0}function A(t,e){return t.line!==e.line?t.line-e.line:t.character-e.character}function Gt(t,e,n){const i=e===n?0:e<n?1:-1,s=Math.min(e,n),r=Math.max(e,n);return{start:t.positionAt(s),end:t.positionAt(r),direction:i}}function me(t,e){let n=0;for(const i of e){if(t<i.start)break;if(t>=i.end)n+=i.text.length-(i.end-i.start);else return i.start+n+i.text.length}return t+n}function wt(t,e,n,i){return e.map((s,r)=>{const[o,a]=n[r],c=me(o,i),h=me(a,i);return Gt(t,s.direction===-1?h:c,s.direction===-1?c:h)})}function zt(t,e){const n=t.direction===-1?t.end:t.start,i=A(n,e.start),s=A(n,e.end);let r=e.end;i<=0?r=e.end:s>=0?r=e.start:r=i===0?e.end:e.start;const o=A(n,r);return{start:o<=0?n:r,end:o<=0?r:n,direction:o===0?0:o<0?1:-1}}function ze(t,e){const n=A(e.start,t.start)<0,i=A(e.end,t.end)>0;return n&&!i?{start:e.start,end:t.end,direction:-1}:i&&!n?{start:t.start,end:e.end,direction:1}:t.direction===-1?{start:e.start,end:t.end,direction:A(e.start,t.end)===0?0:-1}:{start:t.start,end:e.end,direction:A(t.start,e.end)===0?0:1}}function di(t,e){return He(t.map(n=>ze(n,e)))}function He(t){if(t.length<=1)return t;const e=t.map((s,r)=>({index:r,selection:s})).sort((s,r)=>{const o=A(s.selection.start,r.selection.start);if(o!==0)return o;const a=A(s.selection.end,r.selection.end);return a!==0?a:s.index-r.index}),n=[];let i=e[0];for(const s of e.slice(1)){if(Kt(i.selection,s.selection)){const r=s.index>i.index?s:i,o=A(s.selection.start,i.selection.start)<0?s.selection.start:i.selection.start,a=A(s.selection.end,i.selection.end)>0?s.selection.end:i.selection.end;let c=r.selection.direction;c===0&&A(o,a)!==0&&(c=A(r.selection.start,o)===0?-1:1),i={index:r.index,selection:{direction:c,end:a,start:o}};continue}n.push(i),i=s}return n.push(i),n.sort((s,r)=>s.index-r.index).map(({selection:s})=>s)}function Ce(t){const e=t.map(i=>{let s=i.end.line;return i.end.character===0&&A(i.start,i.end)!==0&&s--,{startLine:i.start.line,endLine:Math.max(i.start.line,s)}}).sort((i,s)=>{const r=i.startLine-s.startLine;return r!==0?r:i.endLine-s.endLine}),n=[];for(const i of e){const s=n.at(-1);s!==void 0&&i.startLine<=s.endLine+1?s.endLine=Math.max(s.endLine,i.endLine):n.push({...i})}return n}function fi(t,e,n,i){const s=r=>{const o=r.line+e;if(o>=n){const a=Math.max(0,n-1);return{line:a,character:i(a)}}return o<0?{line:0,character:0}:{line:o,character:r.character}};return{start:s(t.start),end:s(t.end),direction:t.direction}}function ui(t,e){if(e.length===0)return;const n=e.map(c=>I(c)?_t(t,c):c),i=n.map(c=>t.getText(c)),s=i[0];if(s.length===0||i.some(c=>c!==s))return;const r=n.map(c=>[t.offsetAt(c.start),t.offsetAt(c.end)]),o=t.findNextNonOverlappingSubstring(s,r);if(o===void 0)return n.some((c,h)=>{const d=e[h];return A(c.start,d.start)!==0||A(c.end,d.end)!==0||c.direction!==d.direction})?n:void 0;const a=Gt(t,o,o+s.length);return[...n,a]}function gi(t){const e=t.lineCount-1;return{start:{line:0,character:0},end:{line:e,character:t.getLineLength(e)},direction:1}}function Le(t,e,n){let i=0;if(e){const o=t.lineCount-1;i=n===!0&&o>0&&t.getLineLength(o)===0?o-1:o}const s=e?t.getLineLength(i):0,r={line:i,character:s};return{start:r,end:r,direction:1}}function pi(t,e){if(I(e)){const s=e.start.line;return{start:t.offsetAt({line:s,character:0}),end:s<t.lineCount-1?t.offsetAt({line:s+1,character:0}):t.offsetAt({line:s,character:t.getLineLength(s)})}}const n=t.offsetAt(e.start),i=t.offsetAt(e.end);return n<=i?{start:n,end:i}:{start:i,end:n}}function _e(t,e){return e.map(n=>pi(t,n)).sort((n,i)=>{const s=n.start-i.start;return s!==0?s:n.end-i.end})}function vi(t,e){return _e(t,e).map(({start:n,end:i})=>t.getTextSlice(n,i))}function Ht(t,e){const n=_e(t,e),i=t.eol;let s="",r=-1;for(const o of n)if(!(o.end<=o.start)){if(o.start<=r){o.end>r&&(s+=t.getTextSlice(r,o.end),r=o.end);continue}s.length>0&&!_n(s)&&(s+=i),s+=t.getTextSlice(o.start,o.end),r=o.end}return s}function mi(t,e){if(I(e))return Ci(t,e);const[n,i]=A(e.start,e.end)<=0?[e.start,e.end]:[e.end,e.start];return{start:t.offsetAt(n),end:t.offsetAt(i),text:""}}function Ci(t,e){const n=e.start.line,i=t.offsetAt({line:n,character:0}),s=t.offsetAt({line:n,character:t.getLineLength(n)});return n<t.lineCount-1?{start:i,end:t.offsetAt({line:n+1,character:0}),text:""}:n>0?{start:t.offsetAt({line:n-1,character:t.getLineLength(n-1)}),end:s,text:""}:{start:i,end:s,text:""}}function Li(t){const e=[];for(const{edit:n}of t){if(n.start>=n.end)continue;const i=e.at(-1);i!==void 0&&n.start<=i.end?e[e.length-1]={start:i.start,end:Math.max(i.end,n.end),text:""}:e.push(n)}return e}function xi(t,e){const n=Array.from({length:t.length});let i=0,s=0;for(const r of t){for(;i<e.length&&r.edit.start>e[i].end;){const a=e[i];s-=a.end-a.start,i++}const o=e[i];o!==void 0&&r.edit.start>=o.start&&r.edit.start<=o.end?n[r.index]=o.start+s:n[r.index]=r.edit.start+s}return n}function bi(t,e){const n=[...e.map((s,r)=>({index:r,edit:mi(t,s)}))].sort((s,r)=>{const o=s.edit.start-r.edit.start;if(o!==0)return o;const a=s.edit.end-r.edit.end;return a!==0?a:s.index-r.index}),i=Li(n);return{text:Ht(t,e),edits:i,nextSelectionOffsets:xi(n,i)}}function xe(t,e){const n=Math.max(0,e),i=Fe(t);let s=null;for(const a of i){s=a;const c=U(a);if(n<=c+(a.textContent?.length??0)){const h=Se(a,n<c?0:n-c);if(h!==null)return h}}if(s!==null){const a=Se(s,s.textContent?.length??0);return a!==null?a:[s,0]}let r=0,o=null;for(const a of t.childNodes){if(a.nodeType===1&&a.tagName==="BR")return[a,0];if(a.nodeType!==3)continue;o=a;const c=$(o.textContent,o.textContent?.length??0);if(n<=r+c)return[o,$(o.textContent,n-r)];r+=c}return o!==null?[o,$(o.textContent,o.textContent?.length??0)]:[t,0]}function _t(t,e){const{line:n,character:i}=e.start,s=t.getLineText(n),r=Si(s,Math.max(0,Math.min(i,s.length)));return r===void 0?e:{start:{line:n,character:r.start},end:{line:n,character:r.end},direction:1}}function Si(t,e){const n=Oe({granularity:"word"});if(n!==void 0){for(const r of n.segment(t)){if(r.isWordLike!==!0)continue;const o=r.index,a=o+r.segment.length;if(e>=o&&e<=a)return{start:o,end:a}}return}const i=/[\p{Alphabetic}\p{Number}_]+/gu;let s;for(;(s=i.exec(t))!==null;){const r=s.index,o=r+s[0].length;if(e>=r&&e<=o)return{start:r,end:o}}}function wi(t,e){if(!I(e))return[e.start,e.end];const n=B(e),{line:i,character:s}=n;if(s===0){if(i===0)return[n,n];const h=t.getLineLength(i-1);return[{line:i-1,character:h},{line:i,character:0}]}const r=t.getLineText(i),o=Wt(r);let a=s,c;for(;a>0;){const h=st(r,a,!1,o),d=r.slice(h,a),l=/\S/.test(d)?/\p{Alphabetic}|\p{Number}|_/u.test(d)?1:2:0;if(c!==void 0&&l!==c)break;(l!==0||a!==s)&&(c=l),a=h}return[{line:i,character:a},{line:i,character:s}]}function st(t,e,n,i){if(n){for(const s of i)if(s>e)return s;return t.length}for(let s=i.length-1;s>=0;s--){const r=i[s];if(r<e)return r}return 0}function Wt(t){const e=[0],n=Y();if(n!==void 0){for(const s of n.segment(t))s.index>0&&e.push(s.index);return e}let i=0;for(const s of t)i>0&&e.push(i),i+=s.length;return e}function ut(t,e,n,i){const s=t.getLineLength(e);if(i){if(n>=s)return s;const d=t.offsetAt({line:e,character:0}),l=t.getTextSlice(d+n,d+s),f=Y();if(f!==void 0){for(const u of f.segment(l))return n+u.segment.length;return s}for(const u of l)return n+u.length;return s}if(n<=0)return 0;const r=t.offsetAt({line:e,character:0}),o=t.getTextSlice(r,r+n);let a=0;const c=Y();if(c!==void 0){for(const d of c.segment(o))a=d.index;return a}let h=0;for(const d of o)a=h,h+=d.length;return a}function yi(t,e){const n=e.direction===-1;return[t.offsetAt(n?e.end:e.start),t.offsetAt(B(e))]}function ki(t,e){if(!I(e))return{start:e.start,end:e.end};const{line:n,character:i}=e.start,s=t.getLineText(n).length;return i<s?{start:{line:n,character:i},end:{line:n,character:s}}:n<t.lineCount-1?{start:{line:n,character:i},end:{line:n+1,character:0}}:{start:{line:n,character:i},end:{line:n,character:i}}}function We(t,e,n){if(e!==`
|
|
465
|
+
`&&e!=="\r"&&e!==`\r
|
|
466
|
+
`)return e;const i=t.positionAt(n).line,s=t.getLineText(i),r=De(s);return r===0?e:e+s.slice(0,r)}function De(t){let e=0;for(;e<t.length;e++){const n=t.charCodeAt(e);if(n!==32&&n!==9)break}return e}function jt(t,e){const n=[];for(const[s,r]of e)n.push(Math.min(s,r),Math.max(s,r));const i=t.positionsAt(n);return e.map(([s,r],o)=>{const a=s===r?0:s<r?1:-1;return{start:i[o*2],end:i[o*2+1],direction:a}})}function Dt(t,e,n){if(e.text!==""||e.start!==e.end-1)return e;const i=t.positionAt(e.end);if(i.character===0)return e;const s=t.getLineText(i.line),r=s.slice(0,i.character);if(/[^ \t]/.test(r)||s[i.character-1]===" ")return e;const o=Math.max(0,i.character-n),a=s.slice(o,i.character);return a.length===n&&/^ +$/.test(a)?{...e,start:e.end-a.length}:e}function be(t,e){let n=t.nodeType===1?t:t.parentElement;for(;n!==null&>(n)===void 0;)n=n.parentElement;if(n===null)return null;const i=gt(n);if(i===void 0)return null;if(t.nodeType===3)return t.parentElement===null?null:Ft(t.parentElement)!==null?{line:i,character:X(t,e)}:{line:i,character:yt(n,t)+$(t.textContent,e)};if(t.nodeType===1){const s=t;if(s.tagName==="DIV"){let r=0;for(let o=0;o<e;o++)r=X(s.childNodes[o]);return{line:i,character:r}}if(s.tagName==="BR")return{line:i,character:0};if(s.tagName==="SPAN"){if(e<s.childNodes.length){const r=s.childNodes[e];if(r?.nodeType===1){const o=U(r);if(o!==void 0)return{line:i,character:o};const a=Ft(r),c=a===null?void 0:U(a);if(c!==void 0)return{line:i,character:c}}}return{line:i,character:e>0?X(s.childNodes[e-1]):yt(n,s)}}return{line:i,character:yt(n,s)}}return null}function Fe(t){const e=[];for(const n of t.childNodes){if(n.nodeType!==1)continue;const i=n;if(i.tagName==="SPAN"){if(U(i)!==void 0){e.push(i);continue}for(const s of i.childNodes)s.nodeType===1&&U(s)!==void 0&&e.push(s)}}return e}function Se(t,e){let n=Math.max(0,e);const i=[{container:t,index:0}];for(;i.length>0;){const s=i[i.length-1];if(s.index>=s.container.childNodes.length){i.pop();continue}const r=s.container.childNodes[s.index];if(s.index++,r.nodeType===3){const o=$(r.textContent,r.textContent?.length??0);if(n<=o)return[r,n];n-=o}else r.nodeType===1&&i.push({container:r,index:0})}return null}function Ue(t,e){let n=0;const i=[{container:t,index:0}];for(;i.length>0;){const s=i[i.length-1];if(s.index>=s.container.childNodes.length){i.pop();continue}const r=s.container.childNodes[s.index];if(r===e)return n;s.index++,r.nodeType===3?n+=$(r.textContent,r.textContent?.length??0):r.nodeType===1&&i.push({container:r,index:0})}return n}function Ti(t,e){let n=e;for(;n!==null;){if(n===t)return!0;n=n.parentElement}return!1}function yt(t,e){if(e.parentElement===t){let s=0;const r=Array.prototype.indexOf.call(t.childNodes,e);for(let o=0;o<r;o++)s=X(t.childNodes[o]);return s}for(const s of Fe(t))if(Ti(s,e))return U(s)+(e.nodeType===3?Ue(s,e):0);let n=0,i=e.nodeType===1?e:e.parentElement;for(;i!==null&&i.parentElement!==null&>(i.parentElement)===void 0;){const s=i.parentElement,r=Array.prototype.indexOf.call(s.childNodes,i);for(let o=0;o<r;o++)n=X(s.childNodes[o]);i=s}return n}function Ft(t){let e=t;for(;e!==null;){if(gt(e)!==void 0)return null;if(U(e)!==void 0)return e;e=e.parentElement}return null}function X(t,e){if(t===void 0)return 0;if(t.nodeType===3){const r=t.parentElement;if(r===null)return 0;const o=Ft(r);if(o===null)return 0;const a=U(o);if(a===void 0)return 0;const c=e===void 0?$(t.textContent,t.textContent?.length??0):$(t.textContent,e);return a+Ue(o,t)+c}if(t.nodeType!==1)return 0;const n=t;if(n.tagName!=="SPAN"&&n.tagName!=="BR")return 0;const i=U(n);if(i!==void 0)return i+(n.textContent?.length??0);let s=0;for(const r of n.childNodes)s=Math.max(s,X(r));return s}function gt(t){const{line:e,lineType:n}=t.dataset;if(e!==void 0&&n!=="change-deletion"){const i=parseInt(e,10);if(!Number.isNaN(i))return i-1}}function U(t){const{char:e}=t.dataset;if(e!==void 0){const n=parseInt(e,10);if(!Number.isNaN(n))return n}}function $(t,e){const n=t??"",i=n.search(/[\r\n]/);return Math.min(e,i===-1?n.length:i)}const Ei=300,Ai=100,kt="marker-popover";var Mi=class{#e;#t=[];#r=0;#n;#a;#l;#c;#v;#w;#g;#x=!1;constructor(t){this.#e=t}get markers(){return this.#t}isPopoverVisible(){return this.#g!==void 0}updatePopoverPosition(){const t=this.#g,e=this.#n;if(t===void 0||e===void 0)return;const n=this.#t[t];if(n===void 0){this.removePopover();return}this.#L(e,n.start.line,n.start.character)}setMarkers(t,e){this.#r=e.lineCount,this.#t=t.map(n=>({...n,start:e.normalizePosition(n.start),end:e.normalizePosition(n.end)})),this.removePopover()}listenHover(t){this.#l?.forEach(e=>e()),this.#l=void 0,this.#t.length!==0&&(this.#l=[T(t,"mouseover",e=>{if(this.#e.isMouseDown())return;const n=e.composedPath()[0];if(n===void 0)return;const i=this.#u(n);i!==void 0?this.#W(i):(this.#y(),this.#o())}),T(t,"mouseleave",()=>{this.#y(),this.#o()})])}removePopover(){this.#y(),this.#A(),this.#m()}cleanup(){this.#l?.forEach(t=>t()),this.#l=void 0,this.removePopover(),this.#t=[]}#u(t){const e=t.closest("[data-line]");if(e==null)return;const n=W(e);if(n===void 0)return;let i;if(t.tagName==="SPAN"){const r=t.dataset.char;if(r===void 0||(i=parseInt(r,10),Number.isNaN(i)))return}else if(t.tagName==="BR")i=0;else return;const s={line:n-1,character:i};for(let r=this.#t.length-1;r>=0;r--)if(Kt({start:s,end:s},this.#t[r]))return r}#y(){this.#c!==void 0&&(clearTimeout(this.#c),this.#c=void 0),this.#w=void 0}#A(){this.#v!==void 0&&(clearTimeout(this.#v),this.#v=void 0)}#W(t){if(t===this.#g||t===this.#w){this.#A();return}if(this.#y(),this.#A(),this.#n!==void 0){this.#k(t);return}this.#w=t,this.#c=setTimeout(()=>{this.#c=void 0,this.#w=void 0,this.#k(t)},Ei)}#o(){this.#x||(this.#A(),this.#v=setTimeout(()=>{this.#v=void 0,this.#x||this.removePopover()},Ai))}#B(t,e,n,i,s=this.#e.popoverManager.getPlacementBounds()){Ie(t,{gutterWidth:this.#e.getGutterWidth(),placeAbove:i,viewport:s,x:e,y:n})}#L(t,e,n){const{getCharX:i,getLineY:s,getLineHeight:r,popoverManager:o}=this.#e,[a,c]=i(e,n),h=r(),d=s(e)+c*h,l=t.offsetHeight,f={top:d+h,bottom:d+h+l},u={top:d-l,bottom:d},v=e>=this.#r-3,g=o.getPlacementBounds(),p=o.choosePlacement({preferred:f,fallback:u,viewport:g,popoverHeight:l,atDocumentEdge:v,placementKey:kt})==="fallback";this.#B(t,a,p?d:d+h,p,g)}#m(){this.#a?.forEach(t=>t()),this.#a=void 0,this.#n?.remove(),this.#n=void 0,this.#g=void 0,this.#x=!1,this.#e.popoverManager.resetPlacement(kt)}#k(t){if(t===this.#g)return;const e=this.#e.getOverlayElement();if(t>=this.#t.length||e==null)return;const{start:n,message:i,severity:s}=this.#t[t],{line:r,character:o}=n,a=this.#n;if(this.#e.popoverManager.resetPlacement(kt),a!==void 0){Oi(a,s);const c=a.firstElementChild;c?.dataset.markerMessage!==void 0&&(typeof i=="string"?c.textContent=i:i instanceof HTMLElement?c.replaceChildren(i):c.innerHTML=i.html),this.#L(a,r,o),this.#g=t;return}this.#n=k("div",{dataset:{editorWidget:"",markerPopover:"",[pt(s)]:""},children:[k("div",{dataset:"markerMessage",...typeof i=="string"?{textContent:i}:i instanceof HTMLElement?{children:[i]}:{innerHTML:i.html}})]},e),this.#L(this.#n,r,o),this.#g=t,this.#a=[T(this.#n,"mouseenter",()=>{this.#x=!0,this.#A()}),T(this.#n,"mouseleave",()=>{this.#x=!1,this.#o()})]}};const Ri=["error","warning","info","hint"];function Oi(t,e){for(const n of Ri)delete t.dataset[pt(n)];t.dataset[pt(e)]=""}function pt(t){switch(t){case"error":return"markerError";case"warning":return"markerWarning";case"info":return"markerInfo";case"hint":return"markerHint"}}const qt=new Map([["(",")"],["[","]"],["{","}"]]),Ve=new Map([...qt].map(([t,e])=>[e,t])),$e=1e3,Ke=5e4;function Ii(t,e,n){const i=Pi(t,e,t.normalizePosition(n));if(i===void 0)return;const s=qt.get(i.char),r=Ve.get(i.char);if(s!==void 0)return ye(i,Ni(t,e,i,s));if(r!==void 0)return ye(zi(t,e,i,r),i)}function Pi(t,e,n){const i=Bi(n);if(i!==void 0){const s=we(t,e,i);if(s!==void 0)return s}return we(t,e,n)}function Bi(t){if(t.character>0)return{line:t.line,character:t.character-1}}function we(t,e,n){const i=t.getLineText(n.line)[n.character];if(!(i===void 0||!qt.has(i)&&!Ve.has(i)||Hi(e,n)))return{...n,char:i}}function Ni(t,e,n,i){let s=0,r=0,o=0;for(let a=n.line;a<t.lineCount;a++){if(r>=$e)return;r++;const c=t.getLineText(a),h=e.getStringCommentRegexpRangesInLine(a),d={index:0},l=a===n.line?n.character:0;for(let f=l;f<c.length;f++){if(o>=Ke)return;if(o++,Wi(h,f,d))continue;const u=c[f];if(u===n.char)s++;else if(u===i&&(s--,s===0))return{line:a,character:f,char:u}}}}function zi(t,e,n,i){let s=0,r=0,o=0;for(let a=n.line;a>=0;a--){if(r>=$e)return;r++;const c=t.getLineText(a),h=e.getStringCommentRegexpRangesInLine(a),d={index:h===null?-1:h.length-1},l=a===n.line?n.character:c.length-1;for(let f=l;f>=0;f--){if(o>=Ke)return;if(o++,Di(h,f,d))continue;const u=c[f];if(u===n.char)s++;else if(u===i&&(s--,s===0))return{line:a,character:f,char:u}}}}function Hi(t,e){return _i(t.getStringCommentRegexpRangesInLine(e.line),e.character)}function _i(t,e){if(t===null)return!1;for(const[n,i]of t){if(e<n)return!1;if(e<i)return!0}return!1}function Wi(t,e,n){if(t===null)return!1;for(;n.index<t.length&&e>=t[n.index][1];)n.index++;const i=t[n.index];return i!==void 0&&e>=i[0]}function Di(t,e,n){if(t===null)return!1;for(;n.index>=0&&e<t[n.index][0];)n.index--;const i=t[n.index];return i!==void 0&&e<i[1]}function ye(t,e){if(!(t===void 0||e===void 0))return[ke(t),ke(e)]}function ke(t){return{start:{line:t.line,character:t.character},end:{line:t.line,character:t.character+1}}}const Fi=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
467
|
+
<symbol id="diffs-editor-icon-close" viewBox="0 0 16 16">
|
|
468
|
+
<path fill="currentColor" d="M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z"></path>
|
|
469
|
+
</symbol>
|
|
470
|
+
<symbol id="diffs-editor-icon-arrow-up" viewBox="0 0 16 16">
|
|
471
|
+
<path fill="currentColor" transform="rotate(-90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
|
|
472
|
+
</symbol>
|
|
473
|
+
<symbol id="diffs-editor-icon-arrow-down" viewBox="0 0 16 16">
|
|
474
|
+
<path fill="currentColor" transform="rotate(90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
|
|
475
|
+
</symbol>
|
|
476
|
+
<symbol id="diffs-editor-icon-case" viewBox="0 0 16 16">
|
|
477
|
+
<path fill="currentColor" d="M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z"></path>
|
|
478
|
+
<path fill="currentColor" d="M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z"></path>
|
|
479
|
+
</symbol>
|
|
480
|
+
<symbol id="diffs-editor-icon-whole-word" viewBox="0 0 16 16">
|
|
481
|
+
<path fill="currentColor" d="M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z"></path>
|
|
482
|
+
<path fill="currentColor" d="M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z"></path>
|
|
483
|
+
<path fill="currentColor" d="M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z"></path>
|
|
484
|
+
</symbol>
|
|
485
|
+
<symbol id="diffs-editor-icon-regex" viewBox="0 0 16 16">
|
|
486
|
+
<path fill="currentColor" d="M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z"></path>
|
|
487
|
+
<path fill="currentColor" d="M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z"></path>
|
|
488
|
+
</symbol>
|
|
489
|
+
<symbol id="diffs-editor-icon-replace" viewBox="0 0 16 16">
|
|
490
|
+
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M5.28033 5.71967C5.57322 6.01256 5.57322 6.48744 5.28033 6.78033L3.56066 8.5H11.75C12.7165 8.5 13.5 7.7165 13.5 6.75V2.75C13.5 2.33579 13.8358 2 14.25 2C14.6642 2 15 2.33579 15 2.75V6.75C15 8.54493 13.5449 10 11.75 10H3.56066L5.28033 11.7197C5.57322 12.0126 5.57322 12.4874 5.28033 12.7803C4.98744 13.0732 4.51256 13.0732 4.21967 12.7803L1.21967 9.78033C0.926777 9.48744 0.926777 9.01256 1.21967 8.71967L4.21967 5.71967C4.51256 5.42678 4.98744 5.42678 5.28033 5.71967Z"></path>
|
|
491
|
+
</symbol>
|
|
492
|
+
<symbol id="diffs-editor-icon-replace-all" viewBox="0 0 16 16">
|
|
493
|
+
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M10.7197 0.21967C11.0126 -0.0732233 11.4874 -0.0732233 11.7803 0.21967L14.7803 3.21967C15.0732 3.51256 15.0732 3.98744 14.7803 4.28033L11.7803 7.28033C11.4874 7.57322 11.0126 7.57322 10.7197 7.28033C10.4268 6.98744 10.4268 6.51256 10.7197 6.21967L12.4393 4.5H4.25C3.2835 4.5 2.5 5.2835 2.5 6.25V6.875C2.5 7.28921 2.16421 7.625 1.75 7.625C1.33579 7.625 1 7.28921 1 6.875V6.25C1 4.45507 2.45508 3 4.25 3H12.4393L10.7197 1.28033C10.4268 0.987437 10.4268 0.512563 10.7197 0.21967ZM5.28033 8.71967C5.57322 9.01256 5.57322 9.48744 5.28033 9.78033L3.56066 11.5H11.75C12.7165 11.5 13.5 10.7165 13.5 9.75V9.125C13.5 8.71079 13.8358 8.375 14.25 8.375C14.6642 8.375 15 8.71079 15 9.125V9.75C15 11.5449 13.5449 13 11.75 13H3.56066L5.28033 14.7197C5.57322 15.0126 5.57322 15.4874 5.28033 15.7803C4.98744 16.0732 4.51256 16.0732 4.21967 15.7803L1.21967 12.7803C0.926777 12.4874 0.926777 12.0126 1.21967 11.7197L4.21967 8.71967C4.51256 8.42678 4.98744 8.42678 5.28033 8.71967Z"></path>
|
|
494
|
+
</symbol>
|
|
495
|
+
</svg>`,Ui=()=>{const t=document.createElement("div");t.innerHTML=Fi;const e=t.firstElementChild;if(e===null||!(e instanceof SVGSVGElement))throw new Error("Failed to create sprite element");return e},Vi=(t,e=16)=>`<svg width="${e}" height="${e}" aria-hidden="true" focusable="false">
|
|
496
|
+
<use href="#diffs-editor-icon-${t}"></use>
|
|
497
|
+
</svg>`;var $i=class{#e;#t;#r;#n;#a;#l;constructor(t){const{textDocument:e,containerElement:n,defaultQuery:i,mode:s="find",initialMatch:r,scrollToMatch:o,applyReplace:a,onUpdate:c,onClose:h}=t,d={text:i,replaceText:"",caseSensitive:!1,wholeWord:!1,regex:!1},l={all:[],current:void 0},f=k("div",{dataset:{matches:"",noMatches:""},textContent:"No results"}),u=b=>{l.all=d.text!==""?e.search(d):[];const M=l.all.length===0;if(Ct.disabled=M,Lt.disabled=M,M){f.textContent="No results",f.dataset.noMatches="",l.current=void 0,c([]);return}if(delete f.dataset.noMatches,b?.syncSelection===!1){v(c(l.all,{syncSelection:!1}));return}v(c(l.all))};this.#r=u;const v=b=>{if(b===void 0)f.textContent=`${l.all.length} results`;else{const[M,z]=b;f.textContent=`${l.all.findIndex(H=>H[0]===M&&H[1]===z)+1} of ${l.all.length}`}l.current=b},g=(b,M)=>{d[b]=M,u()},p=(b=!1,M=!1)=>{const z=l.all;let H=z[0];if(z.length>0)if(b){const j=l.current?.[0]??0;H=z.at(-1);for(const J of z)if(J[1]<=j)H=J;else break}else{const j=l.current?.[1]??0;for(const J of z)if(J[0]>=j){H=J;break}}H!==void 0&&(v(H),o(H,M)),l.current=H};this.#a=b=>p(b,!0);const m=(b,M)=>({start:b,end:M,text:Sn(z=>e.positionAt(z),z=>e.offsetAt(z),z=>e.getLineText(z),d,b,M)}),C=()=>{if(d.text===""||l.all.length===0)return;let b=l.current;if(b===void 0&&(p(!1,!0),b=l.current,b===void 0))return;const[M,z]=b,H=m(M,z);a([H]),o([M+H.text.length,M+H.text.length],!0),l.current=void 0,u()},x=()=>{d.text===""||l.all.length===0||(a(l.all.map(([b,M])=>m(b,M))),l.current=void 0,u())},L=()=>{this.cleanup(),h()};this.#l=L;const S=b=>k("button",{type:"button",title:b.label,ariaLabel:b.label,dataset:{searchIcon:"",...b.dataset},innerHTML:Vi(b.icon,b.size??16),onclick:b.onClick}),w=(b,M,z)=>{const H=S({icon:b,label:M,size:14,onClick:()=>{const j=!d[z];H.ariaPressed=String(j),g(z,j)}});return H.ariaPressed=String(d[z]),H},R=w("case","Match Case","caseSensitive"),O=w("whole-word","Whole Word","wholeWord"),y=w("regex","Regexp","regex"),E=k("input",{type:"text",placeholder:"Replace",dataset:"replace",value:"",oninput:b=>{d.replaceText=b.target.value},onkeydown:b=>{if(b.isComposing||b.keyCode===229)return;const M=Bt(b);b.key==="Escape"?(b.preventDefault(),L()):b.key==="Enter"?(b.preventDefault(),C()):M!==void 0&&(b.preventDefault(),p(M==="previous",!0))}});this.#t=k("input",{type:"text",placeholder:"Search",dataset:"search",value:i,oninput:b=>{d.text=b.target.value,l.current=void 0,u()},onkeydown:b=>{if(b.isComposing||b.keyCode===229)return;const M=Bt(b);b.key==="Escape"?(b.preventDefault(),L()):b.key==="Enter"?(b.preventDefault(),p(b.shiftKey,!0)):M!==void 0?(b.preventDefault(),p(M==="previous",!0)):rt(b)&&(b.key==="f"||b.code==="KeyF")&&(b.preventDefault(),Yt(b.altKey?"replace":"find"))}});const N=k("div",{dataset:"searchToggles",children:[R,O,y]}),P=k("div",{dataset:{inputBox:"",find:""},children:[this.#t,N]}),_=k("div",{dataset:{inputBox:"",replace:"",replaceCell:""},children:[E]}),F=k("div",{dataset:{replaceActions:"",replaceCell:""},children:[S({icon:"replace",label:"Replace",onClick:C}),S({icon:"replace-all",label:"Replace All",onClick:x})]}),Ct=S({icon:"arrow-up",label:"Previous",onClick:()=>{p(!0)}}),Lt=S({icon:"arrow-down",label:"Next",onClick:()=>{p()}});Ct.disabled=!0,Lt.disabled=!0;const Ge=k("div",{dataset:"searchNav",children:[Ct,Lt]}),je=S({icon:"close",label:"Close",onClick:L,dataset:{searchClose:""}}),Xt=k("div",{dataset:{searchGrid:"",mode:s},children:[P,_,F,f,Ge,je]}),Yt=b=>{Xt.dataset.mode=b,this.#t.focus(),this.#t.select()};this.#n=Yt,this.#e=k("div",{dataset:"searchPanel",children:[k("div",{dataset:"editorWidget",children:[Xt]})]}),l.current=r,n.before(this.#e),requestAnimationFrame(()=>{r!==void 0?u():c([]),this.#t.select()})}focus(){this.#t.focus()}navigate(t){this.#a?.(t)}updateMatches(t){this.#r?.(t)}setMode(t){this.#n?.(t)}close(){this.#l?.()}cleanup(){this.#e.remove()}},Ki=class{#e;#t;#r;constructor(t,e,n){this.#e=k("div",{dataset:{editorWidget:"",selectionActionPopover:""},contentEditable:"false",children:[t]},e),this.#t=this.#e.offsetHeight,this.#r=new ResizeObserver(()=>{const i=this.#e.offsetHeight;i!==this.#t&&(this.#t=i,n())}),this.#r.observe(this.#e)}reposition(t,e,n,i,s,r){this.#e.style.visibility=s?"":"hidden",Ie(this.#e,{gutterWidth:n,placeAbove:i,viewport:r,x:t,y:e})}get height(){return this.#t}cleanup(){this.#r.disconnect(),this.#e.remove()}};function Q(t){return{selections:t.selections?.map(e=>({start:{...e.start},end:{...e.end},direction:e.direction})),view:t.view===void 0?void 0:{...t.view}}}function Gi(t){return typeof t=="object"?t:t==="indexedDB"?new Xi:new ji}var ji=class{#e=new Map;get(t){const e=this.#e.get(t);return e===void 0?void 0:Q(e)}set(t,e){this.#e.set(t,Q(e))}};const qi="pierre-diffs-editor-state",Zi=1,Z="states";var Xi=class{#e=Yi();async get(t){const e=await this.#e;if(e===void 0)return;const n=await Ut(e.transaction(Z,"readonly").objectStore(Z).get(t));return n===void 0?void 0:Q(n)}async set(t,e){const n=await this.#e;n!==void 0&&await Ut(n.transaction(Z,"readwrite").objectStore(Z).put(Q(e),t))}};function Yi(){try{const t=globalThis.indexedDB;if(t===void 0)return Promise.resolve(void 0);const e=t.open(qi,Zi);return e.onupgradeneeded=()=>{const n=e.result;n.objectStoreNames.contains(Z)||n.createObjectStore(Z)},Ut(e)}catch{return Promise.resolve(void 0)}}function Ut(t){return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})}const Qi=4096,Ji=/\p{Mark}/u;var ts=class{#e;#t;#r;#n=new Map;ch=-1;tabSize=2;lineHeight=20;paddingTop=0;init(t){if(this.#e===t&&this.#t!==void 0&&this.ch!==-1)return;if(this.#e=t,this.#t??=document.createElement("canvas").getContext("2d")??void 0,this.#t===void 0)throw new Error("Could not get canvas context");const e=t.parentElement;if(e!==null){const{paddingTop:c}=getComputedStyle(e);c.endsWith("px")&&(this.paddingTop=parseFloat(c.slice(0,-2)))}const{fontSize:n,fontFamily:i,tabSize:s,lineHeight:r}=getComputedStyle(t);r.endsWith("px")?this.lineHeight=parseFloat(r.slice(0,-2)):n.endsWith("px")&&(this.lineHeight=q(parseFloat(n.slice(0,-2))*parseFloat(r)));const o=n+" "+i;(this.#r!==o||this.ch===-1)&&(this.#r=o,this.#t.font=o,this.ch=this.canvasMeasureTextWidth("0"),this.clearTextWidthCache());const a=parseInt(s,10);Number.isNaN(a)||(this.tabSize=a)}remeasureCharacterWidth(){if(this.#t===void 0||this.#r===void 0)return!1;this.#t.font=this.#r;const t=this.canvasMeasureTextWidth("0"),e=t!==this.ch;e&&(this.ch=t);const n=this.#l();return e||n}measureTextWidth(t){if(!t.includes(" "))return this.#a(t);if(this.#t===void 0)throw new Error("Metrics not initialized");const e=ht(t,this.tabSize);if(e!==-1)return e*this.ch;let n=0,i=0;const s=this.tabSize*this.ch;for(let r=0;r<t.length;r++)if(t.charCodeAt(r)===9){if(r>i&&(n+=this.#a(t.slice(i,r))),s>0){const o=n%s;n+=o===0?s:s-o}i=r+1}return i<t.length&&(n+=this.#a(t.slice(i))),q(n)}#a(t){return Zt(t)?this.domMeasureTextWidth(t):this.canvasMeasureTextWidth(t)}canvasMeasureTextWidth(t){if(this.#t===void 0)throw new Error("Metrics not initialized");return q(this.#t.measureText(t).width)}domMeasureTextWidth(t){if(this.#e===void 0)throw new Error("Metrics not initialized");const e=t+"|"+this.#r,n=this.#n.get(e);if(n!==void 0)return n;const i=k("span",{style:{position:"absolute",top:"0",left:"0",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre",font:"inherit"},textContent:t},this.#e);let s;try{s=q(i.getBoundingClientRect().width)}finally{i.remove()}if(this.#n.size>=Qi){const r=this.#n.keys().next().value;r!==void 0&&this.#n.delete(r)}return this.#n.set(e,s),s}clearTextWidthCache(){this.#l()}#l(){const t=this.#n.size>0;return this.#n.clear(),t}};function Zt(t){for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n>=55296&&n<=57343||n===8205||n===65038||n===65039||n>127&&Ji.test(t.charAt(e)))return!0}return!1}function es(t,e){const n=Math.max(0,Math.min(e,t.length));if(n===0||n===t.length||!Zt(t))return n;const i=Y();if(i!==void 0){for(const r of i.segment(t)){const o=r.index,a=o+r.segment.length;if(n>o&&n<a)return a;if(n<=o)break}return n}let s=0;for(const r of t){const o=s+r.length;if(n>s&&n<o)return o;if(n<=s)break;s=o}return n}function ns(t){if(!Zt(t))return;const e=[0],n=Y();if(n!==void 0){for(const s of n.segment(t))e.push(s.index+s.segment.length);return e}let i=0;for(const s of t)i+=s.length,e.push(i);return e}function ht(t,e){let n=0;for(let i=0;i<t.length;i++){const s=t.charCodeAt(i);if(s>127)return-1;n+=s===9?e-n%e:1}return n}const Tt=500;let is=0;var ss=class{#e;#t;#r;#n="dark";#a="";#l;#c;#v;#w;#g;#x;#u;#y;#A;#W=!1;#o=[K];#B=[];#L=0;#m=[];#k=-1;#p=!0;#M=!1;#C=0;#q=++is;#T=-1;#P=-1;#U;#S=0;#R=[];#h=!1;#V=Hn(async t=>{if(this.#W)return;const{startingLine:e=0,totalLines:n=1/0}=t??{},i=Math.min(n===1/0?1/0:e+n,this.#c.lineCount);if(this.#t===void 0&&!lt(this.#c.languageId)){if(await this.#e.loadLanguage(this.#c.languageId),this.#W)return;this.#t=this.#e.getLanguage(this.#c.languageId)}this.#z(),this.#N(i)},500);#F=({data:t})=>{if(typeof t!="object"||t===null)return;const{type:e,tokenizerId:n,jobId:i}=t;e==="tokenize"&&n===this.#q&&typeof i=="number"&&i===this.#C&&(this.#T>=0?this.#I(i):this.#Lt(i))};get themeType(){return this.#n}getStringCommentRegexpRangesInLine(t){if(!this.#u||t<0||t>=this.#c.lineCount||(this.#E(),this.#t===void 0))return null;if(this.#R[t]===void 0){this.#O(t);const e=this.#o[t]??K,n=this.#H(t,e);this.#o[t+1]=n.state}return this.#R[t]??null}constructor({codeOptions:t,highlighter:e,textDocument:n,matchBrackets:i,setStyle:s,onDeferTokenize:r,onThemeChange:o,__debug:a}){const{themeType:c="system",theme:h=Qt,tokenizeMaxLineLength:d=1e3}=t;this.#r=window.matchMedia("(prefers-color-scheme: dark)");let l;if(c==="system"?l=this.#X():l=c,typeof h!="string"&&c==="system"){const f=new MutationObserver(u=>{for(const{type:v,attributeName:g}of u)if(v==="attributes"&&g!==null&&(g==="class"||g.startsWith("data-"))){const p=this.#X();this.#Z(h[p],p);break}});f.observe(document.documentElement,{attributes:!0}),f.observe(document.body,{attributes:!0}),this.#A=[T(this.#r,"change",()=>{const u=this.#X();this.#Z(h[u],u)}),()=>f.disconnect()]}this.#e=e,this.#c=n,this.#v=d,this.#w=s,this.#g=r,this.#x=o,this.#u=i!==!1,this.#y=a??!1,this.#E(),this.#l=[],this.#f(typeof h=="string"?h:h[l],typeof h=="string"?void 0:l)}#Z(t,e){t===this.#a&&e===this.#n||(this.#f(t,e),this.stopBackgroundTokenize(),this.#o=[K],this.#B=[],this.#L=0,this.#m=[],this.#t!==void 0&&this.#c.lineCount>0&&this.#b(0),this.#x?.())}#X(){try{if(typeof document<"u"&&typeof getComputedStyle=="function"&&document.body!=null){const t=getComputedStyle(document.body).colorScheme.split(/\s+/),e=t.includes("dark");if(e!==t.includes("light"))return e?"dark":"light"}}catch{}return this.#r.matches?"dark":"light"}syncTheme(t){const{themeType:e="system",theme:n=Qt}=t;if(typeof n=="string"){const r=this.#e.getTheme(n).type;if(n===this.#a&&r===this.#n)return;this.#Z(n,r);return}const i=e==="system"?this.#X():e,s=n[i];i===this.#n&&s===this.#a||this.#Z(s,i)}#f(t,e){const{theme:n,colorMap:i}=this.#e.setTheme(t),{colors:s={}}=this.#e.getTheme(t),r=s["editor.selectionBackground"],o=s["editor.lineHighlightBackground"],a=o!=null&&o.trim()!==""&&!on.isFullyTransparent(o)?o:void 0,c=s["editor.lineHighlightBorder"]??(a==null?"color-mix(in lab, var(--diffs-bg) 70%, var(--diffs-fg))":"transparent"),h=a==null?"100%":"85%",d=s["editorCursor.foreground"],l=s["editor.findMatchBackground"],f=s["editor.findMatchHighlightBackground"],u=s["editorBracketMatch.background"],v=s["editorBracketMatch.border"],g=s["editorHint.foreground"],p=s["editorInfo.foreground"],m=s["editorWarning.foreground"],C=s["editorError.foreground"];this.#w(`:host {
|
|
498
|
+
--diffs-editor-selection-bg: ${r??"var(--diffs-line-bg)"};
|
|
499
|
+
--diffs-editor-line-highlight-border: ${c};
|
|
500
|
+
--diffs-editor-active-line-source-mix: ${h};
|
|
501
|
+
--diffs-editor-match-bg: ${l??"initial"};
|
|
502
|
+
--diffs-editor-match-highlight-bg: ${f??"initial"};
|
|
503
|
+
--diffs-editor-bracket-match-bg: ${u??"initial"};
|
|
504
|
+
--diffs-editor-bracket-match-border: ${v??"initial"};
|
|
505
|
+
--diffs-editor-cursor-fg: ${d??"initial"};
|
|
506
|
+
--diffs-editor-hint-fg: ${g??"initial"};
|
|
507
|
+
--diffs-editor-info-fg: ${p??"initial"};
|
|
508
|
+
--diffs-editor-warning-fg: ${m??"initial"};
|
|
509
|
+
--diffs-editor-error-fg: ${C??"initial"};
|
|
510
|
+
}`),this.#a=t,this.#n=e??n.type,this.#l=i}#z(){if(this.#a==="")return;const{colorMap:t}=this.#e.setTheme(this.#a);this.#l=t}cleanUp(){this.#W=!0,this.stopBackgroundTokenize(),this.#$(),this.#A?.forEach(t=>t()),this.#A=void 0}tokenize(t,e,n=!1){if(this.#E(),this.#z(),this.#t===void 0&&!lt(this.#c.languageId))throw new Error(`Grammar for language "${this.#c.languageId}" not loaded`);const{lineCount:i}=this.#c,{startingLine:s=0,totalLines:r=1/0}=e??{},o=r===1/0?i:Math.min(s+r,i),a=t.startLine,c=Math.max(s,a),h=e!==void 0&&r!==1/0&&t.lineDelta>0&&a<o&&t.endLine>=o,d=t.lineDelta===0&&(t.changedLineChanges?.every(([,,y])=>y===0)??!0);this.#u&&!d&&(this.#R.length=Math.min(this.#R.length,t.startLine));const l=n&&t.lineDelta!==0&&a>=s,f=d||e===void 0||a>=c,u=t.changedLineRanges??[[a,t.endLine]];this.#B=[],this.#L=0,this.#m=[];let v=-1;if(a<c)for(const[y,E]of u)y<c&&(v=Math.max(v,Math.min(E,c-1)));const g=v>=a&&(d||t.lineDelta<0);d?this.#O(a):(this.#D(t),(e===void 0||a>=c)&&this.#O(c));let p=0,m=u[p][1],C,x=0,L=d?u[p][0]:c,S=!1;const w=new Map,R=g?new Map:void 0;if(R!==void 0&&!d){const y=Math.min(v+1,c,o);if(y>a){this.#O(y);let E=a,N=this.#o[E]??K;for(;E<y;E++){const P=this.#H(E,N);N=P.state,R.set(E,P.resolvedTokens)}this.#o[y]=N}}let O=this.#o[L]??K;for(;L<o;){const y=d?this.#o[L+1]:l?this.#Y(L+1):void 0;f&&(this.#o[L]=O);const{resolvedTokens:E,state:N}=this.#H(L,O);if(O=N,L>=c?w.set(L,E):R?.set(L,E),f&&(this.#o[L+1]=O),S=L>=m&&(d||l)&&y!==void 0&&O.equals(y),S){p++;const P=u[p];if(P===void 0)break;if(P[0]>=o){C=P[0],x=p;break}let _=this.#o[P[0]];if(l)for(let F=L+2;F<=P[0]&&(_=this.#Y(F),_!==void 0);F++)this.#o[F]=_;_===void 0?(m=P[1],L++):(L=P[0],O=_,m=P[1]),S=!1;continue}L++}if(f&&(L<o?this.#o[L+1]=O:this.#o[L]=O),S&&l&&C===void 0){for(let y=L+2;y<=i;y++){const E=this.#Y(y);if(E===void 0)break;this.#o[y]=E}this.#B=[],this.#L=0,this.#m=[]}if(R!==void 0&&R.size>0&&this.#g(R,this.#n),C!==void 0)this.#u&&d&&(this.#R.length=Math.min(this.#R.length,C)),this.#b(C,u,x);else if(!S&&L<i){const y=h&&a>=c?o:a<c&&!d?a:L;this.#u&&d&&(this.#R.length=Math.min(this.#R.length,y)),this.#b(y,u,p)}return w}prebuildStateStack(t){this.#E(),this.#V(t)}stopBackgroundTokenize(){this.#P=-1,!this.#p&&(this.#p=!0,this.#M=!1,this.#k=-1,this.#T=-1,this.#U=void 0,this.#S=0,this.#B=[],this.#L=0,this.#m=[],this.#$())}pauseBackgroundTokenize(){this.#p||this.#M||(this.#y&&console.log("[diffs/editor] background tokenization paused",{jobId:this.#C}),this.#M=!0)}resumeBackgroundTokenize(){this.#p||!this.#M||this.#t===void 0||this.#k<0||(this.#y&&console.log("[diffs/editor] background tokenization resumed",{jobId:this.#C}),this.#M=!1,this.#J(this.#C))}#E(){this.#t===void 0&&!lt(this.#c.languageId)&&this.#e.getLoadedLanguages().includes(this.#c.languageId)&&(this.#t=this.#e.getLanguage(this.#c.languageId))}#s(){this.#h||(globalThis.addEventListener("message",this.#F),this.#h=!0)}#$(){this.#h&&(globalThis.removeEventListener("message",this.#F),this.#h=!1)}#J(t){globalThis.postMessage({type:"tokenize",tokenizerId:this.#q,jobId:t})}#b(t,e,n=0){if(lt(this.#c.languageId))return;const i=++this.#C;this.#y&&console.log("[diffs/editor] background tokenization scheduled",{jobId:i,startLine:t,changedLineRanges:e,changedRangeIndex:n}),this.#p=!1,this.#M=!1,this.#k=t,this.#T>=0&&(this.#P=Math.max(this.#P,this.#T)),this.#T=-1,this.#U=e,this.#S=n,this.#s(),this.#J(i)}#N(t){if(this.#t===void 0||this.#o.length>t)return;if(!this.#p){this.#T>=0?this.#T=Math.max(this.#T,t):this.#P=Math.max(this.#P,t);return}const e=++this.#C;this.#p=!1,this.#M=!1,this.#k=this.#o.length-1,this.#T=t,this.#P=-1,this.#U=void 0,this.#S=0,this.#s(),this.#J(e)}#H(t,e){const n=this.#c.getLineText(t);if(n.length>this.#v)return console.warn(`[diffs] Line(${t}) too long to tokenize: ${n.length}`),this.#_(t,null),{resolvedTokens:[[0,"",n]],state:e};if(this.#t===void 0||n===""||n.trim()==="")return this.#_(t,null),{resolvedTokens:[[0,"",n]],state:e};const i=Et(this.#t,this.#l,n,e,Tt,this.#u);return this.#_(t,i.bracketIgnoredRanges),{resolvedTokens:i.resolvedTokens,state:i.ruleStack}}#_(t,e){this.#u&&(this.#R[t]=e)}#D(t){const e=t.changedLineChanges??[[t.startLine,t.endLine,t.lineDelta]],n=t.startLine+1;n<=this.#o.length-n?(this.#B=this.#o,this.#L=0,this.#o=this.#o.slice(0,n)):(this.#L=n,this.#B=this.#o.slice(n),this.#o.length=Math.min(this.#o.length,n)),this.#m=e}#Y(t){let e=t;for(let n=this.#m.length-1;n>=0;n--){const[i,s,r]=this.#m[n];if(r!==0){if(e>s)e-=r;else if(e>i)return this.#o[t]}}return this.#B[e-this.#L]??this.#o[t]}#O(t,e){const n=Math.min(Math.max(0,t),this.#c.lineCount);if(this.#o.length>n||this.#t===void 0)return!0;const i=e===void 0?0:performance.now();let s=this.#o.length-1,r=this.#o[s]??K;for(;s<n;){this.#o[s]=r;const o=this.#c.getLineText(s);if(o.length<=this.#v&&o!==""&&o.trim()!==""){const a=Et(this.#t,this.#l,o,r,Tt,this.#u,!1);this.#_(s,a.bracketIgnoredRanges),r=a.ruleStack}else this.#_(s,null);if(s++,this.#o[s]=r,e!==void 0&&performance.now()-i>e)break}return s>=n}#I(t){if(this.#p||this.#M||this.#t===void 0||t!==this.#C)return;this.#z();const e=this.#O(this.#T,1);if(!(this.#p||this.#M||t!==this.#C)){if(e){this.stopBackgroundTokenize();return}this.#k=this.#o.length-1,this.#J(t)}}#Lt(t){if(this.#p||this.#M||this.#t===void 0||t!==this.#C)return;this.#z();const e=performance.now(),n=new Map,i=this.#c.lineCount,s=this.#U;let r=this.#k,o=this.#o[r]??K,a=!1,c=this.#S,h=s?.[c]?.[1];for(;r<i;){this.#o[r]=o;const d=h!==void 0?this.#Y(r+1):void 0,l=this.#c.getLineText(r);if(l.length>this.#v)console.warn(`[diffs] Line(${r}) too long to tokenize: ${l.length}`),n.set(r,[[0,"",l]]),this.#_(r,null);else if(l===""||l.trim()==="")n.set(r,[[0,"",l]]),this.#_(r,null);else{const f=Et(this.#t,this.#l,l,o,Tt,this.#u);n.set(r,f.resolvedTokens),this.#_(r,f.bracketIgnoredRanges),o=f.ruleStack}if(this.#o[r+1]=o,a=h!==void 0&&r>=h&&d!==void 0&&o.equals(d),r++,a){c++;const f=s?.[c];if(f===void 0)break;if(h=f[1],this.#o[f[0]]===void 0)a=!1;else{r=f[0],o=this.#o[r]??o,a=!1;continue}}if(performance.now()-e>1)break}if(this.#g(n,this.#n),!(this.#p||this.#M||t!==this.#C)){if(a||r>=i){const d=this.#P;this.stopBackgroundTokenize(),d>=0&&this.#N(d);return}this.#k=r,this.#S=c,this.#J(t)}}};function Et(t,e,n,i,s,r=!0,o=!0){const a=t.tokenizeLine2(n,i,s);a.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);const c=a.tokens,h=c.length/2,d=[],l=[];if(!o&&!r)return{ruleStack:a.ruleStack,resolvedTokens:d,bracketIgnoredRanges:l};for(let f=0;f<h;f++){const u=c[2*f],v=f+1<h?c[2*f+2]:n.length;if(u===v)continue;const g=c[2*f+1];if(o){const p=Jt.getForeground(g);d.push([u,e[p],n.slice(u,v)])}r&&Jt.getTokenType(g)>0&&l.push([u,v])}return{ruleStack:a.ruleStack,resolvedTokens:d,bracketIgnoredRanges:l}}function At(t){return t.map(([e,n,i])=>e===0&&n===""?i===""?k("br"):i:k("span",{dataset:{char:e.toString()},style:`color:${n};`,textContent:i}))}function lt(t){return t==="text"||t==="ansi"}function rs(t){const e=t.getSelection?.();if(e==null||e.rangeCount===0)return;const n=e.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function G(t){if(typeof t.cacheKey!="string"||t.cacheKey.length===0)throw new Error(`Editor persistState requires a non-empty file.cacheKey for "${t.name}". Provide a unique, stable cacheKey for every editable file.`);return t.cacheKey}function Mt(t){return typeof t=="object"&&t!==null&&"then"in t&&typeof t.then=="function"}const os=2,as=1e4,Rt="selection-action",Ot="application/vnd.pierre.diffs-selections+json";var ls=class{#e;#t=new ts;#r;#n;#a=new Map;#l;#c;#v=new Map;#w;#g=0;#x=!1;#u;#y;#A;#W;#o={generation:0,callback:void 0,delivered:!1};#B;#L;#m;#k=new Map;#p=new Map;#M=new Map;#C;#q;#T;#P;#U;#S;#R;#h;#V;#F;#Z;#X;#f;#z;#E;#s;#$;#J;#b;#N;#H;#_=!0;#D=!1;#Y=!1;#O=!1;#I;#Lt=!1;#xt=!1;#st=!1;#at;#Bt=!1;#K;#bt="";#St;#Nt;#i;#Q;#tt;#dt;#kt=!1;#ft=!1;#ct=!1;#zt=!1;#ut;#be=(t,e)=>{if(this.#f?.updateRenderCache(t,e),this.#$!==void 0&&this.#$.totalLines!==1/0){const{startingLine:n,totalLines:i}=this.#$,s=Math.min(n+i,this.#s?.lineCount??0);for(const[r,o]of t)if(r>=n&&r<s){const a=this.#ht(r);a!==void 0&&a.replaceChildren(...At(o))}}};constructor(t={}){this.#e=t}setOptions(t){const e=this.#e.persistStateStorage??"inMemory",n={...this.#e,...t};if(n.persistState===!0&&this.#f?.type==="file"){const i=this.#f.__getCurrentFile?.()??this.#z;i!==void 0&&G(i)}this.#e=n,this.#e.persistState!==!0&&(this.#a.clear(),this.#g++,this.#x=!1),(this.#e.persistStateStorage??"inMemory")!==e&&(this.#g++,this.#l=void 0,this.#c=void 0,this.#v.clear())}edit(t){if(this.#e.persistState===!0&&t.type==="file"){const e=t.__getCurrentFile?.();e!==void 0&&G(e)}return this.#_t(),this.#f=t,this.#Ee(),this.#W=t.attachEditor(this),()=>this.cleanUp()}applyEdits(t,e=!0){const n=this.#s;if(n==null)throw new Error("Editor is not attached");const i=this.#O,s=this.#i,r=s?.map(h=>[n.offsetAt(h.start),n.offsetAt(h.end)]),o=s===void 0?void 0:n.resolveEdits(t).sort((h,d)=>h.start-d.start),a=n.applyEdits(t,e,s);if(a===void 0)return;let c;s!==void 0&&r!==void 0&&o!==void 0&&(c=wt(n,s,r,o),e&&n.setLastUndoSelectionsAfter(c)),this.#j(a,c,this.#it(a),{skipFocus:!i})}get canUndo(){return this.#s?.canUndo??!1}get canRedo(){return this.#s?.canRedo??!1}undo(){this.#Dt("undo")}redo(){this.#Dt("redo")}getFile(){const t=this.#z,e=this.#s;if(t===void 0||e===void 0)return;const n={...t};return Object.defineProperty(n,"contents",{enumerable:!0,get:()=>e.getText()}),n}getText(){return this.#s?.getText()??""}getState(){const t=this.#f;return{selections:this.#i,view:t!=null?{scrollLeft:t.getCodeScrollLeft(),scrollTop:this.#Te()}:void 0}}setState({selections:t,view:e}){if(this.#f===void 0||this.#s===void 0)throw new Error("Editor is not attached");if(this.#_=!1,this.#d(t??[]),e!=null){this.#f.setCodeScrollLeft(e.scrollLeft),e.scrollTop!==void 0&&this.#Qt(e.scrollTop);return}this.#nt()}setSelections(t){const e=this.#s;if(e===void 0)throw new Error("Text document is not initialized");const n=t.map(s=>{let r=e.normalizePosition(s.start),o=e.normalizePosition(s.end),a=s.direction==="none"?0:s.direction==="backward"?-1:1;return A(r,o)>0&&([r,o]=[o,r],a!==0&&(a=a===1?-1:1)),{direction:a,start:r,end:o}});this.#_=!1,this.#d(n);const i=n.at(-1);i!==void 0&&this.#lt(B(i).line),this.#nt()}setMarkers(t){const e=this.#s;if(e===void 0)throw new Error("Text document is not initialized");if(t.length===0){this.#b?.cleanup(),this.#b=void 0,this.#d(this.#i??[]);return}this.#b??=new Mi({popoverManager:this.#Et(),getLineHeight:()=>this.#t.lineHeight,getOverlayElement:()=>this.#V,getGutterWidth:()=>this.#ot(),getCharX:(n,i)=>this.#Ct(n,i),getLineY:n=>this.#mt(n),isMouseDown:()=>this.#st||this.#xt}),this.#b.setMarkers(t,e),this.#h!==void 0&&this.#b.listenHover(this.#h),this.#d(this.#i??[])}focus(t){const e=t?.preventScroll??!1,n=t?.lineNumber;if(n==="first-visible"||typeof n=="number"){const s=this.#s;if(s==null||this.#f==null)return;const r=n==="first-visible"?this.#ze(t?.offset):n;if(r==null)return;const o=s.normalizePosition({line:r-1,character:n==="first-visible"?0:t?.character??0});this.#He(o,e);return}const i=this.#i?.at(-1);if(i!==void 0){const s=i.direction===-1?i.end:i.start;this.#G(s,e)}else this.#G(void 0,e)}blur(){this.#I=void 0,this.#O=!1,this.#D=!1,this.#h?.blur()}cleanUp(t=!1){this.#_t(),t||(this.#o.delivered=!1);const e=this.#f!=null,n=this.#e.persistState===!0;this.#g++,this.#qt(),e&&(this.#x=n),te(this.#ee),this.#r?.cleanUp(),this.#r=void 0,t||(this.#s=void 0,this.#z=void 0),this.#y?.forEach(i=>i()),this.#y=void 0,this.#u?.forEach(i=>i()),this.#u=void 0,this.#W?.(t),this.#W=void 0,this.#L=void 0,this.#m=void 0,this.#k.clear(),this.#p.clear(),this.#M.clear(),this.#C=void 0,this.#q?.remove(),this.#q=void 0,this.#T?.remove(),this.#T=void 0,this.#P?.remove(),this.#P=void 0,this.#U?.remove(),this.#U=void 0,this.#S=void 0,this.#n?.cleanUp(),this.#n=void 0,this.#R=void 0,this.#h?.removeAttribute("contentEditable"),this.#h=void 0,this.#I=void 0,this.#O=!1,this.#V?.remove(),this.#V=void 0,this.#X?.disconnect(),this.#X=void 0,this.#zt=!1,this.#ut!==void 0&&(cancelAnimationFrame(this.#ut),this.#ut=void 0),this.#Yt(),this.#f=void 0}__prepareFile(t){if(this.#e.persistState!==!0)return t;const e=G(t),n=this.#z,i=t.lang??xt(t.name);n!==void 0&&(G(n)!==e||n.name!==t.name||this.#s?.languageId!==i)&&(this.#g++,this.#qt());const s=this.#Gt(t,e);return s===void 0||s.getText()===t.contents?t:{...t,contents:s.getText()}}__postponeBgTokenizeToNextFrame(){const t=this.#r;t!==void 0&&(t.pauseBackgroundTokenize(),requestAnimationFrame(()=>{t.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){const t=this.#h,e=this.#S?.shadowRoot?.activeElement;t!=null&&(this.#O||e===t||e!=null&&t.contains(e))&&(this.#I={})}__syncRenderView=(t,e,n,i,s)=>{const r=this.#f;if(r==null)return;const o=e.shadowRoot;if(o==null){console.error("[editor] Could not find the shadow root.");return}let a,c,h;for(const v of o.querySelectorAll("[data-code]"))if(v.dataset.deletions===void 0){a=v;for(const g of v.children){const p=g,{gutter:m,content:C}=p.dataset;m!==void 0?c=p:C!==void 0&&(h=p)}break}if(a===void 0||h===void 0){this.#I=void 0;return}this.#Et().setViewportElements(e,a),this.#S!==e&&(this.#S=e,this.#q!==void 0&&e.appendChild(this.#q),this.#T!==void 0&&o.appendChild(this.#T),this.#P!==void 0&&o.appendChild(this.#P),this.#U!==void 0&&o.prepend(this.#U));const d=this.#s===void 0||this.#z===void 0||this.#z.name!==n.name||this.#z.lang!==n.lang||this.#z.cacheKey!==n.cacheKey,l=this.#e.persistState===!0?G(n):void 0;let f;if(d){this.#_t();let v="";"contents"in n?v=n.contents:v=n.additionLines.join("");const g=new Ee({maxEntries:this.#e.historyMaxEntries}),{name:p,lang:m,cacheKey:C}=n,x=m??xt(n.name),L=l!==void 0?this.#Gt(n,l):void 0,S=r.type==="file"||L?.getText()===v?L:void 0,w=S??new wn(n.name,v,x,0,g);this.#z={name:p,lang:m,cacheKey:C},this.#s=w,l!==void 0&&(this.#a.set(l,w),f={cacheKey:l,textDocument:w}),this.#r?.cleanUp(),this.#r=void 0,this.#Yt(),this.#p.clear(),this.#i=this.#Nt,this.#e.__debug===!0&&console.log(S!==void 0?"[diffs/editor] cached text document reused for":"[diffs/editor] text document rebuilt from",n.name)}f===void 0&&this.#x&&l!==void 0&&this.#s!==void 0&&(f={cacheKey:l,textDocument:this.#s});const u=this.#s;if(this.#r==null&&u!=null&&(this.#r=new ss({highlighter:t,textDocument:u,codeOptions:this.#f?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#be,onThemeChange:()=>this.#We(),setStyle:v=>{this.#P.textContent=v},__debug:this.#e.__debug})),this.#h!==h&&(this.#R=c,this.#h=zn(h,{contentEditable:"true",role:"textbox",ariaMultiLine:"true",autocapitalize:"off",writingSuggestions:"off",autocorrect:!1,spellcheck:!1,translate:!1}),this.#V!==void 0&&h.after(this.#V),this.#t.init(h),this.#Be(),this.#Ae(h,c),this.#h!==void 0&&this.#e.__debug===!0&&console.log("[diffs/editor] full re-render triggered !!!")),this.#I!=null&&(this.#I.target=h),h.ariaLabel!==n.name&&(h.ariaLabel=n.name),i!==void 0&&i.length>0||this.#et)for(const v of this.#h.children){const g=v,{lineAnnotation:p,lineType:m,separator:C}=g.dataset;(p!==void 0||C!==void 0||m==="change-deletion")&&g.setAttribute("contenteditable","false")}if(this.#Ht(),this.#r?.syncTheme(this.#f?.__getEffectiveCodeOptions()??{}),this.#E=i,this.#$=s,this.#J=s?.totalLines,this.#r?.prebuildStateStack(s),this.#b?.removePopover(),(this.#i!==void 0||this.#Q!==void 0||this.#b!==void 0)&&this.#d(this.#i??[]),this.#Nt!==void 0&&this.#Z!==void 0?(this.#Nt=void 0,this.#nt(!1,"center")):this.#tt!==void 0?this.#Ut(this.#tt,this.#dt,this.#ft):this.#I!==void 0?this.#Ft():this.#i!==void 0&&this.#i.length>0&&this.#O&&!this.#ct&&this.focus({preventScroll:!0}),this.#ct&&this.#N?.focus(),this.#e.__debug===!0&&s!==void 0){const{startingLine:v,totalLines:g}=s;console.log("[diffs/editor] render file:",n.name,"RenderRange:",v+"-"+(v+g),"of",this.#s?.lineCount,"lines")}f!==void 0&&(this.#x=!1,this.#Se(f.cacheKey,f.textDocument)),this.#ke(r)};#Gt(t,e){const n=this.#a.get(e),i=t.lang??xt(t.name);return n?.languageId===i?n:void 0}#jt(){const t=this.#e.persistStateStorage??"inMemory";return(this.#l===void 0||this.#c!==t)&&(this.#l=Gi(t),this.#c=t),this.#l}#qt(){const t=this.#z,e=this.#s;if(this.#e.persistState!==!0||this.#f===void 0||t===void 0||e===void 0)return;const n=G(t);this.#a.set(n,e);let i;try{i=this.#jt()}catch{return}const s=Q(this.getState()),r=this.#w;if(r?.cacheKey===n&&r.textDocument===e){if(this.#w=void 0,e.version===r.documentVersion&&this.#i===r.selections&&s.view?.scrollLeft===r.view?.scrollLeft&&s.view?.scrollTop===r.view?.scrollTop)return;this.#Zt(i,n,s,r.completion);return}this.#Zt(i,n,s)}#Zt(t,e,n,i){const s=this.#v.get(e);if(i!==void 0||s!==void 0){let o=i??Promise.resolve();s!==void 0&&(o=o.then(()=>s)),this.#Xt(e,o.then(()=>t.set(e,n)));return}let r;try{r=t.set(e,n)}catch{return}Mt(r)&&this.#Xt(e,r)}#Xt(t,e){const n=e.catch(()=>{});this.#v.set(t,n),n.finally(()=>{this.#v.get(t)===n&&this.#v.delete(t)})}#Se(t,e){const n=++this.#g,i=e.version,s=this.#i,r=this.getState().view;let o;const a=l=>{const f=this.getState().view;if(n!==this.#g||this.#s!==e||e.version!==i||this.#i!==s||f?.scrollLeft!==r?.scrollLeft||this.#z===void 0||G(this.#z)!==t)return;const u=o?.userScrolled()===!0;if(l===void 0){this.#f?.setCodeScrollLeft(0),u||this.#Qt(0);return}const v=Q(l);u&&v.view!==void 0&&(v.view={scrollLeft:v.view.scrollLeft}),this.setState(v)},c=()=>{let l;try{l=this.#jt().get(t)}catch{return}if(Mt(l))return l.then(a).catch(()=>{});try{a(l)}catch{}},h=this.#v.get(t),d=h===void 0?c():h.then(c);if(Mt(d)){o=this.#we();const l={cacheKey:t,textDocument:e,documentVersion:i,selections:s,view:r,completion:d.catch(()=>{})};this.#w=l,l.completion.finally(()=>{o?.dispose(),this.#w===l&&(this.#w=void 0)})}}#we(){const t=this.#At();if(!(t instanceof HTMLElement))return;let e=!1;const n=["wheel","touchstart","mousedown"],i=()=>{for(const r of n)t.removeEventListener(r,s,{capture:!0})},s=()=>{e=!0,i()};for(const r of n)t.addEventListener(r,s,{capture:!0,passive:!0});return{userScrolled:()=>e,dispose:i}}#gt(t){return this.#f?.isLineRenderable?.(t+1)??!0}get#ye(){const t=this.#f;if(t?.getNearestRenderableLine!=null)return(e,n)=>{const i=t.getNearestRenderableLine(e+1,n);return i==null?void 0:i-1}}#lt(t){this.#gt(t)||this.#f?.revealLine?.(t+1)}get#Tt(){return this.#f?.options.diffStyle??"split"}get#et(){return this.#f?.type==="file-diff"}get#rt(){return this.#f?.options.overflow==="wrap"}#Et(){return this.#n??=new jn({hasActivePopover:()=>this.#H!==void 0||this.#b?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Vt(),this.#b?.updatePopoverPosition()}})}#Ht(){this.#k.clear(),this.#M.clear(),this.#C=void 0}#Yt(){this.#yt(null),this.#L=void 0,this.#m=void 0,this.#Jt(),this.#Y=!1,this.#F?.forEach(t=>t.remove()),this.#F=void 0,this.#i=void 0,this.#tt=void 0,this.#b?.cleanup(),this.#b=void 0,this.#N?.cleanup(),this.#N=void 0,this.#H?.cleanup(),this.#H=void 0,this.#_=!0}#_t(){const t=this.#o;t.generation++,t.callback!=null&&(te(t.callback),t.callback=void 0)}#ke(t){const e=this.#o,n=this.#s;if(e.delivered||e.callback!=null||n==null)return;const{generation:i}=e,s=()=>{if(e.callback!==s||(e.callback=void 0,i!==e.generation||this.#f!==t||this.#s!==n))return;const r=this.#h,o=this.#S?.shadowRoot;r==null||o==null||!o.contains(r)||(e.delivered=!0,this.#e.onAttach?.(this,t))};e.callback=s,at(s)}#At(){const t=this.#f?.getEditorViewport?.();if(t!==void 0)return t;const e=this.#S;if(!(this.#f==null||e==null))return Wn(e)}#Te(){const t=this.#At();return t instanceof HTMLElement?t.scrollTop:t?.defaultView?.scrollY??0}#Qt(t){const e=this.#At();e instanceof HTMLElement?e.scrollTop=t:e instanceof Document&&e.defaultView?.scrollTo({top:t})}#Ee(){this.#q=k("style",{dataset:"editorGlobalCss",textContent:`
|
|
511
|
+
[data-annotation-slot] {
|
|
512
|
+
user-select: none;
|
|
513
|
+
-webkit-user-select: none;
|
|
514
|
+
}
|
|
515
|
+
`}),this.#T=k("style",{dataset:"editorCss",textContent:An}),this.#P=k("style",{dataset:"editorThemeCss"}),this.#U=Ui(),this.#V=k("div",{dataset:"editorOverlay"});const t=i=>{const s=i.composedPath()[0];return s instanceof Node&&this.#h?.contains(s)===!0},e=()=>{this.#I!=null&&(this.#I=void 0,this.#O=!1,this.#D=!1)},n=i=>{if(i.pointerType!=="mouse")return;const s=this.#xt;this.#Jt(),s&&this.#G(),this.#e.enabledSelectionAction===!0&&this.#i!==void 0&&this.#i.length>0&&!I(this.#i.at(-1))&&this.#d(this.#i)};this.#y=[T(document,"focusin",i=>{t(i)||e()},{passive:!0}),T(document,"pointerdown",i=>{t(i)||queueMicrotask(e)},{capture:!0,passive:!0}),T(document,"selectionchange",()=>{const i=this.#S?.shadowRoot;if(this.#D||this.#Y||i==null||!this.#O||this.#i!==void 0&&this.#i.length>1&&!this.#st)return;const s=document.getSelection();if(s==null)return;const r=typeof s.getComposedRanges=="function"?s.getComposedRanges({shadowRoots:[i]})?.[0]:rs(i);if(r===void 0||!this.#Xe(r))return;let o=Xn(r,0);if(o!==void 0){if(this.#st&&this.#Bt&&this.#i!==void 0&&this.#i.length>0){const a=this.#i.at(-1);this.#d([ze(a,o)]);return}if(this.#st)this.#K!==void 0?o=zt(this.#K,o):this.#K=o;else if(this.#K!==void 0)o.direction=zt(this.#K,o).direction;else if(this.#i!==void 0&&this.#i.length===1){const a=this.#i[0];A(a.start,o.start)===0&&A(a.end,o.end)===0&&(o.direction=a.direction)}this.#at!==void 0&&(this.#at.focusLine=B(o).line,this.#fe())||(this.#St!==void 0?this.#d([...this.#St.filter(a=>!Kt(a,o)),o]):this.#d([o]))}},{passive:!0}),T(document,"pointerup",n,{passive:!0}),T(document,"pointercancel",n,{passive:!0}),T(document,"keydown",i=>{i.key==="Shift"&&(this.#K=this.#i?.at(-1))},{passive:!0}),T(document,"keyup",i=>{i.key==="Shift"&&(this.#K=void 0)},{passive:!0})]}#Jt(){this.#A?.forEach(t=>t()),this.#A=void 0,this.#D=!1,this.#xt=!1,this.#st=!1,this.#at=void 0,this.#Bt=!1,this.#K=void 0,this.#St=void 0}#Wt(t){this.#A?.forEach(e=>e()),this.#A=t}#te(){return this.#f?.options.enableLineSelection===!0}#Mt(){this.#Y=this.#i!==void 0}#Ae(t,e){const{onFocus:n,onBlur:i}=this.#e,s=o=>{const a=o.composedPath()[0];return a!==void 0&&(a===t||t.contains(a))};this.#u?.forEach(o=>o()),this.#u=[T(t,"focus",()=>{this.#O=!0,n?.(),!this.#st&&!this.#D&&this.#i!==void 0&&this.#i.length>0&&this.#wt(this.#i.at(-1))},{passive:!0}),T(t,"blur",()=>{this.#I?.target===t&&(this.#I=void 0,this.#D=!1),this.#O=!1,i?.()},{passive:!0}),T(t,"pointerdown",o=>{if(this.#_=!0,this.#Y=!1,o.pointerType!=="mouse")return;if(this.#at=void 0,this.#_e(o)){this.#Ot(!0),this.#i!==void 0&&this.#d([]);return}this.#Ot(!1),this.#b?.removePopover();const a=[];if(ee()&&this.#E!==void 0&&this.#E.length>0){const h=[...t.querySelectorAll("[data-line-annotation]")].map(d=>[T(d,"mouseenter",()=>{this.#D=!0}),T(d,"mouseleave",()=>{this.#D=!1})]).flat();a.push(...h)}this.#st=!0;const c=o.button===0&&o.altKey&&!o.ctrlKey&&!o.metaKey&&!o.shiftKey;if(this.#K=void 0,c?(this.#at={pointerId:o.pointerId,startClientX:o.clientX,clientX:o.clientX,startScrollLeft:t.parentElement?.scrollLeft??0},this.#St=void 0,this.#i=void 0,this.#d([]),a.push(T(document,"pointermove",h=>{const d=this.#at;d===void 0||h.pointerType!=="mouse"||h.pointerId!==d.pointerId||(d.clientX=h.clientX,this.#fe())},{capture:!0,passive:!0}))):o.button===0&&rt(o)&&(this.#St=this.#i?.map(h=>({...h}))),this.#Wt(a),o.shiftKey){const h=this.#i?.at(-1);if(h!==void 0){const d=h.direction===-1?h.end:h.start;this.#wt({start:d,end:d,direction:0})}this.#Bt=!0}},{passive:!0}),T(t,"keydown",o=>{if(!s(o)||(this.#_=!0,this.#Y=!1,o.isComposing||o.keyCode===229))return;const a=En(o,this.#e.keymap);if(a!==void 0){o.preventDefault(),a==="simplifySelection"&&(this.#N?.close(),this.#N=void 0,this.#ct=!1,this.#H?.cleanup(),this.#H=void 0),this.#Dt(a);return}const c=yn(o),h=this.#s;if(this.#i!==void 0&&this.#i.length>0&&c!==void 0&&h!==void 0){const d={getSoftLineOffsets:this.#rt?l=>this.#Kt(l):void 0,resolveRenderableLine:this.#ye};o.shiftKey?this.#d(Jn(h,this.#i,c,d)):this.#d(Be(h,this.#i,c,d)),this.#nt(),o.preventDefault();return}if((o.key.length===1?o.key.toLowerCase():o.key)==="v"&&rt(o)){if(o.repeat&&this.#et){o.preventDefault();return}if(this.#e.clipboard!==void 0){o.preventDefault(),at(this.#ee);return}}if(this.#N!==void 0){const d=Bt(o);if(d!==void 0){o.preventDefault(),this.#N.navigate(d==="previous");return}}}),T(t,"copy",o=>{s(o)&&(o.preventDefault(),this.#he()?o.clipboardData?.setData("text",this.#de()):this.#me(o.clipboardData,this.#Ve(),this.#ve()))}),T(t,"cut",o=>{if(s(o))if(o.preventDefault(),this.#he())o.clipboardData?.setData("text",this.#de());else{const a=this.#ve();this.#me(o.clipboardData,this.#$e(),a)}}),T(t,"paste",o=>{if(!s(o))return;o.preventDefault();const a=o.clipboardData,c=this.#s;if(a===null||c===void 0)return;let h=a.getData("text");const d=this.#i?.length??0;if(d>1){const l=a.getData(Ot);if(l!==void 0)try{const f=JSON.parse(l);Array.isArray(f)&&f.length===d&&(h=f)}catch{}}this.#vt(Array.isArray(h)?h.map(l=>c.normalizeEol(l)):c.normalizeEol(h),void 0,!0,"document")}),T(t,"beforeinput",o=>{s(o)&&o.inputType!=="insertCompositionText"&&(o.preventDefault(),this.#ie(o.inputType,o.data))}),T(t,"drop",o=>{s(o)&&o.preventDefault()}),T(t,"compositionstart",o=>{s(o)&&(this.#Lt=!0,this.#D=!0)},{passive:!0}),T(t,"compositionend",o=>{if(!s(o))return;this.#D=!1;const a=this.#Lt;this.#Lt=!1,(o.data!==""||!a)&&this.#ie("insertText",o.data)},{passive:!0})];const r=this.#S?.shadowRoot?.querySelector("[data-deletions]");if(r!=null&&this.#u.push(T(r,"pointerdown",o=>{const a=o.composedPath();if(ne(a)){this.#Mt();return}const c=a[0],h=c instanceof HTMLElement?c.closest("[data-column-number]"):null;if(h instanceof HTMLElement){if(this.#te()){this.#Mt();return}if(this.#le(h,r,o.pointerType==="mouse"))return}this.#Ot(!0),this.#i!==void 0&&this.#d([])},{passive:!0})),e!==void 0){const o=(c,h=!1)=>{let d=c;return d?.dataset.lineNumberContent!==void 0?d=d.parentElement??void 0:h&&d?.tagName==="SPAN"&&(d=d.closest("[data-line]")),d},a=c=>{if(c===void 0)return;const h=c.dataset.lineType,d=W(c)??W(c,"columnNumber");if(!(d===void 0||h===void 0||!et(h)))return d-1};this.#u.push(T(e,"pointerdown",c=>{const h=c.composedPath();if(ne(h)){this.#Mt();return}const d=o(h[0]);if(d!==void 0&&this.#te()){this.#Mt();return}if(d?.dataset.lineType==="change-deletion"){const v=d.closest("[data-code]");v!=null&&this.#le(d,v,c.pointerType==="mouse");return}if(c.pointerType!=="mouse")return;const l=this.#s,f=a(d);if(f===void 0||l===void 0)return;this.#_=!0,this.#b?.removePopover();const u=this.#oe(f,f,l);this.#xt=!0,this.#K=u,this.#d([u]),this.#wt(u),this.#G(),this.#Wt([T(document,"mousemove",v=>{if(!this.#xt)return;const g=this.#s,p=a(o(v.composedPath()[0],!0));if(p===void 0||g===void 0)return;const m=this.#K?.start.line??p,C=this.#oe(m,p,g);this.#K??=C,this.#d([C]),this.#G(C.direction===-1?C.start:C.end)},{passive:!0})])},{passive:!0}))}this.#b?.listenHover(t),this.#X?.disconnect(),this.#X=new ResizeObserver(this.#Pe),this.#X.observe(t),this.#X.observe(t.parentElement),this.#ne(t)}#ee=async()=>{const t=this.#e.clipboard;if(t!==void 0){let e=await t.readText();const n=this.#i?.length??0;if(n>1){const s=await t.readText(Ot);try{const r=JSON.parse(s);Array.isArray(r)&&r.length===n&&(e=r)}catch{}}const i=this.#s;i!==void 0&&this.#vt(Array.isArray(e)?e.map(s=>i.normalizeEol(s)):i.normalizeEol(e),void 0,!0,"document")}};#ne(t){this.#et&&this.#Tt==="split"&&this.#rt&&(this.#B={top:t.offsetTop,left:t.offsetLeft-this.#ot()},this.#e.__debug===!0&&console.log("[diffs/editor] content offset:",this.#B))}get#pt(){if(this.#et&&this.#Tt==="split"&&this.#rt)return this.#B}#Dt(t){const e=this.#s;if(e!==void 0)switch(t){case"openSearchPanel":this.#pe("find");break;case"openSearchReplacePanel":this.#pe("replace");break;case"findNextMatch":{const n=this.#i;if(n===void 0)break;if(n.some(I)){const i=n.map(s=>I(s)?_t(e,s):s);this.#d(i),this.focus()}else{const i=ui(e,n);if(i!==void 0){this.#d(i);const s=i.at(-1);s!==void 0&&this.#lt(B(s).line),this.#nt()}}break}case"moveLineUp":case"moveLineDown":this.#Ie(t==="moveLineUp"?-1:1);break;case"copyLineUp":case"copyLineDown":this.#Re(t==="copyLineUp"?-1:1);break;case"simplifySelection":{const n=this.#i,i=n?.at(-1);if(n===void 0||i===void 0)break;if(n.length>1)this.#d([i]),this.#G(B(i));else if(!I(i)){const s=B(i);this.#d([{start:s,end:s,direction:0}]),this.#G(s)}break}case"insertBlankLine":this.#Oe();break;case"deleteHardLineForward":this.#qe();break;case"toggleComment":case"toggleBlockComment":{const n=this.#i;if(n===void 0)break;const{lineComment:i,blockComment:s}=In(e.languageId,this.#e.languageCommentConfig);if(t==="toggleComment"&&i!==null){this.#Rt(Pn(e,n,i));break}const r=t==="toggleComment",o=Nn(e,n,s,r);o!==void 0&&this.#Rt(o.edits,r?void 0:a=>o.nextSelectionOffsets.map(([c,h,d])=>({start:a.positionAt(c),end:a.positionAt(h),direction:d})));break}case"indent":case"outdent":case"indentLess":case"indentMore":if(this.#i!==void 0){const n=[],i=[],s=new Set,r=[];for(const a of this.#i){const c=a.start.line,h=t==="outdent"||t==="indentLess",d=t==="indentLess"||t==="indentMore";if(c!==a.end.line||h||d){const l=Yn(e,a,this.#t.tabSize,h);for(const f of l[0]){const u=f.range.start.line;s.has(u)||(s.add(u),n.push(f))}i.push(l[1])}else{const l=e.charAt({line:c,character:0})===" "?" ":" ".repeat(this.#t.tabSize);n.push({range:a,newText:l}),r.push({line:c,startCharacter:a.start.character,addedLength:l.length-(a.end.character-a.start.character),selectionIndex:i.length});const f={line:a.start.line,character:a.start.character+l.length};i.push({start:f,end:f,direction:0})}}for(const a of r){let c=0;for(const h of r)h.line===a.line&&h.startCharacter<a.startCharacter&&(c+=h.addedLength);if(c!==0){const h=i[a.selectionIndex],d={line:a.line,character:h.start.character+c};i[a.selectionIndex]={start:d,end:d,direction:0}}}const o=e.applyEdits(n,!0,this.#i,i);o!==void 0&&this.#j(o,i)}break;case"selectAll":{const n=gi(e);this.#d([n]),this.focus();const i=this.#Le(),s=i[0]?.[0],r=i.at(-1)?.[1];s!==void 0&&r!==void 0&&(this.#Y=!0,this.#wt({start:{line:s,character:0},end:{line:r,character:e.getLineLength(r)},direction:1}));break}case"moveCursorToDocStart":case"moveCursorToDocEnd":{const n=Le(e,t==="moveCursorToDocEnd",this.#et);this.#d([n]),this.#lt(B(n).line),this.#nt()}break;case"expandSelectionDocStart":case"expandSelectionDocEnd":{const n=t==="expandSelectionDocEnd",i=this.#i;if(i!==void 0){const s=Le(e,n,this.#et);this.#d(di(i,s)),this.#lt(B(s).line),this.#nt()}}break;case"undo":case"redo":this.#Me(t);break}}#Me(t){const e=this.#s;if(e===void 0||t==="undo"&&!e.canUndo||t==="redo"&&!e.canRedo)return;const n=this.#i,i=n?.map(d=>[e.offsetAt(d.start),e.offsetAt(d.end)]),s=t==="undo"?e.undo():e.redo();if(s===void 0)return;const[r,o,a,c]=s,h=o??(n!==void 0&&i!==void 0&&c!==void 0?wt(e,n,i,c):void 0);this.#j(r,h,a)}#Rt(t,e){const n=this.#s,i=this.#i;if(n===void 0||i===void 0)return;const s=e===void 0,r=s?i.map(h=>[n.offsetAt(h.start),n.offsetAt(h.end)]):void 0,o=s?t.map(h=>{const d=n.offsetAt(h.range.start),l=n.offsetAt(h.range.end);return{start:Math.min(d,l),end:Math.max(d,l),text:h.newText}}).sort((h,d)=>{const l=h.start-d.start;return l!==0?l:h.end-d.end}):void 0,a=n.applyEdits(t,!0,i,void 0,!0);if(a===void 0)return;const c=s?wt(n,i,r,o):e(n);n.setLastUndoSelectionsAfter(c),this.#j(a,c,this.#it(a))}#Re(t){const e=this.#s,n=this.#i;if(e===void 0||n===void 0)return;const i=Ce(n);if(i.length===0)return;const s=[];let r=0;const o=[];for(const c of i){s.push(r);const h=c.endLine-c.startLine+1;r+=h;const d=e.getText({start:{line:c.startLine,character:0},end:{line:c.endLine,character:e.getLineLength(c.endLine)}});if(t>0){const l={line:c.startLine,character:0};o.push({range:{start:l,end:l},newText:d+e.eol})}else if(c.endLine<e.lineCount-1){const l={line:c.endLine+1,character:0};o.push({range:{start:l,end:l},newText:d+e.eol})}else{const l={line:c.endLine,character:e.getLineLength(c.endLine)};o.push({range:{start:l,end:l},newText:e.eol+d})}}const a=n.map(c=>{const h=c.start.line;let d=0,l=i.length-1;for(;d<=l;){const g=d+l>>>1,p=i[g];if(h<p.startLine)l=g-1;else if(h>p.endLine)d=g+1;else{d=g;break}}const f=Math.max(0,d<=l?d:l),u=i[f],v=s[f]+(t>0?u.endLine-u.startLine+1:0);return{start:{...c.start,line:c.start.line+v},end:{...c.end,line:c.end.line+v},direction:c.direction}});this.#Rt(o,()=>a)}#Oe(){const t=this.#s,e=this.#i;if(t===void 0||e===void 0)return;const n=e.map(c=>B(c).line),i=Array.from(new Set(n)).sort((c,h)=>c-h),s=new Map,r=new Map,o=[];for(let c=0;c<i.length;c++){const h=i[c],d=t.getLineText(h),l=/^\s*/.exec(d)?.[0]??"";s.set(h,c),r.set(h,l);const f={line:h,character:t.getLineLength(h)};o.push({range:{start:f,end:f},newText:t.eol+l})}const a=e.map((c,h)=>{const d=n[h],l={line:d+1+s.get(d),character:r.get(d).length};return{start:l,end:l,direction:0}});this.#Rt(o,()=>a)}#Ie(t){const e=this.#s,n=this.#i;if(e===void 0||n===void 0)return;const i=Ce(n);if(i.length===0||t<0&&i[0].startLine===0||t>0&&i.at(-1).endLine>=e.lineCount-1)return;const s=e.lineCount,r=f=>f<s-1?{line:f+1,character:0}:{line:f,character:e.getLineLength(f)},o=(f,u)=>{const v=f.map(g=>e.getLineText(g)).join(e.eol);return u?v+e.eol:v},a=[];if(t<0)for(const f of i){const u=f.startLine-1,v=[];for(let g=f.startLine;g<=f.endLine;g++)v.push(g);a.push({range:{start:{line:u,character:0},end:r(f.endLine)},newText:o([...v,u],f.endLine<s-1)})}else for(let f=i.length-1;f>=0;f--){const u=i[f],v=u.endLine+1,g=[];for(let p=u.startLine;p<=u.endLine;p++)g.push(p);a.push({range:{start:{line:u.startLine,character:0},end:r(v)},newText:o([v,...g],v<s-1)})}const c=i.at(-1),h=t>0&&c.endLine===s-2?e.getLineLength(c.endLine):e.getLineLength(s-1),d=n.map(f=>fi(f,t,s,u=>u===s-1?h:e.getLineLength(u))),l=e.applyEdits(a,!0,n,d,!0);l!==void 0&&this.#j(l,d)}#Pe=()=>{const t=this.#E?.length??0,e=this.#L,n=this.#m;this.#L=void 0,this.#m=void 0;const i=this.#ot()!==e,s=this.#$t()!==n;!i&&!s||(this.#M.clear(),this.#C=void 0,this.#t.clearTextWidthCache(),s&&(this.#p.clear(),(this.#rt||t>0)&&this.#k.clear()),(this.#i!==void 0||this.#Q!==void 0||this.#b!==void 0)&&(this.#d(this.#i??[]),this.#i!==void 0&&this.#O&&this.focus()),this.#b?.removePopover(),this.#ne(this.#h))};#Be(){if(this.#zt)return;const t=document.fonts;t!==void 0&&(this.#zt=!0,t.ready.then(()=>{this.#h===void 0||!this.#t.remeasureCharacterWidth()||(this.#L=void 0,this.#m=void 0,this.#Ht(),this.#p.clear(),(this.#i!==void 0||this.#Q!==void 0||this.#b!==void 0)&&this.#d(this.#i??[]),this.#b?.removePopover())}))}#Ne(t,e,n=this.#$,i){const s=this.#r,r=this.#f,o=this.#s,a=this.#R,c=this.#h;if(s===void 0||r===void 0||o===void 0||c===void 0)return;s.stopBackgroundTokenize();const h=performance.now(),d=s.tokenize(t,n,!this.#et&&r.getLinePosition!==void 0),l=performance.now();if(d.size>0){const u=c.children,v=new Set;for(const g of d.keys())this.#gt(g)&&v.add(g);for(let g=0;g<u.length;g++){const p=u[g];if(p!==void 0){const m=W(p),C=p.dataset.lineType;if(m===void 0||C==="change-deletion")continue;const x=m-1;if(v.has(x)){const L=d.get(x);if(p.replaceChildren(...At(L)),v.delete(x),v.size===0)break}}}if(v.size>0){let g=0;for(let p=u.length-1;p>=0;p--){const m=u[p],C=W(m);if(C!==void 0&&m.dataset.lineType!=="change-deletion"){g=C;break}}for(const p of v){if(p<g)continue;const m=d.get(p),C=String(p+1);k("div",{dataset:{line:C,lineType:"context",lineIndex:p.toString()},children:At(m)},c),a!==void 0&&k("div",{dataset:{lineType:"context",columnNumber:C,lineIndex:p.toString()},children:[k("span",{dataset:{lineNumberContent:""},textContent:C})]},a)}}}if(t.lineDelta<0)for(const u of[c.children,a?.children??[]])for(let v=u.length-1;v>=0;v--){const g=u[v],p=W(g)??W(g,"columnNumber"),m=g.dataset.lineType;if(!(p===void 0||m==="change-deletion")){if(p-1<t.lineCount)break;g.remove()}}const f=t.lineDelta!==0;if(f){let u=c.children.length;for(const v of c.children){const{bufferSize:g}=v.dataset;g!==void 0&&(u+=parseInt(g)-1)}c.style.gridRow="span "+u,a!==void 0&&(a.style.gridRow="span "+u)}r.updateRenderCache(d,s.themeType,{shouldRefreshDiffsView:this.#et&&!f,lineCountChangeInFlight:f}),f&&r.applyDocumentChange(o,e,i),(f||this.#et&&this.#Tt==="unified")&&this.#Ht(),e!==void 0&&(this.#E=e,Kn(e,c,a)),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${q(performance.now()-l)}ms,`,`tokenize in: ${q(l-h)}ms (${d.size} dirty lines)`)}#ie(t,e){switch(t){case"insertText":{const n=e??"",i=this.#s,s=this.#i,r=i!==void 0&&s!==void 0?si(i,s,n,this.#e.autoSurround):void 0;this.#vt(r??n);break}case"insertCompositionText":break;case"insertLineBreak":case"insertParagraph":this.#vt(this.#s?.eol??`
|
|
516
|
+
`);break;case"deleteContentBackward":this.#Ce();break;case"deleteContentForward":this.#Ce(!0);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":this.#Ge();break;case"deleteWordBackward":this.#je();break;case"insertTranspose":this.#Ze();break;default:console.warn(`[diffs] Unknown input type: ${t}`,e);break}}#G(t,e=!0,n){this.#O=!0,t!==void 0?(this.#D=!0,this.#wt({start:t,end:t,direction:0}),at(()=>{if(n?.()===!1||!this.#O){this.#D=!1;return}this.#h?.focus({preventScroll:e}),at(()=>{this.#D=!1})})):n?.()!==!1?this.#h?.focus({preventScroll:e}):this.#O=!1}#Ft(t){const e=this.#I;if(e==null)return;if(this.#ct){this.#I=void 0,this.#O=!1,this.#D=!1;return}const n=this.#h;if(n==null||!this.#se(n)){this.#I=void 0,this.#O=!1;return}const i=()=>{if(this.#I!==e)return!1;const o=this.#se(n);return this.#I=void 0,o};if(t!=null){this.#G(t,!0,i);return}const s=this.#i?.at(-1);if(s==null){this.#G(void 0,!0,i);return}const r=s.direction===-1?s.end:s.start;this.#G(r,!0,i)}#se(t){const e=this.#S,n=e?.shadowRoot;if(e==null||n==null||this.#h!==t||!n.contains(t))return!1;const{activeElement:i}=n;if(i===t||i!=null&&t.contains(i))return!0;if(i!=null)return!1;const{ownerDocument:s}=e,{activeElement:r}=s;return r==null||r===s.body||r===s.documentElement||r===e}#ze(t=0){const e=this.#h,n=this.#S;if(this.#s==null||e==null||n==null)return;const i=this.#At();if(i===void 0)return;let s,r;if(i instanceof HTMLElement){const a=i.getBoundingClientRect();s=a.top,r=a.bottom}else s=0,r=i.defaultView?.innerHeight??0;const o=n.shadowRoot?.querySelector("[data-diffs-header][data-sticky]");if(o!=null&&(s=Math.max(s,o.getBoundingClientRect().bottom)),Number.isFinite(t)&&(s+=Math.max(0,t)),!(r<=s))for(const a of e.children){const c=a,h=W(c),d=c.dataset.lineType;if(h==null||d==null||!et(d))continue;const l=c.getBoundingClientRect();if(!(l.bottom<=l.top)&&l.top>=s&&l.top<r)return h}}#He(t,e){const n={start:t,end:t,direction:0};this.#_=!1,this.#d([n]),this.#lt(t.line),e?this.#G(t,!0):this.#nt()}#wt(t){const e=window.getSelection();if(e===null)return;let{start:n,end:i,direction:s}=t;A(n,i)>0&&([n,i]=[i,n]);const r=this.#ht(n.line),o=this.#ht(i.line);if(r===void 0||o===void 0)return;let[a,c]=xe(r,n.character),[h,d]=xe(o,i.character);s===-1&&([a,c,h,d]=[h,d,a,c]);try{e.setBaseAndExtent(a,le(a,c),h,le(h,d))}catch(l){console.error("[diffs/editor] failed to update window selection:",l)}}#nt(t=!1,e="nearest"){const n=this.#i?.at(-1);if(n===void 0)return;const i=this.#Z;if(i!==void 0){if(i.scrollIntoView({block:e,inline:"nearest"}),!t){const s=n.direction===-1?n.end:n.start;this.#I!==void 0?this.#Ft(s):this.#G(s)}}else{const s=B(n);this.#Ut(s.line,s.character,t)}}#re(){const t=this.#N!==void 0?48:0,e=this.#ot()+this.#t.ch;return`${t}px ${this.#t.ch}px 0 ${e}px`}#Ut(t,e=0,n=!1){this.__postponeBgTokenizeToNextFrame();const i=k("div",{style:{position:"absolute",left:"0",width:"2px",height:this.#t.lineHeight+"px",scrollMargin:this.#re()}});if(this.#ht(t)!==void 0){const[s,r]=this.#Ct(t,e),o=this.#mt(t)+r*this.#t.lineHeight;if(i.style.top=o+"px",i.style.left=s+"px",this.#V?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),!n){const a={line:t,character:e};this.#I!==void 0?this.#Ft(a):this.#G(a)}this.#tt=void 0,this.#dt=void 0,this.#kt=!1,this.#ft=!1}else{const s=this.#f?.getLinePosition?.(t+1);if(s!==void 0)i.style.top=s.top+"px",this.#S?.shadowRoot?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),s.height>0&&this.#gt(t)?(this.#tt=t,this.#dt=e,this.#ft=n):(this.#tt=void 0,this.#dt=void 0,this.#ft=!1);else{let r=0;if(this.#tt===t&&this.#h!==void 0)for(let a=this.#h.childElementCount-1;a>=0;a--){const c=this.#h.children[a],h=c.dataset.lineType,d=W(c);if(h!==void 0&&et(h)&&d!==void 0){r=(t-(d-1))*this.#t.lineHeight;break}}const o=((this.#E??[]).filter(a=>a.lineNumber<t).length+t)*this.#t.lineHeight+r;i.style.top=o+"px",this.#S?.shadowRoot?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),this.#tt===t&&(r===0||this.#kt)||!this.#gt(t)?(this.#tt=void 0,this.#dt=void 0,this.#kt=!1,this.#ft=!1):(this.#tt=t,this.#dt=e,this.#kt=r!==0,this.#ft=n)}}i.remove()}#oe(t,e,n){const i=r=>({line:r,character:0}),s=r=>({line:r,character:n.getLineText(r).length});return e<t?{start:i(e),end:s(t),direction:-1}:{start:i(t),end:s(e),direction:1}}#_e(t){const e=t.composedPath()[0];return e instanceof HTMLElement&&e.closest("[data-line]")?.getAttribute("data-line-type")==="change-deletion"}#ae(t,e,n){const i=[...n.querySelectorAll("[data-content] > [data-line]")],s=i.indexOf(t),r=i.indexOf(e),[o,a]=r<s?[e,t]:[t,e],c=window.getSelection();if(c!==null){const l=document.createRange();l.setStart(o,0),l.setEnd(a,a.childNodes.length),c.removeAllRanges(),c.addRange(l)}this.#Ot(!0),this.#d([]),this.#yt(W(e)??null,!0,"deletions");const h=Math.min(s,r),d=Math.max(s,r);this.#bt=h<0?"":i.slice(h,d+1).filter(l=>l.getAttribute("data-line-type")==="change-deletion").map(l=>l.textContent??"").join(`
|
|
517
|
+
`)}#ce(t,e){const n=t.parentElement;if(n==null||e==null)return;const i=[...n.children].indexOf(t),s=e.children[i];return s instanceof HTMLElement?s:void 0}#le(t,e,n){const i=e.querySelector("[data-content]"),s=this.#ce(t,i);return s===void 0?!1:(this.#ae(s,s,e),n&&this.#Wt([T(document,"mousemove",r=>{const o=r.composedPath()[0],a=o instanceof HTMLElement?o.closest("[data-column-number]"):null;if(a instanceof HTMLElement&&e.contains(a)){const c=this.#ce(a,i);c!==void 0&&this.#ae(s,c,e)}},{passive:!0})]),!0)}#he(){return this.#S?.shadowRoot?.querySelector("pre")?.hasAttribute("data-deleted-text-selection")??!1}#de(){return this.#bt!==""?this.#bt:window.getSelection()?.toString()??""}#Ot(t){const e=this.#S?.shadowRoot?.querySelector("pre");e!=null&&(t?(e.setAttribute("data-deleted-text-selection",""),this.#yt(null),this.#bt=""):(e.removeAttribute("data-deleted-text-selection"),this.#bt=""))}#yt(t,e=!1,n="additions"){try{this.#f?.setEditorActiveLine(t,{lineNumberOnly:e,side:n})}catch{}}#We(){this.#ut===void 0&&(this.#ut=requestAnimationFrame(()=>{this.#ut=void 0,(this.#i!==void 0||this.#Q!==void 0||this.#b!==void 0)&&this.#d(this.#i??[])}))}#fe(){const t=this.#at,e=this.#K,n=this.#s;if(t===void 0||t.focusLine===void 0||e===void 0||n===void 0)return!1;const i=e.direction===-1?e.end:e.start,s=this.#h?.parentElement?.scrollLeft??0,r=(t.clientX-t.startClientX+s-t.startScrollLeft)/this.#t.ch,o=r<0?-Math.round(-r):Math.round(r),a=Math.max(0,i.character+o),c={line:t.focusLine,character:a};if(t.renderedGoal!==void 0&&A(t.renderedGoal,c)===0)return!0;t.renderedGoal=c;const h=[],d=c.line<i.line?-1:1;for(let l=i.line;;l+=d){if(this.#gt(l)){const f=n.getLineText(l),u=Math.min(i.character,f.length),v=Math.min(a,f.length),g=Nt(f,u),p=v===u?g:Nt(f,v);h.push({start:{line:l,character:Math.min(g,p)},end:{line:l,character:Math.max(g,p)},direction:g===p?0:g<p?1:-1})}if(l===c.line)break}return this.#d(h),!0}#d(t){if(this.__postponeBgTokenizeToNextFrame(),this.#Z=void 0,this.#yt(null),t.length===0&&this.#Q===void 0&&this.#b===void 0){this.#i=void 0,this.#F?.forEach(s=>s.remove()),this.#F?.clear(),this.#H?.cleanup(),this.#H=void 0;return}const e=document.createDocumentFragment(),n={fragment:e,elements:new Map};if(t.length>0){const s=He(t),r=s.at(-1);this.#i=s;const o=s.some(h=>!I(h)),a=B(r).line+1;this.#yt(a,o);for(const h of s)I(h)||this.#It(n,"selection",h),this.#Fe(n,h,h===r);const c=this.#e.matchBrackets!==!1&&this.#s!==void 0&&this.#r!==void 0&&I(r)?Ii(this.#s,this.#r,r.start):void 0;if(c!==void 0)for(const h of c)this.#It(n,"bracketMatch",h)}const i=this.#s;if(this.#Q!==void 0&&i!==void 0){const s=this.#Q,r=this.#$,o=r!==void 0&&Number.isFinite(r.totalLines)||this.#et&&this.#f?.options.expandUnchanged!==!0?this.#Le():void 0,a=this.#i?.at(-1),c=a!==void 0?i.offsetAt(a.start):-1,h=a!==void 0?i.offsetAt(a.end):-1;let d=0;const l=o?.length??1;for(let f=0;f<l;f++){let u=1/0;const v=o?.[f];if(v!==void 0){const[g,p]=v,m=i.offsetAt({line:g,character:0}),C=p+1;u=C<i.lineCount?i.offsetAt({line:C,character:0}):i.offsetAt({line:C-1,character:i.getLineLength(C-1)});let x=d,L=s.length;for(;x<L;){const S=x+Math.floor((L-x)/2);s[S][1]<=m?x=S+1:L=S}d=x}for(;d<s.length;d++){const[g,p]=s[d];if(g>=u)break;const m={start:i.positionAt(g),end:i.positionAt(p)},C=c===g&&h===p;this.#It(n,"match",m,C?"focus":void 0)}}}if(this.#b!==void 0&&i!==void 0)for(const s of this.#b.markers)this.#It(n,"marker",s,pt(s.severity));this.#V?.appendChild(e),this.#F?.forEach(s=>s.remove()),this.#F?.clear(),this.#F=n.elements,this.#Vt()}#It(t,e,n,i){if(this.#s===void 0)return;const{start:s,end:r}=n;let o=s.line,a=r.line+1;if(this.#$!==void 0){const{startingLine:c,totalLines:h}=this.#$;o=Math.max(o,c),a=Math.min(a,c+h)}for(let c=o;c<a;c++){if(!this.#Pt(c))continue;const h=c===r.line,d=c===s.line?s.character:0,l=h?r.character:this.#s.getLineLength(c);if(this.#rt){const g=this.#$t(),p=this.#s.getLineText(c);if(2*this.#t.ch+this.#t.measureTextWidth(p)>g){this.#De(t,c,p,d,l,h,e,i);continue}}let f=0,u=0,v=0;d===0?f=this.#ot()+this.#t.ch+(this.#pt?.left??0):f=this.#Ct(c,d)[0],!h&&e==="selection"&&(v=this.#t.ch),d===l?u=v:u=this.#Ct(c,l)[0]-f+v,this.#ge(t,e,c,0,f,u,i)}}#De(t,e,n,i,s,r,o,a){const c=this.#Kt(e),h=c.length-1,d=this.#ot()+this.#t.ch+(this.#pt?.left??0);for(let l=0;l<h;l++){const f=c[l],u=c[l+1],v=Math.max(i,f),g=Math.min(s,u);if(v>g)continue;const p=this.#ue(n,f,v),m=d+p;let C=0;!r&&l===h-1&&o==="selection"&&(C=this.#t.ch);const x=v===g?C:this.#ue(n,f,g)-p+C;this.#ge(t,o,e,l,m,x,a)}}#ue(t,e,n){if(n<=e)return 0;const i=t.slice(e,n),s=ht(i,this.#t.tabSize);return s!==-1?s*this.#t.ch:this.#t.measureTextWidth(i)}#ge(t,e,n,i,s,r,o){if(r===0)return;const{ch:a,lineHeight:c}=this.#t,h=this.#mt(n)+i*c,d=`${e}-${n}/${i}-${s}-${r} ${o??""}`,l=this.#F,f=(this.#e.roundedSelection??!0)&&e==="selection",u=(p,m,C,x)=>{const L=this.#mt(p)+m*c,S=this.#ht(p);let w="initial";S!==void 0&&(S.dataset.lineType==="change-addition"||S.dataset.selectedLine!==void 0)&&(w=getComputedStyle(S).getPropertyValue("--diffs-line-bg"));const R=`width:${a}px;transform:translateX(${C}px) translateY(${L}px);--diffs-selection-corner-bg:${w}`,O={selectionCorner:"",[x]:""},y=`${e}-block-${p}/${m}-${C}-1ch`;let E=y+"-"+x;if(x==="rbl"){const P=y+"-rtl",_=t.elements.get(P);_!==void 0&&(_.remove(),t.elements.delete(P),E+="-rtl",O.rtl="")}let N=t.elements.get(E);N===void 0&&(l?.has(E)===!0?(N=l.get(E),N.style.cssText=R,l.delete(E)):N=k("div",{dataset:"selectionRange",style:{cssText:R},children:[k("div",{dataset:O})]},t.fragment),t.elements.set(E,N))},v=p=>{const m=s+r,C=p.dataset,x=t.previousSelectionRange;if((x===void 0||x.line!==n||x.wrapLine!==i)&&(t.previousSelectionRange={element:p,line:n,wrapLine:i,left:s,width:r}),x===void 0||m<=x.left)["rtl","rtr","rbl","rbr"].forEach(L=>{C[L]=""});else{const L=x.line,S=x.wrapLine,w=x.left,R=x.element.dataset,O=w+x.width;w>s&&u(L,S,w-a,"rbr"),delete R.rbl,delete C.rtl,delete C.rtr,m>=O&&delete R.rbr,m>O&&(u(L,S,O,"rbl"),C.rtr=""),m<O&&u(n,i,m,"rtl"),s<w&&(C.rtl=""),C.rbl="",C.rbr=""}};let g=t.elements.get(d);if(g!==void 0){f&&v(g);return}l?.has(d)===!0?(g=l.get(d),l.delete(d)):g=k("div",{dataset:o?[e+"Range",o]:e+"Range"},t.fragment),g.style.width=`${r}px`,g.style.transform=`translateX(${s}px) translateY(${h}px)`,f&&v(g),t.elements.set(d,g)}#Fe(t,e,n){const{line:i,character:s}=B(e);if(!this.#Pt(i))return;const[r,o]=this.#Ct(i,s),a="caret-"+i+"/"+o+":"+s;if(t.elements.has(a))return;const c=k("div",{dataset:"caret",style:{transform:`translateX(${r-1}px) translateY(${this.#mt(i)+o*this.#t.lineHeight}px)`}},t.fragment);t.elements.set(a,c),n&&(c.style.scrollMargin=this.#re(),this.#Z=c)}#Vt(){const t=this.#i?.at(-1),e=this.#V,n=this.#s,i=this.#e.renderSelectionAction,s=()=>{this.#H?.cleanup(),this.#H=void 0};if(this.#e.enabledSelectionAction!==!0||i===void 0||t===void 0||I(t)||this.#st||e===void 0||n===void 0){s();return}const r=B(t);if(!this.#Pt(r.line)){s();return}if(this.#H===void 0){if(!this.#_)return;const y=()=>this.#i?.at(-1)??t,E=i({textDocument:n,get selection(){return y()},applyEdits:N=>this.applyEdits(N),getSelectionText:()=>this.#s?.getText(y())??"",replaceSelectionText:N=>{this.#vt(N,[y()])},close:()=>{s(),this.#nt()}});this.#H=new Ki(E,e,()=>this.#Vt()),this.#Et().resetPlacement(Rt)}const o=this.#t.lineHeight,a=t.direction===-1,c={placeAbove:a,anchor:r},h=a?{placeAbove:!1,anchor:t.end}:{placeAbove:!0,anchor:t.start},d=this.#H.height,l=y=>{const[E,N]=this.#Ct(y.anchor.line,y.anchor.character),P=this.#mt(y.anchor.line)+N*o,_=y.placeAbove?P:P+o,F=y.placeAbove?_-d:_;return{top:F,bottom:F+d,left:E,anchorTop:_,rowTop:P}},f=l(c),u=n.lineCount,v=a?r.line<3:r.line>=u-3,g=this.#Pt(h.anchor.line)?l(h):void 0,p=this.#Et(),m=p.getPlacementBounds(),C=g!==void 0&&p.choosePlacement({preferred:f,fallback:g,viewport:m,popoverHeight:d,atDocumentEdge:v,placementKey:Rt})==="fallback";g===void 0&&p.setPlacement("preferred",Rt);const{placeAbove:x}=C?h:c,{left:L,anchorTop:S}=C&&g!==void 0?g:f,w=a?f.rowTop:g?.rowTop??-1/0,R=(a?g?.rowTop??1/0:f.rowTop)+(t.end.line>t.start.line&&t.end.character===0?0:o),O=m===void 0||R>m.top&&w<m.bottom;this.#H.reposition(L,S,this.#ot(),x,O,m)}#pe(t){if(this.#N!==void 0){this.#N.setMode(t);return}this.#Ue(t)}#Ue(t){this.#N?.cleanup();const e=this.#s,n=this.#S?.shadowRoot?.querySelector("pre"),i=this.#i;if(e===void 0||n==null)return;let s="",r;if(i!==void 0&&i.length>0){let c=i.at(-1);if(I(c)){c=_t(e,c),this.#d([...i.slice(0,-1),c]);const h=e.getText(c);h!==""&&!h.includes(`
|
|
518
|
+
`)&&(s=h,r=[e.offsetAt(c.start),e.offsetAt(c.end)])}}const o=([c,h],d)=>{const l=Gt(e,c,h);this.#d([l]),this.#lt(B(l).line),this.#nt(!0),this.#ct=d},a=new $i({textDocument:e,containerElement:n,defaultQuery:s,mode:t,initialMatch:r,scrollToMatch:o,applyReplace:c=>{if(c.length===0)return;const h=e.applyEdits(c.map(d=>({range:{start:e.positionAt(d.start),end:e.positionAt(d.end)},newText:d.text})),!0,this.#i);h!==void 0&&this.#j(h,void 0,this.#it(h),{skipSearchRefresh:!0})},onUpdate:(c,h)=>{if(c.length===0){this.#Q=void 0,this.#d(this.#i??[]);return}if(this.#Q=c,h?.syncSelection===!1){this.#d(this.#i??[]);const u=this.#i?.at(-1);if(u!==void 0){const v=e.offsetAt(u.start),g=e.offsetAt(u.end);for(const p of c)if(p[0]===v&&p[1]===g)return p}return}const d=this.#i?.at(-1);let l=0,f;d!==void 0&&(l=e.offsetAt(d.start));for(const u of c)if(u[0]>=l){f=u;break}return f!==void 0?o(f,!0):this.#d(this.#i??[]),f},onClose:()=>{this.#N=void 0,this.#ct=!1,this.#Q=void 0,this.#d(this.#i??[])}});this.#N=a,this.#ct=!1}#Ve(){const t=this.#s,e=this.#i;return t===void 0||e===void 0?"":Ht(t,e)}#ve(){const t=this.#s,e=this.#i;return t===void 0||e===void 0?[]:vi(t,e)}#me(t,e,n){t!==null&&(t.setData("text",e),n.length>1&&t.setData(Ot,JSON.stringify(n)))}#$e(){const t=this.#s,e=this.#i;if(t===void 0||e===void 0||e.length===0)return"";if(e.some(i=>I(i))){const i=bi(t,e);return this.#Ke(i.edits,i.nextSelectionOffsets),i.text}const n=Ht(t,e);return this.#vt("",void 0,!0),n}#Ke(t,e){const n=this.#s,i=this.#i;if(n===void 0||i===void 0||t.length===0)return;const s=n.applyResolvedEdits(t,!0,i,void 0,!0);if(s===void 0)return;const r=e.map(o=>{const a=n.positionAt(o);return{start:a,end:a,direction:0}});n.setLastUndoSelectionsAfter(r),this.#j(s,r,this.#it(s))}#vt(t,e=this.#i,n=!1,i="selection"){if(e===void 0)return;const s=this.#s,r=e.at(-1);if(s===void 0||r===void 0)return;const{nextSelections:o,change:a}=Array.isArray(t)&&t.length===e.length?ot(s,e,t,this.#E,n,i):ti(s,e,{start:s.offsetAt(r.start),end:s.offsetAt(r.end),text:Array.isArray(t)?t.join(s.eol):t},this.#E,void 0,n);a!==void 0&&this.#j(a,o,this.#it(a))}#Ce(t=!1){const e=this.#i,n=this.#s;if(e===void 0||n===void 0)return;const{nextSelections:i,change:s}=hi(n,e,t,this.#E,this.#t.tabSize);s!==void 0&&this.#j(s,i,this.#it(s))}#Ge(){const t=this.#i,e=this.#s;if(t===void 0||e===void 0)return;const{nextSelections:n,change:i}=ai(e,t,this.#rt?(s,r)=>{const o=this.#Kt(s);for(let a=0;a+1<o.length;a++){const c=o[a],h=o[a+1];if(r>=c&&r<=h)return c}return 0}:void 0,this.#E);i!==void 0&&this.#j(i,n,this.#it(i))}#je(){const t=this.#i,e=this.#s;if(t===void 0||e===void 0)return;const{nextSelections:n,change:i}=ci(e,t,this.#E);i!==void 0&&this.#j(i,n,this.#it(i))}#qe(){const t=this.#i,e=this.#s;if(t===void 0||e===void 0)return;const{nextSelections:n,change:i}=oi(e,t,this.#E);i!==void 0&&this.#j(i,n,this.#it(i))}#Ze(){const t=this.#i,e=this.#s;if(t===void 0||e===void 0)return;const{nextSelections:n,change:i}=ri(e,t,this.#E);i!==void 0&&this.#j(i,n,this.#it(i))}#j(t,e,n,i){const s=this.getFile(),r=this.#e.onChange;if(s!==void 0&&r!==void 0){const c=n??this.#E;r(s,c,{changes:t.changes,file:s,lineAnnotations:c})}if(t.lineDelta!==0||this.#rt)for(const c of this.#k.keys())c>=t.startLine&&this.#k.delete(c);if(this.#p.size>0)if(t.lineDelta===0&&(t.changedLineRanges.length===1||t.changedLineChanges?.every(([,,c])=>c===0)===!0))for(const[c,h]of t.changedLineRanges)for(let d=c;d<=h;d++)this.#p.delete(d);else for(const c of this.#p.keys())c>=t.startLine&&this.#p.delete(c);this.#C=void 0;let o=this.#$,a;if(o!==void 0&&e!==void 0&&e.length>0){const c=e.at(-1),h=o.startingLine+o.totalLines;if(c.end.line>=h){const d=c.end.line-o.startingLine+1,l=this.#J===void 0||this.#J===1/0?1/0:this.#J*os;t.startLine<=h&&d<=l&&this.#gt(c.end.line)?(c.end.line>h&&(a=!0),o={...o,totalLines:d},this.#$=o):a=!0}}if(this.#Ne(t,n,o,a),i?.skipSearchRefresh!==!0&&this.#N!==void 0&&this.#Q!==void 0&&this.#N.updateMatches({syncSelection:!1}),e!==void 0&&(this.#d(e),i?.skipFocus!==!0)){const c=e.at(-1);if(c!==void 0&&this.#lt(B(c).line),this.#Z!==void 0)requestAnimationFrame(()=>{this.#Z?.scrollIntoView({block:"nearest",inline:"nearest"})});else if(e.length>0){const h=B(e.at(-1));this.#Ut(h.line,h.character)}this.focus({preventScroll:!0})}}#it(t){if(this.#E!==void 0){const e=mt(t,this.#E);if(e!==void 0)return this.#s?.setLastUndoLineAnnotations(this.#E,e),e}}#Le(){const t=this.#h;if(t===void 0)return[];const e=[];for(const n of t.children){const i=n,s=i.dataset.lineType,r=W(i);if(r===void 0||s===void 0||!et(s))continue;const o=r-1,a=e.at(-1);a!==void 0&&o<=a[1]+1?a[1]=Math.max(a[1],o):e.push([o,o])}return e}#ht(t){let e=this.#M.get(t);if(e!==void 0)return e??void 0;const n=this.#$;if(n!==void 0&&(t<n.startingLine||t>=n.startingLine+n.totalLines))return;const i=this.#h;if(i!==void 0){if(n!==void 0){const{startingLine:s}=n,{children:r}=i;for(let o=t-s;o<=r.length;o++){const a=r[o];if(a===void 0)break;const c=W(a),h=a.dataset.lineType;if(c!==void 0&&c===t+1&&h!==void 0&&et(h)){e=a;break}}}return e??=i.querySelector(`[data-line="${t+1}"]`+(this.#Tt==="unified"?':not([data-line-type="change-deletion"])':"")),e!==void 0&&this.#M.set(t,e),e??void 0}}#ot(){if(this.#R===void 0)return 0;if(this.#L===void 0){const t=this.#h?.parentElement?.style.getPropertyValue("--diffs-column-number-width");t!==void 0&&t.length>2&&t.endsWith("px")?this.#L=parseInt(t.slice(0,-2),10):this.#L=this.#R.offsetWidth}return this.#L}#$t(){if(this.#h===void 0)return 0;if(this.#m===void 0){const t=this.#h.parentElement?.style.getPropertyValue("--diffs-column-content-width");t!==void 0&&t.length>2&&t.endsWith("px")?this.#m=parseFloat(t.slice(0,-2)):this.#m=this.#h.offsetWidth}return this.#m}#mt(t){const e=this.#k.get(t);if(e!==void 0)return e;const n=this.#ht(t);if(n===void 0)return-1;let i=n.offsetTop+this.#t.paddingTop;return i+=this.#pt?.top??0,this.#k.set(t,i),i}#Ct(t,e){if(this.#C!==void 0&&this.#C[0]===t&&this.#C[1]===e)return[this.#C[2],this.#C[3]];const n=this.#s?.getLineText(t),i=this.#ot()+this.#t.ch;if(n===void 0||n.length===0||e<=0)return[i+(this.#pt?.left??0),0];const s=es(n,Math.min(e,n.length)),r=n.slice(0,s),o=ht(r,this.#t.tabSize);let a=0,c=0;if(o!==-1?a=i+o*this.#t.ch:a=i+this.#t.measureTextWidth(r),this.#rt){const h=this.#$t();if(2*this.#t.ch+this.#t.measureTextWidth(n)>h){const d=this.#xe(t);if(d==null)return[a+(this.#pt?.left??0),0];for(let l=0;l+1<d.length;l++){const f=d[l];if(s<=d[l+1]){c=l;const u=n.slice(f,s),v=ht(u,this.#t.tabSize);v!==-1?a=i+v*this.#t.ch:a=i+this.#t.measureTextWidth(u);break}}}a+=this.#pt?.left??0}return this.#C!==void 0?(this.#C[0]=t,this.#C[1]=e,this.#C[2]=a,this.#C[3]=c):this.#C=[t,e,a,c],[a,c]}#xe(t){const e=this.#p.get(t);if(e!==void 0)return e;this.#p.size>=as&&this.#p.clear();const n=this.#s?.getLineText(t);if(n===void 0||n.length===0){const c=new Uint32Array([0]);return this.#p.set(t,c),c}const i=this.#h;if(i==null||!i.isConnected)return;const s=k("div",{style:{position:"absolute",top:"0",left:"0",width:"100%",boxSizing:"border-box",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre-wrap",wordBreak:"break-word",font:"inherit",paddingInline:"1ch",tabSize:this.#t.tabSize.toString()},textContent:n},i),r=s.firstChild,o=document.createRange(),a=[];try{const c=s.getBoundingClientRect();if(c.width===0)return;const h=ns(n),d=c.left+this.#t.ch,l=h===void 0?n.length:h.length-1,f=m=>h===void 0?m:h[m],u=m=>(o.setStart(r,f(m)),o.setEnd(r,f(m+1)),o.getBoundingClientRect());a.push(0);let v=u(0).top,g=1;for(;g<l;){let m=g,C=l;for(;m<C;){const w=m+C>>1;u(w).top>v?C=w:m=w+1}if(m>=l)break;const{left:x,top:L}=u(m),S=ee()&&x-d>this.#t.ch/2;a.push(f(S?m-1:m)),v=L,g=m+1}const p=new Uint32Array(a.length+1);for(let m=0;m<a.length;m++)p[m]=a[m];return p[a.length]=n.length,this.#p.set(t,p),p}finally{s.remove()}}#Kt(t){const e=this.#xe(t);if(e!==void 0)return e;const n=this.#s?.getLineText(t)?.length??0;return Uint32Array.of(0,n)}#Xe({startContainer:t,endContainer:e}){const n=this.#h;return n===void 0?!1:n.contains(t)&&n.contains(e)}#Pt(t){const e=this.#s?.lineCount??0;return t<0||t>=e?!1:this.#ht(t)!==void 0}};export{ls as Editor,wn as TextDocument};
|