@pi-chamber/web 0.9.4 → 0.9.5

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 (89) hide show
  1. package/README.md +15 -0
  2. package/dist/assets/{DiagramEditor-DuGmiPZ5.js → DiagramEditor-BPDkGHsj.js} +1 -1
  3. package/dist/assets/DiagramView-D_EfDz2d.js +1 -0
  4. package/dist/assets/{DiffView-CBOrV4hS.js → DiffView-BmIVvheE.js} +2 -2
  5. package/dist/assets/FilesView-CJytSUAX.js +6 -0
  6. package/dist/assets/GitView-BNkzec7G.js +8 -0
  7. package/dist/assets/{JsonTreeView-CKWGm5MS.js → JsonTreeView-C1Kzaybf.js} +1 -1
  8. package/dist/assets/MarkdownRendererImpl-qmKiFVpO.js +12 -0
  9. package/dist/assets/PatchDiff-D9JesZL1.js +1 -0
  10. package/dist/assets/{SessionSwitcherContent-z9VYCXrT.js → SessionSwitcherContent-DplV_ApH.js} +1 -1
  11. package/dist/assets/SessionSwitcherDropdown-DdgDKT6K.js +2 -0
  12. package/dist/assets/SessionUnreadDot-BdSDgvhC.js +1 -0
  13. package/dist/assets/SettingsView-z8uf0XyM.js +2 -0
  14. package/dist/assets/SettingsWindow-CPDmgNg2.js +1 -0
  15. package/dist/assets/ToolOutputDialog-DaF1xcM0.js +8 -0
  16. package/dist/assets/ToolPartDiffPreview-Di6Uo0Dt.js +1 -0
  17. package/dist/assets/{VirtualizedFileDiff-DfaXovGB.js → VirtualizedFileDiff-wqcrY0yr.js} +3 -3
  18. package/dist/assets/collapsible-DBQnXTNm.js +1 -0
  19. package/dist/assets/computeVirtualFileMetrics-Cr3jh0d6.js +3 -0
  20. package/dist/assets/contextFileOpenGuard-C_AOTYQD.js +1 -0
  21. package/dist/assets/gitStatusPredicates-BvPOjeOy.js +134 -0
  22. package/dist/assets/index-B8Wt2aN3.js +1 -0
  23. package/dist/assets/index-DIF8b4bh.css +1 -0
  24. package/dist/assets/index-jrfQYSvP.js +8 -0
  25. package/dist/assets/isDiffPlainText-L9uvgz2F.js +1 -0
  26. package/dist/assets/isFilePlainText-C4yk5BOo.js +1 -0
  27. package/dist/assets/main-C1OSzD-E.js +135 -0
  28. package/dist/assets/{main-DG1oZ0Wj.js → main-DCK6lLCo.js} +2 -2
  29. package/dist/assets/{markdownCore-DUjQU2i0.js → markdownCore-Czb_lINQ.js} +2 -2
  30. package/dist/assets/{miniChat-BEAtOkr9.js → miniChat-CXiSlptL.js} +2 -2
  31. package/dist/assets/{mobile-DOFBBQg2.js → mobile-D0HVxiyJ.js} +2 -2
  32. package/dist/assets/renderElectronMiniChatApp-BcG209a4.js +2 -0
  33. package/dist/assets/renderMobileApp-B5x_PWlc.js +11 -0
  34. package/dist/assets/runtimeEndpointReset-CUiPe6dQ.js +53 -0
  35. package/dist/assets/{runtimeSurface-CySRuLbN.js → runtimeSurface-vilE4xyj.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-C4JL1x7k.js → useAppFontEffects-BP07Vl6M.js} +102 -103
  37. package/dist/assets/useFilesViewSearch-oxIKk-ea.js +7 -0
  38. package/dist/assets/usePushVisibilityBeacon-CChMvoTL.js +10 -0
  39. package/dist/assets/useSwitcherItems-_RSo3F-A.js +1 -0
  40. package/dist/assets/{vendor-base-ui-vkqQ2P9o.js → vendor-base-ui-CdaWtC7e.js} +1 -1
  41. package/dist/assets/vendor-beautiful-mermaid-D3YCkKz7.js +111 -0
  42. package/dist/assets/{vendor-codemirror-commands-DYppkHEk.js → vendor-codemirror-commands-CNlncqrr.js} +1 -1
  43. package/dist/assets/{vendor-codemirror-language-data-C493X_9w.js → vendor-codemirror-language-data-BJrrV83E.js} +2 -2
  44. package/dist/assets/{vendor-replit-codemirror-vim-CGHHNQxC.js → vendor-replit-codemirror-vim-DaSwPsXt.js} +1 -1
  45. package/dist/assets/{web-components-B2Rw__yK.js → web-components-B5sMa_kC.js} +3 -3
  46. package/dist/index.html +4 -4
  47. package/dist/mini-chat.html +3 -3
  48. package/dist/mobile.html +3 -3
  49. package/package.json +2 -2
  50. package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -5
  51. package/server/lib/pi/session-daemon/prompt-operations.test.js +142 -0
  52. package/server/lib/pi/session-daemon/sdk-upgrade.test.js +157 -0
  53. package/server/lib/pi/session-daemon/session-daemon.js +230 -76
  54. package/server/lib/pi/session-daemon/session-idle-residency.test.js +742 -0
  55. package/server/lib/pi/session-daemon/session-replay.js +98 -0
  56. package/server/lib/pi/session-daemon/session-replay.test.js +626 -0
  57. package/server/lib/pi/ui-settings-store.js +16 -10
  58. package/server/lib/pi/ui-settings-store.test.js +91 -0
  59. package/server/lib/stt/DOCUMENTATION.md +1 -1
  60. package/server/lib/stt/local/worker-client.js +11 -3
  61. package/server/lib/stt/local/worker-client.test.js +255 -0
  62. package/dist/assets/DiagramView-CHy1Glsl.js +0 -1
  63. package/dist/assets/FilesView-CK2YVs_W.js +0 -6
  64. package/dist/assets/GitView-BEFLOv_7.js +0 -8
  65. package/dist/assets/MarkdownRendererImpl-hE_nmSqe.js +0 -12
  66. package/dist/assets/PatchDiff-BagRxMON.js +0 -1
  67. package/dist/assets/SessionSwitcherDropdown-icxJk_lT.js +0 -2
  68. package/dist/assets/SessionUnreadDot-Bv-5KguB.js +0 -1
  69. package/dist/assets/SettingsView-Ck0qxtKP.js +0 -2
  70. package/dist/assets/SettingsWindow-GQRL2CdD.js +0 -1
  71. package/dist/assets/ToolOutputDialog-CxJUXVZW.js +0 -8
  72. package/dist/assets/ToolPartDiffPreview-BXuLRWHT.js +0 -1
  73. package/dist/assets/collapsible-szfZ0Syc.js +0 -1
  74. package/dist/assets/computeVirtualFileMetrics-DG_E6iaN.js +0 -3
  75. package/dist/assets/contextFileOpenGuard-DPBE3ELv.js +0 -1
  76. package/dist/assets/gitStatusPredicates-OljV4Bb2.js +0 -134
  77. package/dist/assets/index-DNoEeZ2U.css +0 -1
  78. package/dist/assets/index-DmexVlTQ.js +0 -1
  79. package/dist/assets/index-KIdiBFJs.js +0 -8
  80. package/dist/assets/isDiffPlainText-aikgiqLb.js +0 -1
  81. package/dist/assets/isFilePlainText-D-Dl6LqX.js +0 -1
  82. package/dist/assets/main-BXdraZTZ.js +0 -135
  83. package/dist/assets/renderElectronMiniChatApp-B0K72YnS.js +0 -2
  84. package/dist/assets/renderMobileApp-Ca_BO_s4.js +0 -11
  85. package/dist/assets/runtimeEndpointReset-Cx2tsgTo.js +0 -54
  86. package/dist/assets/useFilesViewSearch-Du0DnmKs.js +0 -7
  87. package/dist/assets/usePushVisibilityBeacon-BnHxIv4r.js +0 -10
  88. package/dist/assets/useSwitcherItems-C91mwPJD.js +0 -1
  89. package/dist/assets/vendor-beautiful-mermaid-DneUawHp.js +0 -119
@@ -0,0 +1,111 @@
1
+ import{E as Ae}from"./vendor-elkjs-mzfkf0ML.js";import{d as Ie}from"./vendor-entities-C3BA0AJP.js";var Ot={bg:"#FFFFFF",fg:"#27272A"},it={textSec:60,textMuted:40,textFaint:25,line:50,arrow:85,nodeFill:3,nodeStroke:20,groupHeader:5,innerStroke:12,keyBadge:10};function vt(t,e){const n=[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@400;500;600;700&display=swap');`,...e?["@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');"]:[]],s=`
2
+ /* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
3
+ --_text: var(--fg);
4
+ --_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${it.textSec}%, var(--bg)));
5
+ --_text-muted: var(--muted, color-mix(in srgb, var(--fg) ${it.textMuted}%, var(--bg)));
6
+ --_text-faint: color-mix(in srgb, var(--fg) ${it.textFaint}%, var(--bg));
7
+ --_line: var(--line, color-mix(in srgb, var(--fg) ${it.line}%, var(--bg)));
8
+ --_arrow: var(--accent, color-mix(in srgb, var(--fg) ${it.arrow}%, var(--bg)));
9
+ --_node-fill: var(--surface, color-mix(in srgb, var(--fg) ${it.nodeFill}%, var(--bg)));
10
+ --_node-stroke: var(--border, color-mix(in srgb, var(--fg) ${it.nodeStroke}%, var(--bg)));
11
+ --_group-fill: var(--bg);
12
+ --_group-hdr: color-mix(in srgb, var(--fg) ${it.groupHeader}%, var(--bg));
13
+ --_inner-stroke: color-mix(in srgb, var(--fg) ${it.innerStroke}%, var(--bg));
14
+ --_key-badge: color-mix(in srgb, var(--fg) ${it.keyBadge}%, var(--bg));`;return["<style>",` ${n.join(`
15
+ `)}`,` text { font-family: '${t}', system-ui, sans-serif; }`,...e?[" .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }"]:[],` svg {${s}`," }","</style>"].join(`
16
+ `)}function St(t,e,n,s){const o=[`--bg:${n.bg}`,`--fg:${n.fg}`,n.line?`--line:${n.line}`:"",n.accent?`--accent:${n.accent}`:"",n.muted?`--muted:${n.muted}`:"",n.surface?`--surface:${n.surface}`:"",n.border?`--border:${n.border}`:""].filter(Boolean).join(";");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${e}" width="${t}" height="${e}" style="${o}${s?"":";background:var(--bg)"}">`}var _e=new Set(["i","l","t","f","j","I","1","!","|",".",",",":",";","'"]),We=new Set(["W","M","w","m","@","%"]),He=new Set(["W","M"]),Te=new Set(["(",")","[","]","{","}","/","\\","-",'"',"`"]);function Ee(t){return t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071}function ze(t){return t>=4352&&t<=4447||t>=11904&&t<=12031||t>=12032&&t<=12255||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12544&&t<=12591||t>=12592&&t<=12687||t>=12688&&t<=12799||t>=12800&&t<=13311||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=131072}var Re=new RegExp("\\p{Emoji_Presentation}|\\p{Extended_Pictographic}","u");function Ce(t){return Re.test(t)}function Pe(t){const e=t.codePointAt(0);return e===void 0||Ee(e)?0:ze(e)||Ce(t)?2:t===" "?.3:He.has(t)?1.5:We.has(t)?1.2:_e.has(t)?.4:Te.has(t)?.5:t==="r"?.8:e>=65&&e<=90?1.2:(e>=48&&e<=57,1)}function de(t,e,n){const s=n>=600?.6:n>=500?.57:.54;let o=0;for(const r of t)o+=Pe(r);const i=e*.15;return o*e*s+i}var he=1.3;function ct(t,e,n){const s=t.split(`
17
+ `),o=e*he;let i=0;for(const r of s){const a=r.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi,""),c=de(a,e,n);c>i&&(i=c)}return{width:i,height:s.length*o,lines:s,lineHeight:o}}function q(t){return(t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t).replace(/<br\s*\/?>/gi,`
18
+ `).replace(/\\n/g,`
19
+ `).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,"").replace(/\*\*(.+?)\*\*/g,"<b>$1</b>").replace(new RegExp("(?<!\\*)\\*([^\\s*](?:[^*]*[^\\s*])?)\\*(?!\\*)","g"),"<i>$1</i>").replace(/~~(.+?)~~/g,"<s>$1</s>")}function bt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var jt=/<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;function Xe(t){const e=[];let n=!1,s=!1,o=!1,i=!1,r=0;jt.lastIndex=0;let a;for(;(a=jt.exec(t))!==null;){a.index>r&&e.push({text:t.slice(r,a.index),bold:n,italic:s,underline:o,strikethrough:i}),r=a.index+a[0].length;const c=!!a[1];a[2]?n=!c:a[3]?s=!c:a[4]?o=!c:a[5]&&(i=!c)}return r<t.length&&e.push({text:t.slice(r),bold:n,italic:s,underline:o,strikethrough:i}),e}var Ne=/<\/?(?:b|strong|i|em|u|s|del)\s*>/i;function Ft(t){if(!Ne.test(t))return bt(t);const e=Xe(t);return e.length===0?"":e.every(s=>!s.bold&&!s.italic&&!s.underline&&!s.strikethrough)?e.map(s=>bt(s.text)).join(""):e.map(s=>{const o=bt(s.text);if(!s.bold&&!s.italic&&!s.underline&&!s.strikethrough)return o;const i=[];s.bold&&i.push('font-weight="bold"'),s.italic&&i.push('font-style="italic"');const r=[];return s.underline&&r.push("underline"),s.strikethrough&&r.push("line-through"),r.length&&i.push(`text-decoration="${r.join(" ")}"`),`<tspan ${i.join(" ")}>${o}</tspan>`}).join("")}function tt(t,e,n,s,o,i=.35){const r=t.split(`
20
+ `);if(r.length===1){const l=s*i;return`<text x="${e}" y="${n}" ${o} dy="${l}">${Ft(t)}</text>`}const a=s*he,c=-((r.length-1)/2)*a+s*i,d=r.map((l,f)=>`<tspan x="${e}" dy="${f===0?c:a}">${Ft(l)}</tspan>`).join("");return`<text x="${e}" y="${n}" ${o}>${d}</text>`}function Be(t,e,n,s,o,i,r,a,c){const d=s+r*2,l=o+r*2,f=`<rect x="${e-d/2}" y="${n-l/2}" width="${d}" height="${l}" ${c} />`,h=tt(t,e,n,i,a);return`${f}
21
+ ${h}`}function Ye(t){const e=t.split(`
22
+ `).map(s=>s.trim()).filter(s=>s.length>0&&!s.startsWith("%%"));if(e.length===0)throw new Error("Empty mermaid diagram");const n=e[0];return/^stateDiagram(-v2)?\s*$/i.test(n)?De(e):Ge(e)}function Ge(t){const e=t[0].match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);if(!e)throw new Error(`Invalid mermaid header: "${t[0]}". Expected "graph TD", "flowchart LR", "stateDiagram-v2", etc.`);const s={direction:e[1].toUpperCase(),nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},o=[];for(let i=1;i<t.length;i++){const r=t[i],a=r.match(/^classDef\s+(\w+)\s+(.+)$/);if(a){const u=a[1],g=a[2],p=It(g);s.classDefs.set(u,p);continue}const c=r.match(/^class\s+([\w,-]+)\s+(\w+)$/);if(c){const u=c[1].split(",").map(p=>p.trim()),g=c[2];for(const p of u)s.classAssignments.set(p,g);continue}const d=r.match(/^style\s+([\w,-]+)\s+(.+)$/);if(d){const u=d[1].split(",").map(p=>p.trim()),g=It(d[2]);for(const p of u)s.nodeStyles.set(p,{...s.nodeStyles.get(p),...g});continue}const l=r.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(l){const u=l[1].trim(),g=It(l[2]);if(u==="default")s.linkStyles.set("default",{...s.linkStyles.get("default"),...g});else{const p=u.split(",").map(m=>parseInt(m.trim(),10));for(const m of p)isNaN(m)||s.linkStyles.set(m,{...s.linkStyles.get(m),...g})}continue}const f=r.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(f&&o.length>0){o[o.length-1].direction=f[1].toUpperCase();continue}const h=r.match(/^subgraph\s+(.+)$/);if(h){const u=h[1].trim(),g=u.match(/^([\w-]+)\s*\[(.+)\]$/);let p,m;g?(p=g[1],m=q(g[2])):(m=q(u),p=u.replace(/\s+/g,"_").replace(/[^\w]/g,""));const k={id:p,label:m,nodeIds:[],children:[]};o.push(k);continue}if(r==="end"){const u=o.pop();u&&(o.length>0?o[o.length-1].children.push(u):s.subgraphs.push(u));continue}Ue(r,s,o)}return s}function De(t){const e={direction:"TD",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},n=[],s=new Set;let o=0,i=0;for(let r=1;r<t.length;r++){const a=t[r],c=a.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.length>0?n[n.length-1].direction=c[1].toUpperCase():e.direction=c[1].toUpperCase();continue}const d=a.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(d){const g=d[1].trim(),p=It(d[2]);if(g==="default")e.linkStyles.set("default",{...e.linkStyles.get("default"),...p});else{const m=g.split(",").map(k=>parseInt(k.trim(),10));for(const k of m)isNaN(k)||e.linkStyles.set(k,{...e.linkStyles.get(k),...p})}continue}const l=a.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);if(l){const g=l[1]??l[2],p=l[2],m={id:p,label:g,nodeIds:[],children:[]};n.push(m),s.add(p),e.nodes.delete(p);continue}if(a==="}"){const g=n.pop();g&&(n.length>0?n[n.length-1].children.push(g):e.subgraphs.push(g));continue}const f=a.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);if(f){const g=q(f[1]),p=f[2];yt(e,n,{id:p,label:g,shape:"rounded"});continue}const h=a.match(/^(\[\*\]|[\w\p{L}-]+)\s*(-->)\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);if(h){let g=h[1],p=h[3];const m=h[4]?.trim(),k=m?q(m):void 0;g==="[*]"?(o++,g=`_start${o>1?o:""}`,yt(e,n,{id:g,label:"",shape:"state-start"})):s.has(g)||qt(e,n,g),p==="[*]"?(i++,p=`_end${i>1?i:""}`,yt(e,n,{id:p,label:"",shape:"state-end"})):s.has(p)||qt(e,n,p),e.edges.push({source:g,target:p,label:k,style:"solid",hasArrowStart:!1,hasArrowEnd:!0});continue}const u=a.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);if(u){const g=u[1],p=q(u[2].trim());yt(e,n,{id:g,label:p,shape:"rounded"});continue}}return e}function yt(t,e,n){if(!t.nodes.has(n.id)&&t.nodes.set(n.id,n),e.length>0){const o=e[e.length-1];o.nodeIds.includes(n.id)||o.nodeIds.push(n.id)}}function qt(t,e,n){if(!t.nodes.has(n))yt(t,e,{id:n,label:n,shape:"rounded"});else if(e.length>0){const s=e[e.length-1];s.nodeIds.includes(n)||s.nodeIds.push(n)}}function It(t){const e=t.replace(/;\s*$/,""),n={};for(const s of e.split(",")){const o=s.indexOf(":");if(o>0){const i=s.slice(0,o).trim(),r=s.slice(o+1).trim();i&&r&&(n[i]=r)}}return n}var Oe=/^(<)?(-->|-.->|==>|---|-\.-|===)(?:\|([^|]*)\|)?/,je=/^(<)?(--|-\.|==)\s+(.+?)\s+(-->|---|\.\->|-\.\-|==>|===)/,Fe=[{regex:/^([\w-]+)\(\(\((.+?)\)\)\)/,shape:"doublecircle"},{regex:/^([\w-]+)\(\[(.+?)\]\)/,shape:"stadium"},{regex:/^([\w-]+)\(\((.+?)\)\)/,shape:"circle"},{regex:/^([\w-]+)\[\[(.+?)\]\]/,shape:"subroutine"},{regex:/^([\w-]+)\[\((.+?)\)\]/,shape:"cylinder"},{regex:/^([\w-]+)\[\/(.+?)\\\]/,shape:"trapezoid"},{regex:/^([\w-]+)\[\\(.+?)\/\]/,shape:"trapezoid-alt"},{regex:/^([\w-]+)>(.+?)\]/,shape:"asymmetric"},{regex:/^([\w-]+)\{\{(.+?)\}\}/,shape:"hexagon"},{regex:/^([\w-]+)\[(.+?)\]/,shape:"rectangle"},{regex:/^([\w-]+)\((.+?)\)/,shape:"rounded"},{regex:/^([\w-]+)\{(.+?)\}/,shape:"diamond"}],qe=/^([\w-]+)/,Ve=/^:::([\w][\w-]*)/;function Ue(t,e,n){let s=t.trim();const o=Vt(s,e,n);if(!o||o.ids.length===0)return;s=o.remaining.trim();let i=o.ids;for(;s.length>0;){let r,a,c,d;const l=s.match(Oe);if(l){r=!!l[1];const h=l[2],u=l[3]?.trim();d=u?q(u):void 0,s=s.slice(l[0].length).trim(),a=Ke(h),c=h.endsWith(">")}else{const h=s.match(je);if(!h)break;r=!!h[1];const u=h[3].trim();d=u?q(u):void 0;const g=h[2],p=h[4];s=s.slice(h[0].length).trim(),a=Ze(g,p),c=p.endsWith(">")}const f=Vt(s,e,n);if(!f||f.ids.length===0)break;s=f.remaining.trim();for(const h of i)for(const u of f.ids)e.edges.push({source:h,target:u,label:d,style:a,hasArrowStart:r,hasArrowEnd:c});i=f.ids}}function Vt(t,e,n){const s=Ut(t,e,n);if(!s)return null;const o=[s.id];let i=s.remaining.trim();for(;i.startsWith("&");){i=i.slice(1).trim();const r=Ut(i,e,n);if(!r)break;o.push(r.id),i=r.remaining.trim()}return{ids:o,remaining:i}}function Ut(t,e,n){let s=null,o=t;for(const{regex:r,shape:a}of Fe){const c=t.match(r);if(c){s=c[1];const d=q(c[2]);Qt(e,n,{id:s,label:d,shape:a}),o=t.slice(c[0].length);break}}if(s===null){const r=t.match(qe);r&&(s=r[1],e.nodes.has(s)||Qt(e,n,{id:s,label:s,shape:"rectangle"}),o=t.slice(r[0].length))}if(s===null)return null;const i=o.match(Ve);return i&&(e.classAssignments.set(s,i[1]),o=o.slice(i[0].length)),{id:s,remaining:o}}function Qt(t,e,n){!t.nodes.has(n.id)&&t.nodes.set(n.id,n),Qe(e,n.id)}function Qe(t,e){if(t.length>0){const n=t[t.length-1];n.nodeIds.includes(e)||n.nodeIds.push(e)}}function Ke(t){return t==="-.->"||t==="-.-"?"dotted":t==="==>"||t==="==="?"thick":"solid"}function Ze(t,e){return t==="-."||e===".->"||e==="-.-"?"dotted":t==="=="||e==="==>"||e==="==="?"thick":"solid"}function Je(t){const e={actors:[],messages:[],blocks:[],notes:[]},n=new Set,s=[];for(let o=1;o<t.length;o++){const i=t[o],r=i.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(r){const h=r[1],u=r[2],g=r[3]?.trim()??u,p=q(g);n.has(u)||(n.add(u),e.actors.push({id:u,label:p,type:h}));continue}const a=i.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(a){const h=a[1].toLowerCase(),u=a[2].trim(),g=q(a[3].trim()),p=u.split(",").map(k=>k.trim());for(const k of p)xt(e,n,k);let m="over";h==="left of"?m="left":h==="right of"&&(m="right"),e.notes.push({actorIds:p,text:g,position:m,afterIndex:e.messages.length-1});continue}const c=i.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(c){const h=c[1],u=c[2]?.trim()??"",g=q(u);s.push({type:h,label:g,startIndex:e.messages.length,dividers:[]});continue}const d=i.match(/^(else|and)\s*(.*)$/);if(d&&s.length>0){const h=d[2]?.trim()??"",u=q(h);s[s.length-1].dividers.push({index:e.messages.length,label:u});continue}if(i==="end"&&s.length>0){const h=s.pop();e.blocks.push({type:h.type,label:h.label,startIndex:h.startIndex,endIndex:Math.max(e.messages.length-1,h.startIndex),dividers:h.dividers});continue}const l=i.match(/^(\S+?)\s*(--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(l){const h=l[1],u=l[2],g=l[3],p=l[4],m=q(l[5].trim());xt(e,n,h),xt(e,n,p);const k=u.startsWith("--")?"dashed":"solid",T=u.includes(">>")||u.includes("x")?"filled":"open",L={from:h,to:p,label:m,lineStyle:k,arrowHead:T};g==="+"&&(L.activate=!0),g==="-"&&(L.deactivate=!0),e.messages.push(L);continue}const f=i.match(/^(\S+?)\s*(->>|-->>|-\)|--\)|-x|--x|->|-->)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(f){const h=f[1],u=f[2],g=f[3],p=f[4],m=q(f[5].trim());xt(e,n,h),xt(e,n,p);const k=u.startsWith("--")?"dashed":"solid",T=u.includes(">>")||u.includes("x")?"filled":"open",L={from:h,to:p,label:m,lineStyle:k,arrowHead:T};g==="+"&&(L.activate=!0),g==="-"&&(L.deactivate=!0),e.messages.push(L);continue}}return e}function xt(t,e,n){e.has(n)||(e.add(n),t.actors.push({id:n,label:n,type:"participant"}))}function tn(t){const e={classes:[],relationships:[],namespaces:[]},n=new Map;let s=null,o=null,i=0;for(let r=1;r<t.length;r++){const a=t[r];if(o&&i>0){if(a==="}"){i--,i===0&&(o=null);continue}const g=a.match(/^<<(\w+)>>$/);if(g){o.annotation=g[1];continue}const p=Kt(a);p&&(p.isMethod?o.methods.push(p.member):o.attributes.push(p.member));continue}const c=a.match(/^namespace\s+(\S+)\s*\{$/);if(c){s={name:c[1],classIds:[]};continue}if(a==="}"&&s){e.namespaces.push(s),s=null;continue}const d=a.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(d){const g=d[1],p=d[2],m=gt(n,g);p&&(m.label=`${g}<${p}>`),o=m,i=1,s&&s.classIds.push(g);continue}const l=a.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(l){const g=l[1],p=l[2],m=gt(n,g);p&&(m.label=`${g}<${p}>`),s&&s.classIds.push(g);continue}const f=a.match(/^class\s+(\S+?)\s*\{\s*<<(\w+)>>\s*\}$/);if(f){const g=gt(n,f[1]);g.annotation=f[2];continue}const h=a.match(/^(\S+?)\s*:\s*(.+)$/);if(h){const g=h[2];if(!g.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){const p=gt(n,h[1]),m=Kt(g);m&&(m.isMethod?p.methods.push(m.member):p.attributes.push(m.member));continue}}const u=en(a);if(u){gt(n,u.from),gt(n,u.to),e.relationships.push(u);continue}}return e.classes=[...n.values()],e}function gt(t,e){let n=t.get(e);return n||(n={id:e,label:e,attributes:[],methods:[]},t.set(e,n)),n}function Kt(t){const e=t.trim().replace(/;$/,"");if(!e)return null;let n="",s=e;/^[+\-#~]/.test(s)&&(n=s[0],s=s.slice(1).trim());const o=s.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){const l=o[1].trim(),f=o[2]?.trim()||void 0,h=o[3]?.trim(),u=l.endsWith("$")||s.includes("$"),g=l.endsWith("*")||s.includes("*");return{member:{visibility:n,name:l.replace(/[$*]$/,""),type:h||void 0,isStatic:u,isAbstract:g,isMethod:!0,params:f},isMethod:!0}}const i=s.split(/\s+/);let r,a;i.length>=2?(a=i[0],r=i.slice(1).join(" ")):r=i[0]??s;const c=r.endsWith("$"),d=r.endsWith("*");return{member:{visibility:n,name:r.replace(/[$*]$/,""),type:a||void 0,isStatic:c,isAbstract:d,isMethod:!1},isMethod:!1}}function en(t){const e=t.match(/^(\S+?)\s+(?:"([^"]*?)"\s+)?(<\|--|<\|\.\.|\*--|o--|-->|--\*|--o|--\|>|\.\.>|\.\.\|>|<--|<\.\.?|--)\s+(?:"([^"]*?)"\s+)?(\S+?)(?:\s*:\s*(.+))?$/);if(!e)return null;const n=e[1],s=e[2],o=s?q(s):void 0,i=e[3].trim(),r=e[4],a=r?q(r):void 0,c=e[5],d=e[6]?.trim(),l=d?q(d):void 0,f=nn(i);return f?{from:n,to:c,type:f.type,markerAt:f.markerAt,label:l,fromCardinality:o,toCardinality:a}:null}function nn(t){switch(t.trim()){case"<|--":return{type:"inheritance",markerAt:"from"};case"--|>":return{type:"inheritance",markerAt:"to"};case"<|..":return{type:"realization",markerAt:"from"};case"..|>":return{type:"realization",markerAt:"to"};case"*--":return{type:"composition",markerAt:"from"};case"--*":return{type:"composition",markerAt:"to"};case"o--":return{type:"aggregation",markerAt:"from"};case"--o":return{type:"aggregation",markerAt:"to"};case"-->":return{type:"association",markerAt:"to"};case"<--":return{type:"association",markerAt:"from"};case"..>":return{type:"dependency",markerAt:"to"};case"<..":return{type:"dependency",markerAt:"from"};case"--":return{type:"association",markerAt:"to"};default:return null}}function sn(t){const e={entities:[],relationships:[]},n=new Map;let s=null;for(let o=1;o<t.length;o++){const i=t[o];if(s){if(i==="}"){s=null;continue}const c=on(i);c&&s.attributes.push(c);continue}const r=i.match(/^(\S+)\s*\{$/);if(r){const c=r[1];s=Tt(n,c);continue}const a=rn(i);if(a){Tt(n,a.entity1),Tt(n,a.entity2),e.relationships.push(a);continue}}return e.entities=[...n.values()],e}function Tt(t,e){let n=t.get(e);return n||(n={id:e,label:e,attributes:[]},t.set(e,n)),n}function on(t){const e=t.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!e)return null;const n=e[1],s=e[2],o=e[3]?.trim()??"",i=[];let r;const a=o.match(/"([^"]*)"/);a&&(r=q(a[1]));const c=o.replace(/"[^"]*"/,"").trim();for(const d of c.split(/\s+/)){const l=d.toUpperCase();(l==="PK"||l==="FK"||l==="UK")&&i.push(l)}return{type:n,name:s,keys:i,comment:r}}function rn(t){const e=t.match(/^(\S+)\s+([|o}{]+(?:--|\.\.)[|o}{]+)\s+(\S+)\s*:\s*(.+)$/);if(!e)return null;const n=e[1],s=e[2],o=e[3],i=e[4].trim().replace(/^["']|["']$/g,""),r=q(i),a=s.match(/^([|o}{]+)(--|\.\.?)([|o}{]+)$/);if(!a)return null;const c=a[1],d=a[2],l=a[3],f=Zt(c),h=Zt(l),u=d==="--";return!f||!h?null:{entity1:n,entity2:o,cardinality1:f,cardinality2:h,label:r,identifying:u}}function Zt(t){const e=t.split("").sort().join("");return e==="||"?"one":e==="o|"?"zero-one":e==="|}"||e==="{|"?"many":e==="{o"||e==="o{"?"zero-many":null}function an(t){const e={},n={},s=[];let o,i=!1;for(const r of t){if(/^xychart(-beta)?\b/i.test(r)){/\bhorizontal\b/i.test(r)&&(i=!0);continue}const a=r.match(/^title\s+"([^"]+)"/);if(a){o=a[1];continue}const c=r.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(e.title=c[1]),e.categories=c[2].split(",").map(g=>g.trim());continue}const d=r.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(d){d[1]&&(e.title=d[1]),e.range={min:parseFloat(d[2]),max:parseFloat(d[3])};continue}const l=r.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(n.title=l[1]),n.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}const f=r.match(/^y-axis\s+"([^"]+)"\s*$/);if(f){n.title=f[1];continue}const h=r.match(/^bar\s+\[([^\]]+)\]/);if(h){s.push({type:"bar",data:Jt(h[1])});continue}const u=r.match(/^line\s+\[([^\]]+)\]/);if(u){s.push({type:"line",data:Jt(u[1])});continue}}if(!n.range&&s.length>0){const r=s.flatMap(l=>l.data);let a=Math.min(...r),c=Math.max(...r);const d=c-a||1;a=a-d*.1,c=c+d*.1,a>0&&a<d*.5&&(a=0),n.range={min:a,max:c}}return n.range||(n.range={min:0,max:100}),{title:o,horizontal:i,xAxis:e,yAxis:n,series:s}}function Jt(t){return t.split(",").map(e=>parseFloat(e.trim()))}var Ct="#3b82f6";function fe(t){const e=t.replace("#",""),n=parseInt(e.substring(0,2),16)/255,s=parseInt(e.substring(2,4),16)/255,o=parseInt(e.substring(4,6),16)/255,i=Math.max(n,s,o),r=Math.min(n,s,o),a=(i+r)/2;if(i===r)return[0,0,a*100];const c=i-r,d=a>.5?c/(2-i-r):c/(i+r);let l;return i===n?l=((s-o)/c+(s<o?6:0))/6:i===s?l=((o-n)/c+2)/6:l=((n-s)/c+4)/6,[l*360,d*100,a*100]}function ln(t,e,n){const s=e/100,o=n/100,i=(1-Math.abs(2*o-1))*s,r=i*(1-Math.abs(t/60%2-1)),a=o-i/2;let c,d,l;t<60?(c=i,d=r,l=0):t<120?(c=r,d=i,l=0):t<180?(c=0,d=i,l=r):t<240?(c=0,d=r,l=i):t<300?(c=r,d=0,l=i):(c=i,d=0,l=r);const f=h=>Math.round((h+a)*255).toString(16).padStart(2,"0");return`#${f(c)}${f(d)}${f(l)}`}function te(t){return/^#[0-9a-fA-F]{6}$/.test(t)}function cn(t){return fe(t)[2]<50}function dn(t,e,n){if(t===0)return e;const s=te(e)?e:Ct,o=n&&te(n)?n:void 0,[i,r]=fe(s),a=Math.max(55,Math.min(85,r)),c=Math.ceil(t/2),d=t%2===1,l=o&&cn(o)?!d:d,f=l?Math.max(25,48-c*13):Math.min(78,55+c*11),h=(l?-8:12)*c,u=((i+h)%360+360)%360;return ln(u,a,f)}function J(t,e,n){return de(t,e,n)}function ue(t,e){return t.length*e*.6}var M={nodeLabel:13,edgeLabel:11,groupHeader:12},z={nodeLabel:500,edgeLabel:400,groupHeader:600},$t={horizontal:20,vertical:10,diamondExtra:24},N={outerBox:1,innerBox:.75,connector:1},Z="0.35em",ft={width:8,height:5},Et=null,mt=null;function hn(){if(Et)return;const t=[],e=globalThis.setTimeout;globalThis.setTimeout=(i,r)=>r===0?(t.push(i),0):e(i,r);const n=globalThis,s="self"in n,o=n.self;s&&typeof n.document>"u"&&delete n.self,Et=new Ae,s&&(n.self=o),globalThis.setTimeout=e,t.forEach(i=>i()),mt=Et.worker.worker}function Nt(t){hn();let e,n;const s=mt.onmessage;if(mt.onmessage=o=>{o.data.error?n=o.data.error:e=o.data.data},mt.dispatcher.saveDispatch({data:{id:0,cmd:"layout",graph:t}}),mt.onmessage=s,n)throw n;if(!e)throw new Error("ELK layout did not return synchronously");return e}function ee(t,e,n){if(t.length<2||e.shape==="rectangle"||e.shape==="rounded"||e.shape==="stadium")return t;const s=[...t];if(e.shape==="diamond")if(n)s[0]=ne(t[0],t[1],e);else{const o=t.length-1;s[o]=ne(t[o],t[o-1],e)}return s}function ne(t,e,n){const s=n.x+n.width/2,o=n.y+n.height/2;n.width/2,n.height/2;const i={x:s,y:n.y},r={x:n.x+n.width,y:o},a={x:s,y:n.y+n.height},c={x:n.x,y:o},d=t.x-e.x,l=t.y-e.y;if(Math.abs(d)<Math.abs(l)){const h=t.x;return l>0?h<=s?Lt(h,c,i)??i:Lt(h,i,r)??i:h<=s?Lt(h,a,c)??a:Lt(h,r,a)??a}else{const h=t.y;return d>0?h<=o?Mt(h,i,c)??c:Mt(h,c,a)??c:h<=o?Mt(h,i,r)??r:Mt(h,r,a)??r}}function Mt(t,e,n){const s=n.y-e.y;if(Math.abs(s)<.001)return null;const o=(t-e.y)/s;return o<0||o>1?null:{x:e.x+o*(n.x-e.x),y:t}}function Lt(t,e,n){const s=n.x-e.x;if(Math.abs(s)<.001)return null;const o=(t-e.x)/s;if(o<0||o>1)return null;const i=e.y+o*(n.y-e.y);return{x:t,y:i}}var kt={font:"Inter",padding:40,nodeSpacing:28,layerSpacing:48,mergeEdges:!0,thoroughness:3};function ge(t){switch(t){case"LR":return"RIGHT";case"RL":return"LEFT";case"BT":return"UP";default:return"DOWN"}}function pe(t,e,n){const s=ct(e,M.nodeLabel,z.nodeLabel);let o=s.width+$t.horizontal*2,i=s.height+$t.vertical*2;if(n==="diamond"){const r=Math.max(o,i)+$t.diamondExtra;o=r,i=r}if(n==="circle"||n==="doublecircle"){const r=Math.ceil(Math.sqrt(o*o+i*i))+8;o=n==="doublecircle"?r+12:r,i=o}return n==="hexagon"&&(o+=$t.horizontal),(n==="trapezoid"||n==="trapezoid-alt")&&(o+=$t.horizontal),n==="asymmetric"&&(o+=12),n==="cylinder"&&(i+=14),n==="state-start"||n==="state-end"?{width:28,height:28}:(o=Math.max(o,60),i=Math.max(i,36),{width:o,height:i})}function fn(t,e){const n=new Set,s=new Set;for(const l of t.subgraphs)s.add(l.id),$e(l,n,s);const o=un(t.subgraphs),i=new Map;i.set(null,[]);const r=[];for(let l=0;l<t.edges.length;l++){const f=t.edges[l],h=o.get(f.source),u=o.get(f.target);h&&h===u?(i.has(h)||i.set(h,[]),i.get(h).push({index:l,edge:f})):!h&&!u?i.get(null).push({index:l,edge:f}):r.push({index:l,edge:f,sourceSubgraph:h,targetSubgraph:u})}const a=t.subgraphs.some(l=>l.direction!==void 0),c={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":ge(t.direction),"elk.spacing.nodeNode":String(e.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(e.layerSpacing),"elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"12","elk.padding":`[top=${e.padding},left=${e.padding},bottom=${e.padding},right=${e.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.contentAlignment":"H_CENTER V_CENTER","elk.layered.thoroughness":String(kt.thoroughness),"elk.layered.highDegreeNodes.treatment":"true","elk.layered.highDegreeNodes.threshold":"8","elk.layered.compaction.postCompaction.strategy":"LEFT_RIGHT_CONSTRAINT_LOCKING","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.wrapping.strategy":"OFF","elk.hierarchyHandling":a?"SEPARATE":"INCLUDE_CHILDREN"},children:[],edges:[]},d=new Map;if(a)for(const{index:l,edge:f,sourceSubgraph:h,targetSubgraph:u}of r){if(h){const g=`${h}_out_${l}`;d.has(h)||d.set(h,[]),d.get(h).push({portId:g,edgeIndex:l,direction:"outgoing",internalNodeId:f.source})}if(u){const g=`${u}_in_${l}`;d.has(u)||d.set(u,[]),d.get(u).push({portId:g,edgeIndex:l,direction:"incoming",internalNodeId:f.target})}}for(const[l,f]of t.nodes)if(!n.has(l)&&!s.has(l)){const h=pe(l,f.label,f.shape);c.children.push({id:l,width:h.width,height:h.height,labels:[{text:f.label}]})}for(const l of t.subgraphs)c.children.push(xe(l,t,e,i,d));for(const{index:l,edge:f}of i.get(null)){const h={id:`e${l}`,sources:[f.source],targets:[f.target]};if(f.label){const u=ct(f.label,M.edgeLabel,z.edgeLabel);h.labels=[{text:f.label,width:u.width+8,height:u.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}c.edges.push(h)}for(const{index:l,edge:f,sourceSubgraph:h,targetSubgraph:u}of r){const g={id:`e${l}`,sources:a&&h?[`${h}_out_${l}`]:[f.source],targets:a&&u?[`${u}_in_${l}`]:[f.target]};if(f.label){const p=ct(f.label,M.edgeLabel,z.edgeLabel);g.labels=[{text:f.label,width:p.width+8,height:p.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}c.edges.push(g)}return c}function xe(t,e,n,s,o){const i={"elk.algorithm":"layered","elk.padding":"[top=44,left=16,bottom=16,right=16]","elk.edgeRouting":"ORTHOGONAL","elk.contentAlignment":"H_CENTER V_CENTER","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"12","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.layered.spacing.nodeNodeBetweenLayers":String(n.layerSpacing),"elk.spacing.nodeNode":String(n.nodeSpacing)};t.direction&&(i["elk.direction"]=ge(t.direction));const r={id:t.id,layoutOptions:i,labels:t.label?[{text:t.label}]:void 0,children:[],edges:[]},a=o.get(t.id)??[];a.length>0&&(r.ports=a.map(d=>({id:d.portId})));for(const d of t.nodeIds){const l=e.nodes.get(d);if(l){const f=pe(d,l.label,l.shape);r.children.push({id:d,width:f.width,height:f.height,labels:[{text:l.label}]})}}for(const d of t.children)r.children.push(xe(d,e,n,s,o));const c=s.get(t.id)??[];for(const{index:d,edge:l}of c){const f={id:`e${d}`,sources:[l.source],targets:[l.target]};if(l.label){const h=ct(l.label,M.edgeLabel,z.edgeLabel);f.labels=[{text:l.label,width:h.width+8,height:h.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}r.edges.push(f)}for(const d of a){const l=`e${d.edgeIndex}_internal`,f=d.direction==="incoming"?{id:l,sources:[d.portId],targets:[d.internalNodeId]}:{id:l,sources:[d.internalNodeId],targets:[d.portId]};r.edges.push(f)}return r}function $e(t,e,n){for(const s of t.nodeIds)e.add(s);for(const s of t.children)n.add(s.id),$e(s,e,n)}function un(t){const e=new Map;function n(s){for(const o of s.nodeIds)e.set(o,s.id);for(const o of s.children)n(o)}for(const s of t)n(s);return e}function ye(t){const e=[];for(const n of t)e.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height}),e.push(...ye(n.children));return e}function gn(t,e,n=!1){const s=[],o=[],i=[],r=new Set;for(const g of e.subgraphs)we(g,r);Pt(t,e,r,s,i,0,0);const a=ye(i),c=a.length>0?{leftX:Math.min(...a.map(g=>g.x))-20,rightX:Math.max(...a.map(g=>g.right))+20}:void 0;pn(t,e,o,0,0,c),mn(s,o,e.direction),n&&bn(o,s,i,e.direction);const d=new Map(s.map(g=>[g.id,g]));for(const g of o){const p=d.get(g.source),m=d.get(g.target);p&&(g.points=ee(g.points,p,!0)),m&&(g.points=ee(g.points,m,!1))}let l=t.width??800,f=t.height??600;const h=ft.width,u=kt.padding;for(const g of o){for(const p of g.points)l=Math.max(l,p.x+h+u),f=Math.max(f,p.y+h+u);g.labelPosition&&(l=Math.max(l,g.labelPosition.x+60+u),f=Math.max(f,g.labelPosition.y+20+u))}return{width:l,height:f,nodes:s,edges:o,groups:i}}function Pt(t,e,n,s,o,i,r){if(t.children)for(const a of t.children){const c=(a.x??0)+i,d=(a.y??0)+r,l=a.width??0,f=a.height??0;if(n.has(a.id)){const h=[];Pt(a,e,n,s,h,c,d);const u=be(e.subgraphs,a.id);o.push({id:a.id,label:u?.label??"",x:c,y:d,width:l,height:f,children:h})}else{const h=e.nodes.get(a.id);if(h){const u=$n(a.id,e);s.push({id:a.id,label:h.label,shape:h.shape,x:c,y:d,width:l,height:f,inlineStyle:u})}a.children&&a.children.length>0&&Pt(a,e,n,s,o,c,d)}}}function se(t){if(t.length===0)return{x:0,y:0};if(t.length===1)return t[0];let e=0;for(let s=1;s<t.length;s++){const o=t[s].x-t[s-1].x,i=t[s].y-t[s-1].y;e+=Math.sqrt(o*o+i*i)}let n=e/2;for(let s=1;s<t.length;s++){const o=t[s].x-t[s-1].x,i=t[s].y-t[s-1].y,r=Math.sqrt(o*o+i*i);if(n<=r){const a=n/r;return{x:t[s-1].x+a*o,y:t[s-1].y+a*i}}n-=r}return t[t.length-1]}function pn(t,e,n,s,o,i){const r=new Map;me(t,r,0,0);let a=0;for(const[c,d]of r){const l=e.edges[c];if(!l)continue;const f=[];d.outgoing&&d.outgoing.points.length>0&&f.push(...d.outgoing.points),d.external&&d.external.points.length>0&&(f.length>0?f.push(...d.external.points.slice(1)):f.push(...d.external.points)),d.incoming&&d.incoming.points.length>0&&(f.length>0?f.push(...d.incoming.points.slice(1)):f.push(...d.incoming.points));let h;l.label&&f.length>=2&&(h=d.external?.labelPosition??se(f));const u=xn(f,i,a);u!==f&&a++,l.label&&u!==f&&u.length>=2&&(h=se(u)),n.push({source:l.source,target:l.target,label:l.label,style:l.style,hasArrowStart:l.hasArrowStart,hasArrowEnd:l.hasArrowEnd,points:u,labelPosition:h,inlineStyle:yn(c,e)})}}function xn(t,e,n=0){if(t.length<2)return t;let s=!1;for(let r=1;r<t.length;r++){const a=Math.abs(t[r].x-t[r-1].x),c=Math.abs(t[r].y-t[r-1].y);if(a>1&&c>1){s=!0;break}}if(!s)return t;const o=12,i=[t[0]];for(let r=1;r<t.length;r++){const a=i[i.length-1],c=t[r],d=Math.abs(c.x-a.x),l=Math.abs(c.y-a.y);if(d>1&&l>1)if(e){const f=n%2===0,h=Math.floor(n/2)*o,u=f?e.rightX+h:e.leftX-h;i.push({x:u,y:a.y}),i.push({x:u,y:c.y})}else{const f=(a.y+c.y)/2;i.push({x:a.x,y:f}),i.push({x:c.x,y:f})}i.push(c)}return i}function me(t,e,n,s){if(t.edges)for(const o of t.edges){const i=o.id.endsWith("_internal"),r=parseInt(o.id.substring(1),10);if(isNaN(r))continue;const a=[];if(o.sections&&o.sections.length>0){const l=o.sections[0];if(a.push({x:l.startPoint.x+n,y:l.startPoint.y+s}),l.bendPoints)for(const f of l.bendPoints)a.push({x:f.x+n,y:f.y+s});a.push({x:l.endPoint.x+n,y:l.endPoint.y+s})}let c;if(o.labels&&o.labels.length>0){const l=o.labels[0];l.x!=null&&l.y!=null&&(c={x:l.x+(l.width??0)/2+n,y:l.y+(l.height??0)/2+s})}e.has(r)||e.set(r,{});const d=e.get(r);if(i){const l=o.sources?.[0]??"",f=o.targets?.[0]??"",h=l.includes("_in_")||l.includes("_out_"),u=f.includes("_in_")||f.includes("_out_");h?d.incoming={edgeIndex:r,isInternal:i,points:a,labelPosition:c}:u&&(d.outgoing={edgeIndex:r,isInternal:i,points:a,labelPosition:c})}else d.external={edgeIndex:r,isInternal:i,points:a,labelPosition:c}}if(t.children)for(const o of t.children)me(o,e,n+(o.x??0),s+(o.y??0))}function be(t,e){for(const n of t){if(n.id===e)return n;const s=be(n.children,e);if(s)return s}}function we(t,e){e.add(t.id);for(const n of t.children)we(n,e)}function $n(t,e){let n;const s=e.classAssignments.get(t);if(s){const i=e.classDefs.get(s);i&&(n={...i})}const o=e.nodeStyles.get(t);return o&&(n=n?{...n,...o}:{...o}),n}function yn(t,e){let n;const s=e.linkStyles.get("default");s&&(n={...s});const o=e.linkStyles.get(t);return o&&(n=n?{...n,...o}:{...o}),n}function mn(t,e,n){if(t.length===0)return;const s=n==="LR"||n==="RL",o=new Set;for(const l of e)o.add(`${l.source}:${l.target}`),o.add(`${l.target}:${l.source}`);const i=kt.layerSpacing*.6,r=[...t].sort((l,f)=>s?l.x-f.x:l.y-f.y),a=[];let c=[r[0]];for(let l=1;l<r.length;l++){const f=s?r[l].x:r[l].y,h=s?r[l-1].x:r[l-1].y,u=f-h,g=c.some(p=>o.has(`${p.id}:${r[l].id}`));u<=i&&!g?c.push(r[l]):(a.push(c),c=[r[l]])}a.push(c);const d=new Map;for(const l of a){if(l.length<=1)continue;const f=l.map(p=>s?p.x:p.y),h=Math.min(...f),u=Math.max(...f);if(u-h<=1)continue;const g=(h+u)/2;for(const p of l){const m=s?p.x:p.y,k=g-m;Math.abs(k)>.5&&(s?p.x=g:p.y=g,d.set(p.id,k))}}if(d.size!==0){new Map(t.map(l=>[l.id,l]));for(const l of e){if(l.points.length<2)continue;const f=d.get(l.source),h=d.get(l.target);if(f!=null){const u=l.points[0];s?(u.x+=f,l.points.length>1&&l.points[1].x===u.x-f&&(l.points[1].x+=f)):(u.y+=f,l.points.length>1&&l.points[1].y===u.y-f&&(l.points[1].y+=f))}if(h!=null){const u=l.points[l.points.length-1];if(s){if(u.x+=h,l.points.length>1){const g=l.points[l.points.length-2];g.x===u.x-h&&(g.x+=h)}}else if(u.y+=h,l.points.length>1){const g=l.points[l.points.length-2];g.y===u.y-h&&(g.y+=h)}}}}}function Xt(t,e,n){const s=[];for(const o of n)t>=o.x&&t<=o.x+o.width&&e>=o.y&&e<=o.y+o.height&&(s.push(o),s.push(...Xt(t,e,o.children)));return s}function At(t,e,n,s,o){const r=o==="LR",a=o==="RL",c=o==="BT",d=r||a,l=new Set(Xt(e,n,s).map(p=>p.id)),g=Xt(d?t:e,d?n:t,s).find(p=>!l.has(p.id));return g?r?g.x-12:a?g.x+g.width+12:c?g.y+g.height+12:g.y-12:t}function bn(t,e,n,s){const o=new Map(e.map(h=>[h.id,h])),i=new Set,r=s==="LR",a=s==="RL",c=s==="BT",d=r||a,l=new Map;for(const h of t)h.source!==h.target&&(l.has(h.source)||l.set(h.source,[]),l.get(h.source).push(h));for(const[h,u]of l){if(u.length<2)continue;const g=u[0].style;if(u.some(S=>S.label||S.style!==g))continue;const p=o.get(h);if(!p)continue;const m=u.filter(S=>{const w=o.get(S.target);return w?r?w.x>p.x+p.width:a?w.x+w.width<p.x:c?w.y+w.height<p.y:w.y>p.y+p.height:!1});if(m.length<2)continue;const k=m.map(S=>({edge:S,node:o.get(S.target)})),T=p.x+p.width/2,L=p.y+p.height/2;if(d){const S=r?p.x+p.width:p.x,w=L,Y=r?Math.min(...k.map($=>$.node.x)):Math.max(...k.map($=>$.node.x+$.node.width));let E=S+(Y-S)/2;E=At(E,T,L,n,s);for(const{edge:$,node:x}of k){const b=r?x.x:x.x+x.width,A=x.y+x.height/2;$.points=[{x:S,y:w},{x:E,y:w},{x:E,y:A},{x:b,y:A}],i.add($)}}else{const S=T,w=c?p.y:p.y+p.height,Y=c?Math.max(...k.map($=>$.node.y+$.node.height)):Math.min(...k.map($=>$.node.y));let E=w+(Y-w)/2;E=At(E,T,L,n,s);for(const{edge:$,node:x}of k){const b=x.x+x.width/2,A=c?x.y+x.height:x.y;$.points=[{x:S,y:w},{x:S,y:E},{x:b,y:E},{x:b,y:A}],i.add($)}}}const f=new Map;for(const h of t)i.has(h)||h.source===h.target||(f.has(h.target)||f.set(h.target,[]),f.get(h.target).push(h));for(const[h,u]of f){if(u.length<2)continue;const g=u[0].style;if(u.some(S=>S.label||S.style!==g))continue;const p=o.get(h);if(!p)continue;const m=u.filter(S=>{const w=o.get(S.source);return w?r?w.x+w.width<p.x:a?w.x>p.x+p.width:c?w.y>p.y+p.height:w.y+w.height<p.y:!1});if(m.length<2)continue;const k=m.map(S=>({edge:S,node:o.get(S.source)})),T=p.x+p.width/2,L=p.y+p.height/2;if(d){const S=r?p.x:p.x+p.width,w=L,Y=r?Math.max(...k.map($=>$.node.x+$.node.width)):Math.min(...k.map($=>$.node.x));let E=Y+(S-Y)/2;E=At(E,T,L,n,s);for(const{edge:$,node:x}of k){const b=r?x.x+x.width:x.x,A=x.y+x.height/2;$.points=[{x:b,y:A},{x:E,y:A},{x:E,y:w},{x:S,y:w}]}}else{const S=T,w=c?p.y+p.height:p.y,Y=c?Math.min(...k.map($=>$.node.y)):Math.max(...k.map($=>$.node.y+$.node.height));let E=Y+(w-Y)/2;E=At(E,T,L,n,s);for(const{edge:$,node:x}of k){const b=x.x+x.width/2,A=c?x.y:x.y+x.height;$.points=[{x:b,y:A},{x:b,y:E},{x:S,y:E},{x:S,y:w}]}}}}function wn(t,e={}){const n={...kt,...e},s=fn(t,n),o=Nt(s);return gn(o,t,kt.mergeEdges)}function kn(t,e,n="Inter",s=!1){const o=[];o.push(St(t.width,t.height,e,s)),o.push(vt(n,!1)),o.push("<defs>"),o.push(vn());const i=new Set;for(const r of t.edges)r.inlineStyle?.stroke&&i.add(r.inlineStyle.stroke);for(const r of i)o.push(Sn(r));o.push("</defs>");for(const r of t.groups)o.push(ve(r));for(const r of t.edges)o.push(Mn(r));for(const r of t.edges)r.label&&o.push(An(r));for(const r of t.nodes)o.push(_n(r));return o.push("</svg>"),o.join(`
23
+ `)}function vn(){const t=ft.width,e=ft.height,n='fill="var(--_arrow)" stroke="var(--_arrow)" stroke-width="0.75" stroke-linejoin="round"',s=t-1;return` <marker id="arrowhead" markerWidth="${t}" markerHeight="${e}" refX="${s}" refY="${e/2}" orient="auto">
24
+ <polygon points="0 0, ${t} ${e/2}, 0 ${e}" ${n} />
25
+ </marker>
26
+ <marker id="arrowhead-start" markerWidth="${t}" markerHeight="${e}" refX="1" refY="${e/2}" orient="auto-start-reverse">
27
+ <polygon points="${t} 0, 0 ${e/2}, ${t} ${e}" ${n} />
28
+ </marker>`}function Sn(t){const e=ft.width,n=ft.height,s=Q(t),o=`fill="${s}" stroke="${s}" stroke-width="0.75" stroke-linejoin="round"`,i=e-1,r=ke(t);return` <marker id="arrowhead-${r}" markerWidth="${e}" markerHeight="${n}" refX="${i}" refY="${n/2}" orient="auto">
29
+ <polygon points="0 0, ${e} ${n/2}, 0 ${n}" ${o} />
30
+ </marker>
31
+ <marker id="arrowhead-start-${r}" markerWidth="${e}" markerHeight="${n}" refX="1" refY="${n/2}" orient="auto-start-reverse">
32
+ <polygon points="${e} 0, 0 ${n/2}, ${e} ${n}" ${o} />
33
+ </marker>`}function ke(t){return t.replace(/[^a-zA-Z0-9]/g,e=>e.charCodeAt(0).toString(16))}function ve(t,e){const n=M.groupHeader+16,s=[];s.push(`<g class="subgraph" data-id="${Q(t.id)}" data-label="${Q(t.label)}">`),s.push(` <rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),s.push(` <rect x="${t.x}" y="${t.y}" width="${t.width}" height="${n}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),s.push(" "+tt(t.label,t.x+12,t.y+n/2,M.groupHeader,`font-size="${M.groupHeader}" font-weight="${z.groupHeader}" fill="var(--_text-sec)"`));for(const o of t.children)s.push(ve(o));return s.push("</g>"),s.join(`
34
+ `)}function Mn(t){if(t.points.length<2)return"";const e=Ln(t.points),n=t.style==="dotted"?' stroke-dasharray="4 4"':"",s=t.style==="thick"?N.connector*2:N.connector,o=Q(t.inlineStyle?.stroke??"var(--_line)"),i=Q(t.inlineStyle?.["stroke-width"]??String(s)),r=t.inlineStyle?.stroke?`-${ke(t.inlineStyle.stroke)}`:"";let a="";t.hasArrowEnd&&(a+=` marker-end="url(#arrowhead${r})"`),t.hasArrowStart&&(a+=` marker-start="url(#arrowhead-start${r})"`);const c=['class="edge"',`data-from="${Q(t.source)}"`,`data-to="${Q(t.target)}"`,`data-style="${t.style}"`,`data-arrow-start="${t.hasArrowStart}"`,`data-arrow-end="${t.hasArrowEnd}"`];return t.label&&c.push(`data-label="${Q(t.label)}"`),`<polyline ${c.join(" ")} points="${e}" fill="none" stroke="${o}" stroke-width="${i}"${n}${a} />`}function Ln(t){return t.map(e=>`${e.x},${e.y}`).join(" ")}function An(t,e){const n=t.labelPosition??In(t.points),s=t.label,o=8,i=ct(s,M.edgeLabel,z.edgeLabel),r=Be(s,n.x,n.y,i.width,i.height,M.edgeLabel,o,`text-anchor="middle" font-size="${M.edgeLabel}" font-weight="${z.edgeLabel}" fill="var(--_text-sec)"`,'rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="1"');return`<g class="edge-label" data-from="${Q(t.source)}" data-to="${Q(t.target)}" data-label="${Q(s)}">
35
+ ${r.replace(/\n/g,`
36
+ `)}
37
+ </g>`}function In(t){if(t.length===0)return{x:0,y:0};if(t.length===1)return t[0];let e=0;for(let s=1;s<t.length;s++)e+=oe(t[s-1],t[s]);let n=e/2;for(let s=1;s<t.length;s++){const o=oe(t[s-1],t[s]);if(n<=o){const i=n/o;return{x:t[s-1].x+i*(t[s].x-t[s-1].x),y:t[s-1].y+i*(t[s].y-t[s-1].y)}}n-=o}return t[t.length-1]}function oe(t,e){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function _n(t,e){const n=Wn(t),s=jn(t),o=[];return o.push(`<g class="node" data-id="${Q(t.id)}" data-label="${Q(t.label)}" data-shape="${t.shape}">`),o.push(` ${n.replace(/\n/g,`
38
+ `)}`),s&&o.push(` ${s.replace(/\n/g,`
39
+ `)}`),o.push("</g>"),o.join(`
40
+ `)}function Wn(t){const{x:e,y:n,width:s,height:o,shape:i,inlineStyle:r}=t,a=Q(r?.fill??"var(--_node-fill)"),c=Q(r?.stroke??"var(--_node-stroke)"),d=Q(r?.["stroke-width"]??String(N.innerBox));switch(i){case"diamond":return Rn(e,n,s,o,a,c,d);case"rounded":return Tn(e,n,s,o,a,c,d);case"stadium":return En(e,n,s,o,a,c,d);case"circle":return zn(e,n,s,o,a,c,d);case"subroutine":return Cn(e,n,s,o,a,c,d);case"doublecircle":return Pn(e,n,s,o,a,c,d);case"hexagon":return Xn(e,n,s,o,a,c,d);case"cylinder":return Nn(e,n,s,o,a,c,d);case"asymmetric":return Bn(e,n,s,o,a,c,d);case"trapezoid":return Yn(e,n,s,o,a,c,d);case"trapezoid-alt":return Gn(e,n,s,o,a,c,d);case"state-start":return Dn(e,n,s,o);case"state-end":return On(e,n,s,o);default:return Hn(e,n,s,o,a,c,d)}}function Hn(t,e,n,s,o,i,r){return`<rect x="${t}" y="${e}" width="${n}" height="${s}" rx="0" ry="0" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Tn(t,e,n,s,o,i,r){return`<rect x="${t}" y="${e}" width="${n}" height="${s}" rx="6" ry="6" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function En(t,e,n,s,o,i,r){const a=s/2;return`<rect x="${t}" y="${e}" width="${n}" height="${s}" rx="${a}" ry="${a}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function zn(t,e,n,s,o,i,r){const a=t+n/2,c=e+s/2,d=Math.min(n,s)/2;return`<circle cx="${a}" cy="${c}" r="${d}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Rn(t,e,n,s,o,i,r){const a=t+n/2,c=e+s/2,d=n/2,l=s/2;return`<polygon points="${[`${a},${c-l}`,`${a+d},${c}`,`${a},${c+l}`,`${a-d},${c}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Cn(t,e,n,s,o,i,r){return`<rect x="${t}" y="${e}" width="${n}" height="${s}" rx="0" ry="0" fill="${o}" stroke="${i}" stroke-width="${r}" />
41
+ <line x1="${t+8}" y1="${e}" x2="${t+8}" y2="${e+s}" stroke="${i}" stroke-width="${r}" />
42
+ <line x1="${t+n-8}" y1="${e}" x2="${t+n-8}" y2="${e+s}" stroke="${i}" stroke-width="${r}" />`}function Pn(t,e,n,s,o,i,r){const a=t+n/2,c=e+s/2,d=Math.min(n,s)/2,l=d-5;return`<circle cx="${a}" cy="${c}" r="${d}" fill="${o}" stroke="${i}" stroke-width="${r}" />
43
+ <circle cx="${a}" cy="${c}" r="${l}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Xn(t,e,n,s,o,i,r){const a=s/4;return`<polygon points="${[`${t+a},${e}`,`${t+n-a},${e}`,`${t+n},${e+s/2}`,`${t+n-a},${e+s}`,`${t+a},${e+s}`,`${t},${e+s/2}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Nn(t,e,n,s,o,i,r){const c=t+n/2,d=e+7,l=s-14;return`<rect x="${t}" y="${d}" width="${n}" height="${l}" fill="${o}" stroke="none" />
44
+ <line x1="${t}" y1="${d}" x2="${t}" y2="${d+l}" stroke="${i}" stroke-width="${r}" />
45
+ <line x1="${t+n}" y1="${d}" x2="${t+n}" y2="${d+l}" stroke="${i}" stroke-width="${r}" />
46
+ <ellipse cx="${c}" cy="${e+s-7}" rx="${n/2}" ry="7" fill="${o}" stroke="${i}" stroke-width="${r}" />
47
+ <ellipse cx="${c}" cy="${d}" rx="${n/2}" ry="7" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Bn(t,e,n,s,o,i,r){return`<polygon points="${[`${t+12},${e}`,`${t+n},${e}`,`${t+n},${e+s}`,`${t+12},${e+s}`,`${t},${e+s/2}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Yn(t,e,n,s,o,i,r){const a=n*.15;return`<polygon points="${[`${t+a},${e}`,`${t+n-a},${e}`,`${t+n},${e+s}`,`${t},${e+s}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Gn(t,e,n,s,o,i,r){const a=n*.15;return`<polygon points="${[`${t},${e}`,`${t+n},${e}`,`${t+n-a},${e+s}`,`${t+a},${e+s}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${r}" />`}function Dn(t,e,n,s){const o=t+n/2,i=e+s/2,r=Math.min(n,s)/2-2;return`<circle cx="${o}" cy="${i}" r="${r}" fill="var(--_text)" stroke="none" />`}function On(t,e,n,s){const o=t+n/2,i=e+s/2,r=Math.min(n,s)/2-2,a=r-4;return`<circle cx="${o}" cy="${i}" r="${r}" fill="none" stroke="var(--_text)" stroke-width="${N.innerBox*2}" />
48
+ <circle cx="${o}" cy="${i}" r="${a}" fill="var(--_text)" stroke="none" />`}function jn(t,e){if((t.shape==="state-start"||t.shape==="state-end")&&!t.label)return"";const n=t.x+t.width/2,s=t.y+t.height/2,o=Q(t.inlineStyle?.color??"var(--_text)");return tt(t.label,n,s,M.nodeLabel,`text-anchor="middle" font-size="${M.nodeLabel}" font-weight="${z.nodeLabel}" fill="${o}"`)}function Q(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var W={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:20,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10};function Fn(t,e={}){if(t.actors.length===0)return{width:0,height:0,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[]};const n=t.actors.map(x=>{const b=J(x.label,M.nodeLabel,z.nodeLabel);return Math.max(b+W.actorPadX*2,80)}),s=[];let o=W.padding+n[0]/2;for(let x=0;x<t.actors.length;x++){if(x>0){const b=Math.max(W.actorGap,(n[x-1]+n[x])/2+40);o+=b}s.push(o)}const i=new Map;for(let x=0;x<t.actors.length;x++)i.set(t.actors[x].id,x);const r=W.padding,a=t.actors.map((x,b)=>({id:x.id,label:x.label,type:x.type,x:s[b],y:r,width:n[b],height:W.actorHeight}));let c=r+W.actorHeight+W.headerGap;const d=[],l=new Map;for(const x of t.blocks){const b=l.get(x.startIndex)??0;l.set(x.startIndex,Math.max(b,W.blockHeaderExtra));for(const A of x.dividers){const P=l.get(A.index)??0;l.set(A.index,Math.max(P,W.dividerExtra))}}const f=new Map;for(const x of t.notes){const b=f.get(x.afterIndex)??[];b.push(x),f.set(x.afterIndex,b)}const h=[],u=new Map,g=[],p=4;for(let x=0;x<t.messages.length;x++){const b=t.messages[x],A=i.get(b.from)??0,P=i.get(b.to)??0,I=b.from===b.to,D=l.get(x)??0;D>0&&(c+=D);const j=s[A],nt=s[P];if(d.push({from:b.from,to:b.to,label:b.label,lineStyle:b.lineStyle,arrowHead:b.arrowHead,x1:j,x2:nt,y:c,isSelf:I}),b.activate){u.has(b.to)||u.set(b.to,[]);const V=u.get(b.to),R=V.length;V.push({startY:c,depth:R})}if(b.deactivate){const V=u.get(b.from);if(V&&V.length>0){const{startY:R,depth:H}=V.pop(),B=i.get(b.from)??0,X=H*p;g.push({actorId:b.from,x:s[B]-W.activationWidth/2+X,topY:R,bottomY:c,width:W.activationWidth})}}c+=I?W.selfMessageHeight+W.messageRowHeight:W.messageRowHeight;const K=f.get(x);if(K&&K.length>0){const V=I?W.selfMessageHeight:0;let R=d[x].y+V+8;for(const H of K){const B=Math.max(W.noteWidth,J(H.text,M.edgeLabel,z.edgeLabel)+W.notePadX*2),X=M.edgeLabel+W.notePadY*2,_=i.get(H.actorIds[0]??"")??0;let F;if(H.position==="left")F=s[_]-n[_]/2-B-W.noteGap;else if(H.position==="right")F=s[_]+n[_]/2+W.noteGap;else if(H.actorIds.length>1){const st=i.get(H.actorIds[H.actorIds.length-1]??"")??_;F=(s[_]+s[st])/2-B/2}else F=s[_]-B/2;h.push({text:H.text,x:F,y:R,width:B,height:X,position:H.position,actors:H.actorIds}),R+=X+4}c=Math.max(c,R+W.messageRowHeight/2)}}for(const[x,b]of u)for(const{startY:A,depth:P}of b){const I=i.get(x)??0,D=P*p;g.push({actorId:x,x:s[I]-W.activationWidth/2+D,topY:A,bottomY:c-W.messageRowHeight/2,width:W.activationWidth})}const m=t.blocks.map(x=>{const b=d[x.startIndex],A=d[x.endIndex],P=(b?.y??c)-W.blockPadTop,I=(A?.y??c)+W.blockPadBottom+12,D=new Set;for(let H=x.startIndex;H<=x.endIndex;H++){const B=t.messages[H];B&&(D.add(i.get(B.from)??0),D.add(i.get(B.to)??0))}if(D.size===0)for(let H=0;H<t.actors.length;H++)D.add(H);const j=Math.min(...D),nt=Math.max(...D),K=s[j]-n[j]/2-W.blockPadX,V=s[nt]+n[nt]/2+W.blockPadX,R=x.dividers.map(H=>{const B=d[H.index],X=B?.y??c;let _=28;if(H.label&&B?.label){const F=`[${H.label}]`,st=J(F,M.edgeLabel,z.edgeLabel),dt=K+8,pt=dt+st,ut=J(B.label,M.edgeLabel,z.edgeLabel),ht=B.isSelf?B.x1+36:(B.x1+B.x2)/2-ut/2,at=ht+ut;pt>ht&&dt<at&&(_=36)}return{y:X-_,label:H.label}});return{type:x.type,label:x.label,x:K,y:P,width:V-K,height:I-P,dividers:R}}),k=h,T=c+W.padding;let L=W.padding,S=0;for(const x of a)L=Math.min(L,x.x-x.width/2),S=Math.max(S,x.x+x.width/2);for(const x of m)L=Math.min(L,x.x),S=Math.max(S,x.x+x.width);for(const x of k)L=Math.min(L,x.x),S=Math.max(S,x.x+x.width);for(const x of d)if(x.isSelf&&x.label){const P=x.x1+30+8,I=J(x.label,M.edgeLabel,z.edgeLabel);S=Math.max(S,P+I+8)}const w=L<W.padding?W.padding-L:0;if(w>0){for(const x of a)x.x+=w;for(const x of d)x.x1+=w,x.x2+=w;for(const x of g)x.x+=w;for(const x of m)x.x+=w;for(const x of k)x.x+=w;for(let x=0;x<s.length;x++)s[x]+=w}const Y=t.actors.map((x,b)=>({actorId:x.id,x:s[b],topY:r+W.actorHeight,bottomY:T-W.padding})),E=S+w+W.padding,$=T;return{width:Math.max(E,200),height:Math.max($,100),actors:a,lifelines:Y,messages:d,activations:g,blocks:m,notes:k}}function qn(t,e,n="Inter",s=!1){const o=[];o.push(St(t.width,t.height,e,s)),o.push(vt(n,!1)),o.push("<defs>"),o.push(Vn()),o.push("</defs>");for(const i of t.blocks)o.push(Jn(i));for(const i of t.lifelines)o.push(Qn(i));for(const i of t.activations)o.push(Kn(i));for(const i of t.messages)o.push(Zn(i));for(const i of t.notes)o.push(ts(i));for(const i of t.actors)o.push(Un(i));return o.push("</svg>"),o.join(`
49
+ `)}function Vn(){const t=ft.width,e=ft.height;return` <marker id="seq-arrow" markerWidth="${t}" markerHeight="${e}" refX="${t}" refY="${e/2}" orient="auto-start-reverse">
50
+ <polygon points="0 0, ${t} ${e/2}, 0 ${e}" fill="var(--_arrow)" />
51
+ </marker>
52
+ <marker id="seq-arrow-open" markerWidth="${t}" markerHeight="${e}" refX="${t}" refY="${e/2}" orient="auto-start-reverse">
53
+ <polyline points="0 0, ${t} ${e/2}, 0 ${e}" fill="none" stroke="var(--_arrow)" stroke-width="1" />
54
+ </marker>`}function Un(t){const{id:e,x:n,y:s,width:o,height:i,label:r,type:a}=t,c=[];if(c.push(`<g class="actor" data-id="${ot(e)}" data-label="${ot(r)}" data-type="${a}">`),a==="actor"){const d=i/24*.9,l=n-12*d,f=s+(i-24*d)/2,h=N.outerBox/d,u="var(--_line)";c.push(` <g transform="translate(${l},${f}) scale(${d})">
55
+ <path d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" fill="none" stroke="${u}" stroke-width="${h}" />
56
+ <path d="M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z" fill="none" stroke="${u}" stroke-width="${h}" />
57
+ <path d="M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563" fill="none" stroke="${u}" stroke-width="${h}" />
58
+ </g>`),c.push(" "+tt(r,n,s+i+14,M.nodeLabel,`font-size="${M.nodeLabel}" text-anchor="middle" font-weight="${z.nodeLabel}" fill="var(--_text)"`))}else{const d=n-o/2;c.push(` <rect x="${d}" y="${s}" width="${o}" height="${i}" rx="4" ry="4" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),c.push(" "+tt(r,n,s+i/2,M.nodeLabel,`font-size="${M.nodeLabel}" text-anchor="middle" font-weight="${z.nodeLabel}" fill="var(--_text)"`))}return c.push("</g>"),c.join(`
59
+ `)}function Qn(t){return`<line class="lifeline" data-actor="${ot(t.actorId)}" x1="${t.x}" y1="${t.topY}" x2="${t.x}" y2="${t.bottomY}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`}function Kn(t){return`<rect class="activation" data-actor="${ot(t.actorId)}" x="${t.x}" y="${t.topY}" width="${t.width}" height="${t.bottomY-t.topY}" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />`}function Zn(t){const e=[],n=t.lineStyle==="dashed"?' stroke-dasharray="6 4"':"",s=t.arrowHead==="filled"?"seq-arrow":"seq-arrow-open";if(e.push(`<g class="message" data-from="${ot(t.from)}" data-to="${ot(t.to)}" data-label="${ot(t.label)}" data-line-style="${t.lineStyle}" data-arrow-head="${t.arrowHead}" data-self="${t.isSelf}">`),t.isSelf)e.push(` <polyline points="${t.x1},${t.y} ${t.x1+30},${t.y} ${t.x1+30},${t.y+20} ${t.x2},${t.y+20}" fill="none" stroke="var(--_line)" stroke-width="${N.connector}"${n} marker-end="url(#${s})" />`),e.push(" "+tt(t.label,t.x1+30+8,t.y+20/2,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="start" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`));else{e.push(` <line x1="${t.x1}" y1="${t.y}" x2="${t.x2}" y2="${t.y}" stroke="var(--_line)" stroke-width="${N.connector}"${n} marker-end="url(#${s})" />`);const o=(t.x1+t.x2)/2;e.push(" "+tt(t.label,o,t.y-10,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`))}return e.push("</g>"),e.join(`
60
+ `)}function Jn(t){const e=[],n=t.label?` data-label="${ot(t.label)}"`:"";e.push(`<g class="block" data-type="${ot(t.type)}"${n}>`),e.push(` <rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="0" ry="0" fill="none" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`);const s=`${t.type}${t.label?` [${t.label}]`:""}`,o=s.split(`
61
+ `)[0],i=J(o,M.edgeLabel,z.groupHeader)+16,r=18;e.push(` <rect x="${t.x}" y="${t.y}" width="${i}" height="${r}" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),e.push(" "+tt(s,t.x+6,t.y+r/2,M.edgeLabel,`font-size="${M.edgeLabel}" font-weight="${z.groupHeader}" fill="var(--_text-sec)"`));for(const a of t.dividers)e.push(` <line x1="${t.x}" y1="${a.y}" x2="${t.x+t.width}" y2="${a.y}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`),a.label&&e.push(" "+tt(`[${a.label}]`,t.x+8,a.y+14,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="start" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`));return e.push("</g>"),e.join(`
62
+ `)}function ts(t){const{x:n,y:s,width:o,height:i}=t,r=t.actors&&t.actors.length>0?` data-actors="${t.actors.map(ot).join(",")}"`:"",a=t.position?` data-position="${ot(t.position)}"`:"",c=[`${n},${s}`,`${n+o-6},${s}`,`${n+o},${s+6}`,`${n+o},${s+i}`,`${n},${s+i}`].join(" ");return`<g class="note"${a}${r}>
63
+ <polygon points="${c}" fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />
64
+ <polygon points="${n+o-6},${s} ${n+o},${s+6} ${n+o-6},${s+6}" fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />
65
+ ${tt(t.text,n+o/2,s+i/2,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`)}
66
+ </g>`}function ot(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var O={padding:40,boxPadX:8,headerBaseHeight:32,annotationHeight:16,memberRowHeight:20,sectionPadY:8,emptySectionHeight:8,minWidth:120,memberFontSize:11,nodeSpacing:40,layerSpacing:60};function es(t,e){const n=new Map;for(const o of t.classes){const i=o.annotation?O.headerBaseHeight+O.annotationHeight:O.headerBaseHeight,r=o.attributes.length>0?o.attributes.length*O.memberRowHeight+O.sectionPadY:O.emptySectionHeight,a=o.methods.length>0?o.methods.length*O.memberRowHeight+O.sectionPadY:O.emptySectionHeight,c=J(o.label,M.nodeLabel,z.nodeLabel),d=ie(o.attributes),l=ie(o.methods),f=Math.max(O.minWidth,c+O.boxPadX*2,d+O.boxPadX*2,l+O.boxPadX*2),h=i+r+a;n.set(o.id,{width:f,height:h,headerHeight:i,attrHeight:r,methodHeight:a})}const s={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.spacing.nodeNode":String(O.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(O.layerSpacing),"elk.padding":`[top=${O.padding},left=${O.padding},bottom=${O.padding},right=${O.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(const o of t.classes){const i=n.get(o.id);s.children.push({id:o.id,width:i.width,height:i.height})}for(let o=0;o<t.relationships.length;o++){const i=t.relationships[o],r={id:`e${o}`,sources:[i.from],targets:[i.to]};if(i.label){const a=ct(i.label,M.edgeLabel,z.edgeLabel);r.labels=[{text:i.label,width:a.width+8,height:a.height+6}]}s.edges.push(r)}return{elkGraph:s,classSizes:n}}function ns(t,e,n){const s=new Map;for(const r of e.classes)s.set(r.id,r);const o=[];for(const r of t.children??[]){const a=s.get(r.id);if(a){const c=n.get(a.id);o.push({id:a.id,label:a.label,annotation:a.annotation,attributes:a.attributes,methods:a.methods,x:r.x??0,y:r.y??0,width:r.width??c.width,height:r.height??c.height,headerHeight:c.headerHeight,attrHeight:c.attrHeight,methodHeight:c.methodHeight})}}const i=[];for(let r=0;r<(t.edges?.length??0);r++){const a=t.edges[r],c=e.relationships[r],d=[];if(a.sections&&a.sections.length>0){const f=a.sections[0];if(d.push({x:f.startPoint.x,y:f.startPoint.y}),f.bendPoints)for(const h of f.bendPoints)d.push({x:h.x,y:h.y});d.push({x:f.endPoint.x,y:f.endPoint.y})}let l;if(a.labels&&a.labels.length>0){const f=a.labels[0];f.x!=null&&f.y!=null&&(l={x:f.x+(f.width??0)/2,y:f.y+(f.height??0)/2})}i.push({from:c.from,to:c.to,type:c.type,markerAt:c.markerAt,label:c.label,fromCardinality:c.fromCardinality,toCardinality:c.toCardinality,points:d,labelPosition:l})}return{width:t.width??600,height:t.height??400,classes:o,relationships:i}}function ss(t,e={}){if(t.classes.length===0)return{width:0,height:0,classes:[],relationships:[]};const{elkGraph:n,classSizes:s}=es(t),o=Nt(n);return ns(o,t,s)}function ie(t){if(t.length===0)return 0;let e=0;for(const n of t){const s=os(n),o=ue(s,O.memberFontSize);o>e&&(e=o)}return e}function os(t){const e=t.visibility?`${t.visibility} `:"",n=t.isMethod?`${t.name}(${t.params||""})`:t.name,s=t.type?`: ${t.type}`:"";return`${e}${n}${s}`}var Wt={memberSize:11,memberWeight:400,annotationSize:10,annotationWeight:500};function is(t,e,n="Inter",s=!1){const o=[];o.push(St(t.width,t.height,e,s)),o.push(vt(n,!0)),o.push("<defs>"),o.push(rs()),o.push("</defs>");for(const i of t.relationships)o.push(ls(i));for(const i of t.classes)o.push(as(i));for(const i of t.relationships)o.push(hs(i));return o.push("</svg>"),o.join(`
67
+ `)}function rs(){return` <marker id="cls-inherit" markerWidth="12" markerHeight="10" refX="12" refY="5" orient="auto-start-reverse">
68
+ <polygon points="0 0, 12 5, 0 10" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
69
+ </marker>
70
+ <marker id="cls-composition" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
71
+ <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--_arrow)" stroke="var(--_arrow)" stroke-width="1" />
72
+ </marker>
73
+ <marker id="cls-aggregation" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
74
+ <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
75
+ </marker>
76
+ <marker id="cls-arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto-start-reverse">
77
+ <polyline points="0 0, 8 3, 0 6" fill="none" stroke="var(--_arrow)" stroke-width="1.5" />
78
+ </marker>`}function as(t){const{x:e,y:n,width:s,height:o,headerHeight:i,attrHeight:r,methodHeight:a}=t,c=[],d=t.annotation?` data-annotation="${lt(t.annotation)}"`:"";c.push(`<g class="class-node" data-id="${lt(t.id)}" data-label="${lt(t.label)}"${d}>`),c.push(` <rect x="${e}" y="${n}" width="${s}" height="${o}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),c.push(` <rect x="${e}" y="${n}" width="${s}" height="${i}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`);let l=n+i/2;if(t.annotation){const g=n+12;c.push(` <text x="${e+s/2}" y="${g}" text-anchor="middle" dy="${Z}" font-size="${Wt.annotationSize}" font-weight="${Wt.annotationWeight}" font-style="italic" fill="var(--_text-muted)">&lt;&lt;${_t(t.annotation)}&gt;&gt;</text>`),l=n+i/2+6}c.push(" "+tt(t.label,e+s/2,l,M.nodeLabel,`text-anchor="middle" font-size="${M.nodeLabel}" font-weight="700" fill="var(--_text)"`));const f=n+i;c.push(` <line x1="${e}" y1="${f}" x2="${e+s}" y2="${f}" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />`);const h=20;for(let g=0;g<t.attributes.length;g++){const p=t.attributes[g],m=f+4+g*h+h/2;c.push(" "+re(p,e+O.boxPadX,m))}const u=f+r;c.push(` <line x1="${e}" y1="${u}" x2="${e+s}" y2="${u}" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />`);for(let g=0;g<t.methods.length;g++){const p=t.methods[g],m=u+4+g*h+h/2;c.push(" "+re(p,e+O.boxPadX,m))}return c.push("</g>"),c.join(`
79
+ `)}function re(t,e,n){const s=t.isAbstract?' font-style="italic"':"",o=t.isStatic?' text-decoration="underline"':"",i=[];t.visibility&&i.push(`<tspan fill="var(--_text-faint)">${_t(t.visibility)} </tspan>`);const r=t.isMethod?`${t.name}(${t.params||""})`:t.name;return i.push(`<tspan fill="var(--_text-sec)">${_t(r)}</tspan>`),t.type&&(i.push('<tspan fill="var(--_text-faint)">: </tspan>'),i.push(`<tspan fill="var(--_text-muted)">${_t(t.type)}</tspan>`)),`<text x="${e}" y="${n}" class="mono" dy="${Z}" font-size="${Wt.memberSize}" font-weight="${Wt.memberWeight}"${s}${o}>${i.join("")}</text>`}function ls(t){if(t.points.length<2)return"";const e=t.points.map(r=>`${r.x},${r.y}`).join(" "),s=t.type==="dependency"||t.type==="realization"?' stroke-dasharray="6 4"':"",o=cs(t.type,t.markerAt),i=['class="class-relationship"',`data-from="${lt(t.from)}"`,`data-to="${lt(t.to)}"`,`data-type="${t.type}"`,`data-marker-at="${t.markerAt}"`];return t.label&&i.push(`data-label="${lt(t.label)}"`),t.fromCardinality&&i.push(`data-from-cardinality="${lt(t.fromCardinality)}"`),t.toCardinality&&i.push(`data-to-cardinality="${lt(t.toCardinality)}"`),`<polyline ${i.join(" ")} points="${e}" fill="none" stroke="var(--_line)" stroke-width="${N.connector}"${s}${o} />`}function cs(t,e){const n=ds(t);return n?e==="from"?` marker-start="url(#${n})"`:` marker-end="url(#${n})"`:""}function ds(t){switch(t){case"inheritance":case"realization":return"cls-inherit";case"composition":return"cls-composition";case"aggregation":return"cls-aggregation";case"association":case"dependency":return"cls-arrow";default:return null}}function hs(t){if(!t.label&&!t.fromCardinality&&!t.toCardinality||t.points.length<2)return"";const e=[];if(t.label){const n=t.labelPosition??fs(t.points);e.push(tt(t.label,n.x,n.y-8,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`))}if(t.fromCardinality){const n=t.points[0],s=t.points[1],o=ae(n,s);e.push(tt(t.fromCardinality,n.x+o.x,n.y+o.y,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`))}if(t.toCardinality){const n=t.points[t.points.length-1],s=t.points[t.points.length-2],o=ae(n,s);e.push(tt(t.toCardinality,n.x+o.x,n.y+o.y,M.edgeLabel,`font-size="${M.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`))}return e.join(`
80
+ `)}function fs(t){if(t.length===0)return{x:0,y:0};const e=Math.floor(t.length/2);return t[e]}function ae(t,e){const n=e.x-t.x,s=e.y-t.y;return Math.abs(n)>Math.abs(s)?{x:n>0?14:-14,y:-10}:{x:-14,y:s>0?14:-14}}var _t=bt;function lt(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var et={padding:40,boxPadX:14,headerHeight:34,rowHeight:22,minWidth:140,attrFontSize:11,nodeSpacing:70,layerSpacing:90};function us(t,e){const n=new Map;for(const o of t.entities){const i=J(o.label,M.nodeLabel,z.nodeLabel);let r=0;for(const d of o.attributes){const l=`${d.type} ${d.name}${d.keys.length>0?" "+d.keys.join(","):""}`,f=ue(l,et.attrFontSize);f>r&&(r=f)}const a=Math.max(et.minWidth,i+et.boxPadX*2,r+et.boxPadX*2),c=et.headerHeight+Math.max(o.attributes.length,1)*et.rowHeight;n.set(o.id,{width:a,height:c})}const s={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.spacing.nodeNode":String(et.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(et.layerSpacing),"elk.padding":`[top=${et.padding},left=${et.padding},bottom=${et.padding},right=${et.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(const o of t.entities){const i=n.get(o.id);s.children.push({id:o.id,width:i.width,height:i.height})}for(let o=0;o<t.relationships.length;o++){const i=t.relationships[o],r=ct(i.label,M.edgeLabel,z.edgeLabel),a={id:`e${o}`,sources:[i.entity1],targets:[i.entity2]};i.label&&(a.labels=[{text:i.label,width:r.width+8,height:r.height+6}]),s.edges.push(a)}return{elkGraph:s,entitySizes:n}}function gs(t,e,n){const s=new Map;for(const r of e.entities)s.set(r.id,r);const o=[];for(const r of t.children??[]){const a=s.get(r.id);a&&o.push({id:a.id,label:a.label,attributes:a.attributes,x:r.x??0,y:r.y??0,width:r.width??n.get(a.id).width,height:r.height??n.get(a.id).height,headerHeight:et.headerHeight,rowHeight:et.rowHeight})}const i=[];for(let r=0;r<(t.edges?.length??0);r++){const a=t.edges[r],c=e.relationships[r],d=[];if(a.sections&&a.sections.length>0){const l=a.sections[0];if(d.push({x:l.startPoint.x,y:l.startPoint.y}),l.bendPoints)for(const f of l.bendPoints)d.push({x:f.x,y:f.y});d.push({x:l.endPoint.x,y:l.endPoint.y})}i.push({entity1:c.entity1,entity2:c.entity2,cardinality1:c.cardinality1,cardinality2:c.cardinality2,label:c.label,identifying:c.identifying,points:d})}return{width:t.width??600,height:t.height??400,entities:o,relationships:i}}function ps(t,e={}){if(t.entities.length===0)return{width:0,height:0,entities:[],relationships:[]};const{elkGraph:n,entitySizes:s}=us(t),o=Nt(n);return gs(o,t,s)}var rt={attrSize:11,attrWeight:400,keySize:9,keyWeight:600};function xs(t,e,n="Inter",s=!1){const o=[];o.push(St(t.width,t.height,e,s)),o.push(vt(n,!0)),o.push("<defs>"),o.push("</defs>");for(const i of t.relationships)o.push(ms(i));for(const i of t.entities)o.push($s(i));for(const i of t.relationships)o.push(ws(i));for(const i of t.relationships)o.push(bs(i));return o.push("</svg>"),o.join(`
81
+ `)}function $s(t){const{id:e,x:n,y:s,width:o,height:i,headerHeight:r,rowHeight:a,label:c,attributes:d}=t,l=[];l.push(`<g class="entity" data-id="${wt(e)}" data-label="${wt(c)}">`),l.push(` <rect x="${n}" y="${s}" width="${o}" height="${i}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),l.push(` <rect x="${n}" y="${s}" width="${o}" height="${r}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${N.outerBox}" />`),l.push(" "+tt(c,n+o/2,s+r/2,M.nodeLabel,`text-anchor="middle" font-size="${M.nodeLabel}" font-weight="700" fill="var(--_text)"`));const f=s+r;l.push(` <line x1="${n}" y1="${f}" x2="${n+o}" y2="${f}" stroke="var(--_node-stroke)" stroke-width="${N.innerBox}" />`);for(let h=0;h<d.length;h++){const u=d[h],g=f+h*a+a/2;l.push(" "+ys(u,n,g,o).replace(/\n/g,`
82
+ `))}return d.length===0&&l.push(` <text x="${n+o/2}" y="${f+a/2}" text-anchor="middle" dy="${Z}" font-size="${rt.attrSize}" fill="var(--_text-faint)" font-style="italic">(no attributes)</text>`),l.push("</g>"),l.join(`
83
+ `)}function ys(t,e,n,s){const o=[],i=t.comment&&t.comment.length>0;if(i){const d=t.comment.replace(/<br\s*\/?>/gi,`
84
+ `);o.push(`<g><title>${zt(d)}</title>`)}let r=0;if(t.keys.length>0){const d=t.keys.join(",");r=J(d,rt.keySize,rt.keyWeight)+8,o.push(`<rect x="${e+6}" y="${n-7}" width="${r}" height="14" rx="2" ry="2" fill="var(--_key-badge)" />`),o.push(`<text x="${e+6+r/2}" y="${n}" text-anchor="middle" dy="${Z}" font-size="${rt.keySize}" font-weight="${rt.keyWeight}" fill="var(--_text-sec)">${t.keys.join(",")}</text>`)}const a=e+8+(r>0?r+6:0);o.push(`<text x="${a}" y="${n}" class="mono" dy="${Z}" font-size="${rt.attrSize}" font-weight="${rt.attrWeight}"><tspan fill="var(--_text-muted)">${zt(t.type)}</tspan></text>`);const c=e+s-8;return o.push(`<text x="${c}" y="${n}" class="mono" text-anchor="end" dy="${Z}" font-size="${rt.attrSize}" font-weight="${rt.attrWeight}"><tspan fill="var(--_text-sec)">${zt(t.name)}</tspan></text>`),i&&o.push("</g>"),o.join(`
85
+ `)}function ms(t){if(t.points.length<2)return"";const e=t.points.map(i=>`${i.x},${i.y}`).join(" "),n=t.identifying?"":' stroke-dasharray="6 4"',s=t.label?` data-label="${wt(t.label)}"`:"";return`<polyline ${['class="er-relationship"',`data-entity1="${wt(t.entity1)}"`,`data-entity2="${wt(t.entity2)}"`,`data-cardinality1="${t.cardinality1}"`,`data-cardinality2="${t.cardinality2}"`,`data-identifying="${t.identifying}"`].join(" ")}${s} points="${e}" fill="none" stroke="var(--_line)" stroke-width="${N.connector}"${n} />`}function bs(t){if(!t.label||t.points.length<2)return"";const e=ks(t.points),n=ct(t.label,M.edgeLabel,z.edgeLabel),s=n.width+8,o=n.height+6;return`<rect x="${e.x-s/2}" y="${e.y-o/2}" width="${s}" height="${o}" rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
86
+ ${tt(t.label,e.x,e.y,M.edgeLabel,`text-anchor="middle" font-size="${M.edgeLabel}" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`)}`}function ws(t){if(t.points.length<2)return"";const e=[],n=t.points[0],s=t.points[1];e.push(le(n,s,t.cardinality1));const o=t.points[t.points.length-1],i=t.points[t.points.length-2];return e.push(le(o,i,t.cardinality2)),e.join(`
87
+ `)}function le(t,e,n){const s=[],o=N.connector+.25,i=t.x-e.x,r=t.y-e.y,a=Math.sqrt(i*i+r*r);if(a===0)return"";const c=i/a,d=r/a,l=-d,f=c,h=t.x-c*4,u=t.y-d*4,g=t.x-c*16,p=t.y-d*16,m=n==="one"||n==="zero-one",k=n==="many"||n==="zero-many",T=n==="zero-one"||n==="zero-many";if(m){s.push(`<line x1="${h+l*6}" y1="${u+f*6}" x2="${h-l*6}" y2="${u-f*6}" stroke="var(--_line)" stroke-width="${o}" />`);const S=h-c*4,w=u-d*4;s.push(`<line x1="${S+l*6}" y1="${w+f*6}" x2="${S-l*6}" y2="${w-f*6}" stroke="var(--_line)" stroke-width="${o}" />`)}if(k){const S=h,w=u;s.push(`<line x1="${S+l*7}" y1="${w+f*7}" x2="${g}" y2="${p}" stroke="var(--_line)" stroke-width="${o}" />`),s.push(`<line x1="${S}" y1="${w}" x2="${g}" y2="${p}" stroke="var(--_line)" stroke-width="${o}" />`),s.push(`<line x1="${S-l*7}" y1="${w-f*7}" x2="${g}" y2="${p}" stroke="var(--_line)" stroke-width="${o}" />`)}if(T){const L=k?20:12,S=t.x-c*L,w=t.y-d*L;s.push(`<circle cx="${S}" cy="${w}" r="4" fill="var(--bg)" stroke="var(--_line)" stroke-width="${o}" />`)}return s.join(`
88
+ `)}function ks(t){if(t.length===0)return{x:0,y:0};if(t.length===1)return t[0];let e=0;for(let o=1;o<t.length;o++){const i=t[o].x-t[o-1].x,r=t[o].y-t[o-1].y;e+=Math.sqrt(i*i+r*r)}if(e===0)return t[0];const n=e/2;let s=0;for(let o=1;o<t.length;o++){const i=t[o].x-t[o-1].x,r=t[o].y-t[o-1].y,a=Math.sqrt(i*i+r*r);if(s+a>=n){const c=a>0?(n-s)/a:0;return{x:t[o-1].x+i*c,y:t[o-1].y+r*c}}s+=a}return t[t.length-1]}var zt=bt;function wt(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var v={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendGap:6,legendItemGap:16};function vs(t,e={}){return t.horizontal?Ms(t):Ss(t)}function Ss(t){const e=!!t.title,n=!!t.xAxis.title,s=!!t.yAxis.title,o=t.series.length>1,i=t.yAxis.range,r=Se(i.min,i.max),a=Math.max(...r.map(R=>J(Ht(R),v.axisLabelFontSize,v.axisLabelFontWeight)),v.yLabelWidth),c=v.padding+(e?v.titleHeight:0)+(o?v.legendHeight:0),d=v.padding+v.xLabelHeight+(n?v.axisTitlePad:0),l=v.padding+a+v.yLabelGap+(s?v.axisTitlePad:0),f=v.padding,h=v.plotWidth,u=v.plotHeight,g=l+h+f,p=c+u+d,m={x:l,y:c,width:h,height:u},k=Bt(t),T=R=>l+(R+.5)*(h/k),L=h/k,S=R=>{const H=(R-i.min)/(i.max-i.min||1);return c+u-H*u},w=Ls(t,T,c+u),Y=r.map(R=>({label:Ht(R),x:l,y:S(R),tx:l-v.tickLength,ty:S(R),labelX:l-v.yLabelGap,labelY:S(R),textAnchor:"end"})),E=r.map(R=>({x1:l,y1:S(R),x2:l+h,y2:S(R)})),$=Yt(t,k),x=t.series.map((R,H)=>H),b=As(t,T,S,L,i.min,$,x),A=Is(t,T,S,$,x),P=v.padding+(e?v.titleHeight:0)+v.legendHeight/2,I=o?Me(t,g/2,P,x):[],D={x1:l,y1:c+u,x2:l+h,y2:c+u},j={x1:l,y1:c,x2:l,y2:c+u},nt={ticks:w,line:D,...n?{title:{text:t.xAxis.title,x:l+h/2,y:p-v.padding}}:{}},K={ticks:Y,line:j,...s?{title:{text:t.yAxis.title,x:v.padding+4,y:c+u/2,rotate:-90}}:{}},V=e?{text:t.title,x:g/2,y:v.padding+v.titleFontSize}:void 0;return{width:g,height:p,title:V,xAxis:nt,yAxis:K,plotArea:m,bars:b,lines:A,gridLines:E,legend:I}}function Ms(t){const e=!!t.title,n=!!t.xAxis.title,s=!!t.yAxis.title,o=t.series.length>1,i=t.yAxis.range,r=Se(i.min,i.max),a=Bt(t),c=Yt(t,a),d=Math.max(...c.map(_=>J(_,v.axisLabelFontSize,v.axisLabelFontWeight)),40),l=v.padding+(e?v.titleHeight:0)+(o?v.legendHeight:0),f=v.padding+v.xLabelHeight+(s?v.axisTitlePad:0),h=v.padding+d+v.yLabelGap+(n?v.axisTitlePad:0),u=v.padding,g=v.plotWidth,p=v.plotHeight,m=h+g+u,k=l+p+f,T={x:h,y:l,width:g,height:p},L=_=>{const F=(_-i.min)/(i.max-i.min||1);return h+F*g},S=p/a,w=_=>l+(_+.5)*S,Y=r.map(_=>({label:Ht(_),x:L(_),y:l+p,tx:L(_),ty:l+p+v.tickLength,labelX:L(_),labelY:l+p+18,textAnchor:"middle"})),E=c.map((_,F)=>({label:_,x:h,y:w(F),tx:h-v.tickLength,ty:w(F),labelX:h-v.yLabelGap,labelY:w(F),textAnchor:"end"})),$=r.map(_=>({x1:L(_),y1:l,x2:L(_),y2:l+p})),x=t.series.map((_,F)=>F),A=t.series.filter(_=>_.type==="bar").length,P=[];if(A>0){const _=S*(1-v.barPadRatio),F=A>1?(_-(A-1)*v.barGroupGap)/A:_,st=Math.min(F,v.maxBarWidth),dt=A>1?st*A+v.barGroupGap*(A-1):st;let pt=0,ut=0;for(const ht of t.series){if(ht.type!=="bar"){ut++;continue}for(let at=0;at<ht.data.length;at++){const Le=w(at)-dt/2+pt*(st+v.barGroupGap),Gt=L(Math.max(ht.data[at],i.min)),Dt=L(Math.max(0,i.min));P.push({x:Math.min(Dt,Gt),y:Le,width:Math.abs(Gt-Dt),height:st,value:ht.data[at],label:c[at],seriesIndex:pt,colorIndex:x[ut]})}pt++,ut++}}const I=[];let D=0,j=0;for(const _ of t.series){if(_.type!=="line"){j++;continue}const F=_.data.map((st,dt)=>({x:L(st),y:w(dt),value:st,label:c[dt]}));I.push({points:F,seriesIndex:D,colorIndex:x[j]}),D++,j++}const nt={x1:h,y1:l+p,x2:h+g,y2:l+p},K={x1:h,y1:l,x2:h,y2:l+p},V={ticks:Y,line:nt,...s?{title:{text:t.yAxis.title,x:h+g/2,y:k-v.padding}}:{}},R={ticks:E,line:K,...n?{title:{text:t.xAxis.title,x:v.padding+4,y:l+p/2,rotate:-90}}:{}},H=e?{text:t.title,x:m/2,y:v.padding+v.titleFontSize}:void 0,B=v.padding+(e?v.titleHeight:0)+v.legendHeight/2,X=o?Me(t,m/2,B,x):[];return{width:m,height:k,horizontal:!0,title:H,xAxis:V,yAxis:R,plotArea:T,bars:P,lines:I,gridLines:$,legend:X}}function Bt(t){if(t.xAxis.categories)return t.xAxis.categories.length;for(const e of t.series)if(e.data.length>0)return e.data.length;return 1}function Yt(t,e){if(t.xAxis.categories)return t.xAxis.categories;if(t.xAxis.range){const{min:n,max:s}=t.xAxis.range,o=e>1?(s-n)/(e-1):0;return Array.from({length:e},(i,r)=>Ht(n+o*r))}return Array.from({length:e},(n,s)=>String(s+1))}function Ls(t,e,n,s){const o=Bt(t);return Yt(t,o).map((r,a)=>({label:r,x:e(a),y:n,tx:e(a),ty:n+v.tickLength,labelX:e(a),labelY:n+18,textAnchor:"middle"}))}function As(t,e,n,s,o,i,r){const c=t.series.filter(m=>m.type==="bar").length;if(c===0)return[];const d=s*(1-v.barPadRatio),l=c>1?(d-(c-1)*v.barGroupGap)/c:d,f=Math.min(l,v.maxBarWidth),h=c>1?f*c+v.barGroupGap*(c-1):f,u=[];let g=0,p=0;for(const m of t.series){if(m.type!=="bar"){p++;continue}for(let k=0;k<m.data.length;k++){const S=e(k)-h/2+g*(f+v.barGroupGap),w=n(m.data[k]),Y=n(Math.max(0,o));u.push({x:S,y:Math.min(w,Y),width:f,height:Math.abs(Y-w),value:m.data[k],label:i[k],seriesIndex:g,colorIndex:r[p]})}g++,p++}return u}function Is(t,e,n,s,o){const i=[];let r=0,a=0;for(const c of t.series){if(c.type!=="line"){a++;continue}const d=c.data.map((l,f)=>({x:e(f),y:n(l),value:l,label:s[f]}));i.push({points:d,seriesIndex:r,colorIndex:o[a]}),r++,a++}return i}function Se(t,e){const n=e-t;if(n<=0)return[t];const s=n/6,o=Math.pow(10,Math.floor(Math.log10(s))),i=s/o;let r;i<=1.5?r=o:i<=3?r=2*o:i<=7?r=5*o:r=10*o;const a=Math.ceil(t/r)*r,c=[];for(let d=a;d<=e+r*.001;d+=r)c.push(Math.round(d*1e10)/1e10);return c}function Ht(t){return Number.isInteger(t)?String(t):t.toFixed(Math.abs(t)<10?1:0)}function Me(t,e,n,s){const o=[];let i=0,r=0;for(let l=0;l<t.series.length;l++){const f=t.series[l],h=f.type==="bar"?`Bar ${i+1}`:`Line ${r+1}`;o.push({label:h,x:0,y:n,type:f.type,seriesIndex:f.type==="bar"?i:r,colorIndex:s[l]}),f.type==="bar"?i++:r++}const a=o.map(l=>{const f=J(l.label,v.legendFontSize,v.legendFontWeight);return v.legendSwatchW+v.legendGap+f}),c=a.reduce((l,f)=>l+f,0)+(o.length-1)*v.legendItemGap;let d=e-c/2;for(let l=0;l<o.length;l++)o[l].x=d,d+=a[l]+v.legendItemGap;return o}var G={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},C={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function _s(t,e,n="Inter",s=!1,o=!1){const i=[],r=Math.max(0,...t.bars.map($=>$.colorIndex),...t.lines.map($=>$.colorIndex)),a=St(t.width,t.height,e,s).replace("<svg ",`<svg data-xychart-colors="${r}" `);i.push(a),i.push(vt(n,!1));const c=Math.max(...t.lines.map($=>$.points.length),0),d=c>0&&c<=12,{style:l}=Ws(t,o,d,e.accent,e.bg);i.push(l);const{plotArea:f}=t,h=t.xAxis.ticks.map($=>$.x),u=t.horizontal?t.yAxis.ticks.map($=>$.y):t.gridLines.map($=>$.y1),g=h.length>1?Math.abs(h[1]-h[0]):f.width/6,p=u.length>1?Math.abs(u[1]-u[0]):f.height/6,m=g/Math.max(1,Math.round(g/20)),k=p/Math.max(1,Math.round(p/20)),T=h[0]??f.x,L=u[0]??f.y,S=T-Math.ceil((T-f.x)/m)*m,w=L-Math.ceil((L-f.y)/k)*k;for(let $=w;$<=f.y+f.height+.5;$+=k)for(let x=S;x<=f.x+f.width+.5;x+=m)i.push(`<circle cx="${y(x)}" cy="${y($)}" r="1.5" class="xychart-grid"/>`);const Y=[];for(const $ of t.bars){const x=` data-value="${$.value}"${$.label?` data-label="${U($.label)}"`:""}`,b=t.horizontal?Ts($.x,$.y,$.width,$.height,G.barRadius):Hs($.x,$.y,$.width,$.height,G.barRadius);if(i.push(`<path d="${b}" class="xychart-bar xychart-color-${$.colorIndex}"${x}/>`),o){const A=Rt($.value),P=$.label?`${$.label}: ${A}`:A,I=ce($.x+$.width/2,$.y,A);Y.push(`<g class="xychart-bar-group"><rect x="${y($.x)}" y="${y($.y)}" width="${y($.width)}" height="${y($.height)}" fill="transparent"/><title>${U(P)}</title>`+I+"</g>")}}for(const $ of t.lines){if($.points.length===0)continue;const x=Es($.points);i.push(`<path d="${x}" class="xychart-line-shadow xychart-color-${$.colorIndex}" transform="translate(0,2)"/>`),i.push(`<path d="${x}" class="xychart-line xychart-color-${$.colorIndex}"/>`)}const E=[];if(o||d){const $=new Map;for(const b of t.legend)b.type==="line"&&$.set(b.seriesIndex,b.label);const x=new Map;for(const b of t.lines)for(const A of b.points){const P=y(A.x);x.has(P)||x.set(P,[]),x.get(P).push({x:A.x,y:A.y,value:A.value,label:A.label,seriesIndex:b.seriesIndex,colorIndex:b.colorIndex})}for(const b of x.values()){const A=b[0].x,P=b[0].label||"";if(o&&b.length>1){const I=Math.min(...b.map(X=>X.y)),D=Math.max(...b.map(X=>X.y)),j=G.dotRadius*3,nt=`<rect x="${y(A-j)}" y="${y(I-j)}" width="${y(j*2)}" height="${y(D-I+j*2)}" fill="transparent" class="xychart-hit"/>`,K=b.map(X=>({text:Rt(X.value),legendLabel:$.get(X.seriesIndex)||`Line ${X.seriesIndex+1}`})),V=zs(A,I-G.dotRadius,P,K),R=K.map(X=>X.text),H=P?`${P}: ${R.join(" · ")}`:R.join(" · ");let B=`<g class="xychart-dot-group">${nt}`;for(const X of b){const _=` data-value="${X.value}"${X.label?` data-label="${U(X.label)}"`:""}`;B+=`<circle cx="${y(X.x)}" cy="${y(X.y)}" r="${G.dotRadius}" class="xychart-dot xychart-color-${X.colorIndex}"${_}/>`}B+=`<title>${U(H)}</title>${V}</g>`,E.push(B)}else if(o){const I=b[0],D=` data-value="${I.value}"${I.label?` data-label="${U(I.label)}"`:""}`,j=Rt(I.value),nt=I.label?`${I.label}: ${j}`:j,K=ce(A,I.y-G.dotRadius,j),V=d?`<circle cx="${y(A)}" cy="${y(I.y)}" r="${G.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:"";E.push(`<g class="xychart-dot-group">${V}<circle cx="${y(I.x)}" cy="${y(I.y)}" r="${G.dotRadius}" class="xychart-dot xychart-color-${I.colorIndex}"${D}/><title>${U(nt)}</title>${K}</g>`)}else for(const I of b){const D=` data-value="${I.value}"${I.label?` data-label="${U(I.label)}"`:""}`;i.push(`<circle cx="${y(I.x)}" cy="${y(I.y)}" r="${G.dotRadius}" class="xychart-dot xychart-color-${I.colorIndex}"${D}/>`)}}}for(const $ of t.xAxis.ticks)i.push(`<text x="${$.labelX}" y="${$.labelY}" text-anchor="${$.textAnchor}" font-size="${G.labelSize}" font-weight="${G.labelWeight}" dy="${Z}" class="xychart-label">${U($.label)}</text>`);for(const $ of t.yAxis.ticks)i.push(`<text x="${$.labelX}" y="${$.labelY}" text-anchor="${$.textAnchor}" font-size="${G.labelSize}" font-weight="${G.labelWeight}" dy="${Z}" class="xychart-label">${U($.label)}</text>`);if(t.xAxis.title){const $=t.xAxis.title,x=$.rotate?` transform="rotate(${$.rotate},${$.x},${$.y})"`:"";i.push(`<text x="${$.x}" y="${$.y}" text-anchor="middle"${x} font-size="${G.axisTitleSize}" font-weight="${G.axisTitleWeight}" dy="${Z}" class="xychart-axis-title">${U($.text)}</text>`)}if(t.yAxis.title){const $=t.yAxis.title,x=$.rotate?` transform="rotate(${$.rotate},${$.x},${$.y})"`:"";i.push(`<text x="${$.x}" y="${$.y}" text-anchor="middle"${x} font-size="${G.axisTitleSize}" font-weight="${G.axisTitleWeight}" dy="${Z}" class="xychart-axis-title">${U($.text)}</text>`)}t.title&&i.push(`<text x="${t.title.x}" y="${t.title.y}" text-anchor="middle" font-size="${G.titleSize}" font-weight="${G.titleWeight}" dy="${Z}" class="xychart-title">${U(t.title.text)}</text>`);for(const $ of t.legend){if($.type==="bar")i.push(`<rect x="${$.x}" y="${$.y-14/2}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${$.colorIndex}"/>`);else{const P=$.y;i.push(`<line x1="${$.x}" y1="${P}" x2="${$.x+14}" y2="${P}" stroke-width="${G.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${$.colorIndex}"/>`)}i.push(`<text x="${$.x+14+6}" y="${$.y}" text-anchor="start" font-size="${G.legendSize}" font-weight="${G.legendWeight}" dy="${Z}" class="xychart-label">${U($.label)}</text>`)}for(const $ of Y)i.push($);for(const $ of E)i.push($);return i.push("</svg>"),i.join(`
89
+ `)}function Ws(t,e,n,s,o){const i=s??Ct,r=new Set;for(const h of t.bars)r.add(h.colorIndex);for(const h of t.lines)r.add(h.colorIndex);const a=[];for(const h of[...r].sort((u,g)=>u-g)){const u=h===0?`var(--accent, ${Ct})`:dn(h,i,o);a.push(` --xychart-color-${h}: ${u};`),a.push(` --xychart-bar-fill-${h}: color-mix(in srgb, var(--bg) 75%, var(--xychart-color-${h}) 25%);`)}const c=[];for(const h of[...r].sort((u,g)=>u-g)){const u=`var(--xychart-color-${h})`;c.push(` .xychart-bar.xychart-color-${h} { stroke: ${u}; fill: var(--xychart-bar-fill-${h}); }`),c.push(` path.xychart-color-${h}, line.xychart-color-${h} { stroke: ${u}; }`),c.push(` circle.xychart-color-${h} { fill: ${u}; }`)}const d=e?`
90
+ .xychart-tip { opacity: 0; pointer-events: none; }
91
+ .xychart-tip-bg { fill: var(--_text); filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--fg) 20%, transparent)); }
92
+ .xychart-tip-text { fill: var(--bg); font-size: ${C.fontSize}px; font-weight: ${C.fontWeight}; }
93
+ .xychart-tip-ptr { fill: var(--_text); }
94
+ .xychart-bar-group:hover .xychart-tip,
95
+ .xychart-dot-group:hover .xychart-tip { opacity: 1; }`:"",l=a.length>0?`
96
+ svg {
97
+ ${a.join(`
98
+ `)}
99
+ }`:"";return{style:`<style>
100
+ .xychart-grid { fill: var(--_inner-stroke); stroke: none; opacity: 0.65; }
101
+ .xychart-bar { stroke-width: 1.5; }
102
+ .xychart-line { fill: none; stroke-width: ${G.lineWidth}; stroke-linecap: round; stroke-linejoin: round; }
103
+ .xychart-line-shadow { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.12; }
104
+ .xychart-dot { stroke: var(--bg); stroke-width: 2; }
105
+ .xychart-label { fill: var(--_text-muted); }
106
+ .xychart-axis-title { fill: var(--_text-sec); }
107
+ .xychart-title { fill: var(--_text); }${l}
108
+ ${c.join(`
109
+ `)}${d}
110
+ </style>`,defs:""}}function Hs(t,e,n,s,o){const i=Math.min(o,n/2,s/2);return i<=0?`M${y(t)},${y(e)} h${y(n)} v${y(s)} h${y(-n)} Z`:[`M${y(t)},${y(e+i)}`,`Q${y(t)},${y(e)} ${y(t+i)},${y(e)}`,`L${y(t+n-i)},${y(e)}`,`Q${y(t+n)},${y(e)} ${y(t+n)},${y(e+i)}`,`L${y(t+n)},${y(e+s-i)}`,`Q${y(t+n)},${y(e+s)} ${y(t+n-i)},${y(e+s)}`,`L${y(t+i)},${y(e+s)}`,`Q${y(t)},${y(e+s)} ${y(t)},${y(e+s-i)}`,"Z"].join(" ")}function Ts(t,e,n,s,o){const i=Math.min(o,n/2,s/2);return i<=0?`M${y(t)},${y(e)} h${y(n)} v${y(s)} h${y(-n)} Z`:[`M${y(t+i)},${y(e)}`,`L${y(t+n-i)},${y(e)}`,`Q${y(t+n)},${y(e)} ${y(t+n)},${y(e+i)}`,`L${y(t+n)},${y(e+s-i)}`,`Q${y(t+n)},${y(e+s)} ${y(t+n-i)},${y(e+s)}`,`L${y(t+i)},${y(e+s)}`,`Q${y(t)},${y(e+s)} ${y(t)},${y(e+s-i)}`,`L${y(t)},${y(e+i)}`,`Q${y(t)},${y(e)} ${y(t+i)},${y(e)}`,"Z"].join(" ")}function Es(t){if(t.length===0)return"";if(t.length===1)return`M${y(t[0].x)},${y(t[0].y)}`;if(t.length===2)return`M${y(t[0].x)},${y(t[0].y)} L${y(t[1].x)},${y(t[1].y)}`;const e=t.length,n=[],s=[];for(let a=0;a<e-1;a++)n.push(t[a+1].x-t[a].x),s.push(n[a]===0?0:(t[a+1].y-t[a].y)/n[a]);const o=new Array(e).fill(0);if(e>2){const a=new Array(e).fill(0),c=new Array(e).fill(0);for(let d=1;d<e-1;d++){const l=2*(n[d-1]+n[d]),f=3*(s[d]-s[d-1]);if(d===1)a[d]=n[d]/l,c[d]=f/l;else{const h=l-n[d-1]*a[d-1];a[d]=n[d]/h,c[d]=(f-n[d-1]*c[d-1])/h}}for(let d=e-2;d>=1;d--)o[d]=c[d]-a[d]*o[d+1]}const i=new Array(e).fill(0);for(let a=0;a<e-1;a++)i[a]=s[a]-n[a]*(2*o[a]+o[a+1])/3;i[e-1]=s[e-2]+n[e-2]*o[e-2]/3;let r=`M${y(t[0].x)},${y(t[0].y)}`;for(let a=0;a<e-1;a++){const c=n[a]/3,d=t[a].x+c,l=t[a].y+i[a]*c,f=t[a+1].x-c,h=t[a+1].y-i[a+1]*c;r+=` C${y(d)},${y(l)} ${y(f)},${y(h)} ${y(t[a+1].x)},${y(t[a+1].y)}`}return r}function zs(t,e,n,s){const a=J(n,C.fontSize,600),c=Math.max(...s.map(w=>{const Y=J(w.legendLabel,C.fontSize,C.fontWeight),E=J(w.text,C.fontSize,C.fontWeight);return Y+10+E})),d=Math.max(a,c)+C.padX*2,l=26+s.length*20+6,f=Math.max(C.minY,e-C.offsetY-l-C.pointerSize),h=t-d/2,u=t,g=f+l,p=C.pointerSize,m=`<polygon points="${y(u-p)},${y(g)} ${y(u+p)},${y(g)} ${y(u)},${y(g+p)}" class="xychart-tip xychart-tip-ptr"/>`;let k=`<rect x="${y(h)}" y="${y(f)}" width="${y(d)}" height="${l}" rx="${C.rx}" class="xychart-tip xychart-tip-bg"/>`;k+=m;let T=f+6+20/2;k+=`<text x="${y(t)}" y="${y(T)}" text-anchor="middle" font-weight="600" font-size="${C.fontSize}" dy="${Z}" class="xychart-tip xychart-tip-text">${U(n)}</text>`;const L=h+C.padX,S=h+d-C.padX;for(const w of s)T+=20,k+=`<text x="${y(L)}" y="${y(T)}" text-anchor="start" font-size="${C.fontSize}" font-weight="${C.fontWeight}" dy="${Z}" class="xychart-tip xychart-tip-text">${U(w.legendLabel)}</text>`,k+=`<text x="${y(S)}" y="${y(T)}" text-anchor="end" font-size="${C.fontSize}" font-weight="${C.fontWeight}" dy="${Z}" class="xychart-tip xychart-tip-text">${U(w.text)}</text>`;return k}function ce(t,e,n){const o=J(n,C.fontSize,C.fontWeight)+C.padX*2,i=C.height,r=Math.max(C.minY,e-C.offsetY-i-C.pointerSize),a=t-o/2,c=t,d=r+i/2,l=t,f=r+i,h=C.pointerSize,u=`<polygon points="${y(l-h)},${y(f)} ${y(l+h)},${y(f)} ${y(l)},${y(f+h)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${y(a)}" y="${y(r)}" width="${y(o)}" height="${i}" rx="${C.rx}" class="xychart-tip xychart-tip-bg"/>`+u+`<text x="${y(c)}" y="${y(d)}" text-anchor="middle" dy="${Z}" class="xychart-tip xychart-tip-text">${U(n)}</text>`}function Rt(t){return Number.isInteger(t)?t.toLocaleString("en-US"):t.toFixed(Math.abs(t)<10?1:0)}function y(t){return String(Math.round(t*10)/10)}function U(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Rs(t){const e=t.trim().split(/[\n;]/)[0]?.trim().toLowerCase()??"";return/^xychart(-beta)?\b/.test(e)?"xychart":/^sequencediagram\s*$/.test(e)?"sequence":/^classdiagram\s*$/.test(e)?"class":/^erdiagram\s*$/.test(e)?"er":"flowchart"}function Cs(t){return{bg:t.bg??Ot.bg,fg:t.fg??Ot.fg,line:t.line,accent:t.accent,muted:t.muted,surface:t.surface,border:t.border}}function Ys(t,e={}){t=Ie(t);const n=Cs(e),s=e.font??"Inter",o=e.transparent??!1,i=Rs(t),r=t.split(`
111
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("%%"));switch(i){case"sequence":{const a=Je(r),c=Fn(a,e);return qn(c,n,s,o)}case"class":{const a=tn(r),c=ss(a,e);return is(c,n,s,o)}case"er":{const a=sn(r),c=ps(a,e);return xs(c,n,s,o)}case"xychart":{const a=an(r),c=vs(a,e);return _s(c,n,s,o,e.interactive??!1)}default:{const a=Ye(t),c=wn(a,e);return kn(c,n,s,o)}}}export{Ys as r};
@@ -1 +1 @@
1
- import{i as He,T as P,F as le,e as Ke,a as h,b as se,f as E,S as ce,C as $e,m as We,A as ie,l as $}from"./vendor-codemirror-state-CNWM3Q8V.js";import{E as x,a as je}from"./vendor-codemirror-view-Ct4T37Ue.js";import{I as ue,p as fe,q as v,s as W,r as D,t as G,i as Qe}from"./vendor-codemirror-language-BByA_dGF.js";import{N as F}from"./vendor-lezer-common-B3-cUCR_.js";const Xe=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=Q(e.state,r.from);return n.line?Ye(e):n.block?we(e):!1};function j(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}const Ye=j(tt,0),Ze=j(ae,0),we=j((e,t)=>ae(e,t,et(t)),0);function Q(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}const M=50;function _e(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-M,n),s=e.sliceDoc(l,l+M),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+r.length)==r)return{open:{pos:n-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-n<=2*M?u=a=e.sliceDoc(n,l):(u=e.sliceDoc(n,n+M),a=e.sliceDoc(l-M,l));let p=/^\s*/.exec(u)[0].length,O=/\s*$/.exec(a)[0].length,L=a.length-O-r.length;return u.slice(p,p+t.length)==t&&a.slice(L,L+r.length)==r?{open:{pos:n+p+t.length,margin:/\s/.test(u.charAt(p+t.length))?1:0},close:{pos:l-O-r.length,margin:/\s/.test(a.charAt(L-1))?1:0}}:null}function et(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function ae(e,t,r=t.selection.ranges){let n=r.map(o=>Q(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,s)=>_e(t,n[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,s)=>l[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=n[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function tt(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:s}of r){let c=n.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=Q(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let p=/^\s*/.exec(a.text)[0].length,O=p==a.length,L=a.text.slice(p,p+f.length)==f?p:-1;p<a.text.length&&p<i&&(i=p),n.push({line:a,comment:L,token:f,indent:p,empty:O,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=i);n.length==c+1&&(n[c].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of n)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of n)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const z=ie.define(),nt=ie.define(),rt=le.define(),he=le.define({combine(e){return Ke(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),de=He.define({create(){return B.empty},update(e,t){let r=t.state.facet(he),n=t.annotation(z);if(n){let i=m.fromTransaction(t,n.selection),f=n.side,u=f==0?e.undone:e.done;return i?u=R(u,u.length,r.minDepth,i):u=ge(u,t.startState.selection),new B(f==0?n.rest:u,f==0?u:n.rest)}let l=t.annotation(nt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(P.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=m.fromTransaction(t),s=t.annotation(P.time),c=t.annotation(P.userEvent);return o?e=e.addChanges(o,s,c,r,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new B(e.done.map(m.fromJSON),e.undone.map(m.fromJSON))}});function un(e={}){return[de,he.of(e),x.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?me:t.inputType=="historyRedo"?q:null;return n?(t.preventDefault(),n(r)):!1}})]}function I(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(de,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}const me=I(0,!1),q=I(1,!1),ot=I(0,!0),lt=I(1,!0);class m{constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new m(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new m(t.changes&&$e.fromJSON(t.changes),[],t.mapped&&We.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,r){let n=g;for(let l of t.startState.facet(rt)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new m(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,g)}static selection(t){return new m(void 0,g,void 0,void 0,t)}}function R(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function st(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<r.length;){let f=r[i++],u=r[i++];c>=f&&s<=u&&(n=!0)}}),n}function ct(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function pe(e,t){return e.length?t.length?e.concat(t):e:t}const g=[],it=200;function ge(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-it));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),R(e,e.length-1,1e9,r.setSelAfter(n)))}else return[m.selection([t])]}function ut(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function J(e,t){if(!e.length)return e;let r=e.length,n=g;for(;r;){let l=ft(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[m.selection(n)]:g}function ft(e,t,r){let n=pe(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):g,r);if(!e.changes)return m.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new m(l,ce.mapEffects(e.effects,t),s,e.startSelection.map(o),n)}const at=/^(input\.type|delete)($|\.)/;class B{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new B(this.done,this.undone):this}addChanges(t,r,n,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!n||at.test(n))&&(!c.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,st(c.changes,t.changes))||n=="input.type.compose")?s=R(s,s.length-1,l.minDepth,new m(t.changes.compose(c.changes),pe(ce.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,g)):s=R(s,s.length,l.minDepth,t),new B(s,g,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:g;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&ct(o[o.length-1],t)?this:new B(ge(this.done,t),this.undone,r,n)}addMapping(t){return new B(J(this.done,t),J(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:z.of({side:t,rest:ut(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?g:l.slice(0,l.length-1);return o.mapped&&(c=J(c,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:z.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}B.empty=new B(g,g);const fn=[{key:"Mod-z",run:me,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:q,preventDefault:!0},{linux:"Ctrl-Shift-z",run:q,preventDefault:!0},{key:"Mod-u",run:ot,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:lt,preventDefault:!0}];function C(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function k(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=C(e.selection,r);return n.eq(e.selection,!0)?!1:(t(k(e,n)),!0)}function N(e,t){return h.cursor(t?e.to:e.from)}function X(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):N(r,t))}function d(e){return e.textDirectionAt(e.state.selection.main.head)==je.LTR}const ye=e=>X(e,!d(e)),ke=e=>X(e,d(e)),an=e=>X(e,!1);function Ae(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):N(r,t))}const ht=e=>Ae(e,!d(e)),dt=e=>Ae(e,d(e));function mt(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function U(e,t,r){let n=W(e).resolveInner(t.head),l=r?F.closedBy:F.openedBy;for(let i=t.head;;){let f=r?n.childAfter(i):n.childBefore(i);if(!f)break;mt(e,f,l)?n=f:i=r?f.to:f.from}let o=n.type.prop(l),s,c;return o&&(s=r?D(e,n.from,1):D(e,n.to,-1))&&s.matched?c=r?s.end.to:s.end.from:c=r?n.to:n.from,h.cursor(c,r?-1:1)}const pt=e=>A(e,t=>U(e.state,t,!d(e))),gt=e=>A(e,t=>U(e.state,t,d(e)));function Be(e,t){return A(e,r=>{if(!r.empty)return N(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}const Se=e=>Be(e,!1),De=e=>Be(e,!0);function xe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(x.scrollMargins)){let s=o(e);s?.top&&(r=Math.max(s?.top,r)),s?.bottom&&(n=Math.max(s?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ce(e,t){let r=xe(e),{state:n}=e,l=C(n.selection,s=>s.empty?e.moveVertically(s,t,r.height):N(s,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let s=e.coordsAtPos(n.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+r.marginTop,f=c.bottom-r.marginBottom;s&&s.top>i&&s.bottom<f&&(o=x.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(k(n,l),{effects:o}),!0}const Z=e=>Ce(e,!1),H=e=>Ce(e,!0);function S(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=h.cursor(n.from+o))}return l}const yt=e=>A(e,t=>S(e,t,!0)),kt=e=>A(e,t=>S(e,t,!1)),At=e=>A(e,t=>S(e,t,!d(e))),Bt=e=>A(e,t=>S(e,t,d(e))),St=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Dt=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function xt(e,t,r){let n=!1,l=C(e.selection,o=>{let s=D(e,o.head,-1)||D(e,o.head,1)||o.head>0&&D(e,o.head-1,1)||o.head<e.doc.length&&D(e,o.head+1,-1);if(!s||!s.end)return o;n=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return h.cursor(c)});return n?(t(k(e,l)),!0):!1}const Ct=({state:e,dispatch:t})=>xt(e,t);function y(e,t){let r=C(e.state.selection,n=>{let l=t(n);return h.range(n.anchor,l.head,l.goalColumn,l.bidiLevel||void 0)});return r.eq(e.state.selection)?!1:(e.dispatch(k(e.state,r)),!0)}function Le(e,t){return y(e,r=>e.moveByChar(r,t))}const Me=e=>Le(e,!d(e)),Ee=e=>Le(e,d(e));function Te(e,t){return y(e,r=>e.moveByGroup(r,t))}const Lt=e=>Te(e,!d(e)),Mt=e=>Te(e,d(e)),Et=e=>y(e,t=>U(e.state,t,!d(e))),Tt=e=>y(e,t=>U(e.state,t,d(e)));function Oe(e,t){return y(e,r=>e.moveVertically(r,t))}const be=e=>Oe(e,!1),ve=e=>Oe(e,!0);function Re(e,t){return y(e,r=>e.moveVertically(r,t,xe(e).height))}const w=e=>Re(e,!1),_=e=>Re(e,!0),Ot=e=>y(e,t=>S(e,t,!0)),bt=e=>y(e,t=>S(e,t,!1)),vt=e=>y(e,t=>S(e,t,!d(e))),Rt=e=>y(e,t=>S(e,t,d(e))),It=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from)),Nt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to)),ee=({state:e,dispatch:t})=>(t(k(e,{anchor:0})),!0),te=({state:e,dispatch:t})=>(t(k(e,{anchor:e.doc.length})),!0),ne=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:0})),!0),re=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ut=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Vt=({state:e,dispatch:t})=>{let r=V(e).map(({from:n,to:l})=>h.range(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(r),userEvent:"select"})),!0},Pt=({state:e,dispatch:t})=>{let r=C(e.selection,n=>{let l=W(e),o=l.resolveStack(n.from,1);if(n.empty){let s=l.resolveStack(n.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:c}=s;if((c.from<n.from&&c.to>=n.to||c.to>n.to&&c.from<=n.from)&&s.next)return h.range(c.to,c.from)}return n});return r.eq(e.selection)?!1:(t(k(e,r)),!0)};function Ie(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let s=r.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==n.ranges.length?!1:(e.dispatch(k(r,h.create(l,l.length-1))),!0)}const Jt=e=>Ie(e,!1),Gt=e=>Ie(e,!0),Ft=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=h.create([r.main]):r.main.empty||(n=h.create([h.cursor(r.main.head)])),n?(t(k(e,n)),!0):!1};function T(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(r="delete.backward",i=b(e,i,!1)):i>s&&(r="delete.forward",i=b(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=b(e,s,!1),c=b(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?x.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function b(e,t,r){if(e instanceof x)for(let n of e.state.facet(x.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}const Ne=(e,t,r)=>T(e,n=>{let l=n.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(r&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=$(c,o.tabSize),u=f%G(o)||G(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=E(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=E(s.text,i-s.from,!1,!1)+s.from);return i}),K=e=>Ne(e,!1,!0),Ue=e=>Ne(e,!0,!1),Ve=(e,t)=>T(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),s=l.charCategorizer(n);for(let c=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let i=E(o.text,n-o.from,t)+o.from,f=o.text.slice(Math.min(n,i)-o.from,Math.max(n,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||n!=r.head)&&(c=u),n=i}return n}),Pe=e=>Ve(e,!1),zt=e=>Ve(e,!0),qt=e=>T(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),Ht=e=>T(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Kt=e=>T(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),$t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:se.of(["",""])},range:h.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Wt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),s=l==o.from?l-1:E(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:E(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function V(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function Je(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of V(e)){if(r?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(r?o.to+1:o.from-1),c=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const jt=({state:e,dispatch:t})=>Je(e,t,!1),Qt=({state:e,dispatch:t})=>Je(e,t,!0);function Ge(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of V(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Xt=({state:e,dispatch:t})=>Ge(e,t,!1),Yt=({state:e,dispatch:t})=>Ge(e,t,!0),Zt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(V(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=C(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function wt(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=W(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(F.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}const oe=Fe(!1),_t=Fe(!0);function Fe(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&wt(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new ue(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=fe(f,o);for(u==null&&(u=$(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",v(t,u)];return i&&a.push(v(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:se.of(a)},range:h.cursor(o+1+a[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let s=n.from;s<=n.to;){let c=e.doc.lineAt(s);c.number>r&&(n.empty||n.to>c.from)&&(t(c,l,n),r=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const en=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new ue(e,{overrideIndentation:o=>{let s=r[o];return s??-1}}),l=Y(e,(o,s,c)=>{let i=fe(n,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=v(e,i);(f!=u||c.from<o.from+f.length)&&(r[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ze=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{n.push({from:r.from,insert:e.facet(Qe)})}),{userEvent:"input.indent"})),!0),qe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=$(l,e.tabSize),s=0,c=v(e,Math.max(0,o-G(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),tn=e=>(e.setTabFocusMode(),!0),nn=[{key:"Ctrl-b",run:ye,shift:Me,preventDefault:!0},{key:"Ctrl-f",run:ke,shift:Ee},{key:"Ctrl-p",run:Se,shift:be},{key:"Ctrl-n",run:De,shift:ve},{key:"Ctrl-a",run:St,shift:It},{key:"Ctrl-e",run:Dt,shift:Nt},{key:"Ctrl-d",run:Ue},{key:"Ctrl-h",run:K},{key:"Ctrl-k",run:qt},{key:"Ctrl-Alt-h",run:Pe},{key:"Ctrl-o",run:$t},{key:"Ctrl-t",run:Wt},{key:"Ctrl-v",run:H}],rn=[{key:"ArrowLeft",run:ye,shift:Me,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ht,shift:Lt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:At,shift:vt,preventDefault:!0},{key:"ArrowRight",run:ke,shift:Ee,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:dt,shift:Mt,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Bt,shift:Rt,preventDefault:!0},{key:"ArrowUp",run:Se,shift:be,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ee,shift:ne},{mac:"Ctrl-ArrowUp",run:Z,shift:w},{key:"ArrowDown",run:De,shift:ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:te,shift:re},{mac:"Ctrl-ArrowDown",run:H,shift:_},{key:"PageUp",run:Z,shift:w},{key:"PageDown",run:H,shift:_},{key:"Home",run:kt,shift:bt,preventDefault:!0},{key:"Mod-Home",run:ee,shift:ne},{key:"End",run:yt,shift:Ot,preventDefault:!0},{key:"Mod-End",run:te,shift:re},{key:"Enter",run:oe,shift:oe},{key:"Mod-a",run:Ut},{key:"Backspace",run:K,shift:K,preventDefault:!0},{key:"Delete",run:Ue,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:zt,preventDefault:!0},{mac:"Mod-Backspace",run:Ht,preventDefault:!0},{mac:"Mod-Delete",run:Kt,preventDefault:!0}].concat(nn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),hn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:pt,shift:Et},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:gt,shift:Tt},{key:"Alt-ArrowUp",run:jt},{key:"Shift-Alt-ArrowUp",run:Xt},{key:"Alt-ArrowDown",run:Qt},{key:"Shift-Alt-ArrowDown",run:Yt},{key:"Mod-Alt-ArrowUp",run:Jt},{key:"Mod-Alt-ArrowDown",run:Gt},{key:"Escape",run:Ft},{key:"Mod-Enter",run:_t},{key:"Alt-l",mac:"Ctrl-l",run:Vt},{key:"Mod-i",run:Pt,preventDefault:!0},{key:"Mod-[",run:qe},{key:"Mod-]",run:ze},{key:"Mod-Alt-\\",run:en},{key:"Shift-Mod-k",run:Zt},{key:"Shift-Mod-\\",run:Ct},{key:"Mod-/",run:Xe},{key:"Alt-A",run:Ze},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tn}].concat(rn),dn={key:"Tab",run:ze,shift:qe};export{qe as a,yt as b,kt as c,an as d,en as e,oe as f,ye as g,un as h,ze as i,dn as j,hn as k,fn as l,q as r,rn as s,me as u};
1
+ import{i as He,T as P,F as le,e as Ke,a as h,b as se,f as E,S as ce,C as $e,m as We,A as ie,l as $}from"./vendor-codemirror-state-CNWM3Q8V.js";import{E as x,a as je}from"./vendor-codemirror-view-Ct4T37Ue.js";import{I as ue,p as fe,q as v,s as W,r as D,t as G,i as Qe}from"./vendor-codemirror-language-BByA_dGF.js";import{N as F}from"./vendor-lezer-common-B3-cUCR_.js";const Xe=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=Q(e.state,r.from);return n.line?Ye(e):n.block?we(e):!1};function j(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}const Ye=j(tt,0),Ze=j(ae,0),we=j((e,t)=>ae(e,t,et(t)),0);function Q(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}const M=50;function _e(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-M,n),s=e.sliceDoc(l,l+M),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+r.length)==r)return{open:{pos:n-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-n<=2*M?u=a=e.sliceDoc(n,l):(u=e.sliceDoc(n,n+M),a=e.sliceDoc(l-M,l));let p=/^\s*/.exec(u)[0].length,O=/\s*$/.exec(a)[0].length,L=a.length-O-r.length;return u.slice(p,p+t.length)==t&&a.slice(L,L+r.length)==r?{open:{pos:n+p+t.length,margin:/\s/.test(u.charAt(p+t.length))?1:0},close:{pos:l-O-r.length,margin:/\s/.test(a.charAt(L-1))?1:0}}:null}function et(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function ae(e,t,r=t.selection.ranges){let n=r.map(o=>Q(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,s)=>_e(t,n[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,s)=>l[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=n[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function tt(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:s}of r){let c=n.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=Q(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let p=/^\s*/.exec(a.text)[0].length,O=p==a.length,L=a.text.slice(p,p+f.length)==f?p:-1;p<a.text.length&&p<i&&(i=p),n.push({line:a,comment:L,token:f,indent:p,empty:O,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=i);n.length==c+1&&(n[c].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of n)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of n)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const z=ie.define(),nt=ie.define(),rt=le.define(),he=le.define({combine(e){return Ke(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),de=He.define({create(){return B.empty},update(e,t){let r=t.state.facet(he),n=t.annotation(z);if(n){let i=m.fromTransaction(t,n.selection),f=n.side,u=f==0?e.undone:e.done;return i?u=R(u,u.length,r.minDepth,i):u=ge(u,t.startState.selection),new B(f==0?n.rest:u,f==0?u:n.rest)}let l=t.annotation(nt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(P.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=m.fromTransaction(t),s=t.annotation(P.time),c=t.annotation(P.userEvent);return o?e=e.addChanges(o,s,c,r,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new B(e.done.map(m.fromJSON),e.undone.map(m.fromJSON))}});function un(e={}){return[de,he.of(e),x.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?me:t.inputType=="historyRedo"?q:null;return n?(t.preventDefault(),n(r)):!1}})]}function I(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(de,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}const me=I(0,!1),q=I(1,!1),ot=I(0,!0),lt=I(1,!0);class m{constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new m(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new m(t.changes&&$e.fromJSON(t.changes),[],t.mapped&&We.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,r){let n=g;for(let l of t.startState.facet(rt)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new m(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,g)}static selection(t){return new m(void 0,g,void 0,void 0,t)}}function R(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function st(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<r.length;){let f=r[i++],u=r[i++];c>=f&&s<=u&&(n=!0)}}),n}function ct(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function pe(e,t){return e.length?t.length?e.concat(t):e:t}const g=[],it=200;function ge(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-it));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),R(e,e.length-1,1e9,r.setSelAfter(n)))}else return[m.selection([t])]}function ut(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function J(e,t){if(!e.length)return e;let r=e.length,n=g;for(;r;){let l=ft(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[m.selection(n)]:g}function ft(e,t,r){let n=pe(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):g,r);if(!e.changes)return m.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new m(l,ce.mapEffects(e.effects,t),s,e.startSelection.map(o),n)}const at=/^(input\.type|delete)($|\.)/;class B{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new B(this.done,this.undone):this}addChanges(t,r,n,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!n||at.test(n))&&(!c.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,st(c.changes,t.changes))||n=="input.type.compose")?s=R(s,s.length-1,l.minDepth,new m(t.changes.compose(c.changes),pe(ce.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,g)):s=R(s,s.length,l.minDepth,t),new B(s,g,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:g;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&ct(o[o.length-1],t)?this:new B(ge(this.done,t),this.undone,r,n)}addMapping(t){return new B(J(this.done,t),J(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:z.of({side:t,rest:ut(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?g:l.slice(0,l.length-1);return o.mapped&&(c=J(c,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:z.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}B.empty=new B(g,g);const fn=[{key:"Mod-z",run:me,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:q,preventDefault:!0},{linux:"Ctrl-Shift-z",run:q,preventDefault:!0},{key:"Mod-u",run:ot,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:lt,preventDefault:!0}];function C(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function k(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=C(e.selection,r);return n.eq(e.selection,!0)?!1:(t(k(e,n)),!0)}function N(e,t){return h.cursor(t?e.to:e.from)}function X(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):N(r,t))}function d(e){return e.textDirectionAt(e.state.selection.main.head)==je.LTR}const ye=e=>X(e,!d(e)),ke=e=>X(e,d(e)),an=e=>X(e,!1);function Ae(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):N(r,t))}const ht=e=>Ae(e,!d(e)),dt=e=>Ae(e,d(e));function mt(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function U(e,t,r){let n=W(e).resolveInner(t.head),l=r?F.closedBy:F.openedBy;for(let i=t.head;;){let f=r?n.childAfter(i):n.childBefore(i);if(!f)break;mt(e,f,l)?n=f:i=r?f.to:f.from}let o=n.type.prop(l),s,c;return o&&(s=r?D(e,n.from,1):D(e,n.to,-1))&&s.matched?c=r?s.end.to:s.end.from:c=r?n.to:n.from,h.cursor(c,r?-1:1)}const pt=e=>A(e,t=>U(e.state,t,!d(e))),gt=e=>A(e,t=>U(e.state,t,d(e)));function Be(e,t){return A(e,r=>{if(!r.empty)return N(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}const Se=e=>Be(e,!1),De=e=>Be(e,!0);function xe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(x.scrollMargins)){let s=o(e);s?.top&&(r=Math.max(s?.top,r)),s?.bottom&&(n=Math.max(s?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ce(e,t){let r=xe(e),{state:n}=e,l=C(n.selection,s=>s.empty?e.moveVertically(s,t,r.height):N(s,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let s=e.coordsAtPos(n.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+r.marginTop,f=c.bottom-r.marginBottom;s&&s.top>i&&s.bottom<f&&(o=x.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(k(n,l),{effects:o}),!0}const Z=e=>Ce(e,!1),H=e=>Ce(e,!0);function S(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=h.cursor(n.from+o))}return l}const yt=e=>A(e,t=>S(e,t,!0)),kt=e=>A(e,t=>S(e,t,!1)),At=e=>A(e,t=>S(e,t,!d(e))),Bt=e=>A(e,t=>S(e,t,d(e))),St=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Dt=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function xt(e,t,r){let n=!1,l=C(e.selection,o=>{let s=D(e,o.head,-1)||D(e,o.head,1)||o.head>0&&D(e,o.head-1,1)||o.head<e.doc.length&&D(e,o.head+1,-1);if(!s||!s.end)return o;n=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return h.cursor(c)});return n?(t(k(e,l)),!0):!1}const Ct=({state:e,dispatch:t})=>xt(e,t);function y(e,t){let r=C(e.state.selection,n=>{let l=t(n);return h.range(n.anchor,l.head,l.goalColumn,l.bidiLevel||void 0)});return r.eq(e.state.selection)?!1:(e.dispatch(k(e.state,r)),!0)}function Le(e,t){return y(e,r=>e.moveByChar(r,t))}const Me=e=>Le(e,!d(e)),Ee=e=>Le(e,d(e));function Te(e,t){return y(e,r=>e.moveByGroup(r,t))}const Lt=e=>Te(e,!d(e)),Mt=e=>Te(e,d(e)),Et=e=>y(e,t=>U(e.state,t,!d(e))),Tt=e=>y(e,t=>U(e.state,t,d(e)));function Oe(e,t){return y(e,r=>e.moveVertically(r,t))}const be=e=>Oe(e,!1),ve=e=>Oe(e,!0);function Re(e,t){return y(e,r=>e.moveVertically(r,t,xe(e).height))}const w=e=>Re(e,!1),_=e=>Re(e,!0),Ot=e=>y(e,t=>S(e,t,!0)),bt=e=>y(e,t=>S(e,t,!1)),vt=e=>y(e,t=>S(e,t,!d(e))),Rt=e=>y(e,t=>S(e,t,d(e))),It=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from)),Nt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to)),ee=({state:e,dispatch:t})=>(t(k(e,{anchor:0})),!0),te=({state:e,dispatch:t})=>(t(k(e,{anchor:e.doc.length})),!0),ne=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:0})),!0),re=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ut=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Vt=({state:e,dispatch:t})=>{let r=V(e).map(({from:n,to:l})=>h.range(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(r),userEvent:"select"})),!0},Pt=({state:e,dispatch:t})=>{let r=C(e.selection,n=>{let l=W(e),o=l.resolveStack(n.from,1);if(n.empty){let s=l.resolveStack(n.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:c}=s;if((c.from<n.from&&c.to>=n.to||c.to>n.to&&c.from<=n.from)&&s.next)return h.range(c.to,c.from)}return n});return r.eq(e.selection)?!1:(t(k(e,r)),!0)};function Ie(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let s=r.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==n.ranges.length?!1:(e.dispatch(k(r,h.create(l,l.length-1))),!0)}const Jt=e=>Ie(e,!1),Gt=e=>Ie(e,!0),Ft=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=h.create([r.main]):r.main.empty||(n=h.create([h.cursor(r.main.head)])),n?(t(k(e,n)),!0):!1};function T(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(r="delete.backward",i=b(e,i,!1)):i>s&&(r="delete.forward",i=b(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=b(e,s,!1),c=b(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?x.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function b(e,t,r){if(e instanceof x)for(let n of e.state.facet(x.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}const Ne=(e,t,r)=>T(e,n=>{let l=n.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(r&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=$(c,o.tabSize),u=f%G(o)||G(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=E(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=E(s.text,i-s.from,!1,!1)+s.from);return i}),K=e=>Ne(e,!1,!0),Ue=e=>Ne(e,!0,!1),Ve=(e,t)=>T(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),s=l.charCategorizer(n);for(let c=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let i=E(o.text,n-o.from,t)+o.from,f=o.text.slice(Math.min(n,i)-o.from,Math.max(n,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||n!=r.head)&&(c=u),n=i}return n}),Pe=e=>Ve(e,!1),zt=e=>Ve(e,!0),qt=e=>T(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),Ht=e=>T(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Kt=e=>T(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),$t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:se.of(["",""])},range:h.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Wt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),s=l==o.from?l-1:E(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:E(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function V(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function Je(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of V(e)){if(r?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(r?o.to+1:o.from-1),c=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const jt=({state:e,dispatch:t})=>Je(e,t,!1),Qt=({state:e,dispatch:t})=>Je(e,t,!0);function Ge(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of V(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Xt=({state:e,dispatch:t})=>Ge(e,t,!1),Yt=({state:e,dispatch:t})=>Ge(e,t,!0),Zt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(V(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=C(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function wt(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=W(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(F.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}const oe=Fe(!1),_t=Fe(!0);function Fe(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&wt(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new ue(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=fe(f,o);for(u==null&&(u=$(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",v(t,u)];return i&&a.push(v(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:se.of(a)},range:h.cursor(o+1+a[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let s=n.from;s<=n.to;){let c=e.doc.lineAt(s);c.number>r&&(n.empty||n.to>c.from)&&(t(c,l,n),r=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const en=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new ue(e,{overrideIndentation:o=>{let s=r[o];return s??-1}}),l=Y(e,(o,s,c)=>{let i=fe(n,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=v(e,i);(f!=u||c.from<o.from+f.length)&&(r[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ze=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{n.push({from:r.from,insert:e.facet(Qe)})}),{userEvent:"input.indent"})),!0),qe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=$(l,e.tabSize),s=0,c=v(e,Math.max(0,o-G(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),tn=e=>(e.setTabFocusMode(),!0),nn=[{key:"Ctrl-b",run:ye,shift:Me,preventDefault:!0},{key:"Ctrl-f",run:ke,shift:Ee},{key:"Ctrl-p",run:Se,shift:be},{key:"Ctrl-n",run:De,shift:ve},{key:"Ctrl-a",run:St,shift:It},{key:"Ctrl-e",run:Dt,shift:Nt},{key:"Ctrl-d",run:Ue},{key:"Ctrl-h",run:K},{key:"Ctrl-k",run:qt},{key:"Ctrl-Alt-h",run:Pe},{key:"Ctrl-o",run:$t},{key:"Ctrl-t",run:Wt},{key:"Ctrl-v",run:H}],rn=[{key:"ArrowLeft",run:ye,shift:Me,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ht,shift:Lt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:At,shift:vt,preventDefault:!0},{key:"ArrowRight",run:ke,shift:Ee,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:dt,shift:Mt,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Bt,shift:Rt,preventDefault:!0},{key:"ArrowUp",run:Se,shift:be,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ee,shift:ne},{mac:"Ctrl-ArrowUp",run:Z,shift:w},{key:"ArrowDown",run:De,shift:ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:te,shift:re},{mac:"Ctrl-ArrowDown",run:H,shift:_},{key:"PageUp",run:Z,shift:w},{key:"PageDown",run:H,shift:_},{key:"Home",run:kt,shift:bt,preventDefault:!0},{key:"Mod-Home",run:ee,shift:ne},{key:"End",run:yt,shift:Ot,preventDefault:!0},{key:"Mod-End",run:te,shift:re},{key:"Enter",run:oe,shift:oe},{key:"Mod-a",run:Ut},{key:"Backspace",run:K,shift:K,preventDefault:!0},{key:"Delete",run:Ue,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:zt,preventDefault:!0},{mac:"Mod-Backspace",run:Ht,preventDefault:!0},{mac:"Mod-Delete",run:Kt,preventDefault:!0}].concat(nn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),hn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:pt,shift:Et},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:gt,shift:Tt},{key:"Alt-ArrowUp",run:jt},{key:"Shift-Alt-ArrowUp",run:Xt},{key:"Alt-ArrowDown",run:Qt},{key:"Shift-Alt-ArrowDown",run:Yt},{key:"Mod-Alt-ArrowUp",run:Jt},{key:"Mod-Alt-ArrowDown",run:Gt},{key:"Escape",run:Ft},{key:"Mod-Enter",run:_t},{key:"Alt-l",mac:"Ctrl-l",run:Vt},{key:"Mod-i",run:Pt,preventDefault:!0},{key:"Mod-[",run:qe},{key:"Mod-]",run:ze},{key:"Mod-Alt-\\",run:en},{key:"Shift-Mod-k",run:Zt},{key:"Shift-Mod-\\",run:Ct},{key:"Mod-/",run:Xe},{key:"Alt-A",run:Ze},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tn}].concat(rn),dn={key:"Tab",run:ze,shift:qe};export{qe as a,yt as b,kt as c,an as d,en as e,oe as f,ye as g,un as h,ze as i,fn as j,dn as k,hn as l,q as r,rn as s,me as u};