@davmash/bygone 0.10.1 → 0.11.1

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +64 -0
  3. package/bin/bygone.js +18 -1
  4. package/cli/commandSpec.js +22 -2
  5. package/cli/completions.js +30 -8
  6. package/cli/correspondence.js +71 -0
  7. package/cli/dependencies.js +62 -0
  8. package/cli/evidence.js +67 -0
  9. package/cli/present.js +61 -16
  10. package/cli/tour.js +18 -1
  11. package/cli/tourExport.js +1 -1
  12. package/completions/_bygone +15 -3
  13. package/completions/bygone +13 -5
  14. package/completions/bygone.fish +9 -0
  15. package/docs/change-tour-format.md +60 -6
  16. package/docs/correspondence.md +259 -0
  17. package/docs/dependencies.md +94 -0
  18. package/docs/evidence-review.md +163 -0
  19. package/docs/generating-change-tours.md +3 -0
  20. package/docs/present.md +3 -0
  21. package/docs/product-surface.md +2 -1
  22. package/docs/releasing.md +11 -0
  23. package/docs/vscode-integration.md +183 -0
  24. package/media/diff.worker.js +10 -9
  25. package/media/webview.css +1 -1
  26. package/media/webview.js +167 -167
  27. package/out/changeCorrespondence.js +739 -0
  28. package/out/changeTour.js +1366 -967
  29. package/out/dependencyGraph.js +213939 -0
  30. package/out/gitComparison.js +4 -0
  31. package/out/requirements.js +427 -0
  32. package/out/reviewDependencies.js +669 -0
  33. package/out/reviewWorkspace.js +1129 -0
  34. package/out/standalone-main.js +3382 -1341
  35. package/out/tourCoverage.js +1852 -1448
  36. package/package.json +2 -2
  37. package/schemas/change-tour-source.schema.json +48 -3
  38. package/web/export-runtime.json +6 -6
  39. package/web/index.html +13 -0
  40. package/web/presenter.css +81 -0
  41. package/web/web-host.js +23 -20
@@ -0,0 +1,183 @@
1
+ # VS Code SCM, symbols and document editing
2
+
3
+ The contextual Bygone panel uses VS Code's built-in Git API for repository
4
+ identity and change notifications. Source Control actions choose HEAD → index
5
+ or index → working document. Ordinary source following chooses HEAD → working
6
+ document. Symbol navigation changes the focus within that comparison, never
7
+ its revisions. Native SCM diff following is opt-in.
8
+
9
+ ## Snapshot and edit contract
10
+
11
+ `followController.ts` owns the comparison and captured endpoints. HEAD and index
12
+ reads are checked again before publication; working content comes from the open
13
+ `TextDocument`, including unsaved edits. Each policy reads only its endpoints.
14
+ Staged comparisons therefore remain usable even if unrelated working bytes are
15
+ binary or oversized. Git renames retain separate source and destination paths.
16
+
17
+ The installed document-symbol provider identifies the enclosing declaration.
18
+ `liveSymbols.ts` runs Strand's existing inventory and correspondence matcher in
19
+ a cancelable worker. Whole-snapshot and symbol-substring digests are checked
20
+ before accepting ranges. Dirty-to-staged navigation needs an accepted mapping;
21
+ matching names or offsets are insufficient. Committed correspondence artifacts
22
+ and their validation contract are unchanged.
23
+
24
+ Native insertions exactly at either edge of a focused symbol return to file
25
+ context: the inserted text may belong to that declaration or its neighbor.
26
+ Boundary edits made inside Bygone retain the known slice binding. Edits strictly
27
+ inside a slice and shifts caused by edits before it continue to track normally.
28
+
29
+ Working full-file views and symbol slices are projections of the same document.
30
+ `followSync.js` allows one edit in flight and keeps subsequent typing until an
31
+ acknowledgment. `followEdits.ts` computes a granular replacement, preserving
32
+ unrelated text and UTF-16/CRLF boundaries. Before submission, the controller
33
+ checks the projection identity, document version, range and content. An older
34
+ token from an unchanged refresh is accepted only when all those checks still
35
+ match the current projection; a changed version is always rejected. There is no
36
+ asynchronous gap between that check and `workspace.applyEdit`.
37
+
38
+ VS Code's extension host attaches the open document's version to bulk text edits;
39
+ the main thread rejects a changed version before applying them. See the
40
+ [1.74 extension-host bulk edit implementation](https://github.com/microsoft/vscode/blob/1.74.0/src/vs/workbench/api/common/extHostBulkEdits.ts)
41
+ and [main-thread validation](https://github.com/microsoft/vscode/blob/1.74.0/src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts).
42
+ The integration suite submits competing native and Bygone edits without waiting
43
+ between them and verifies rejection rather than an overwritten native edit.
44
+
45
+ Rejected drafts open in untitled recovery documents. Pending text is also kept
46
+ in workspace state for restoration. Draft clearing is guarded against newer
47
+ drafts. Save, undo and redo operate on the authoritative VS Code document; typing
48
+ does not save or stage. Other comparison panels observe the document change.
49
+ The existing manual two-way bridge also checks its base text and document version.
50
+
51
+ Save, undo and redo retain the document binding from when they were requested.
52
+ Commands queued behind an edit execute in order, including repeated undo requests.
53
+ If the comparison changes before a document command executes, Bygone rejects it
54
+ with a notice rather than applying it to the new document. Recovery deduplicates
55
+ a draft only against an entire current, version-validated projection; a matching
56
+ prefix or an obsolete snapshot is insufficient.
57
+
58
+ Pin freezes the target, historical snapshots and symbol focus. A pinned working
59
+ projection remains editable. Repository changes produce a notice until Resume;
60
+ unpinned comparisons keep their policy when a file leaves its SCM group.
61
+ Live staged and working comparisons reconcile Git-reported rename paths while
62
+ preserving their comparison policy. A captured staged pin remains
63
+ visible even if the live index enters a conflict; Resume checks the current
64
+ index again. Working-change actions also appear in Git's separate untracked group.
65
+ If the Git API repository disappears, live SCM comparisons become unavailable
66
+ until it returns. Captured staged pins remain read-only and explicitly report
67
+ that Git integration is unavailable; Resume requires the repository again.
68
+
69
+ ## Supported scope and budgets
70
+
71
+ - Trusted local text files; maximum 128 KiB and 5,000 lines per endpoint.
72
+ - JavaScript/TypeScript symbol analysis, including JSX/TSX, for the selected file
73
+ pair or Git-reported rename. No repository-wide cross-file symbol matching.
74
+ - HEAD/index/absent endpoints are read-only. Conflicts, binary/invalid text and
75
+ unsupported editor inputs have explicit unavailable states.
76
+ - The matcher allows 300 ms, 20,000 candidate comparisons and 2,000 result records.
77
+ A 2.5-second worker deadline also bounds inventory/parsing and startup. Cancellation
78
+ terminates stale workers. File rendering does not wait for optional analysis.
79
+ - Missing, ambiguous or budget-limited correspondence retains file context or a
80
+ known one-sided slice; it never supplies an inferred counterpart. Invalid syntax
81
+ during typing retains the guarded editable range until it can be analyzed again.
82
+
83
+ ## Reproducing verification
84
+
85
+ Run the normal checks from a clean dependency install:
86
+
87
+ ```sh
88
+ npm ci
89
+ npm test
90
+ npm run lint
91
+ npm run bundle:check
92
+ npm run package:vsix
93
+ ```
94
+
95
+ The Extension Host runner makes disposable synthetic repositories and a disposable
96
+ extension profile. It never stages, commits or checks out the developer's repository.
97
+ On Linux with Xvfb and an installed VS Code binary:
98
+
99
+ ```sh
100
+ BYGONE_VSCODE_EXECUTABLE=/path/to/code xvfb-run -a node scripts/test-following.mjs
101
+ BYGONE_SCM_TEST=1 BYGONE_VSCODE_EXECUTABLE=/path/to/code xvfb-run -a node scripts/test-following.mjs
102
+ ```
103
+
104
+ Set `BYGONE_VSCODE_VERSION` instead to let the runner download a version. Compile
105
+ first (`npm test` includes compilation). The SCM suite injects a renderer driver
106
+ only into the disposable test bundle, so it exercises actual Monaco edits and
107
+ messages without adding production test commands.
108
+
109
+ ## Verification record: 2026-10-24
110
+
111
+ Implementation branch: `feat/vscode-scm-symbol-integration`, based on
112
+ `ec318cfbd9d9cddef2fcac150723958c0f7987c2`. These checks ran against the feature
113
+ implementation before its initial commit, not a published release.
114
+
115
+ | Check | Result |
116
+ | --- | --- |
117
+ | Regression suite | 433 Node tests plus the existing diff-engine runner passed |
118
+ | TypeScript, ESLint, renderer size budgets | Passed |
119
+ | VSIX contents and packaging | Passed; 14 archive entries, 2.65 MB compressed, including the 3.39 MiB Strand worker |
120
+ | Original following suite | 16 cases passed on VS Code 1.74.0 and 1.143.1, Linux ARM64 in a fresh Lima guest checkout |
121
+ | SCM/symbol/editing suite | 19 cases passed on both versions; staged/dirty separation, full-file and slice edits, save/shared undo/redo, range shifts, temporary syntax errors, concurrent rejection/recovery, composition across unchanged refreshes, rapid typing, multiple panels, exact snapshot reveal, native Git lifecycle and disabled-Git fallback |
122
+ | Snapshot fixtures | Added/deleted/renamed files, unborn HEAD, linked worktrees, multiple repositories, conflict stages, encoding/binary/size rejection |
123
+ | Symbol adapter | Renames, duplicate method names, unmatched additions, digest/range validation and worker cancellation |
124
+
125
+ Cold worker measurements in the same Linux ARM64 guest (three runs per input,
126
+ adding an unsaved prefix; no warm worker reuse):
127
+
128
+ | Input | Bytes | Symbols / accepted pairs | Elapsed |
129
+ | --- | ---: | ---: | ---: |
130
+ | `followEdits.ts` | 2,272 | 6 / 6 | 109–153 ms |
131
+ | `gitIntegration.ts` | 4,403 | 22 / 22 | 111–171 ms |
132
+ | `followController.ts` | 35,789 | 70 / 70 | 222–238 ms |
133
+ | 50 repetitive generated functions | 3,380 | 50 / 0 (record budget) | 122–130 ms |
134
+ | 500 repetitive generated functions | 34,781 | 500 / 0 (candidate budget) | 186–202 ms |
135
+
136
+ These are bounded fixture observations, not a general latency guarantee.
137
+ The repetitive cases deliberately demonstrate safe budget fallbacks.
138
+
139
+ Verification limits: IME coverage dispatches composition events in real Monaco;
140
+ it does not drive an operating-system input method. Symbol navigation exercises
141
+ the installed TypeScript provider and command-generated cursor selections, not
142
+ physical clicks in Outline/Go to Symbol. Restoration exercises the serializer
143
+ and persisted-draft constructor path, not a whole application restart. Remote and
144
+ untrusted workspace guards were inspected; a remote host and restricted-mode
145
+ window were not launched. macOS/Windows Extension Hosts, marketplace installation,
146
+ release CI and publication were not exercised.
147
+
148
+ ## Review-fix verification: 2026-10-26
149
+
150
+ The fixes applied over `cfd5e335d75f2be324c0865abe4c2f5bdece06f5` passed
151
+ 435 Node tests plus the existing diff-engine runner, TypeScript compilation,
152
+ ESLint, renderer size budgets and VSIX packaging. In a fresh Linux ARM64 Lima
153
+ checkout, all 25 SCM cases and all 16 original following cases passed on each
154
+ of VS Code 1.74.0 and 1.143.1. Host and guest source/test SHA-256 hashes matched.
155
+
156
+ Six added Extension Host cases cover complete rejected deletion/reversion recovery,
157
+ deferred Save/Undo/Redo across a comparison switch, repeated Undo followed by
158
+ Save and Pin, a live staged rename, conflict-after-staged-pin, and separate
159
+ untracked resources. The untracked case checks the contributed menu conditions
160
+ and executes the command with a resource argument; it does not physically click
161
+ the SCM menu. The earlier platform, IME, restart, remote/restricted-host and
162
+ release-verification limits still apply.
163
+
164
+ ## Rebase and follow-up fixes: 2026-10-26
165
+
166
+ Rebased onto main `728f41e6`, preserving both the requirements and VS Code
167
+ build/test entries. The rebased changes passed 464 Node tests plus the existing
168
+ diff-engine runner. Final source passed TypeScript, ESLint, renderer size budgets
169
+ and VSIX packaging. A fresh Linux ARM64 Lima checkout passed all 29 SCM cases
170
+ and all 16 following cases on each of VS Code 1.74.0 and 1.143.1.
171
+
172
+ New regressions cover native insertions at both symbol boundaries, index refresh
173
+ for two-dot filenames, live working comparisons through successive staged
174
+ renames, loss/recovery of the Git API in an already-open comparison, and the
175
+ explicit read-only snapshot behavior of a staged pin while Git is unavailable.
176
+ The platform and interaction limits above still apply; hosted CI was not run.
177
+
178
+ ## Pinned evidence handoff
179
+
180
+ [Evidence Review](evidence-review.md) uses this same editing bridge for full-file
181
+ and exact symbol projections. Its left endpoint is an immutable cited snapshot,
182
+ and its Return action restores the originating review. It does not stage files
183
+ or alter saved evidence while editing.
@@ -1,15 +1,16 @@
1
- "use strict";(()=>{function C(){}C.prototype={diff:function(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var s=this;function l(S){return i?(setTimeout(function(){i(void 0,S)},0),!0):S}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var d=t.length,c=e.length,f=1,u=d+c;o.maxEditLength&&(u=Math.min(u,o.maxEditLength));var h=(r=o.timeout)!==null&&r!==void 0?r:1/0,b=Date.now()+h,y=[{oldPos:-1,lastComponent:void 0}],a=this.extractCommon(y[0],t,e,0);if(y[0].oldPos+1>=c&&a+1>=d)return l([{value:this.join(t),count:t.length}]);var g=-1/0,m=1/0;function w(){for(var S=Math.max(g,-f);S<=Math.min(m,f);S+=2){var x=void 0,E=y[S-1],v=y[S+1];E&&(y[S-1]=void 0);var N=!1;if(v){var I=v.oldPos-S;N=v&&0<=I&&I<d}var T=E&&E.oldPos+1<c;if(!N&&!T){y[S]=void 0;continue}if(!T||N&&E.oldPos+1<v.oldPos?x=s.addToPath(v,!0,void 0,0):x=s.addToPath(E,void 0,!0,1),a=s.extractCommon(x,t,e,S),x.oldPos+1>=c&&a+1>=d)return l(He(s,x.lastComponent,t,e,s.useLongestToken));y[S]=x,x.oldPos+1>=c&&(m=Math.min(m,S-1)),a+1>=d&&(g=Math.max(g,S+1))}f++}if(i)(function S(){setTimeout(function(){if(f>u||Date.now()>b)return i();w()||S()},0)})();else for(;f<=u&&Date.now()<=b;){var p=w();if(p)return p}},addToPath:function(e,t,r,o){var i=e.lastComponent;return i&&i.added===t&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:t,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:i}}},extractCommon:function(e,t,r,o){for(var i=t.length,s=r.length,l=e.oldPos,d=l-o,c=0;d+1<i&&l+1<s&&this.equals(t[d+1],r[l+1]);)d++,l++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=l,d},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function He(n,e,t,r,o){for(var i=[],s;e;)i.push(e),s=e.previousComponent,delete e.previousComponent,e=s;i.reverse();for(var l=0,d=i.length,c=0,f=0;l<d;l++){var u=i[l];if(u.removed){if(u.value=n.join(r.slice(f,f+u.count)),f+=u.count,l&&i[l-1].added){var b=i[l-1];i[l-1]=i[l],i[l]=b}}else{if(!u.added&&o){var h=t.slice(c,c+u.count);h=h.map(function(a,g){var m=r[f+g];return m.length>a.length?m:a}),u.value=n.join(h)}else u.value=n.join(t.slice(c,c+u.count));c+=u.count,u.added||(f+=u.count)}}var y=i[d-1];return d>1&&typeof y.value=="string"&&(y.added||y.removed)&&n.equals("",y.value)&&(i[d-2].value+=y.value,i.pop()),i}var We=new C;function ue(n,e,t){return We.diff(n,e,t)}var fe=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ae=/\S/,Z=new C;Z.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!ae.test(n)&&!ae.test(e)};Z.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&fe.test(e[t])&&fe.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function ce(n,e,t){return Z.diff(n,e,t)}var de=new C;de.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
2
- `));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var r=0;r<t.length;r++){var o=t[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var $e=new C;$e.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Be=new C;Be.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function U(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?U=function(e){return typeof e}:U=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(n)}var Ge=Object.prototype.toString,H=new C;H.useLongestToken=!0;H.tokenize=de.tokenize;H.castInput=function(n){var e=this.options,t=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(i,s){return typeof s>"u"?t:s}:r;return typeof n=="string"?n:JSON.stringify(J(n,null,null,o),o," ")};H.equals=function(n,e){return C.prototype.equals.call(H,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function J(n,e,t,r,o){e=e||[],t=t||[],r&&(n=r(o,n));var i;for(i=0;i<e.length;i+=1)if(e[i]===n)return t[i];var s;if(Ge.call(n)==="[object Array]"){for(e.push(n),s=new Array(n.length),t.push(s),i=0;i<n.length;i+=1)s[i]=J(n[i],e,t,r,o);return e.pop(),t.pop(),s}if(n&&n.toJSON&&(n=n.toJSON()),U(n)==="object"&&n!==null){e.push(n),s={},t.push(s);var l=[],d;for(d in n)n.hasOwnProperty(d)&&l.push(d);for(l.sort(),i=0;i<l.length;i+=1)d=l[i],s[d]=J(n[d],e,t,r,d);e.pop(),t.pop()}else s=n;return s}var P=new C;P.tokenize=function(n){return n.slice()};P.join=P.removeEmpty=function(n){return n};function ge(n,e,t){return P.diff(n,e,t)}var Pe=2e4,ze=100,Y=Fe("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Pe),Ae=Fe("BYGONE_DIFF_TIMEOUT_MS",ze);function Re(n,e,t={}){let r=pe(n),o=pe(e);if(n===e)return me(r);if(r.length===o.length&&r.every((a,g)=>a===o[g])){let a=me(r),g=n.match(/[^\n]*\n|[^\n]+$/g)||[],m=e.match(/[^\n]*\n|[^\n]+$/g)||[];return r.forEach((w,p)=>{g[p]!==m[p]&&(a.leftLines[p].kind=a.rows[p].left.kind="removed",a.rightLines[p].kind=a.rows[p].right.kind="added",a.leftLines[p].inlineDetail=a.rightLines[p].inlineDetail="line-ending",a.blocks.push(W("replace",p,p+1,p,p+1)))}),a.blocks=he(a.blocks),a.hasChanges=!0,a.formattingOnly=!0,a}let i=qe(r,o),s=ge(i.left,i.right,{timeout:t.timeoutMs??Ae});if(!s)return Xe(r,o);let l=s.map(a=>({...a,value:a.value.map(g=>i.lines[g])})),d=[],c=[],f=[],u=[],h=1,b=1;for(let a=0;a<l.length;a++){let g=l[a],m=g.removed?g.value:[],w=g.added?g.value:[];if(!g.added&&!g.removed){for(let p of g.value)c.push(A("context",p,h)),f.push(A("context",p,b)),d.push(_(M("context",p,h++),M("context",p,b++)));continue}if(g.removed&&a+1<l.length&&l[a+1].added){let p=l[a+1],S=Ye(m,p.value,h,b,d,c,f,u);h=S.left,b=S.right,a++;continue}if(g.removed){let p=c.length,S=f.length;for(let x of m)c.push(A("removed",x,h)),d.push(_(M("removed",x,h++),O()));u.push(W("delete",p,c.length,S,f.length));continue}if(g.added){let p=c.length,S=f.length;for(let x of w)f.push(A("added",x,b)),d.push(_(O(),M("added",x,b++)));u.push(W("insert",p,c.length,S,f.length))}}let y=d.some(a=>a.left.kind!=="context"||a.right.kind!=="context");return Te({rows:d,leftLines:c,rightLines:f,blocks:he(u),reflows:u.filter(a=>a.reflow),hasChanges:y,quality:"exact"})}function Te(n){for(let e of n.blocks)if(e.kind==="replace")for(let t of["left","right"])for(let r=e[`${t}Start`];r<e[`${t}End`];r++){let o=n[`${t}Lines`][r];o.kind!=="context"&&!o.segments&&(o.inlineDetail="omitted")}return n}function he(n){let e=[],t=!1;for(let o of n){let i=o.kind!=="replace",s=e[e.length-1];i&&t&&s.leftEnd===o.leftStart&&s.rightEnd===o.rightStart?(s.leftEnd=o.leftEnd,s.rightEnd=o.rightEnd,s.leftEnd>s.leftStart&&s.rightEnd>s.rightStart&&(s.kind="replace")):e.push({...o}),t=i}let r=[];for(let o of e){let i={...o};delete i.reflow;let s=r[r.length-1];s?.kind===i.kind&&s.leftEnd===i.leftStart&&s.rightEnd===i.rightStart?(s.leftEnd=i.leftEnd,s.rightEnd=i.rightEnd):r.push(i)}return r}function qe(n,e){let t=new Map,r=[],o=i=>{let s=t.get(i);if(s!==void 0)return s;let l=r.length;return t.set(i,l),r.push(i),l};return{left:n.map(o),right:e.map(o),lines:r}}function me(n){return{rows:n.map((e,t)=>_(M("context",e,t+1),M("context",e,t+1))),leftLines:n.map((e,t)=>A("context",e,t+1)),rightLines:n.map((e,t)=>A("context",e,t+1)),blocks:[],hasChanges:!1,quality:"exact"}}function Xe(n,e){let t=n.map((s,l)=>A("removed",s,l+1)),r=e.map((s,l)=>A("added",s,l+1)),o=[...n.map((s,l)=>_(M("removed",s,l+1),O())),...e.map((s,l)=>_(O(),M("added",s,l+1)))],i="replace";return n.length===0?i="insert":e.length===0&&(i="delete"),Te({rows:o,leftLines:t,rightLines:r,blocks:o.length===0?[]:[W(i,0,n.length,0,e.length)],hasChanges:o.length>0,quality:"fallback"})}function pe(n){if(n.length===0)return[];let e=n.replace(/\r\n/g,`
1
+ "use strict";(()=>{function C(){}C.prototype={diff:function(e,t){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=o.callback;typeof o=="function"&&(r=o,o={}),this.options=o;var s=this;function l(x){return r?(setTimeout(function(){r(void 0,x)},0),!0):x}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var d=t.length,u=e.length,f=1,a=d+u;o.maxEditLength&&(a=Math.min(a,o.maxEditLength));var v=(i=o.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+v,p=[{oldPos:-1,lastComponent:void 0}],c=this.extractCommon(p[0],t,e,0);if(p[0].oldPos+1>=u&&c+1>=d)return l([{value:this.join(t),count:t.length}]);var h=-1/0,g=1/0;function b(){for(var x=Math.max(h,-f);x<=Math.min(g,f);x+=2){var y=void 0,I=p[x-1],w=p[x+1];I&&(p[x-1]=void 0);var N=!1;if(w){var E=w.oldPos-x;N=w&&0<=E&&E<d}var T=I&&I.oldPos+1<u;if(!N&&!T){p[x]=void 0;continue}if(!T||N&&I.oldPos+1<w.oldPos?y=s.addToPath(w,!0,void 0,0):y=s.addToPath(I,void 0,!0,1),c=s.extractCommon(y,t,e,x),y.oldPos+1>=u&&c+1>=d)return l(We(s,y.lastComponent,t,e,s.useLongestToken));p[x]=y,y.oldPos+1>=u&&(g=Math.min(g,x-1)),c+1>=d&&(h=Math.max(h,x+1))}f++}if(r)(function x(){setTimeout(function(){if(f>a||Date.now()>m)return r();b()||x()},0)})();else for(;f<=a&&Date.now()<=m;){var S=b();if(S)return S}},addToPath:function(e,t,i,o){var r=e.lastComponent;return r&&r.added===t&&r.removed===i?{oldPos:e.oldPos+o,lastComponent:{count:r.count+1,added:t,removed:i,previousComponent:r.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:i,previousComponent:r}}},extractCommon:function(e,t,i,o){for(var r=t.length,s=i.length,l=e.oldPos,d=l-o,u=0;d+1<r&&l+1<s&&this.equals(t[d+1],i[l+1]);)d++,l++,u++;return u&&(e.lastComponent={count:u,previousComponent:e.lastComponent}),e.oldPos=l,d},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],i=0;i<e.length;i++)e[i]&&t.push(e[i]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function We(n,e,t,i,o){for(var r=[],s;e;)r.push(e),s=e.previousComponent,delete e.previousComponent,e=s;r.reverse();for(var l=0,d=r.length,u=0,f=0;l<d;l++){var a=r[l];if(a.removed){if(a.value=n.join(i.slice(f,f+a.count)),f+=a.count,l&&r[l-1].added){var m=r[l-1];r[l-1]=r[l],r[l]=m}}else{if(!a.added&&o){var v=t.slice(u,u+a.count);v=v.map(function(c,h){var g=i[f+h];return g.length>c.length?g:c}),a.value=n.join(v)}else a.value=n.join(t.slice(u,u+a.count));u+=a.count,a.added||(f+=a.count)}}var p=r[d-1];return d>1&&typeof p.value=="string"&&(p.added||p.removed)&&n.equals("",p.value)&&(r[d-2].value+=p.value,r.pop()),r}var $e=new C;function de(n,e,t){return $e.diff(n,e,t)}var ue=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ce=/\S/,Q=new C;Q.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!ce.test(n)&&!ce.test(e)};Q.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&ue.test(e[t])&&ue.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function ge(n,e,t){return Q.diff(n,e,t)}var he=new C;he.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
2
+ `));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var i=0;i<t.length;i++){var o=t[i];i%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var Be=new C;Be.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ge=new C;Ge.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function U(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?U=function(e){return typeof e}:U=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(n)}var Ue=Object.prototype.toString,W=new C;W.useLongestToken=!0;W.tokenize=he.tokenize;W.castInput=function(n){var e=this.options,t=e.undefinedReplacement,i=e.stringifyReplacer,o=i===void 0?function(r,s){return typeof s>"u"?t:s}:i;return typeof n=="string"?n:JSON.stringify(Z(n,null,null,o),o," ")};W.equals=function(n,e){return C.prototype.equals.call(W,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function Z(n,e,t,i,o){e=e||[],t=t||[],i&&(n=i(o,n));var r;for(r=0;r<e.length;r+=1)if(e[r]===n)return t[r];var s;if(Ue.call(n)==="[object Array]"){for(e.push(n),s=new Array(n.length),t.push(s),r=0;r<n.length;r+=1)s[r]=Z(n[r],e,t,i,o);return e.pop(),t.pop(),s}if(n&&n.toJSON&&(n=n.toJSON()),U(n)==="object"&&n!==null){e.push(n),s={},t.push(s);var l=[],d;for(d in n)n.hasOwnProperty(d)&&l.push(d);for(l.sort(),r=0;r<l.length;r+=1)d=l[r],s[d]=Z(n[d],e,t,i,d);e.pop(),t.pop()}else s=n;return s}var z=new C;z.tokenize=function(n){return n.slice()};z.join=z.removeEmpty=function(n){return n};function ee(n,e,t){return z.diff(n,e,t)}var Pe=2e4,qe=100,j=Fe("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Pe),Re=Fe("BYGONE_DIFF_TIMEOUT_MS",qe);function Te(n,e,t={}){let i=ve(n),o=ve(e);if(n===e)return pe(i);if(i.length===o.length&&i.every((m,p)=>m===o[p])){let m=pe(i),p=n.match(/[^\n]*\n|[^\n]+$/g)||[],c=e.match(/[^\n]*\n|[^\n]+$/g)||[];return i.forEach((h,g)=>{p[g]!==c[g]&&(m.leftLines[g].kind=m.rows[g].left.kind="removed",m.rightLines[g].kind=m.rows[g].right.kind="added",m.leftLines[g].inlineDetail=m.rightLines[g].inlineDetail="line-ending",m.blocks.push($("replace",g,g+1,g,g+1)))}),m.blocks=me(m.blocks),m.hasChanges=!0,m.formattingOnly=!0,m}let r=Xe(i,o,t.timeoutMs??Re);if(!r)return Ye(i,o);let s=[],l=[],d=[],u=[],f=1,a=1;for(let m=0;m<r.length;m++){let p=r[m],c=p.removed?p.value:[],h=p.added?p.value:[];if(!p.added&&!p.removed){for(let g of p.value)l.push(R("context",g,f)),d.push(R("context",g,a)),s.push(k(A("context",g,f++),A("context",g,a++)));continue}if(p.removed&&m+1<r.length&&r[m+1].added){let g=r[m+1],b=Ke(c,g.value,f,a,s,l,d,u);f=b.left,a=b.right,m++;continue}if(p.removed){let g=l.length,b=d.length;for(let S of c)l.push(R("removed",S,f)),s.push(k(A("removed",S,f++),H()));u.push($("delete",g,l.length,b,d.length));continue}if(p.added){let g=l.length,b=d.length;for(let S of h)d.push(R("added",S,a)),s.push(k(H(),A("added",S,a++)));u.push($("insert",g,l.length,b,d.length))}}let v=s.some(m=>m.left.kind!=="context"||m.right.kind!=="context");return Ce({rows:s,leftLines:l,rightLines:d,blocks:me(u),reflows:u.filter(m=>m.reflow),hasChanges:v,quality:"exact"})}function Ce(n){for(let e of n.blocks)if(e.kind==="replace")for(let t of["left","right"])for(let i=e[`${t}Start`];i<e[`${t}End`];i++){let o=n[`${t}Lines`][i];o.kind!=="context"&&!o.segments&&(o.inlineDetail="omitted")}return n}function me(n){let e=[],t=!1;for(let o of n){let r=o.kind!=="replace",s=e[e.length-1];r&&t&&s.leftEnd===o.leftStart&&s.rightEnd===o.rightStart?(s.leftEnd=o.leftEnd,s.rightEnd=o.rightEnd,s.leftEnd>s.leftStart&&s.rightEnd>s.rightStart&&(s.kind="replace")):e.push({...o}),t=r}let i=[];for(let o of e){let r={...o};delete r.reflow;let s=i[i.length-1];s?.kind===r.kind&&s.leftEnd===r.leftStart&&s.rightEnd===r.rightStart?(s.leftEnd=r.leftEnd,s.rightEnd=r.rightEnd):i.push(r)}return i}function Xe(n,e,t){let i=Date.now()+t,o=p=>p.flatMap((c,h)=>{let g=M(c);return O(g)?[{key:g,index:h}]:[]}),r=o(n),s=o(e),l=ee(r.map(p=>p.key),s.map(p=>p.key),{timeout:i-Date.now()});if(!l)return;let d=[],u=0,f=0,a=(p,c)=>{if(u===p&&f===c)return!0;let h=je(n.slice(u,p),e.slice(f,c)),g=ee(h.left,h.right,{timeout:i-Date.now()});return g?(d.push(...g.map(b=>({...b,value:b.value.map(S=>h.lines[S])}))),!0):!1},v=0,m=0;for(let p of l){if(p.removed){v+=p.value.length;continue}if(p.added){m+=p.value.length;continue}for(let c=0;c<p.value.length;c++){let h=r[v++].index,g=s[m++].index;if(!a(h,g))return;let b=n[h],S=e[g];b===S?d.push({value:[b]}):d.push({removed:!0,value:[b]},{added:!0,value:[S]}),u=h+1,f=g+1}}return a(n.length,e.length)?d:void 0}function je(n,e){let t=new Map,i=[],o=r=>{let s=t.get(r);if(s!==void 0)return s;let l=i.length;return t.set(r,l),i.push(r),l};return{left:n.map(o),right:e.map(o),lines:i}}function pe(n){return{rows:n.map((e,t)=>k(A("context",e,t+1),A("context",e,t+1))),leftLines:n.map((e,t)=>R("context",e,t+1)),rightLines:n.map((e,t)=>R("context",e,t+1)),blocks:[],hasChanges:!1,quality:"exact"}}function Ye(n,e){let t=n.map((s,l)=>R("removed",s,l+1)),i=e.map((s,l)=>R("added",s,l+1)),o=[...n.map((s,l)=>k(A("removed",s,l+1),H())),...e.map((s,l)=>k(H(),A("added",s,l+1)))],r="replace";return n.length===0?r="insert":e.length===0&&(r="delete"),Ce({rows:o,leftLines:t,rightLines:i,blocks:o.length===0?[]:[$(r,0,n.length,0,e.length)],hasChanges:o.length>0,quality:"fallback"})}function ve(n){if(n.length===0)return[];let e=n.replace(/\r\n/g,`
3
3
  `).split(`
4
- `);return e[e.length-1]===""&&e.pop(),e}function Ye(n,e,t,r,o,i,s,l){let d=K(n,e),c=d.filter(v=>v.left!==void 0&&v.right!==void 0&&ne(v.left,v.right)).length,f=!d.some(v=>v.reflow)&&Ke(n,e,c),u=d.flatMap(v=>v.reflow||v.left===void 0||v.right===void 0||ne(v.left,v.right)?[v]:[{left:v.left},{right:v.right}]),h=[];for(let v=0;v<u.length;){let N=u[v];if(N.reflow||N.left!==void 0&&N.right!==void 0){h.push(N),v++;continue}let I=v;for(;v<u.length&&!u[v].reflow&&(u[v].left===void 0||u[v].right===void 0);)v++;let T=u.slice(I,v),L=T.filter(F=>F.left!==void 0),D=T.filter(F=>F.right!==void 0);if(L.length===1&&D.length===1)h.push({left:L[0].left,right:D[0].right});else for(let F of T)h.push(F)}let b=t,y=r,a=[],g=[],m=()=>{vn(a,g),a=[],g=[]},w,p=!1,S=i.length,x=s.length,E=()=>{if(!w)return;let v=W(w,S,i.length,x,s.length);p&&(v.reflow=!0),l.push(v)};for(let{left:v,right:N,reflow:I}of h){(I||v!==void 0&&N!==void 0)&&m();let T=f||I||v!==void 0&&N!==void 0?"replace":v!==void 0?"delete":"insert";(w!==T||p!==!!I||I?.start)&&(E(),w=T,p=!!I,S=i.length,x=s.length);let L,D;v!==void 0&&(L=A("removed",v,b),i.push(L)),N!==void 0&&(D=A("added",N,y),s.push(D)),I?(L&&(L.segments=I.leftSegments),D&&(D.segments=I.rightSegments)):L&&D?pn(L,D):f&&(L&&Me(L),D&&Me(D)),!I&&(v===void 0||N===void 0)&&(L&&a.push(L),D&&g.push(D)),o.push(_(v===void 0?O():M("removed",v,b++),N===void 0?O():M("added",N,y++)))}return E(),m(),{left:b,right:y}}function ne(n,e){if(!n.trim()&&!e.trim()||V(n,e).eligible)return!0;let r=$(n);if(r&&r===$(e))return!0;let o=new Set(G(R(n)).filter(ve));return G(R(e)).some(i=>o.has(i)&&ve(i))}var je=new Set(["and","are","for","from","into","that","the","this","to","with"]);function ve(n){return n.length>=3&&/^[\p{L}\p{N}_$]+$/u.test(n)&&!je.has(n)}function Ke(n,e,t){if(t===0)return!1;let r=Math.max(n.length,e.length);if(r<=2||t*2>=r)return!0;let o=[...n,...e].map(Ve);return o[0]!==null&&o.every(i=>i===o[0])}function Ve(n){let e=n.trimStart();return/^[-*+]\s+/.test(e)?"bullet":/^\d+[.)]\s+/.test(e)?"ordered":/^>\s+/.test(e)?"quote":null}var Ce=1e4,te=2e3,Je=.52,Ze=.35,_e=.38,Qe=.33,ke=.86,j=.08,z=.05,q=-.12,be=5e3,en=2e3,nn=5e7,we=4,tn=8,Q=4;function Se(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t],o=[r],i=r.match(/^(\s*)(?:[\w-]+:\s+|[-*+]\s+)(\S.*)$/);if(i&&!/^[|>\[{]/.test(i[2]))for(;t+1<n.length;){let s=n[t+1];if(!s.trim()||s.length-s.trimStart().length<=i[1].length||/^\s*(?:[\w-]+:|[-*+]\s|\d+[.)]\s|#)/.test(s))break;o.push(s),t++}e.push(o.join(`
4
+ `);return e[e.length-1]===""&&e.pop(),e}function Ke(n,e,t,i,o,r,s,l){let d=K(n,e),u=d.filter(w=>w.left!==void 0&&w.right!==void 0&&re(w.left,w.right)).length,f=!d.some(w=>w.reflow)&&Je(n,e,u),a=d.flatMap(w=>w.reflow||w.left===void 0||w.right===void 0||re(w.left,w.right)?[w]:[{left:w.left},{right:w.right}]),v=[];for(let w=0;w<a.length;){let N=a[w];if(N.reflow||N.left!==void 0&&N.right!==void 0){v.push(N),w++;continue}let E=w;for(;w<a.length&&!a[w].reflow&&(a[w].left===void 0||a[w].right===void 0);)w++;let T=a.slice(E,w),L=T.filter(F=>F.left!==void 0),D=T.filter(F=>F.right!==void 0);if(L.length===1&&D.length===1)v.push({left:L[0].left,right:D[0].right});else for(let F of T)v.push(F)}let m=t,p=i,c=[],h=[],g=()=>{wn(c,h),c=[],h=[]},b,S=!1,x=r.length,y=s.length,I=()=>{if(!b)return;let w=$(b,x,r.length,y,s.length);S&&(w.reflow=!0),l.push(w)};for(let{left:w,right:N,reflow:E}of v){(E||w!==void 0&&N!==void 0)&&g();let T=f||E||w!==void 0&&N!==void 0?"replace":w!==void 0?"delete":"insert";(b!==T||S!==!!E||E?.start)&&(I(),b=T,S=!!E,x=r.length,y=s.length);let L,D;w!==void 0&&(L=R("removed",w,m),r.push(L)),N!==void 0&&(D=R("added",N,p),s.push(D)),E?(L&&(L.segments=E.leftSegments),D&&(D.segments=E.rightSegments)):L&&D?bn(L,D):f&&(L&&Ae(L),D&&Ae(D)),!E&&(w===void 0||N===void 0)&&(L&&c.push(L),D&&h.push(D)),o.push(k(w===void 0?H():A("removed",w,m++),N===void 0?H():A("added",N,p++)))}return I(),g(),{left:m,right:p}}function re(n,e){if(!n.trim()&&!e.trim()||J(n,e).eligible)return!0;let i=B(n);if(i&&i===B(e))return!0;let o=new Set(G(M(n)).filter(be));return G(M(e)).some(r=>o.has(r)&&be(r))}var Ve=new Set(["and","are","for","from","into","that","the","this","to","with"]);function be(n){return n.length>=3&&/^[\p{L}\p{N}_$]+$/u.test(n)&&!Ve.has(n)}function Je(n,e,t){if(t===0)return!1;let i=Math.max(n.length,e.length);if(i<=2||t*2>=i)return!0;let o=[...n,...e].map(Ze);return o[0]!==null&&o.every(r=>r===o[0])}function Ze(n){let e=n.trimStart();return/^[-*+]\s+/.test(e)?"bullet":/^\d+[.)]\s+/.test(e)?"ordered":/^>\s+/.test(e)?"quote":null}var ke=1e4,ie=2e3,Qe=.52,en=.35,_e=.38,nn=.33,Oe=.86,Y=.08,P=.05,q=-.12,we=5e3,tn=2e3,rn=5e7,Se=4,on=8,ne=4;function xe(n){let e=[];for(let t=0;t<n.length;t++){let i=n[t],o=[i],r=i.match(/^(\s*)(?:[\w-]+:\s+|[-*+]\s+)(\S.*)$/);if(r&&!/^[|>\[{]/.test(r[2]))for(;t+1<n.length;){let s=n[t+1];if(!s.trim()||s.length-s.trimStart().length<=r[1].length||/^\s*(?:[\w-]+:|[-*+]\s|\d+[.)]\s|#)/.test(s))break;o.push(s),t++}e.push(o.join(`
5
5
  `))}return e}function K(n,e){if([...n,...e].some(o=>o.includes(`
6
- `)))return ee(n,e);let t=Se(n),r=Se(e);return t.length===n.length&&r.length===e.length?ee(n,e):ee(t,r).flatMap(o=>{let i=o.left?.split(`
6
+ `)))return te(n,e);let t=xe(n),i=xe(e);return t.length===n.length&&i.length===e.length?te(n,e):te(t,i).flatMap(o=>{let r=o.left?.split(`
7
7
  `)||[],s=o.right?.split(`
8
- `)||[];if(!i.length||!s.length)return[...i.map(u=>({left:u})),...s.map(u=>({right:u}))];if(i.length===1&&s.length===1)return[o];let d=le(o.left,o.right)||se(o.left,o.right),c=d&&k(d.leftSegments),f=d&&k(d.rightSegments);return Array.from({length:Math.max(i.length,s.length)},(u,h)=>({left:i[h],right:s[h],reflow:{start:h===0,leftSegments:c?.[h],rightSegments:f?.[h]}}))})}function ee(n,e){if(n.length===0)return e.map(a=>({right:a}));if(e.length===0)return n.map(a=>({left:a}));let t=0;for(;t<Math.min(n.length,e.length)&&n[t].trim()===e[t].trim();)t++;if(t)return[...n.slice(0,t).map((a,g)=>({left:a,right:e[g]})),...K(n.slice(t),e.slice(t))];let r=1,o=1,i=n[0].trim().replace(/\s+/g," "),s=e[0].trim().replace(/\s+/g," ");for(;i&&s&&i!==s;)if(s.startsWith(i+" ")&&r<n.length)i+=" "+n[r++].trim().replace(/\s+/g," ");else if(i.startsWith(s+" ")&&o<e.length)s+=" "+e[o++].trim().replace(/\s+/g," ");else break;if(i===s&&(r>1||o>1)&&![...n,...e].some(a=>a.includes(`
9
- `))){let a=le(n.slice(0,r).join(`
8
+ `)||[];if(!r.length||!s.length)return[...r.map(a=>({left:a})),...s.map(a=>({right:a}))];if(r.length===1&&s.length===1)return[o];let d=ae(o.left,o.right)||fe(o.left,o.right),u=d&&_(d.leftSegments),f=d&&_(d.rightSegments);return Array.from({length:Math.max(r.length,s.length)},(a,v)=>({left:r[v],right:s[v],reflow:{start:v===0,leftSegments:u?.[v],rightSegments:f?.[v]}}))})}function te(n,e){if(n.length===0)return e.map(c=>({right:c}));if(e.length===0)return n.map(c=>({left:c}));let t=0;for(;t<Math.min(n.length,e.length)&&n[t].trim()===e[t].trim();)t++;if(t)return[...n.slice(0,t).map((c,h)=>({left:c,right:e[h]})),...K(n.slice(t),e.slice(t))];let i=1,o=1,r=n[0].trim().replace(/\s+/g," "),s=e[0].trim().replace(/\s+/g," ");for(;r&&s&&r!==s;)if(s.startsWith(r+" ")&&i<n.length)r+=" "+n[i++].trim().replace(/\s+/g," ");else if(r.startsWith(s+" ")&&o<e.length)s+=" "+e[o++].trim().replace(/\s+/g," ");else break;if(r===s&&(i>1||o>1)&&![...n,...e].some(c=>c.includes(`
9
+ `))){let c=ae(n.slice(0,i).join(`
10
10
  `),e.slice(0,o).join(`
11
- `));if(a){let g=k(a.leftSegments),m=k(a.rightSegments);return[...Array.from({length:Math.max(r,o)},(w,p)=>({left:p<r?n[p]:void 0,right:p<o?e[p]:void 0,reflow:{start:p===0,leftSegments:g[p],rightSegments:m[p]}})),...K(n.slice(r),e.slice(o))]}}let l=n.reduce((a,g)=>a+Math.min(g.length,te),0),d=e.reduce((a,g)=>a+Math.min(g.length,te),0);if(l*d>nn)return ye(n,e,!0);if(n.length===1&&e.length===1){let a=V(n[0],e[0]);return!n[0].trim()&&!e[0].trim()||(a.eligible||a.score>=Ze)&&ne(n[0],e[0])&&ie(n[0],e[0])&&B(R(n[0]))&&B(R(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>Ce)return ye(n,e);let c=rn(n,e),f=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),u=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));f[0][0]=0;for(let a=1;a<=n.length;a++)f[a][0]=f[a-1][0]+q,u[a][0]="left";for(let a=1;a<=e.length;a++)f[0][a]=f[0][a-1]+q,u[0][a]="right";for(let a=1;a<=n.length;a++)for(let g=1;g<=e.length;g++){let m=c[a-1][g-1],p=[{move:"left",score:f[a-1][g]+q},{move:"right",score:f[a][g-1]+q},{move:"match",score:m===null?Number.NEGATIVE_INFINITY:f[a-1][g-1]+m}].reduce((S,x)=>x.score>S.score?x:S);f[a][g]=p.score,u[a][g]=p.move}let h=[],b=n.length,y=e.length;for(;b>0||y>0;){let a=u[b][y];a==="match"?h.push({left:n[--b],right:e[--y]}):a==="left"?h.push({left:n[--b]}):h.push({right:e[--y]})}return h.reverse()}function V(n,e){let t=R(n),r=R(e),o=B(t),i=B(r);if(o&&i&&t===r)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};if(!o||!i)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};let s=G(t),l=G(r),d=w=>w.length<=te?w:[0,Math.floor(w.length/2)-300,w.length-600].map(p=>w.slice(p,p+600)).join(" "),c=mn(d(t),d(r)),f=gn(s,l),u=Math.min(t.length,r.length)/Math.max(t.length,r.length),h=hn(s,l),b=w=>w.match(/^(?:(?:const|let|var)\s+)?([\p{L}_$][\p{L}\p{N}_$.-]*\s*(?::|=(?!=)))\s*/u)?.[1].replace(/\s+/g,""),y=b(t),a=y&&y===b(r)?.12:0,g=Math.min(1,c*.52+f*.32+u*.1+h*.06+a),m=a>0||c>=.52||f>=.45||c>=.48&&f>=.28;return{score:g,eligible:m&&g>=Je,characterSimilarity:c,tokenSimilarity:f,lengthSimilarity:u}}function rn(n,e){let t=n.map(a=>e.map(g=>V(a,g))),r=Oe(n,e),o=t.map(a=>re(a)),i=e.map((a,g)=>re(t.map(m=>m[g]))),s=t.map((a,g)=>a.map((m,w)=>{if(r.has(`${g}:${w}`))return Math.max(m.score,1);if(!m.eligible)return null;let p=o[g],S=i[w],x=m.score===p.best&&m.score===S.best,E=m.score>=ke?j/2:j,v=p.best-p.second>=E,N=S.best-S.second>=E;return x&&v&&N?m.score:null}));if(Math.max(n.length,e.length)>tn||Math.abs(n.length-e.length)>Q)return s;let l=(a,g,m)=>a.score>=_e&&ie(n[g],e[m])&&Math.abs(g-m)<=Q,d=t.map((a,g)=>X(a,(m,w)=>l(m,g,w))),c=e.map((a,g)=>X(t.map(m=>m[g]),(m,w)=>l(m,w,g))),f=(a,g,m)=>a.score>=Qe&&ie(n[g],e[m])&&Math.abs(g-m)<=Q,u=t.map((a,g)=>X(a,(m,w)=>f(m,g,w))),h=e.map((a,g)=>X(t.map(m=>m[g]),(m,w)=>f(m,w,g))),b=(a,g)=>{let m=t[a][g];if(!l(m,a,g))return!1;let w=d[a],p=c[g];return m.score===w.best&&m.score===p.best&&w.best-w.second>=z&&p.best-p.second>=z},y=(a,g)=>{let m=t[a][g];if(!f(m,a,g))return!1;let w=u[a],p=h[g];return m.score===w.best&&m.score===p.best&&w.best-w.second>=z&&p.best-p.second>=z};return s.map((a,g)=>a.map((m,w)=>{if(m!==null)return m;let p=b(g,w)&&(on(s,g,w)||sn(t,g,w,b)),S=ln(t,g,w,(x,E)=>f(t[x][E],x,E),y);return!p&&!S?null:t[g][w].score}))}function on(n,e,t){return e>0&&t>0&&n[e-1][t-1]!==null||e+1<n.length&&t+1<n[e+1].length&&n[e+1][t+1]!==null}function sn(n,e,t,r){return e>0&&t>0&&r(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&r(e+1,t+1)}function ln(n,e,t,r,o){let i=e,s=t;for(;i>0&&s>0&&r(i-1,s-1);)i--,s--;let l=e,d=t,c=n[e][t].score,f=1;for(;l+1<n.length&&d+1<n[l+1].length&&r(l+1,d+1);)l++,d++,c+=n[l][d].score,f++;for(let u=e-1,h=t-1;u>=i&&h>=s;u--,h--)c+=n[u][h].score,f++;return f>=3&&c/f>=_e&&o(i,s)&&o(l,d)}function X(n,e){let t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return n.forEach((o,i)=>{e(o,i)&&(o.score>t?(r=t,t=o.score):o.score>r&&(r=o.score))}),{best:t,second:r}}function re(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let r of n)r.eligible&&(r.score>e?(t=e,e=r.score):r.score>t&&(t=r.score));return{best:e,second:t}}function ye(n,e,t=!1){let r=fn(n,e,t);if(r.length===0)return[...n.map(l=>({left:l})),...e.map(l=>({right:l}))];let o=[],i=0,s=0;for(let l of r)Le(o,n.slice(i,l.leftIndex),e.slice(s,l.rightIndex)),o.push({left:n[l.leftIndex],right:e[l.rightIndex]}),i=l.leftIndex+1,s=l.rightIndex+1;return Le(o,n.slice(i),e.slice(s)),o}function fn(n,e,t){let r=an(n,e,t);if(r===null)return[];let o=Oe(n,e),i=r.map(({leftIndex:f,rightIndex:u,exact:h})=>({leftIndex:f,rightIndex:u,exact:h,structural:o.has(`${f}:${u}`),match:V(n[f],e[u])})).filter(f=>f.exact||f.structural||f.match.eligible),s=Ee(i,"leftIndex"),l=Ee(i,"rightIndex"),d=i.filter(f=>{if(f.exact||f.structural)return!0;let u=s.get(f.leftIndex),h=l.get(f.rightIndex);if(!u||!h||f.match.score!==u.best||f.match.score!==h.best)return!1;let b=f.match.score>=ke?j/2:j;return u.best-u.second>=b&&h.best-h.second>=b}),c=cn(d,e.length);return c.length<=en?c:[]}function an(n,e,t){let r=xe(n,R),o=xe(e,R),i=new Map;for(let[d,c]of r){let f=o.get(d);if(!B(d)||c.length!==1||f?.length!==1)continue;let u=c[0],h=f[0];if(i.set(`${u}:${h}`,{leftIndex:u,rightIndex:h,exact:!0}),i.size>be)return null}if(t)return[...i.values()];let s=Ne(n),l=Ne(e);for(let[d,c]of s){let f=l.get(d);if(!(!f||c.length>we||f.length>we))for(let u of c)for(let h of f){let b=`${u}:${h}`;if(!i.has(b)&&(i.set(b,{leftIndex:u,rightIndex:h,exact:!1}),i.size>be))return null}}return[...i.values()]}function xe(n,e){let t=new Map;return n.forEach((r,o)=>{let i=e(r),s=t.get(i)??[];s.push(o),t.set(i,s)}),t}function Ne(n){let e=new Map;return n.forEach((t,r)=>{let o=new Set(G(R(t)).filter(un));for(let i of o){let s=e.get(i)??[];s.push(r),e.set(i,s)}}),e}function un(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function Ee(n,e){let t=new Map;for(let r of n){let o=t.get(r[e])??[];o.push(r.match),t.set(r[e],o)}return new Map([...t].map(([r,o])=>[r,re(o)]))}function cn(n,e){let t=[...n].sort((c,f)=>c.leftIndex-f.leftIndex||c.rightIndex-f.rightIndex),r=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),i=new Array(t.length).fill(0),s=new Array(t.length).fill(-1);for(let c=0;c<t.length;){let f=c+1;for(;f<t.length&&t[f].leftIndex===t[c].leftIndex;)f++;for(let u=c;u<f;u++){let h=Ie(r,o,t[u].rightIndex),b=t[u].exact||t[u].structural?.5:0;i[u]=h.score+t[u].match.score+b,s[u]=h.candidateIndex}for(let u=c;u<f;u++)dn(r,o,t[u].rightIndex+1,i[u],u);c=f}let l=Ie(r,o,e+1),d=[];for(let c=l.candidateIndex;c>=0;c=s[c])d.push({leftIndex:t[c].leftIndex,rightIndex:t[c].rightIndex});return d.reverse()}function Ie(n,e,t){let r=0,o=-1;for(let i=t;i>0;i-=i&-i)n[i]>r&&(r=n[i],o=e[i]);return{score:r,candidateIndex:o}}function dn(n,e,t,r,o){for(let i=t;i<n.length;i+=i&-i)r>n[i]&&(n[i]=r,e[i]=o)}function Le(n,e,t){if(e.length*t.length<=Ce){n.push(...K(e,t));return}n.push(...e.map(r=>({left:r}))),n.push(...t.map(r=>({right:r})))}function R(n){return n.trim().replace(/\s+/g," ")}function Oe(n,e){let t=De(n),r=De(e),o=new Set;for(let[i,s]of t){let l=r.get(i);s.length===1&&l?.length===1&&o.add(`${s[0]}:${l[0]}`)}return o}function De(n){let e=new Map;return n.forEach((t,r)=>{let o=$(t);if(!o)return;let i=e.get(o)??[];i.push(r),e.set(o,i)}),e}function ie(n,e){let t=$(n),r=$(e);return!t||!r?t===r:t.split(":",1)[0]===r.split(":",1)[0]}function $(n){let e=R(n),t=[["function",/^(?:(?:export|default)\s+)*(?:async\s+)?function\s*\*?\s*([\p{L}_$][\p{L}\p{N}_$]*)\s*\(/u],["function",/^(?:async\s+)?def\s+([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["function",/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([\p{L}_][\p{L}\p{N}_]*)\s*(?:<[^>]*>)?\s*\(/u],["function",/^func\s+(?:\([^)]*\)\s*)?([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["class",/^(?:(?:export|default|abstract|public)\s+)*class\s+([\p{L}_$][\p{L}\p{N}_$]*)\b/u]];for(let[r,o]of t){let i=e.match(o);if(i)return`${r}:${i[1]}`}return null}function B(n){return n.length<3?!1:/[\p{L}\p{N}_$]/u.test(n)&&!/^[\s()[\]{};,.:+\-*/=>|&!?'"`]+$/.test(n)}function G(n){return n.toLowerCase().match(/[\p{L}_$][\p{L}\p{N}_$]*|\p{N}+(?:\.\p{N}+)?|[^\s\p{L}\p{N}_$]/gu)??[]}function gn(n,e){if(n.length+e.length===0)return 1;let t=new Map;n.forEach(o=>t.set(o,(t.get(o)??0)+1));let r=0;for(let o of e){let i=t.get(o)??0;i>0&&(r++,t.set(o,i-1))}return 2*r/(n.length+e.length)}function hn(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,r=n[n.length-1]===e[e.length-1]?.5:0;return t+r}function mn(n,e){let t=n.length+e.length;return t===0?1:2*ue(n,e).filter(o=>!o.added&&!o.removed).reduce((o,i)=>o+i.value.length,0)/t}function pn(n,e){let t=le(n.content,e.content);if(t){n.segments=t.leftSegments,e.segments=t.rightSegments;return}let r=se(n.content,e.content);r&&(n.segments=r.leftSegments,e.segments=r.rightSegments)}function vn(n,e){if(!n.length||!e.length||n.length===1&&e.length===1)return;let t=f=>f.reduce((u,h)=>u+h.content.length+1,-1);if(t(n)>Y||t(e)>Y)return;let r=n.map(f=>f.content).join(`
11
+ `));if(c){let h=_(c.leftSegments),g=_(c.rightSegments);return[...Array.from({length:Math.max(i,o)},(b,S)=>({left:S<i?n[S]:void 0,right:S<o?e[S]:void 0,reflow:{start:S===0,leftSegments:h[S],rightSegments:g[S]}})),...K(n.slice(i),e.slice(o))]}}let l=n.reduce((c,h)=>c+Math.min(h.length,ie),0),d=e.reduce((c,h)=>c+Math.min(h.length,ie),0);if(l*d>rn)return ye(n,e,!0);if(n.length===1&&e.length===1){let c=J(n[0],e[0]);return!n[0].trim()&&!e[0].trim()||(c.eligible||c.score>=en)&&re(n[0],e[0])&&se(n[0],e[0])&&O(M(n[0]))&&O(M(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>ke)return ye(n,e);let u=sn(n,e),f=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),a=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));f[0][0]=0;for(let c=1;c<=n.length;c++)f[c][0]=f[c-1][0]+q,a[c][0]="left";for(let c=1;c<=e.length;c++)f[0][c]=f[0][c-1]+q,a[0][c]="right";for(let c=1;c<=n.length;c++)for(let h=1;h<=e.length;h++){let g=u[c-1][h-1],S=[{move:"left",score:f[c-1][h]+q},{move:"right",score:f[c][h-1]+q},{move:"match",score:g===null?Number.NEGATIVE_INFINITY:f[c-1][h-1]+g}].reduce((x,y)=>y.score>x.score?y:x);f[c][h]=S.score,a[c][h]=S.move}let v=[],m=n.length,p=e.length;for(;m>0||p>0;){let c=a[m][p];c==="match"?v.push({left:n[--m],right:e[--p]}):c==="left"?v.push({left:n[--m]}):v.push({right:e[--p]})}return v.reverse()}function J(n,e){let t=M(n),i=M(e),o=O(t),r=O(i);if(o&&r&&t===i)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};if(!o||!r)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};let s=G(t),l=G(i),d=b=>b.length<=ie?b:[0,Math.floor(b.length/2)-300,b.length-600].map(S=>b.slice(S,S+600)).join(" "),u=vn(d(t),d(i)),f=mn(s,l),a=Math.min(t.length,i.length)/Math.max(t.length,i.length),v=pn(s,l),m=b=>b.match(/^(?:(?:const|let|var)\s+)?([\p{L}_$][\p{L}\p{N}_$.-]*\s*(?::|=(?!=)))\s*/u)?.[1].replace(/\s+/g,""),p=m(t),c=p&&p===m(i)?.12:0,h=Math.min(1,u*.52+f*.32+a*.1+v*.06+c),g=c>0||u>=.52||f>=.45||u>=.48&&f>=.28;return{score:h,eligible:g&&h>=Qe,characterSimilarity:u,tokenSimilarity:f,lengthSimilarity:a}}function sn(n,e){let t=n.map(c=>e.map(h=>J(c,h))),i=He(n,e),o=t.map(c=>oe(c)),r=e.map((c,h)=>oe(t.map(g=>g[h]))),s=t.map((c,h)=>c.map((g,b)=>{if(i.has(`${h}:${b}`))return Math.max(g.score,1);if(!g.eligible)return null;let S=o[h],x=r[b],y=g.score===S.best&&g.score===x.best,I=g.score>=Oe?Y/2:Y,w=S.best-S.second>=I,N=x.best-x.second>=I;return y&&w&&N?g.score:null}));if(Math.max(n.length,e.length)>on||Math.abs(n.length-e.length)>ne)return s;let l=(c,h,g)=>c.score>=_e&&se(n[h],e[g])&&Math.abs(h-g)<=ne,d=t.map((c,h)=>X(c,(g,b)=>l(g,h,b))),u=e.map((c,h)=>X(t.map(g=>g[h]),(g,b)=>l(g,b,h))),f=(c,h,g)=>c.score>=nn&&se(n[h],e[g])&&Math.abs(h-g)<=ne,a=t.map((c,h)=>X(c,(g,b)=>f(g,h,b))),v=e.map((c,h)=>X(t.map(g=>g[h]),(g,b)=>f(g,b,h))),m=(c,h)=>{let g=t[c][h];if(!l(g,c,h))return!1;let b=d[c],S=u[h];return g.score===b.best&&g.score===S.best&&b.best-b.second>=P&&S.best-S.second>=P},p=(c,h)=>{let g=t[c][h];if(!f(g,c,h))return!1;let b=a[c],S=v[h];return g.score===b.best&&g.score===S.best&&b.best-b.second>=P&&S.best-S.second>=P};return s.map((c,h)=>c.map((g,b)=>{if(g!==null)return g;let S=m(h,b)&&(ln(s,h,b)||fn(t,h,b,m)),x=an(t,h,b,(y,I)=>f(t[y][I],y,I),p);return!S&&!x?null:t[h][b].score}))}function ln(n,e,t){return e>0&&t>0&&n[e-1][t-1]!==null||e+1<n.length&&t+1<n[e+1].length&&n[e+1][t+1]!==null}function fn(n,e,t,i){return e>0&&t>0&&i(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&i(e+1,t+1)}function an(n,e,t,i,o){let r=e,s=t;for(;r>0&&s>0&&i(r-1,s-1);)r--,s--;let l=e,d=t,u=n[e][t].score,f=1;for(;l+1<n.length&&d+1<n[l+1].length&&i(l+1,d+1);)l++,d++,u+=n[l][d].score,f++;for(let a=e-1,v=t-1;a>=r&&v>=s;a--,v--)u+=n[a][v].score,f++;return f>=3&&u/f>=_e&&o(r,s)&&o(l,d)}function X(n,e){let t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return n.forEach((o,r)=>{e(o,r)&&(o.score>t?(i=t,t=o.score):o.score>i&&(i=o.score))}),{best:t,second:i}}function oe(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let i of n)i.eligible&&(i.score>e?(t=e,e=i.score):i.score>t&&(t=i.score));return{best:e,second:t}}function ye(n,e,t=!1){let i=un(n,e,t);if(i.length===0)return[...n.map(l=>({left:l})),...e.map(l=>({right:l}))];let o=[],r=0,s=0;for(let l of i)De(o,n.slice(r,l.leftIndex),e.slice(s,l.rightIndex)),o.push({left:n[l.leftIndex],right:e[l.rightIndex]}),r=l.leftIndex+1,s=l.rightIndex+1;return De(o,n.slice(r),e.slice(s)),o}function un(n,e,t){let i=cn(n,e,t);if(i===null)return[];let o=He(n,e),r=i.map(({leftIndex:f,rightIndex:a,exact:v})=>({leftIndex:f,rightIndex:a,exact:v,structural:o.has(`${f}:${a}`),match:J(n[f],e[a])})).filter(f=>f.exact||f.structural||f.match.eligible),s=Ee(r,"leftIndex"),l=Ee(r,"rightIndex"),d=r.filter(f=>{if(f.exact||f.structural)return!0;let a=s.get(f.leftIndex),v=l.get(f.rightIndex);if(!a||!v||f.match.score!==a.best||f.match.score!==v.best)return!1;let m=f.match.score>=Oe?Y/2:Y;return a.best-a.second>=m&&v.best-v.second>=m}),u=gn(d,e.length);return u.length<=tn?u:[]}function cn(n,e,t){let i=Ne(n,M),o=Ne(e,M),r=new Map;for(let[d,u]of i){let f=o.get(d);if(!O(d)||u.length!==1||f?.length!==1)continue;let a=u[0],v=f[0];if(r.set(`${a}:${v}`,{leftIndex:a,rightIndex:v,exact:!0}),r.size>we)return null}if(t)return[...r.values()];let s=Ie(n),l=Ie(e);for(let[d,u]of s){let f=l.get(d);if(!(!f||u.length>Se||f.length>Se))for(let a of u)for(let v of f){let m=`${a}:${v}`;if(!r.has(m)&&(r.set(m,{leftIndex:a,rightIndex:v,exact:!1}),r.size>we))return null}}return[...r.values()]}function Ne(n,e){let t=new Map;return n.forEach((i,o)=>{let r=e(i),s=t.get(r)??[];s.push(o),t.set(r,s)}),t}function Ie(n){let e=new Map;return n.forEach((t,i)=>{let o=new Set(G(M(t)).filter(dn));for(let r of o){let s=e.get(r)??[];s.push(i),e.set(r,s)}}),e}function dn(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function Ee(n,e){let t=new Map;for(let i of n){let o=t.get(i[e])??[];o.push(i.match),t.set(i[e],o)}return new Map([...t].map(([i,o])=>[i,oe(o)]))}function gn(n,e){let t=[...n].sort((u,f)=>u.leftIndex-f.leftIndex||u.rightIndex-f.rightIndex),i=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),r=new Array(t.length).fill(0),s=new Array(t.length).fill(-1);for(let u=0;u<t.length;){let f=u+1;for(;f<t.length&&t[f].leftIndex===t[u].leftIndex;)f++;for(let a=u;a<f;a++){let v=Le(i,o,t[a].rightIndex),m=t[a].exact||t[a].structural?.5:0;r[a]=v.score+t[a].match.score+m,s[a]=v.candidateIndex}for(let a=u;a<f;a++)hn(i,o,t[a].rightIndex+1,r[a],a);u=f}let l=Le(i,o,e+1),d=[];for(let u=l.candidateIndex;u>=0;u=s[u])d.push({leftIndex:t[u].leftIndex,rightIndex:t[u].rightIndex});return d.reverse()}function Le(n,e,t){let i=0,o=-1;for(let r=t;r>0;r-=r&-r)n[r]>i&&(i=n[r],o=e[r]);return{score:i,candidateIndex:o}}function hn(n,e,t,i,o){for(let r=t;r<n.length;r+=r&-r)i>n[r]&&(n[r]=i,e[r]=o)}function De(n,e,t){if(e.length*t.length<=ke){n.push(...K(e,t));return}n.push(...e.map(i=>({left:i}))),n.push(...t.map(i=>({right:i})))}function M(n){return n.trim().replace(/\s+/g," ")}function He(n,e){let t=Me(n),i=Me(e),o=new Set;for(let[r,s]of t){let l=i.get(r);s.length===1&&l?.length===1&&o.add(`${s[0]}:${l[0]}`)}return o}function Me(n){let e=new Map;return n.forEach((t,i)=>{let o=B(t);if(!o)return;let r=e.get(o)??[];r.push(i),e.set(o,r)}),e}function se(n,e){let t=B(n),i=B(e);return!t||!i?t===i:t.split(":",1)[0]===i.split(":",1)[0]}function B(n){let e=M(n),t=[["function",/^(?:(?:export|default)\s+)*(?:async\s+)?function\s*\*?\s*([\p{L}_$][\p{L}\p{N}_$]*)\s*\(/u],["function",/^(?:async\s+)?def\s+([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["function",/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([\p{L}_][\p{L}\p{N}_]*)\s*(?:<[^>]*>)?\s*\(/u],["function",/^func\s+(?:\([^)]*\)\s*)?([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["class",/^(?:(?:export|default|abstract|public)\s+)*class\s+([\p{L}_$][\p{L}\p{N}_$]*)\b/u]];for(let[i,o]of t){let r=e.match(o);if(r)return`${i}:${r[1]}`}return null}function O(n){return n.length<3?!1:/[\p{L}\p{N}_$]/u.test(n)&&!/^[\s()[\]{};,.:+\-*/=>|&!?'"`]+$/.test(n)}function G(n){return n.toLowerCase().match(/[\p{L}_$][\p{L}\p{N}_$]*|\p{N}+(?:\.\p{N}+)?|[^\s\p{L}\p{N}_$]/gu)??[]}function mn(n,e){if(n.length+e.length===0)return 1;let t=new Map;n.forEach(o=>t.set(o,(t.get(o)??0)+1));let i=0;for(let o of e){let r=t.get(o)??0;r>0&&(i++,t.set(o,r-1))}return 2*i/(n.length+e.length)}function pn(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,i=n[n.length-1]===e[e.length-1]?.5:0;return t+i}function vn(n,e){let t=n.length+e.length;return t===0?1:2*de(n,e).filter(o=>!o.added&&!o.removed).reduce((o,r)=>o+r.value.length,0)/t}function bn(n,e){let t=ae(n.content,e.content);if(t){n.segments=t.leftSegments,e.segments=t.rightSegments;return}let i=fe(n.content,e.content);i&&(n.segments=i.leftSegments,e.segments=i.rightSegments)}function wn(n,e){if(!n.length||!e.length||n.length===1&&e.length===1)return;let t=f=>f.reduce((a,v)=>a+v.content.length+1,-1);if(t(n)>j||t(e)>j)return;let i=n.map(f=>f.content).join(`
12
12
  `),o=e.map(f=>f.content).join(`
13
- `),i=se(r,o);if(!i)return;let{leftSegments:s,rightSegments:l}=i,d=k(s),c=k(l);n.forEach((f,u)=>{f.segments=d[u]}),e.forEach((f,u)=>{f.segments=c[u]})}function Me(n){/[^\s]/.test(n.content)&&(n.segments=[{kind:n.kind,text:n.content,emphasis:!0}])}var oe=new Intl.Segmenter(void 0,{granularity:"grapheme"});function bn(n,e){if(n===e)return n?[{value:n}]:[];let t=Array.from(oe.segment(n),l=>l.segment),r=Array.from(oe.segment(e),l=>l.segment),o=Math.min(t.length,r.length),i=0,s=0;for(;i<o&&t[i]===r[i];)i++;for(;s<o&&t[t.length-s-1]===r[r.length-s-1];)s++;return s===o&&i<o&&(i=0),s=Math.min(s,o-i),[{value:t.slice(0,i).join("")},{value:t.slice(i,t.length-s).join(""),removed:!0},{value:r.slice(i,r.length-s).join(""),added:!0},{value:s?t.slice(-s).join(""):""}].filter(l=>l.value.length>0)}function wn(n,e){let t=ce(n,e,{timeout:Ae,maxEditLength:2e3});if(!t)return;let r=u=>new Set([...Array.from(oe.segment(u),h=>h.index),u.length]),o=r(n),i=r(e),s=[],l=0,d=0,c="",f="";for(let u=0;u<t.length;){let h=t[u];if(!h.added&&!h.removed)c+=h.value,f+=h.value,l+=h.value.length,d+=h.value.length,u++;else for(;u<t.length&&(t[u].added||t[u].removed);){let b=t[u++];b.removed?(c+=b.value,l+=b.value.length):(f+=b.value,d+=b.value.length)}if(o.has(l)&&i.has(d)){for(let b of bn(c,f)){let y=s[s.length-1];y&&y.added===b.added&&y.removed===b.removed?y.value+=b.value:s.push(b)}c="",f=""}}return s}function se(n,e){if(n.length>Y||e.length>Y)return;let t=wn(n,e);if(!t)return;let r=[],o=[],i=!1;for(let s of t){let l=s.value;if(!s.added&&!s.removed){let c={kind:"context",text:l,emphasis:!1};r.push(c),o.push(c);continue}let d=l.length>0;i=i||d,s.removed&&r.push({kind:"removed",text:l,emphasis:d}),s.added&&o.push({kind:"added",text:l,emphasis:d})}return{leftSegments:r,rightSegments:o,hasInlineChanges:i}}function le(n,e){let t=n.split(/(\S+)/),r=e.split(/(\S+)/);if(t.length!==r.length||t.some((l,d)=>d%2===1&&l!==r[d]))return;let o=[],i=[],s=(l,d,c)=>{if(!c)return;let f=l[l.length-1];f?.kind===d?f.text+=c:l.push({kind:d,text:c,emphasis:d!=="context"})};return t.forEach((l,d)=>{let c=r[d],f=0;if(d>0)for(;f<Math.min(l.length,c.length)&&l[f]===c[f];)f++;let u=0;for(;u<Math.min(l.length,c.length)-f&&l[l.length-u-1]===c[c.length-u-1];)u++;if(d===0)for(;f<Math.min(l.length,c.length)-u&&l[f]===c[f];)f++;s(o,"context",l.slice(0,f)),s(i,"context",c.slice(0,f)),s(o,"removed",l.slice(f,l.length-u)),s(i,"added",c.slice(f,c.length-u)),s(o,"context",l.slice(l.length-u)),s(i,"context",c.slice(c.length-u))}),{leftSegments:o,rightSegments:i}}function k(n){let e=[[]];for(let t of n)t.text.split(`
14
- `).forEach((r,o)=>{o>0&&e.push([]),r&&e[e.length-1].push({...t,text:r})});return e}function O(){return{kind:"placeholder",content:"",lineNumber:null}}function M(n,e,t){return{kind:n,content:e,lineNumber:t}}function A(n,e,t){return{kind:n,content:e,lineNumber:t}}function _(n,e){return{left:n,right:e}}function W(n,e,t,r,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:r,rightEnd:o}}function Fe(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,r=Number.parseInt(t??"",10);return Number.isFinite(r)&&r>0?r:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:r}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof r!="string"))try{let o=Re(t,r);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
13
+ `),r=fe(i,o);if(!r)return;let{leftSegments:s,rightSegments:l}=r,d=_(s),u=_(l);n.forEach((f,a)=>{f.segments=d[a]}),e.forEach((f,a)=>{f.segments=u[a]})}function Ae(n){/[^\s]/.test(n.content)&&(n.segments=[{kind:n.kind,text:n.content,emphasis:!0}])}var le=new Intl.Segmenter(void 0,{granularity:"grapheme"});function Sn(n,e){if(n===e)return n?[{value:n}]:[];let t=Array.from(le.segment(n),l=>l.segment),i=Array.from(le.segment(e),l=>l.segment),o=Math.min(t.length,i.length),r=0,s=0;for(;r<o&&t[r]===i[r];)r++;for(;s<o&&t[t.length-s-1]===i[i.length-s-1];)s++;return s===o&&r<o&&(r=0),s=Math.min(s,o-r),[{value:t.slice(0,r).join("")},{value:t.slice(r,t.length-s).join(""),removed:!0},{value:i.slice(r,i.length-s).join(""),added:!0},{value:s?t.slice(-s).join(""):""}].filter(l=>l.value.length>0)}function xn(n,e){let t=ge(n,e,{timeout:Re,maxEditLength:2e3});if(!t)return;let i=a=>new Set([...Array.from(le.segment(a),v=>v.index),a.length]),o=i(n),r=i(e),s=[],l=0,d=0,u="",f="";for(let a=0;a<t.length;){let v=t[a];if(!v.added&&!v.removed)u+=v.value,f+=v.value,l+=v.value.length,d+=v.value.length,a++;else for(;a<t.length&&(t[a].added||t[a].removed);){let m=t[a++];m.removed?(u+=m.value,l+=m.value.length):(f+=m.value,d+=m.value.length)}if(o.has(l)&&r.has(d)){for(let m of Sn(u,f)){let p=s[s.length-1];p&&p.added===m.added&&p.removed===m.removed?p.value+=m.value:s.push(m)}u="",f=""}}return s}function fe(n,e){if(n.length>j||e.length>j)return;let t=xn(n,e);if(!t)return;let i=[],o=[],r=!1;for(let s of t){let l=s.value;if(!s.added&&!s.removed){let u={kind:"context",text:l,emphasis:!1};i.push(u),o.push(u);continue}let d=l.length>0;r=r||d,s.removed&&i.push({kind:"removed",text:l,emphasis:d}),s.added&&o.push({kind:"added",text:l,emphasis:d})}return{leftSegments:V(i),rightSegments:V(o),hasInlineChanges:r}}function ae(n,e){let t=n.split(/(\S+)/),i=e.split(/(\S+)/);if(t.length!==i.length||t.some((l,d)=>d%2===1&&l!==i[d]))return;let o=[],r=[],s=(l,d,u)=>{if(!u)return;let f=l[l.length-1];f?.kind===d?f.text+=u:l.push({kind:d,text:u,emphasis:d!=="context"})};return t.forEach((l,d)=>{let u=i[d],f=0;if(d>0)for(;f<Math.min(l.length,u.length)&&l[f]===u[f];)f++;let a=0;for(;a<Math.min(l.length,u.length)-f&&l[l.length-a-1]===u[u.length-a-1];)a++;if(d===0)for(;f<Math.min(l.length,u.length)-a&&l[f]===u[f];)f++;s(o,"context",l.slice(0,f)),s(r,"context",u.slice(0,f)),s(o,"removed",l.slice(f,l.length-a)),s(r,"added",u.slice(f,u.length-a)),s(o,"context",l.slice(l.length-a)),s(r,"context",u.slice(u.length-a))}),{leftSegments:V(o),rightSegments:V(r)}}function V(n){let e=[];return _(n).forEach((t,i)=>{i>0&&e.push({kind:"context",text:`
14
+ `,emphasis:!1});let o=t.map(u=>u.text).join(""),r=o.match(/^[\t ]*/u)[0].length,s=0,l=0,d="context";for(let u of t){if(s>=r)break;u.emphasis&&(l+=Math.min(u.text.length,r-s),d=u.kind),s+=u.text.length}l&&e.push({kind:d,text:o.slice(0,l),emphasis:!0}),r>l&&e.push({kind:"context",text:o.slice(l,r),emphasis:!1}),s=0;for(let u of t){let f=Math.max(0,r-s);f<u.text.length&&e.push({...u,text:u.text.slice(f)}),s+=u.text.length}}),e}function _(n){let e=[[]];for(let t of n)t.text.split(`
15
+ `).forEach((i,o)=>{o>0&&e.push([]),i&&e[e.length-1].push({...t,text:i})});return e}function H(){return{kind:"placeholder",content:"",lineNumber:null}}function A(n,e,t){return{kind:n,content:e,lineNumber:t}}function R(n,e,t){return{kind:n,content:e,lineNumber:t}}function k(n,e){return{left:n,right:e}}function $(n,e,t,i,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:i,rightEnd:o}}function Fe(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,i=Number.parseInt(t??"",10);return Number.isFinite(i)&&i>0?i:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:i}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof i!="string"))try{let o=Te(t,i);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
15
16
  //# sourceMappingURL=diff.worker.js.map