isorite 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/core.js +175 -14
  2. package/dist/main.js +1217 -52
  3. package/notes/algorithms/the-quadtree/subdivision.svg +15 -0
  4. package/notes/algorithms/the-quadtree.md +2 -0
  5. package/package.json +2 -1
  6. package/plugin/server.ts +1 -1
  7. package/web/_app/immutable/assets/{0.CTbO0owi.css → 0.DcsDj0O1.css} +1 -1
  8. package/web/_app/immutable/assets/5.DbDKXCoO.css +1 -0
  9. package/web/_app/immutable/assets/NoteEditor.S3q5lmKq.css +1 -0
  10. package/web/_app/immutable/assets/drawn.CHbcoujQ.css +1 -0
  11. package/web/_app/immutable/chunks/{8wVGBFSs.js → -2Meesge.js} +3 -3
  12. package/web/_app/immutable/chunks/{BL3mLym4.js → 9z49435t.js} +1 -1
  13. package/web/_app/immutable/chunks/{DMAYXnpq.js → BA8Hpxhg.js} +1 -1
  14. package/web/_app/immutable/chunks/{CKSRTWxH.js → BAclEN0O.js} +1 -1
  15. package/web/_app/immutable/chunks/{DECNRCf2.js → BLmF1B2i.js} +1 -1
  16. package/web/_app/immutable/chunks/{CiVjR8gq.js → BTclWEfx.js} +1 -1
  17. package/web/_app/immutable/chunks/{Cp_JbuGh.js → BWVMfAMh.js} +1 -1
  18. package/web/_app/immutable/chunks/{D4fLEcOQ.js → BXAOBcPb.js} +1 -1
  19. package/web/_app/immutable/chunks/BYSDTLqw.js +1 -0
  20. package/web/_app/immutable/chunks/{DDuWClBR.js → BgT6ZdzK.js} +1 -1
  21. package/web/_app/immutable/chunks/{CO2Y5y64.js → Bq2GBAJ0.js} +1 -1
  22. package/web/_app/immutable/chunks/BqrMZ9MX.js +1 -0
  23. package/web/_app/immutable/chunks/{BN6xhG8e.js → Bt7VOT5H.js} +1 -1
  24. package/web/_app/immutable/chunks/{BGbXxNFa.js → BuUzVkG2.js} +1 -1
  25. package/web/_app/immutable/chunks/{Brxvm_b1.js → By4S_gy5.js} +1 -1
  26. package/web/_app/immutable/chunks/{CRIvE37b.js → BymwHy7o.js} +1 -1
  27. package/web/_app/immutable/chunks/{BrqJKzQU.js → CD6xPodA.js} +1 -1
  28. package/web/_app/immutable/chunks/{BXF2XoRC.js → CMeq8te_.js} +1 -1
  29. package/web/_app/immutable/chunks/CODXTnUW.js +523 -0
  30. package/web/_app/immutable/chunks/{CEufJyoj.js → CQd9D8Nc.js} +1 -1
  31. package/web/_app/immutable/chunks/{BrGmYbJT.js → CT_Ry4q8.js} +1 -1
  32. package/web/_app/immutable/chunks/{CQadubS9.js → C_amgxV1.js} +1 -1
  33. package/web/_app/immutable/chunks/{GRrQoDGJ.js → CfL6O_ia.js} +1 -1
  34. package/web/_app/immutable/chunks/{spNKdrPy.js → CjtKPNlv.js} +1 -1
  35. package/web/_app/immutable/chunks/{DxLkKbK2.js → Cl5zRP_n.js} +1 -1
  36. package/web/_app/immutable/chunks/{CETSRtnV.js → CyFLqlvP.js} +1 -1
  37. package/web/_app/immutable/chunks/{Bq5hCPe1.js → Czz9qOh8.js} +1 -1
  38. package/web/_app/immutable/chunks/{BguXRgvc.js → D3-rqfsM.js} +1 -1
  39. package/web/_app/immutable/chunks/{bcQIrid8.js → D5XlJBy8.js} +1 -1
  40. package/web/_app/immutable/chunks/{TuFg0KqZ.js → D5vocsTl.js} +1 -1
  41. package/web/_app/immutable/chunks/{CTscJvp6.js → D95RKsvN.js} +1 -1
  42. package/web/_app/immutable/chunks/{BzI3yqBQ.js → DBC2xjOo.js} +1 -1
  43. package/web/_app/immutable/chunks/DDVefAkE.js +7 -0
  44. package/web/_app/immutable/chunks/{BsLNwr5A.js → DF89zyH-.js} +1 -1
  45. package/web/_app/immutable/chunks/DGmSCGD3.js +1 -0
  46. package/web/_app/immutable/chunks/{DacMdKjW.js → DNjLZcwq.js} +1 -1
  47. package/web/_app/immutable/chunks/{C-dfcq9W.js → DRX-TQzj.js} +1 -1
  48. package/web/_app/immutable/chunks/{BunrC_8P.js → DX4bJJO0.js} +1 -1
  49. package/web/_app/immutable/chunks/{EQVRMnZU.js → DXK7PB4g.js} +1 -1
  50. package/web/_app/immutable/chunks/{mbLqADPr.js → DXTK-eyo.js} +1 -1
  51. package/web/_app/immutable/chunks/{DII7jNnq.js → DaulBP5z.js} +1 -1
  52. package/web/_app/immutable/chunks/{wCTXGvXm.js → DbNETcPs.js} +1 -1
  53. package/web/_app/immutable/chunks/Db_gdTNI.js +1 -0
  54. package/web/_app/immutable/chunks/{CX-xckzu.js → DfCZPwp1.js} +1 -1
  55. package/web/_app/immutable/chunks/{DKNOMI4Y.js → Dh1lBxfx.js} +1 -1
  56. package/web/_app/immutable/chunks/DktGnzDy.js +151 -0
  57. package/web/_app/immutable/chunks/{BgczuZKA.js → DkxkvOjx.js} +1 -1
  58. package/web/_app/immutable/chunks/{0M1khDs2.js → DlXrOzlh.js} +1 -1
  59. package/web/_app/immutable/chunks/{B85D_PlV.js → Dpa4Syyy.js} +1 -1
  60. package/web/_app/immutable/chunks/DshHzxgH.js +1 -0
  61. package/web/_app/immutable/chunks/DuLysVkb.js +1 -0
  62. package/web/_app/immutable/chunks/{CdY1YAit.js → EMo1IeTW.js} +1 -1
  63. package/web/_app/immutable/chunks/F7HCRtmu.js +1 -0
  64. package/web/_app/immutable/chunks/Iqr2CudW.js +3 -0
  65. package/web/_app/immutable/chunks/{CoyQYage.js → RFxekmX-.js} +1 -1
  66. package/web/_app/immutable/chunks/{vk5Wkr31.js → RlApGeew.js} +1 -1
  67. package/web/_app/immutable/chunks/{CLVUDRRk.js → Xm0YTnxV.js} +1 -1
  68. package/web/_app/immutable/chunks/{CZ8wTb_M.js → gPtCGHiy.js} +1 -1
  69. package/web/_app/immutable/chunks/{B3aPQAYq.js → mLFVM17H.js} +1 -1
  70. package/web/_app/immutable/chunks/{D4SKbj9K.js → oWM_kgYq.js} +1 -1
  71. package/web/_app/immutable/chunks/{wj7G6pU5.js → rghE0CVz.js} +1 -1
  72. package/web/_app/immutable/chunks/{B9YLdnR_.js → tUSDgbpy.js} +1 -1
  73. package/web/_app/immutable/chunks/{DTdlqvEb.js → vfDvz3qP.js} +1 -1
  74. package/web/_app/immutable/chunks/{BRKS-CCX.js → whhiiiga.js} +1 -1
  75. package/web/_app/immutable/chunks/wxBqjpRy.js +1 -0
  76. package/web/_app/immutable/entry/app.wp4GfiBT.js +2 -0
  77. package/web/_app/immutable/entry/start.PPXyd7_0.js +1 -0
  78. package/web/_app/immutable/nodes/0.JerS9yOA.js +26 -0
  79. package/web/_app/immutable/nodes/1.C-RxYNx3.js +1 -0
  80. package/web/_app/immutable/nodes/2.Bbkruoyi.js +1 -0
  81. package/web/_app/immutable/nodes/3.BkpGKa9k.js +1 -0
  82. package/web/_app/immutable/nodes/4.Bj25nsxG.js +2 -0
  83. package/web/_app/immutable/nodes/5.D9sfzyBX.js +9 -0
  84. package/web/_app/immutable/nodes/6.Di1re0aR.js +1 -0
  85. package/web/_app/immutable/nodes/7.MWEn-qPC.js +1 -0
  86. package/web/_app/version.json +1 -1
  87. package/web/index.html +18 -17
  88. package/web/kit/chart.js +55 -0
  89. package/web/kit/isorite.css +32 -0
  90. package/web/kit/kit.css +80 -0
  91. package/web/kit/kit.js +543 -0
  92. package/web/kit/licenses/d3.txt +13 -0
  93. package/web/kit/licenses/interval-tree-1d.txt +22 -0
  94. package/web/kit/licenses/isoformat.txt +13 -0
  95. package/web/kit/licenses/katex.txt +21 -0
  96. package/web/kit/licenses/observablehq-plot.txt +13 -0
  97. package/web/kit/licenses/three.txt +21 -0
  98. package/web/kit/math.css +1 -0
  99. package/web/kit/math.js +257 -0
  100. package/web/kit/model.js +4236 -0
  101. package/web/kit/plain.css +16 -0
  102. package/web/_app/immutable/assets/5.TsqJFEFF.css +0 -1
  103. package/web/_app/immutable/assets/NoteEditor.8wWtZK_A.css +0 -1
  104. package/web/_app/immutable/chunks/CBWiKnLz.js +0 -1
  105. package/web/_app/immutable/chunks/CHbKgHy3.js +0 -1
  106. package/web/_app/immutable/chunks/CJ1dhP0p.js +0 -1
  107. package/web/_app/immutable/chunks/CLkY0zVi.js +0 -1
  108. package/web/_app/immutable/chunks/D-aFnd2T.js +0 -1
  109. package/web/_app/immutable/chunks/DRQEUdad.js +0 -1
  110. package/web/_app/immutable/chunks/DZYaqCwi.js +0 -1
  111. package/web/_app/immutable/chunks/D_19S_Iu.js +0 -1
  112. package/web/_app/immutable/chunks/DcgxJ8bF.js +0 -673
  113. package/web/_app/immutable/chunks/Ddgejj-u.js +0 -1
  114. package/web/_app/immutable/chunks/nMarIA7J.js +0 -3
  115. package/web/_app/immutable/chunks/vUsuwDSf.js +0 -6
  116. package/web/_app/immutable/entry/app.CswuY3sh.js +0 -2
  117. package/web/_app/immutable/entry/start.D8ZvSyBD.js +0 -1
  118. package/web/_app/immutable/nodes/0.DBoa3NAQ.js +0 -26
  119. package/web/_app/immutable/nodes/1.DrwFerb8.js +0 -1
  120. package/web/_app/immutable/nodes/2.DPmbppXV.js +0 -1
  121. package/web/_app/immutable/nodes/3.BW7AbIrS.js +0 -1
  122. package/web/_app/immutable/nodes/4.B5HAyMKs.js +0 -2
  123. package/web/_app/immutable/nodes/5.BvScSoCM.js +0 -5
  124. package/web/_app/immutable/nodes/6.Bna6qY2G.js +0 -1
  125. package/web/_app/immutable/nodes/7.BxQaF3lD.js +0 -1
@@ -1,2 +1,2 @@
1
- import{_ as e,i as t,o as n,r,u as i,x as a}from"./CX-xckzu.js";import{r as o,t as s}from"./DciMwFJ1.js";import{s as c}from"./DECNRCf2.js";import{r as l}from"./BrqJKzQU.js";import{g as u,h as d,s as f,u as p}from"./8wVGBFSs.js";var m=class{type=`ishikawa`;title;root;stack=[];baseLevel;addNode(e,t){let n={text:t,children:[]};if(!this.root){this.root=n,this.stack=[{level:0,node:n}];return}this.baseLevel??=e;let r=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=r;)i.pop();i[i.length-1].node.children.push(n),i.push({level:r,node:n})}},h=[`$end`,`EOF`,`SPACELINE`,`NL`,`ISHIKAWA`,`SPACELIST`,`TEXT`];function g(e,t){let n=0;for(;n<13;){let r=e.charCodeAt(t+n),i=`ishikawa-beta`.charCodeAt(n);if(r!==i&&(r+32!==i||r<65||r>90))break;n++}return n===13&&!u(e.charCodeAt(t+13))?13:n>=8&&!u(e.charCodeAt(t+8))?8:0}function _(e){let t=[],n=[],r=[],i=e.length,a=0;for(;a<i;){let o=a,s=-1;for(;o<i&&d(e.charCodeAt(o));)e.charCodeAt(o)===10&&(s=o),o++;let c,l;if(e.charCodeAt(o)===37&&e.charCodeAt(o+1)===37)for(c=2,l=o+2;l<i;){let t=e.charCodeAt(l);if(t===10||t===13||t===8232||t===8233)break;l++}else if(o===a){let t=g(e,a);t>0?(c=4,l=a+t):(c=6,l=e.indexOf(`
1
+ import{_ as e,i as t,o as n,r,u as i,x as a}from"./DfCZPwp1.js";import{r as o,t as s}from"./DciMwFJ1.js";import{s as c}from"./BLmF1B2i.js";import{r as l}from"./CD6xPodA.js";import{g as u,h as d,s as f,u as p}from"./-2Meesge.js";var m=class{type=`ishikawa`;title;root;stack=[];baseLevel;addNode(e,t){let n={text:t,children:[]};if(!this.root){this.root=n,this.stack=[{level:0,node:n}];return}this.baseLevel??=e;let r=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=r;)i.pop();i[i.length-1].node.children.push(n),i.push({level:r,node:n})}},h=[`$end`,`EOF`,`SPACELINE`,`NL`,`ISHIKAWA`,`SPACELIST`,`TEXT`];function g(e,t){let n=0;for(;n<13;){let r=e.charCodeAt(t+n),i=`ishikawa-beta`.charCodeAt(n);if(r!==i&&(r+32!==i||r<65||r>90))break;n++}return n===13&&!u(e.charCodeAt(t+13))?13:n>=8&&!u(e.charCodeAt(t+8))?8:0}function _(e){let t=[],n=[],r=[],i=e.length,a=0;for(;a<i;){let o=a,s=-1;for(;o<i&&d(e.charCodeAt(o));)e.charCodeAt(o)===10&&(s=o),o++;let c,l;if(e.charCodeAt(o)===37&&e.charCodeAt(o+1)===37)for(c=2,l=o+2;l<i;){let t=e.charCodeAt(l);if(t===10||t===13||t===8232||t===8233)break;l++}else if(o===a){let t=g(e,a);t>0?(c=4,l=a+t):(c=6,l=e.indexOf(`
2
2
  `,a),l===-1&&(l=i))}else s>a?(c=2,l=s+1):s===a?(c=3,l=a+1):(c=5,l=o);t.push(c),n.push(a),r.push(l),a=l}return t.push(1,0),n.push(i,i),r.push(i,i),{types:t,starts:n,ends:r}}var v=`'SPACELINE', 'NL', 'EOF'`;function y(e,t){let{types:n,starts:r,ends:i}=_(e),a=0,o=t=>{throw f(`ishikawa`,e,r[a],`Expecting ${t}, got '${h[n[a]]}'`)};if(n[a]===2){for(a++;n[a]===2||n[a]===3;)a++;n[a]!==4&&o(`'SPACELINE', 'NL', 'ISHIKAWA'`)}else n[a]!==4&&o(`'SPACELINE', 'ISHIKAWA'`);for(a++,n[a]===3&&a++;;){let s=n[a];if(s===6||s===5&&n[a+1]===6){let c=s===6?a:a+1;a=c+1,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(v),t.addNode(s===6?0:i[c-1]-r[c-1],e.slice(r[c],i[c]).trim())}else s===2||s===5?(a++,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(s===5?`${v}, 'TEXT'`:v)):o(`'SPACELINE', 'SPACELIST', 'TEXT'`);for(a++;n[a]===3||n[a]===1;)a++;if(n[a]===0)return}}var b=.5,x=Math.hypot(b,1),S=14,C=6,w=8,T=22,E=18,D=5,O=26,k=34,A=28,j=10,M=5;function N(e,t,n,r,a){let o=i(e.text,!1,n,r,180),s=Math.round(a*1.5),c=[],l=[],u=[],d=(e,n,r)=>{let i=e.length;for(let a=i-1;a>=0;a--)u.push({node:e[t?i-1-a:a],depth:n,parent:r,slot:a,bone:-1})};for(d(e.children,2,-1);u.length>0;){let e=u.pop();if(e.bone!==-1){l.push(e.bone);continue}let t=c.length;c.push({label:i(e.node.text,!1,n,a,200),depth:e.depth,parent:e.parent,slot:e.slot,kids:e.node.children.length,rise:0,at:0,textEnd:0}),e.depth%2==0?l.push(t):(e.bone=t,u.push(e)),d(e.node.children,e.depth+1,t)}let f=S;for(let e of l){let t=Math.max(c[e].label.height,s)+C;c[e].rise=f+t/2,f+=t}let p=o.width+2*j,m=p/2;for(let e of c){let t=e.parent===-1?void 0:c[e.parent];e.depth%2==0?(e.at=t?t.at:0,e.textEnd=e.at-(e.kids>0?(e.kids+1)*T:E)-D):(e.at=t.at-(t.kids-e.slot)*T,e.textEnd=e.at-D),m=Math.max(m,e.label.width-e.textEnd)}return{node:e,label:o,boxW:p,boxH:o.height+2*M,bones:c,rise:f+w,reach:m}}function P(e,t,n){return s(n,r=>F(e,t,n,r))}function F(o,s,l,u){let d=l.fontSize??16,f=Math.round(d*.875),m=l.measurer??p(l.fontFamily,l.fontFamilyMono),h=l.padding??8;if(u)return I(o,l);let g=o.root,_=i(o.title,!1,m,d,4e3,1),v=_.height>0?_.height+12:0,y=``,S=0,C=0,w=0,T=0;if(g){let e=i(g.text,!1,m,d,200,1),o=Math.max(e.height+24,48),s=e.width+24+o/2,l=g.children.map((e,t)=>N(e,t%2==0,m,d,f));for(let e of l)e.rise=Math.max(e.rise,o/2+14);let u=[],p=-k;for(let e=0;e<l.length;e+=2){if(e>0){let t=0;for(let n=0;n<2;n++){let r=l[e-2+n],i=l[e+n];r&&(t=Math.max(t,r.reach+(i?i.boxW/2:0)))}p-=t+O}u.push(p,p)}let h=l.length>0?p-A:-k;C=s,S=h,w=-o/2,T=o/2;let _=``;l.forEach((e,i)=>{let o=i%2==0?-1:1,s=u[i],l=(e,t)=>s+e-t*b,d=l(0,e.rise),p=o*e.rise,m=`M${a(s-b/x*7)},${a(o*7/x)}L${a(d)},${a(p)}`,h=``;for(let t of e.bones){let r=o*t.rise;if(t.depth%2==0)m+=`M${a(l(t.at,t.rise))},${a(r)}H${a(l(t.textEnd+D,t.rise))}`;else{let n=e.bones[t.parent].rise;m+=`M${a(l(t.at,n))},${a(o*n)}L${a(l(t.at,t.rise))},${a(r)}`}let i=l(t.textEnd,t.rise);h+=n(t.label,i-t.label.width/2,r,t.depth>2?` fill="var(--_m)"`:``),S=Math.min(S,i-t.label.width)}let g=p+o*(e.boxH/2);S=Math.min(S,d-e.boxW/2),C=Math.max(C,d+e.boxW/2),w=Math.min(w,g-e.boxH/2),T=Math.max(T,g+e.boxH/2),_+=`<g class="pele-ishikawa-category" data-id="${t(e.node.text)}"><path class="pele-ishikawa-bones" d="${m}" fill="none" stroke="var(--_l)"/>`+c(`arrow_point`,s,0,b/x,-o/x,`var(--_l)`)+`<rect x="${a(d-e.boxW/2)}" y="${a(g-e.boxH/2)}" width="${a(e.boxW)}" height="${a(e.boxH)}" fill="var(--_s)" stroke="var(--_b)"${r}/>`+n(e.label,d,g,` class="pele-label"`)+(h?`<g class="pele-ishikawa-causes" font-size="${f}">${h}</g>`:``)+`</g>`});let v=o/2;y=`<path class="pele-ishikawa-spine" d="M${a(h)},0H${a(-7)}" fill="none" stroke="var(--_l)"/>`+c(`arrow_point`,0,0,1,0,`var(--_l)`)+_+`<g class="pele-ishikawa-head" data-id="${t(g.text)}"><path d="M0,${a(-v)}H${a(s-v)}A${a(v)},${a(v)} 0 0 1 ${a(s-v)},${a(v)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+n(e,12+e.width/2,0,` class="pele-label" font-weight="var(--_hw)"`)+`</g>`}let E=Math.max(C-S,_.width),j=Math.ceil(E+2*h),M=Math.ceil(T-w+v+2*h),P=h+(E-(C-S))/2-S,F=h+v-w;return{svg:e(`ishikawa`,j,M,d,l,{},n(_,j/2,h+_.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(y?`<g transform="translate(${a(P)},${a(F)})">${y}</g>`:``)),width:j,height:M,links:[]}}function I(r,s){let c=s.fontSize??16,u=Math.round(c*.875),d=s.measurer??p(s.fontFamily,s.fontFamilyMono),f=s.padding??8,m=Math.max(140,(s.maxWidth??320)-2*f),h=i(r.title,!1,d,c,o(s),1),g=[],_=r.root?[{node:r.root,depth:0,parent:-1}]:[],v=0;for(;_.length;){let e=_.pop(),t=g.length;g.push({...e,x:0,y:0,w:0,h:0}),v=Math.max(v,e.depth);for(let n=e.node.children.length-1;n>=0;n--)_.push({node:e.node.children[n],depth:e.depth+1,parent:t})}let y=Math.min(20,Math.max(2,(m-120)/Math.max(1,v))),b=f+(h.height?h.height+12:0),x=h.width,S=``,C=``;for(let e of g){e.x=f+e.depth*y;let r=Math.max(60,m-e.depth*y-20);e.label=l(i(e.node.text,!1,d,e.depth<2?c:u,r,+(e.depth<2)),d,r),e.w=e.label.width+20,e.h=e.label.height+12,e.y=b,b+=e.h+12,x=Math.max(x,e.x-f+e.w);let o=e.depth<2;if(S+=`<g class="pele-node ${e.depth===0?`pele-ishikawa-head`:e.depth===1?`pele-ishikawa-category`:`pele-ishikawa-cause`}" data-id="${t(e.node.text)}">`+(o?`<rect x="${a(e.x)}" y="${a(e.y)}" width="${a(e.w)}" height="${a(e.h)}" rx="${e.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:``)+n(e.label,e.x+e.w/2,e.y+e.h/2,` class="pele-label"${e.depth<2?` font-weight="var(--_hw)"`:``}${e.depth>1?` font-size="${u}"`:``}`)+`</g>`,e.parent>=0){let t=g[e.parent],n=t.x+y/2;C+=`<path class="pele-edge" d="M${a(n)},${a(t.y+t.h)}V${a(e.y+e.h/2)}H${a(e.x)}" fill="none" stroke="var(--_b)"/>`}}let w=Math.ceil(x+2*f),T=Math.ceil(Math.max(f+h.height,b-12)+f),E=n(h,w/2,f+h.height/2,` class="pele-title" font-weight="var(--_tw)"`)+C+S;return{svg:e(`ishikawa`,w,T,c,s,{},E),width:w,height:T,links:[]}}var L={type:`ishikawa`,parse(e,t,n){let r=new m;return r.title=n,y(e,r),r},render:P};export{L as ishikawa};
@@ -1,2 +1,2 @@
1
- import{h as e}from"./8wVGBFSs.js";function t(e,t){let n=e.indexOf(`
1
+ import{h as e}from"./-2Meesge.js";function t(e,t){let n=e.indexOf(`
2
2
  `,t);return n===-1?e.length:n}function n(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function r(n,r){let i=n.length,a=r;for(;a<i;){let r=n.charCodeAt(a);if(r===37&&n.charCodeAt(a+1)!==123)a=t(n,a);else{if(r===10)return a;if(e(r))do a++;while(a<i&&e(n.charCodeAt(a)));else if(r===35)a=t(n,a);else return a}}return a}function i(t,n){let r=n;for(;e(t.charCodeAt(r));)r++;return r}function a(e,r,a,o){let s=n(e,r,`accdescr`);if(!s&&!n(e,r,`acctitle`))return r;let c=e.length,l=i(e,r+8),u=e.charCodeAt(l),d=(t,n,r)=>{a.types.push(t),a.texts.push(e.slice(n,r)),a.starts.push(n)};if(u===58){l=i(e,l+1);let n=t(e,l);return d(s?o+2:o,r,l),d(s?o+3:o+1,l,n),n}if(!s||u!==123)return r;for(l=i(e,l+1);e.charCodeAt(l)!==125;){let t=e.indexOf(`}`,l);if(t===-1&&(t=c),d(o+4,l,t),l===c)return c;l=t}return l+1}export{a as i,r as n,t as r,n as t};
@@ -1,2 +1,2 @@
1
- import{_ as e,f as t,i as n,o as r,u as i,x as a}from"./CX-xckzu.js";import{n as o,r as s}from"./DciMwFJ1.js";import{a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./BunrC_8P.js";import{PeleError as w,u as T}from"./8wVGBFSs.js";var E=32;function D(e){return new w(e,`semantic`,{type:`radar`})}function O(e,t){let n=e.axes.map(e=>({name:e.name,label:e.label??e.name})),r=e.curves.map(e=>{let t;if(e.entries[0].axis===void 0)t=e.entries.map(e=>e.value);else{if(n.length===0)throw D(`Axes must be populated before curves for reference entries`);let r=new Map;for(let t of e.entries)t.axis!==void 0&&!r.has(t.axis.$refText)&&r.set(t.axis.$refText,t.value);t=n.map(e=>{let t=r.get(e.name);if(t===void 0)throw D(`Missing entry for axis `+e.label);return t})}return{name:e.name,label:e.label??e.name,entries:t}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`};for(let t of e.options)t.name===`showLegend`?i.showLegend=t.value:t.name===`graticule`?i.graticule=t.value:i[t.name]=t.value;return i.ticks>E&&(i.ticks=E),{type:`radar`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
1
+ import{_ as e,f as t,i as n,o as r,u as i,x as a}from"./DfCZPwp1.js";import{n as o,r as s}from"./DciMwFJ1.js";import{a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./DX4bJJO0.js";import{PeleError as w,u as T}from"./-2Meesge.js";var E=32;function D(e){return new w(e,`semantic`,{type:`radar`})}function O(e,t){let n=e.axes.map(e=>({name:e.name,label:e.label??e.name})),r=e.curves.map(e=>{let t;if(e.entries[0].axis===void 0)t=e.entries.map(e=>e.value);else{if(n.length===0)throw D(`Axes must be populated before curves for reference entries`);let r=new Map;for(let t of e.entries)t.axis!==void 0&&!r.has(t.axis.$refText)&&r.set(t.axis.$refText,t.value);t=n.map(e=>{let t=r.get(e.name);if(t===void 0)throw D(`Missing entry for axis `+e.label);return t})}return{name:e.name,label:e.label??e.name,entries:t}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`};for(let t of e.options)t.name===`showLegend`?i.showLegend=t.value:t.name===`graticule`?i.graticule=t.value:i[t.name]=t.value;return i.ticks>E&&(i.ticks=E),{type:`radar`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
2
2
  `):void 0,axes:n,curves:r,options:i}}var k=0,A=0;function j(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function M(e,t){(t<k||t>=A)&&(k=t,A=j(e,t));let n=A;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let t=j(e,n+1),r=t-n-1;if(r>0&&e.charCodeAt(t)!==46)return t;if(r>1)return t-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var N=c.pattern,P=/[\t ]*accDescr\s*{/y,F=-2;function I(e,t){return P.lastIndex=t,P.test(e)&&(F===-2&&(F=e.lastIndexOf(`}`)),P.lastIndex>F)?-1:(N.lastIndex=t,N.test(e)?N.lastIndex:-1)}var L={name:`ID`,pattern:/[\w]([-\w]*\w)?/y},R=e=>({name:e,pattern:e,longer:[L]}),z=e=>({name:e,pattern:e}),B=[z(`radar-beta:`),{...m(`radar-beta`),longer:[L]},R(`showLegend`),R(`graticule`),R(`curve`),R(`ticks`),R(`axis`),R(`max`),R(`min`),z(`:`),z(`,`),z(`[`),z(`]`),z(`{`),z(`}`),{name:`GRATICULE`,pattern:/circle|polygon/y},{name:`BOOLEAN`,pattern:/true|false/y},{...c,match:I},S,y,{name:`NUMBER`,pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:M},g,L,h,C,b,v,x];function V(e){return k=A=0,F=-2,_(e,B,`radar`)}function H(e){let t=new p(V(e),B,`radar`),n={$type:`Radar`,axes:[],curves:[],options:[]},r=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail(`a line break or the end of input`),r())},a=()=>{if(!t.accept(11))return;let e=d(t.expect(21));return t.expect(12),e},o=e=>{if(!e)return{$type:`Entry`,value:Number(t.expect(20))};let n={$refText:t.expect(22)};return t.accept(9),{$type:`Entry`,axis:n,value:Number(t.expect(20))}},s=()=>{let e=t.expect(22),n=a(),i={$type:`Curve`,name:e,entries:[]};n!==void 0&&(i.label=n),t.expect(13),r(),t.kind!==20&&t.kind!==22&&t.fail(`a number or an axis name`);let s=t.kind===22;for(i.entries.push(o(s));t.accept(10);)r(),i.entries.push(o(s));return r(),t.expect(14),i},c=()=>{let e={$type:`Axis`,name:t.expect(22)},n=a();return n!==void 0&&(e.label=n),e},m=()=>{let e=t.kind,n=t.take(),r;return r=e===2?t.expect(16)===`true`:e===3?t.expect(15):Number(t.expect(20)),{$type:`Option`,name:n,value:r}},h=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(r(),t.accept(0)||(t.expect(1),t.accept(9)),r();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:n.accDescr=l(t.take()),i();break;case 18:n.accTitle=f(t.take()),i();break;case 19:n.title=u(t.take()),i();break;case 6:t.i++;do n.axes.push(c());while(t.accept(10));break;case 4:t.i++;do n.curves.push(s());while(t.accept(10));break;default:for(h()||t.fail(`an axis, a curve, an option, a title, or a line break`),n.options.push(m());t.accept(10);)h()||t.fail(`an option`),n.options.push(m())}return n}var U=12,W=26,G=24;function K(e,t,n,r,i){let a=e.radar?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function ee(e,t,n,r){let i=Math.min(Math.max(e,t),n),a=r*(i-t);return Number.isFinite(a)?a/(n-t):r*((i-t)/(n-t))}function te(e,t){let n=e.length,r=`M${a(e[0].x)},${a(e[0].y)}`;for(let i=0;i<n;i++){let o=e[(i-1+n)%n],s=e[i],c=e[(i+1)%n],l=e[(i+2)%n];r+=` C${a(s.x+(c.x-o.x)*t)},${a(s.y+(c.y-o.y)*t)} ${a(c.x-(l.x-s.x)*t)},${a(c.y-(l.y-s.y)*t)} ${a(c.x)},${a(c.y)}`}return r+` Z`}function q(e){let t=``;for(let n of e)t+=(t?` `:``)+a(n.x)+`,`+a(n.y);return t}function J(e,t,n){let r=K(t,`width`,320,1,4e3);return o(n,r,160,(i,a)=>Y(e,t,n,i,K(t,`height`,320,1,4e3)*i/r,a))}function Y(o,c,l,u,d,f){let p=l.fontSize??16,m=Math.round(p*.875),h=l.measurer??T(l.fontFamily,l.fontFamilyMono),g=l.padding??8,_=K(c,`axisScaleFactor`,1,0,10),v=K(c,`axisLabelFactor`,1.05,0,10),y=K(c,`curveTension`,.17,0,1),b=Math.min(u,d)/2,{axes:x,curves:S}=o,{ticks:C,graticule:w,min:E}=o.options,D=x.length,O=x.map((e,t)=>{let n=2*Math.PI*t/D-Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}),k=o.options.max;if(k===null){k=-1/0;for(let e of S)for(let t of e.entries)t>k&&(k=t)}let A=-u/2-K(c,`marginLeft`,16,0,2e3),j=u/2+K(c,`marginRight`,16,0,2e3),M=-d/2-K(c,`marginTop`,16,0,2e3),N=d/2+K(c,`marginBottom`,16,0,2e3),P=``;for(let e=0;e<C;e++){let t=Math.min(b,b*(e+1)/C);P+=w===`circle`?`<circle r="${a(t)}"/>`:`<polygon points="${q(O.map(e=>({x:e.x*t,y:e.y*t})))}"/>`}let F=``,I=``;O.forEach((e,t)=>{let o=b*_;F+=`M0,0L${a(e.x*o)},${a(e.y*o)}`;let s=i(x[t].label,!1,h,m,4e3),c=b*v+6,l=e.x*c+(e.x>.01?s.width/2:e.x<-.01?-s.width/2:0),u=e.y*c+(e.y>.01?s.height/2:e.y<-.01?-s.height/2:0);I+=`<g class="pele-axis-label" data-id="${n(x[t].name)}">${r(s,l,u,``)}</g>`,A=Math.min(A,l-s.width/2),j=Math.max(j,l+s.width/2),M=Math.min(M,u-s.height/2),N=Math.max(N,u+s.height/2)});let L=``;S.forEach((e,r)=>{if(e.entries.length!==D)return;let i=e.entries.map((e,t)=>{let n=ee(e,E,k,b),r=Number.isFinite(n)?n:0;return{x:O[t].x*r,y:O[t].y*r}}),a=t(r),o=` class="pele-curve" data-id="${n(e.name)}" fill="${a}" stroke="${a}"`;L+=w===`circle`?`<path${o} d="${te(i,y)}"/>`:`<polygon${o} points="${q(i)}"/>`});let R=o.options.showLegend?S.map(e=>i(e.label,!1,h,m,4e3)):[],z=0;for(let e of R)z=Math.max(z,e.width);let B=R.length*W,V=f?-(U+8+z)/2:j+G,H=f?N+G/2:-B/2;R.length>0&&f?(A=Math.min(A,V),j=Math.max(j,-V),N=H+B):R.length>0&&(j=V+U+8+z,M=Math.min(M,-B/2),N=Math.max(N,B/2));let J=``;R.forEach((e,i)=>{let o=H+i*W+W/2,s=t(i);J+=`<g class="pele-legend-item" data-id="${n(S[i].name)}"><rect x="${a(V)}" y="${a(o-U/2)}" width="${U}" height="${U}" rx="2" fill="${s}" fill-opacity="0.4" stroke="${s}"/>`+r(e,V+U+8+e.width/2,o,``)+`</g>`});let Y=i(o.title,!1,h,p,s(l),1),X=Y.height>0?Y.height+8:0,Z=Math.max(j-A,Y.width),Q=Math.ceil(Z+2*g),$=Math.ceil(N-M+X+2*g),ne=`translate(${a(g+(Z-(j-A))/2-A)},${a(g+X-M)})`,re=r(Y,Q/2,g+Y.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="${ne}">`+(P?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${P}</g>`:``)+(F?`<path class="pele-axes" d="${F}" fill="none" stroke="var(--_b)"/>`:``)+(L?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${L}</g>`:``)+(I?`<g class="pele-axis-labels" font-size="${m}">${I}</g>`:``)+(J?`<g class="pele-legend" font-size="${m}">${J}</g>`:``)+`</g>`;return{svg:e(`radar`,Q,$,p,l,o,re),width:Q,height:$,links:[]}}var X={type:`radar`,parse:(e,t,n)=>O(H(e),n),render:J};export{X as radar};
@@ -1 +1 @@
1
- import{_ as e,b as t,f as n,i as r,o as i,p as a,u as o,x as s,y as c}from"./CX-xckzu.js";import{r as l,t as u}from"./DciMwFJ1.js";import{n as d,r as f,t as p}from"./spNKdrPy.js";import{t as m}from"./CoyQYage.js";import{a as ee,i as h,o as g}from"./DKNOMI4Y.js";import{PeleError as _,f as v,u as y}from"./8wVGBFSs.js";var b=11,x=class{type=`mindmap`;title;nodes=[];getType=p;baseLevel=0;open=[];addNode(e,t,n,r){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let a=this.open,o=a.length;for(;o>0&&a[o-1].level>=e;)o--;let s=a[o-1];if(!s&&!i)throw new _(`There can be only one root. No parent could be found for ("${n}")`,`semantic`,{type:`mindmap`});let c={id:this.nodes.length,nodeId:t,level:e,descr:n,type:r,children:[],isRoot:i};s&&(c.section=s.isRoot?s.children.length%b:s.section,s.children.push(c)),a.length=o,a.push(c),this.nodes.push(c)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};function S(e,t){f(e,t,!1)}var te=[``,`rounded`,`rect`,`circle`,`cloud`,`bang`,`hex`],ne=`stadium`,re=36,ie=8,ae=18,oe=52,se=28,ce=6,le=12,ue=.22,C=6,w=28,de=12,fe=8,pe=10;function me(e,t,n,r){if(e.lines.length<2)return i(e,t+e.width/2,n,` class="pele-label"`,r);let o=``,s=n-e.height/2;for(let n=0;n<e.lines.length;n++)o+=i(c(e,n),t+e.widths[n]/2,s+a(e,n),` class="pele-label"`,r);return o}function he(e,t,n){return u(n,r=>T(e,t,n,r))}function T(a,c,u,f){let p=u.fontSize??16,_=u.measurer??y(u.fontFamily,u.fontFamilyMono),b=u.padding??8,x=u.icons,S=c.mindmap?.maxNodeWidth,he=typeof S==`number`&&S>0?Math.min(S,2e3):200,T=p*1.25,E=a.nodes,D=E.length,O=new Int32Array(D),k=new Int32Array(D);for(let e=0;e<D;e++)for(let t of E[e].children)O[t.id]=e,k[t.id]=k[e]+1;let ge=f&&u.maxWidth!==void 0&&u.maxWidth>0?u.maxWidth-2*b:1/0,A=Array(D),j=Array(D),M=new Float64Array(D),N=new Float64Array(D),P=new Float64Array(D),F=new Float64Array(D),I=new Uint8Array(D);for(let e=0;e<D;e++){let t=E[e];I[e]=+(t.icon!==void 0&&v(t.icon)!==``);let n=Math.min(he,Math.max(72,ge-k[e]*w-2*ce-(I[e]?T+C:0))),r=A[e]=o(t.descr,!0,_,p,n),i=r.width+(I[e]?T+(r.width>0?C:0):0),a=Math.max(r.height,Math.round(p*1.5)),s=te[t.type]||(e===0?ne:``);if(f&&e===0&&s!==`rect`&&s!==`rounded`&&(s=ne),j[e]=s,s===``){let n=t.children.length>0;M[e]=i+2*(n?le:ce),N[e]=a+(n?6:0),F[e]=N[e]/2}else{let t=h(s,i,a);M[e]=t.w,N[e]=t.h,P[e]=t.dy,F[e]=t.h/2}}let L=new Float64Array(D),R=new Float64Array(D),z=new Float64Array(D),_e=new Float64Array(D),ve=0,ye=(e,t,n,r)=>{let i=0,a=0;for(let o=t;o<n;o++){let t=e[o].id;R[t]=i,a=e[o].children.length>0||o+1<n&&e[o+1].children.length>0?Math.max(r,ae):r,i+=L[t]+a}ve=i-a;let o=e[t].id,s=e[n-1].id;return(R[o]+z[o]+F[o]+R[s]+z[s]+F[s])/2};for(let e=D-1;e>0;e--){let t=E[e].children;if(t.length===0){L[e]=N[e];continue}let n=ye(t,0,t.length,ie)-F[e],r=Math.min(0,n);L[e]=Math.max(ve,n+N[e])-r,z[e]=n-r,_e[e]=-r}let B=new Float64Array(D),V=new Float64Array(D),H=new Float64Array(D),U=new Int8Array(D),be=new Float64Array(D);if(f){let e=0;for(let t=0;t<D;t++)t>0&&O[t]===0&&(e+=pe),B[t]=k[t]*w+M[t]/2,V[t]=e,e+=N[t]+pe}else if(D>0){let e=E[0].children,t=e.length,n=0;for(let t of e)n+=L[t.id];let r=t,i=1/0,a=0;for(let o=1;o<t;o++){a+=L[e[o-1].id];let s=Math.abs(2*a-n+(2*o-t)*se);s<i&&(i=s,r=o)}for(let n=0,i=r,a=1;n<t;n=i,i=t,a=-1){let t=ye(e,n,i,se);for(let r=n;r<i;r++){let n=e[r].id;H[n]=R[n]-t,U[n]=a}}V[0]=-N[0]/2;for(let e=0;e<D;e++){e>0&&(V[e]=H[e]+z[e]);for(let t of E[e].children){let n=t.id;e>0&&(U[n]=U[e],H[n]=H[e]+_e[e]+R[n]),B[n]=B[e]+U[n]*(M[e]/2+(e>0?re:oe)+M[n]/2)}}}let W=0,G=0,K=0,q=0,J=``,Y=``,X=``,Z=``,xe=e=>{X!==``&&(J+=`<g class="pele-branch pele-section-${e??0}"><g class="pele-edges" fill="none" stroke="${Z}" stroke-width="1.5">${Y}</g>${X}</g>`,Y=X=``)};for(let e=1;e<=D;e++){let a=e%D,o=E[a],c=j[a],l=A[a],u=B[a],p=V[a];if(W=Math.min(W,u-M[a]/2),G=Math.max(G,u+M[a]/2),K=Math.min(K,p),q=Math.max(q,p+N[a]),(a===0||O[a]===0)&&xe(E[e-1].section),a>0&&f){O[a]===0&&(Z=n(o.section??0));let e=O[a],t=e===0?Math.min(Math.max(de,N[0]/2),w-fe):de,r=B[e]-M[e]/2+Math.min(t,M[e]/2),i=be[e]||V[e]+N[e],l=u-M[a]/2+(c?g(c,M[a],N[a],3):0),d=p+F[a],f=Math.max(0,Math.min(fe,l-r,d-i));be[e]=d-f,Y+=`<path class="pele-edge" d="M${s(r)},${s(i)}V${s(d-f)}Q${s(r)},${s(d)} ${s(r+f)},${s(d)}H${s(l)}"/>`}else if(a>0){O[a]===0&&(Z=n(o.section??0));let e=O[a],t=U[a],r=t>0?1:3,i=B[e]+t*(M[e]/2-(j[e]?g(j[e],M[e],N[e],r):0)),l=V[e]+F[e],d=u-t*M[a]/2+(c?t*g(c,M[a],N[a],4-r):0),f=p+F[a],m=s((i+d)/2);Y+=`<path class="pele-edge" d="M${s(i)},${s(l)}C${m},${s(l)} ${m},${s(f)} ${s(d)},${s(f)}"/>`}let m=!c&&o.children.length>0,h=` fill="${Z}" fill-opacity="${ue}" stroke="${Z}"`,_=``;c?_=a>0?ee(c,M[a],N[a],h,` stroke="${Z}"`):ee(c,M[a],N[a],` fill="var(--_s)" stroke="var(--_b)"`,` stroke="var(--_b)"`):m&&(_=`<rect x="${s(-M[a]/2)}" y="${s(-N[a]/2)}" width="${s(M[a])}" height="${s(N[a])}" rx="${s(N[a]/2)}"${h}/>`);let v=0;o.icon&&I[a]&&(v=(T+(l.width>0?C:0))/2,_+=d(o.icon,-v-l.width/2,P[a]-T/2,T,x));let y=`<g class="pele-node pele-shape-${c||(m?`branch`:`text`)}${a>0?``:` pele-root`}${t(o.class??``)}" data-id="${r(o.nodeId)}" transform="translate(${s(u)},${s(p+N[a]/2)})">`+_+(f&&!c?me(l,v-l.width/2,P[a],x):i(l,v,P[a],` class="pele-label"`,x))+`</g>`;a>0?X+=y:J+=y}let Q=m(a.title,_,p,l(u)),Se=Q.height>0?Q.height+16:0,Ce=Math.max(G-W,Q.width),$=Math.ceil(Ce+2*b),we=Math.ceil(q-K+Se+2*b),Te=i(Q,$/2,b+Q.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${s(b-W+(Ce-G+W)/2)},${s(b+Se-K)})">${J}</g>`;return{svg:e(`mindmap`,$,we,p,u,{},Te),width:$,height:we,links:[]}}var E={type:`mindmap`,math:!0,parse(e,t,n){let r=new x;return r.title=n,S(e,r),r},render:he};export{E as mindmap};
1
+ import{_ as e,b as t,f as n,i as r,o as i,p as a,u as o,x as s,y as c}from"./DfCZPwp1.js";import{r as l,t as u}from"./DciMwFJ1.js";import{n as d,r as f,t as p}from"./CjtKPNlv.js";import{t as m}from"./RFxekmX-.js";import{a as ee,i as h,o as g}from"./Dh1lBxfx.js";import{PeleError as _,f as v,u as y}from"./-2Meesge.js";var b=11,x=class{type=`mindmap`;title;nodes=[];getType=p;baseLevel=0;open=[];addNode(e,t,n,r){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let a=this.open,o=a.length;for(;o>0&&a[o-1].level>=e;)o--;let s=a[o-1];if(!s&&!i)throw new _(`There can be only one root. No parent could be found for ("${n}")`,`semantic`,{type:`mindmap`});let c={id:this.nodes.length,nodeId:t,level:e,descr:n,type:r,children:[],isRoot:i};s&&(c.section=s.isRoot?s.children.length%b:s.section,s.children.push(c)),a.length=o,a.push(c),this.nodes.push(c)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};function S(e,t){f(e,t,!1)}var te=[``,`rounded`,`rect`,`circle`,`cloud`,`bang`,`hex`],ne=`stadium`,re=36,ie=8,ae=18,oe=52,se=28,ce=6,le=12,ue=.22,C=6,w=28,de=12,fe=8,pe=10;function me(e,t,n,r){if(e.lines.length<2)return i(e,t+e.width/2,n,` class="pele-label"`,r);let o=``,s=n-e.height/2;for(let n=0;n<e.lines.length;n++)o+=i(c(e,n),t+e.widths[n]/2,s+a(e,n),` class="pele-label"`,r);return o}function he(e,t,n){return u(n,r=>T(e,t,n,r))}function T(a,c,u,f){let p=u.fontSize??16,_=u.measurer??y(u.fontFamily,u.fontFamilyMono),b=u.padding??8,x=u.icons,S=c.mindmap?.maxNodeWidth,he=typeof S==`number`&&S>0?Math.min(S,2e3):200,T=p*1.25,E=a.nodes,D=E.length,O=new Int32Array(D),k=new Int32Array(D);for(let e=0;e<D;e++)for(let t of E[e].children)O[t.id]=e,k[t.id]=k[e]+1;let ge=f&&u.maxWidth!==void 0&&u.maxWidth>0?u.maxWidth-2*b:1/0,A=Array(D),j=Array(D),M=new Float64Array(D),N=new Float64Array(D),P=new Float64Array(D),F=new Float64Array(D),I=new Uint8Array(D);for(let e=0;e<D;e++){let t=E[e];I[e]=+(t.icon!==void 0&&v(t.icon)!==``);let n=Math.min(he,Math.max(72,ge-k[e]*w-2*ce-(I[e]?T+C:0))),r=A[e]=o(t.descr,!0,_,p,n),i=r.width+(I[e]?T+(r.width>0?C:0):0),a=Math.max(r.height,Math.round(p*1.5)),s=te[t.type]||(e===0?ne:``);if(f&&e===0&&s!==`rect`&&s!==`rounded`&&(s=ne),j[e]=s,s===``){let n=t.children.length>0;M[e]=i+2*(n?le:ce),N[e]=a+(n?6:0),F[e]=N[e]/2}else{let t=h(s,i,a);M[e]=t.w,N[e]=t.h,P[e]=t.dy,F[e]=t.h/2}}let L=new Float64Array(D),R=new Float64Array(D),z=new Float64Array(D),_e=new Float64Array(D),ve=0,ye=(e,t,n,r)=>{let i=0,a=0;for(let o=t;o<n;o++){let t=e[o].id;R[t]=i,a=e[o].children.length>0||o+1<n&&e[o+1].children.length>0?Math.max(r,ae):r,i+=L[t]+a}ve=i-a;let o=e[t].id,s=e[n-1].id;return(R[o]+z[o]+F[o]+R[s]+z[s]+F[s])/2};for(let e=D-1;e>0;e--){let t=E[e].children;if(t.length===0){L[e]=N[e];continue}let n=ye(t,0,t.length,ie)-F[e],r=Math.min(0,n);L[e]=Math.max(ve,n+N[e])-r,z[e]=n-r,_e[e]=-r}let B=new Float64Array(D),V=new Float64Array(D),H=new Float64Array(D),U=new Int8Array(D),be=new Float64Array(D);if(f){let e=0;for(let t=0;t<D;t++)t>0&&O[t]===0&&(e+=pe),B[t]=k[t]*w+M[t]/2,V[t]=e,e+=N[t]+pe}else if(D>0){let e=E[0].children,t=e.length,n=0;for(let t of e)n+=L[t.id];let r=t,i=1/0,a=0;for(let o=1;o<t;o++){a+=L[e[o-1].id];let s=Math.abs(2*a-n+(2*o-t)*se);s<i&&(i=s,r=o)}for(let n=0,i=r,a=1;n<t;n=i,i=t,a=-1){let t=ye(e,n,i,se);for(let r=n;r<i;r++){let n=e[r].id;H[n]=R[n]-t,U[n]=a}}V[0]=-N[0]/2;for(let e=0;e<D;e++){e>0&&(V[e]=H[e]+z[e]);for(let t of E[e].children){let n=t.id;e>0&&(U[n]=U[e],H[n]=H[e]+_e[e]+R[n]),B[n]=B[e]+U[n]*(M[e]/2+(e>0?re:oe)+M[n]/2)}}}let W=0,G=0,K=0,q=0,J=``,Y=``,X=``,Z=``,xe=e=>{X!==``&&(J+=`<g class="pele-branch pele-section-${e??0}"><g class="pele-edges" fill="none" stroke="${Z}" stroke-width="1.5">${Y}</g>${X}</g>`,Y=X=``)};for(let e=1;e<=D;e++){let a=e%D,o=E[a],c=j[a],l=A[a],u=B[a],p=V[a];if(W=Math.min(W,u-M[a]/2),G=Math.max(G,u+M[a]/2),K=Math.min(K,p),q=Math.max(q,p+N[a]),(a===0||O[a]===0)&&xe(E[e-1].section),a>0&&f){O[a]===0&&(Z=n(o.section??0));let e=O[a],t=e===0?Math.min(Math.max(de,N[0]/2),w-fe):de,r=B[e]-M[e]/2+Math.min(t,M[e]/2),i=be[e]||V[e]+N[e],l=u-M[a]/2+(c?g(c,M[a],N[a],3):0),d=p+F[a],f=Math.max(0,Math.min(fe,l-r,d-i));be[e]=d-f,Y+=`<path class="pele-edge" d="M${s(r)},${s(i)}V${s(d-f)}Q${s(r)},${s(d)} ${s(r+f)},${s(d)}H${s(l)}"/>`}else if(a>0){O[a]===0&&(Z=n(o.section??0));let e=O[a],t=U[a],r=t>0?1:3,i=B[e]+t*(M[e]/2-(j[e]?g(j[e],M[e],N[e],r):0)),l=V[e]+F[e],d=u-t*M[a]/2+(c?t*g(c,M[a],N[a],4-r):0),f=p+F[a],m=s((i+d)/2);Y+=`<path class="pele-edge" d="M${s(i)},${s(l)}C${m},${s(l)} ${m},${s(f)} ${s(d)},${s(f)}"/>`}let m=!c&&o.children.length>0,h=` fill="${Z}" fill-opacity="${ue}" stroke="${Z}"`,_=``;c?_=a>0?ee(c,M[a],N[a],h,` stroke="${Z}"`):ee(c,M[a],N[a],` fill="var(--_s)" stroke="var(--_b)"`,` stroke="var(--_b)"`):m&&(_=`<rect x="${s(-M[a]/2)}" y="${s(-N[a]/2)}" width="${s(M[a])}" height="${s(N[a])}" rx="${s(N[a]/2)}"${h}/>`);let v=0;o.icon&&I[a]&&(v=(T+(l.width>0?C:0))/2,_+=d(o.icon,-v-l.width/2,P[a]-T/2,T,x));let y=`<g class="pele-node pele-shape-${c||(m?`branch`:`text`)}${a>0?``:` pele-root`}${t(o.class??``)}" data-id="${r(o.nodeId)}" transform="translate(${s(u)},${s(p+N[a]/2)})">`+_+(f&&!c?me(l,v-l.width/2,P[a],x):i(l,v,P[a],` class="pele-label"`,x))+`</g>`;a>0?X+=y:J+=y}let Q=m(a.title,_,p,l(u)),Se=Q.height>0?Q.height+16:0,Ce=Math.max(G-W,Q.width),$=Math.ceil(Ce+2*b),we=Math.ceil(q-K+Se+2*b),Te=i(Q,$/2,b+Q.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${s(b-W+(Ce-G+W)/2)},${s(b+Se-K)})">${J}</g>`;return{svg:e(`mindmap`,$,we,p,u,{},Te),width:$,height:we,links:[]}}var E={type:`mindmap`,math:!0,parse(e,t,n){let r=new x;return r.title=n,S(e,r),r},render:he};export{E as mindmap};
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,d as n,i as r,o as i,s as a,u as o,x as s}from"./CX-xckzu.js";import{o as c,r as l}from"./DciMwFJ1.js";import{a as u,s as d}from"./DECNRCf2.js";import{a as f}from"./DKNOMI4Y.js";import{o as p,t as m}from"./BN6xhG8e.js";import{n as h}from"./BrqJKzQU.js";import{PeleError as g,g as _,h as v,s as y,u as b}from"./8wVGBFSs.js";var x=new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),S=new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function C(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?S:x).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function w(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:C(e,n))}function T(e,t,n){n===void 0?e[t]??=``:w(e,t,n)}function E(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,C(e,t)):e.label=t??``}var D=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{_ as e,a as t,d as n,i as r,o as i,s as a,u as o,x as s}from"./DfCZPwp1.js";import{o as c,r as l}from"./DciMwFJ1.js";import{a as u,s as d}from"./BLmF1B2i.js";import{a as f}from"./Dh1lBxfx.js";import{o as p,t as m}from"./Bt7VOT5H.js";import{n as h}from"./CD6xPodA.js";import{PeleError as g,g as _,h as v,s as y,u as b}from"./-2Meesge.js";var x=new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),S=new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function C(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?S:x).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function w(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:C(e,n))}function T(e,t,n){n===void 0?e[t]??=``:w(e,t,n)}function E(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,C(e,t)):e.label=t??``}var D=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}element(e,t,n,r){let i=typeof n==`string`?t.get(n):void 0;return i===void 0&&(i={alias:``,label:``,parent:void 0},e.push(i),typeof n==`string`?(i.alias=n,t.set(n,i)):(i.aliasAttr=n,C(i,n))),E(i,r),i}addPersonOrSystem(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);T(n,`descr`,t[2]),this.finishShape(n,e,t,3)}addContainer(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);T(n,`techn`,t[2]),T(n,`descr`,t[3]),this.finishShape(n,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,n,r){w(e,`sprite`,n[r]),w(e,`tags`,n[r+1]),w(e,`link`,n[r+2]),e.kind=t,e.parent=this.current}boundary(e,t){let n=this.element(this.boundaries,this.boundaryIndex,e[0],e[1]);return e[2]===void 0?n.type=t:w(n,`type`,e[2]),n}open(e){e.parent=this.current,this.stack.push(this.current),this.current=e}addPersonOrSystemBoundary(e,t=`system`){let n=this.boundary(e,t);w(n,`tags`,e[3]),w(n,`link`,e[4]),this.open(n)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,`container`)}addDeploymentNode(e,t){let n=this.boundary(t,`node`);T(n,`descr`,t[3]),w(n,`sprite`,t[4]),w(n,`tags`,t[5]),w(n,`link`,t[6]),n.nodeType=e,this.open(n)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(e,t){let n=t[0],r=t[1];if(n===void 0||r===void 0||t[2]===void 0)return;let i=typeof n==`string`&&typeof r==`string`,a=i?this.relIndex.get(n)?.get(r):void 0;if(a===void 0){if(a={type:e,from:``,to:``,label:``},this.rels.push(a),i){let e=this.relIndex.get(n);e===void 0&&this.relIndex.set(n,e=new Map),e.set(r,a)}typeof n==`string`?a.from=n:a.fromAttr=n,typeof r==`string`?a.to=r:a.toAttr=r}a.type=e,E(a,t[2]),T(a,`techn`,t[3]),T(a,`descr`,t[4]),w(a,`sprite`,t[5]),w(a,`tags`,t[6]),w(a,`link`,t[7])}getC4Shape(e){return this.shapeIndex.get(e)??this.boundaryIndex.get(e)}updateElStyle(e,t){let n=typeof t[0]==`string`?this.getC4Shape(t[0]):void 0;n!==void 0&&(w(n,`bgColor`,t[1]),w(n,`fontColor`,t[2]),w(n,`borderColor`,t[3]),w(n,`shadowing`,t[4]),w(n,`shape`,t[5]),w(n,`sprite`,t[6]),w(n,`techn`,t[7]),w(n,`legendText`,t[8]),w(n,`legendSprite`,t[9]))}updateRelStyle(e,t){let n=t[0],r=t[1],i=typeof n==`string`&&typeof r==`string`?this.relIndex.get(n)?.get(r):void 0;if(i===void 0)return;w(i,`textColor`,t[2]),w(i,`lineColor`,t[3]);let a=t[4],o=t[5];typeof a==`string`?i.offsetX=parseInt(a):a!==void 0&&C(i,a),typeof o==`string`?i.offsetY=parseInt(o):o!==void 0&&C(i,o)}updateLayoutConfig(e,t){let n=e=>e===void 0?NaN:parseInt(typeof e==`string`?e:e.value),r=n(t[0]),i=n(t[1]);r>=1&&(this.shapeInRow=r),i>=1&&(this.boundaryInRow=i)}},O=`$end.INVALID.direction_tb.direction_bt.direction_rl.direction_lr.title.accDescription.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.NEWLINE.C4_CONTEXT.C4_CONTAINER.C4_COMPONENT.C4_DYNAMIC.C4_DEPLOYMENT.PERSON.PERSON_EXT.SYSTEM.SYSTEM_DB.SYSTEM_QUEUE.SYSTEM_EXT.SYSTEM_EXT_DB.SYSTEM_EXT_QUEUE.CONTAINER.CONTAINER_DB.CONTAINER_QUEUE.CONTAINER_EXT.CONTAINER_EXT_DB.CONTAINER_EXT_QUEUE.COMPONENT.COMPONENT_DB.COMPONENT_QUEUE.COMPONENT_EXT.COMPONENT_EXT_DB.COMPONENT_EXT_QUEUE.ENTERPRISE_BOUNDARY.SYSTEM_BOUNDARY.BOUNDARY.CONTAINER_BOUNDARY.NODE.NODE_L.NODE_R.REL.BIREL.REL_U.REL_D.REL_L.REL_R.REL_B.REL_INDEX.UPDATE_EL_STYLE.UPDATE_REL_STYLE.UPDATE_LAYOUT_CONFIG.EOF_IN_STRUCT.ATTRIBUTE_EMPTY.STR.STR_KEY.STR_VALUE.LBRACE.RBRACE.EOF`.split(`.`),k=new Map([[`C4Context`,14],[`C4Container`,15],[`C4Component`,16],[`C4Dynamic`,17],[`C4Deployment`,18],[`Person`,19],[`Person_Ext`,20],[`System`,21],[`SystemDb`,22],[`SystemQueue`,23],[`System_Ext`,24],[`SystemDb_Ext`,25],[`SystemQueue_Ext`,26],[`Container`,27],[`ContainerDb`,28],[`ContainerQueue`,29],[`Container_Ext`,30],[`ContainerDb_Ext`,31],[`ContainerQueue_Ext`,32],[`Component`,33],[`ComponentDb`,34],[`ComponentQueue`,35],[`Component_Ext`,36],[`ComponentDb_Ext`,37],[`ComponentQueue_Ext`,38],[`Enterprise_Boundary`,39],[`System_Boundary`,40],[`Boundary`,41],[`Container_Boundary`,42],[`Deployment_Node`,43],[`Node`,43],[`Node_L`,44],[`Node_R`,45],[`Rel`,46],[`BiRel`,47],[`Rel_Up`,48],[`Rel_U`,48],[`Rel_Down`,49],[`Rel_D`,49],[`Rel_Left`,50],[`Rel_L`,50],[`Rel_Right`,51],[`Rel_R`,51],[`Rel_Back`,52],[`RelIndex`,53],[`UpdateElementStyle`,54],[`UpdateRelStyle`,55],[`UpdateLayoutConfig`,56]]),A=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],j=/[\n\r\u2028\u2029]/g,M=/title[^\S\r\n]*(?=[\r\n]|$)\s*/y;function N(e){let t=e.length,n=[],r=[],i=[],a=0,o=9,s=0,c=!1,l=-2,u=-1,d=0,f=(e,t,a)=>{n.push(e),r.push(t),i.push(a),s=a},p=n=>{for(;n<t&&v(e.charCodeAt(n));)n++;return n},m=(n,r)=>{let i=e.indexOf(n,r);return i===-1?t:i},h=(n,r)=>{let i=s+n.length;if(!e.startsWith(n,s)||!v(e.charCodeAt(i)))return!1;let a=++i;for(;i<t;){let t=e.charCodeAt(i);if(t===35||t===10||t===59)break;i++}return i!==a&&(f(r,s,i),!0)};for(;;){if(c){f(0,t,t);break}s>=t&&(c=!0);let n=e.charCodeAt(s);if(a===0){if(s>=t){f(64,t,t);continue}if(l!==-1&&s>=d&&(l<s&&(l=e.indexOf(`direction`,s)),l!==-1&&(u<s&&(j.lastIndex=s,u=j.test(e)?j.lastIndex-1:t),l<u))){let t=!1;for(let n=0;n<4&&!t;n++)A[n].lastIndex=s,A[n].test(e)&&(f(2+n,s,A[n].lastIndex),t=!0);if(t)continue;d=u}if(n===116){if(M.lastIndex=s,M.test(e)){s=M.lastIndex;continue}if(h(`title`,6))continue}if(n===97){if(h(`accDescription`,7))continue;let t=e.startsWith(`accTitle`,s);if(t||e.startsWith(`accDescr`,s)){let n=p(s+8),r=e.charCodeAt(n);if(r===58){f(t?8:10,s,p(n+1)),o=t?9:11,a=7;continue}if(r===123&&!t){s=p(n+1),a=8;continue}}}if(n===37&&e.charCodeAt(s+1)===37){let n=m(`
3
3
  `,s+2);for(;n<t&&(e.charCodeAt(n)===10||e.charCodeAt(n)===13);)n++;s=n;continue}if(v(n)){let n=s,r=-1;for(;n<t;){let t=e.charCodeAt(n);if(!v(t))break;t===10&&(r=n),n++}r===-1?s=n:f(13,s,r+1);continue}if(n===123){f(62,s,s+1);continue}if(n===125){f(63,s,s+1);continue}if(_(n)){let n=s+1;for(;n<t&&_(e.charCodeAt(n));)n++;let r=n-s<=19?k.get(e.slice(s,n)):void 0;if(r!==void 0){r>18&&(a=1),f(r,s,n);continue}}f(1,s,s);break}if(a===1){if(s>=t)f(57,t,t);else if(n===40){let t=s+1;for(;e.charCodeAt(t)===32;)t++;e.charCodeAt(t)===44?f(58,s,t+1):s++,a=2}else if(n===41)s++,a=0;else{f(1,s,s);break}}else if(a===2){if(s>=t)continue;if(n===41)s++,a=0;else if(n===44)e.charCodeAt(s+1)===44?f(58,s,s+2):s++;else{let t=s;for(;e.charCodeAt(t)===32;)t++;let n=e.charCodeAt(t);n===34?e.charCodeAt(t+1)===34?f(58,s,t+2):(s=t+1,a=3):n===36?(s=t+1,a=4):f(59,s,m(`,`,s))}}else if(a===3)n===34?(s++,a=2):f(59,s,m(`"`,s));else if(a===4)f(60,s,m(`=`,s)),a=5;else if(a===5){if(s>=t)continue;let r=s+1;if(n===61)for(;e.charCodeAt(r)===32;)r++;if(n!==61||e.charCodeAt(r)!==34){f(1,s,s);break}s=r+1,a=6}else if(a===6){if(s>=t)continue;n===34?(s++,a=2):f(61,s,m(`"`,s))}else a===7?(f(o,s,m(`
4
4
  `,s)),a=0):n===125?(s++,a=0):f(12,s,m(`}`,s))}return{types:n,starts:r,ends:i}}var P=[`person`,`external_person`,`system`,`system_db`,`system_queue`,`external_system`,`external_system_db`,`external_system_queue`,`container`,`container_db`,`container_queue`,`external_container`,`external_container_db`,`external_container_queue`,`component`,`component_db`,`component_queue`,`external_component`,`external_component_db`,`external_component_queue`],F=[`rel`,`birel`,`rel_u`,`rel_d`,`rel_l`,`rel_r`,`rel_b`,`rel`],I=[`node`,`nodeL`,`nodeR`],ee=`'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'`,te=`'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'`;function L(e){return e===6||e===7||e===8||e===10||e===12}function ne(e){return e>=19&&e<=56}function R(e,t){let{types:n,starts:r,ends:i}=N(e),a=0,o=t=>e.slice(r[t],i[t]),s=t=>{let i=n[a];throw i===1?y(`c4`,e,r[a],``,!0):y(`c4`,e,r[a],`Expecting ${t}, got '${O[i]}'`)},c=e=>{n[a]!==e&&s(`'${O[e]}'`),a++},l=()=>{let e=[];for(;;){let t=n[a];if(t===59)e.push(o(a++).trim());else if(t===58)e.push(``),a++;else if(t===60)a++,n[a]!==61&&s(`'STR_VALUE'`),e.push({key:o(a-1).trim(),value:o(a).trim()}),a++;else break}return e.length===0&&s(te),e},u=e=>{e===6?t.setTitle(o(a++).substring(6)):e===7?t.setAccDescription(o(a++).substring(15)):e===12?t.setAccDescription(o(a++).trim()):(a++,e===8?(n[a]!==9&&s(`'acc_title_value'`),t.setTitle(o(a++).trim())):(n[a]!==11&&s(`'acc_descr_value'`),t.setAccDescription(o(a++).trim())))},d=e=>{a++;let r=l();if(e<=26)t.addPersonOrSystem(P[e-19],r);else if(e<=32)t.addContainer(P[e-19],r);else if(e<=38)t.addComponent(P[e-19],r);else{if(e<=45)return e===39?r.splice(2,0,`ENTERPRISE`):e===40?r.splice(2,0,`SYSTEM`):e===42&&r.splice(2,0,`CONTAINER`),e>=43?t.addDeploymentNode(I[e-43],r):e===42?t.addContainerBoundary(r):t.addPersonOrSystemBoundary(r),n[a]===62?(a++,c(13)):n[a]===13?(a++,c(62),n[a]===13&&a++):s(`'NEWLINE', 'LBRACE'`),!0;e<=53?(e===53&&r.splice(0,1),t.addRel(F[e-46],r)):e===54?t.updateElStyle(`update_el_style`,r):e===55?t.updateRelStyle(`update_rel_style`,r):t.updateLayoutConfig(`update_layout_config`,r)}return!1},f=n[a];(f<14||f>18)&&s(ee),a++,c(13);let p=0,m=0;for(;;){let e=n[a];if(m===3||m===4){if(e===13){a++,m=2;continue}if(m===3&&ne(e)){m=1;continue}}else if(ne(e)){d(e)?(p++,m=1):m=4;continue}else if(L(e)&&m!==1){u(e),m=3;continue}else m!==2&&s(`'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'`);if(p>0)e!==63&&s(`'NEWLINE', 'RBRACE'`),a++,t.popBoundaryParseStack(),p--,m=4;else{e!==64&&s(`'NEWLINE', 'EOF'`),a++,c(0),t.setC4Type(o(0));return}}}var z=28,B=20,V=7,H=8,U=30,W=88,G=160,re=8,ie=26,ae=e=>Math.min(12,Math.max(6,e/14)),oe=e=>Math.min(12,e/4);function K(e,t,n,r,i,a,o,s){let c=0,l=1;if(o===0){if(i<e||i>n)return 1/0}else{let t=(e-i)/o,r=(n-i)/o;c=Math.max(c,Math.min(t,r)),l=Math.min(l,Math.max(t,r))}if(s===0){if(a<t||a>r)return 1/0}else{let e=(t-a)/s,n=(r-a)/s;c=Math.max(c,Math.min(e,n)),l=Math.min(l,Math.max(e,n))}return c<=l?c:1/0}function q(e,t,n,r,i,a,o,s){let c=o/n,l=s/r,u=(i-e)/n,d=(a-t)/r,f=c*c+l*l,p=2*(c*u+l*d),m=u*u+d*d-1,h=p*p-4*f*m;if(f===0||h<0)return 1/0;let g=(-p-Math.sqrt(h))/(2*f);return g>=0&&g<=1?g:m<=0?0:1/0}function J(e,t,n,r,i){let{x:a,y:o,w:s,h:c}=e,l=r-t,u=i-n;if(e.form===`person`)return Math.min(K(a,o+ie,a+s,o+c,t,n,l,u),q(a+s/2,o+14,13,13,t,n,l,u));if(e.form===`cyl`){let e=ae(s);return Math.min(K(a,o+e,a+s,o+c-e,t,n,l,u),q(a+s/2,o+e,s/2,e,t,n,l,u),q(a+s/2,o+c-e,s/2,e,t,n,l,u))}if(e.form===`h-cyl`){let e=oe(c);return Math.min(K(a+e,o,a+s-e,o+c,t,n,l,u),q(a+e,o+c/2,e,c/2,t,n,l,u),q(a+s-e,o+c/2,e,c/2,t,n,l,u))}return K(a,o,a+s,o+c,t,n,l,u)}function se(e,t,n,r,i){for(let a=2;a<e.length;a+=2){let o=e[a-2],s=e[a-1];if(K(t,n,r,i,o,s,e[a]-o,e[a+1]-s)<=1)return!0}return!1}function Y(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function ce(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t.x+t.w/2,o=t.y+t.h/2,s=Y(e,t);if(s||Y(t,e)){let n=s?e:t,r=s?t:e,i=r.x+r.w/2,a=r.y+r.h/2,o=r.x-n.x,c=n.x+n.w-r.x-r.w,l=r.y-n.y,u=n.y+n.h-r.y-r.h,d=Math.min(o,c,l,u),f=d===o?n.x:d===c?n.x+n.w:i,p=d===o||d===c?a:d===u?n.y+n.h:n.y,m=Math.min(J(r,f,p,i,a),1),h=f+(i-f)*m,g=p+(a-p)*m;return s?[f,p,h,g]:[h,g,f,p]}let c=r,l=i,u=a,d=o,f=Math.max(e.x,t.x),p=Math.min(e.x+e.w,t.x+t.w),m=Math.max(e.y,t.y),h=Math.min(e.y+e.h,t.y+t.h);f<p?c=u=(f+p)/2:m<h&&(l=d=(m+h)/2);let g=Math.hypot(u-c,d-l)||1,_=-(d-l)/g*n,v=(u-c)/g*n,y=J(e,u+_,d+v,c+_,l+v),b=J(t,c+_,l+v,u+_,d+v);return y<=1&&b<=1?(c+=_,l+=v,u+=_,d+=v):(c=r,l=i,u=a,d=o,y=Math.min(J(e,u,d,c,l),1),b=Math.min(J(t,c,l,u,d),1)),[u+(c-u)*y,d+(l-d)*y,c+(u-c)*b,l+(d-l)*b]}var le=6,ue=3,de=12,fe=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(e,t,n,r){let i=Math.min(n,r),a=Math.max(n,r),o=(e,n)=>{for(let r=0;r<e.length;r+=3)if(Math.abs(e[r]-t)<n&&e[r+1]<a&&e[r+2]>i)return!0;return!1};return!o(e?this.upright:this.level,le)&&!o(this.frames[+!e],ue)}crossings(e){let t=0;for(let n=2;n<e.length;n+=2){let r=e[n]===e[n-2],i=r?e[n]:e[n+1],a=Math.min(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),o=Math.max(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),s=r?this.level:this.upright;for(let e=0;e<s.length;e+=3)s[e]>a&&s[e]<o&&s[e+1]<i&&s[e+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,n,r,i){let a=this.taken.get(e)??[],o=[];for(let e=0;e<9&&o.length<4;e++){let s=n+(e&1?1:-1)*Math.ceil(e/2)*de;if(s<r||s>i)continue;let c=!0;for(let e=0;e<a.length;e+=2)a[e]===t&&Math.abs(a[e+1]-s)<de&&(c=!1);c&&o.push(s)}return o.length?o:[n]}claim(e,t,n){let r=this.taken.get(e);r?r.push(t,n):this.taken.set(e,[t,n])}};function pe(e,t,n){let r=e.length,i=Math.sign(e[2]-e[0]),a=Math.sign(e[3]-e[1]),o=`M${s(e[0]+i*t)},${s(e[1]+a*t)}`;for(let t=2;t<r-2;t+=2){let n=e[t],r=e[t+1],i=Math.sign(n-e[t-2]),a=Math.sign(r-e[t-1]),c=Math.sign(e[t+2]-n),l=Math.sign(e[t+3]-r),u=Math.min(H,Math.abs(n-e[t-2]+r-e[t-1])/2,Math.abs(e[t+2]-n+e[t+3]-r)/2);o+=`${i?`H`+s(n-i*u):`V`+s(r-a*u)}Q${s(n)},${s(r)} ${s(n+c*u)},${s(r+l*u)}`}let c=Math.sign(e[r-2]-e[r-4]),l=Math.sign(e[r-1]-e[r-3]);return o+(c?`H`+s(e[r-2]-c*n):`V`+s(e[r-1]-l*n))}function me(e,t,n,r){for(let i of t)if(i!==n&&i!==r&&se(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function he(e,t,n,r,i){let a=e.length;return{d:pe(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[a-2],ey:e[a-1],edx:Math.sign(e[a-2]-e[a-4]),edy:Math.sign(e[a-1]-e[a-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:G,...i,points:e}}function ge(e,t){let n=[],r=(e+t)/2,i=Math.max(V,(t-e)/4);for(let a=0;a<9;a++){let o=r+(a&1?1:-1)*Math.ceil(a/2)*i;o>=e+le&&o<=t-le&&n.push(o)}return n}function _e(e,t,n,r,i,a){let o=e.x+e.w/2,s=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,u,d=(i,a,o)=>{if(!me(i,n,e,t))return;for(let e=2;e<i.length;e+=2){let t=i[e]===i[e-2];if(!r.free(t,t?i[e]:i[e+1],t?i[e-1]:i[e-2],t?i[e+1]:i[e]))return}let s=r.crossings(i)*1e6;for(let e=2;e<i.length;e+=2)s+=Math.abs(i[e]-i[e-2])+Math.abs(i[e+1]-i[e-1]);(!u||s<u.cost)&&(u={points:i,cost:s,upright:a,sides:o})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let n=c>o,i=Math.sign(l-s),a=n?[1,0]:[0,1],f=ge(n?e.x+e.w:t.x+t.w,n?t.x:e.x);e:for(let n of r.ports(e,a[0],s+i*e.h/4,e.y+8,e.y+e.h-8))for(let s of r.ports(t,a[1],l-i*t.h/4,t.y+8,t.y+t.h-8))for(let r of f){let i=r+(o-r)*Math.min(J(e,r,n,o,n),1),l=r+(c-r)*Math.min(J(t,r,s,c,s),1),f=u;if(d([i,n,r,n,r,s,l,s],!0,a),u!==f)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let n=l>s,i=Math.sign(c-o),a=n?[3,2]:[2,3],f=ge(n?e.y+e.h:t.y+t.h,n?t.y:e.y);e:for(let n of r.ports(e,a[0],o+i*e.w/4,e.x+8,e.x+e.w-8))for(let o of r.ports(t,a[1],c-i*t.w/4,t.x+8,t.x+t.w-8))for(let r of f){let i=r+(s-r)*Math.min(J(e,n,r,n,s),1),c=r+(l-r)*Math.min(J(t,o,r,o,l),1),f=u;if(d([n,i,n,r,o,r,o,c],!1,a),u!==f)break e}}if(!u)return;let{points:f,upright:p,sides:m}=u;return r.take(f),r.claim(e,m[0],p?f[1]:f[0]),r.claim(t,m[1],p?f[7]:f[6]),he(f,2,i,a,{room:p?W:G})}function ve(e,t,n,r,i,a,o){if(e===t){let t=Math.min(e.h/2-4,10),n=Math.hypot(z,t),r=e.x+e.w,i=e.y+e.h/2,c=z/n,l=t/n;return{d:`M${s(r+c*a)},${s(i-t-l*a)}C${s(r+z)},${s(i-t*2)} ${s(r+z)},${s(i+t*2)} ${s(r+c*o)},${s(i+t+l*o)}`,sx:r,sy:i-t,sdx:-c,sdy:l,ex:r,ey:i+t,edx:-c,edy:-l,x0:r+z+4,y0:i,x1:r+z+4,y1:i,nx:1,ny:0,lean:0,room:64,points:[]}}let[c,l,u,d]=ce(e,t,n),f=c===u,p=!1;if(r&&!Y(e,t)&&!Y(t,e))for(let n of r)n!==e&&n!==t&&K(n.x,n.y,n.x+n.w,n.y+n.h,c,l,u-c,d-l)<=1&&(p=!0);if(r&&p&&!f&&l!==d){let n=_e(e,t,r,i,a,o);if(n)return n;i.squeezed++}if(r&&p&&(f||l===d)){let n=n=>{let i=n?-1/0:1/0,a=e=>{let t=f?e.x:e.y;i=n?Math.max(i,t+(f?e.w:e.h)):Math.min(i,t)};a(e),a(t);for(let n of r)n!==e&&n!==t&&K(n.x,n.y,n.x+n.w,n.y+n.h,c,l,u-c,d-l)<=1&&a(n);return i},s=f?Math.min(e.y,t.y):Math.min(e.x,t.x),p=f?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),m=(n,i)=>{for(let a of r){if(a===e||a===t)continue;let r=f?a.y<p&&a.y+a.h>s:a.x<p&&a.x+a.w>s,o=f?a.x:a.y,c=o+(f?a.w:a.h);if(r&&(n?c>i:o<i))return!1}return!0},h=e.x+e.w/2,g=e.y+e.h/2,_=t.x+t.w/2,v=t.y+t.h/2,y=Math.sign(f?v-g:_-h),b=a=>{let o=n(a),s=a?1:-1,c=f?+!!a:a?3:2,l=f?i.ports(e,c,g+y*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,c,h+y*e.w/4,e.x+8,e.x+e.w-8)[0],u=f?i.ports(t,c,v-y*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,c,_-y*t.w/4,t.x+8,t.x+t.w-8)[0],d=n=>{if(f){let r=n+(h-n)*Math.min(J(e,n,l,h,l),1),i=n+(_-n)*Math.min(J(t,n,u,_,u),1);return[r,l,n,l,n,u,i,u]}let r=n+(g-n)*Math.min(J(e,l,n,l,g),1),i=n+(v-n)*Math.min(J(t,u,n,u,v),1);return[l,r,l,n,u,n,u,i]},p=d(o+s*B);for(let n=0;n<=4;n++){let a=o+s*(B+n*V),m=d(a);if(me(m,r,e,t)&&(p=m,i.free(f,a,l,u)))return{points:p,side:c,p0:l,p1:u,step:n}}return{points:p,side:c,p0:l,p1:u,step:5}},x=f?d>l:u<c,S=m(x,n(x)),C=m(!x,n(!x)),w=b(x),T=S===C?b(!x):void 0,E=e=>i.crossings(e.points)*8+e.step,D=C&&!S||T&&E(T)<E(w)?!x:x,{points:O,side:k,p0:A,p1:j,step:M}=D===x?w:T??b(!x),N=D?1:-1;return M>4&&i.squeezed++,i.take(O),i.claim(e,k,A),i.claim(t,k,j),he(O,2,a,o,f?{nx:N,lean:U,room:W}:{room:G})}let m=Math.hypot(u-c,d-l)||1,h=(u-c)/m,g=(d-l)/m;return(f||l===d)&&i.take([c,l,u,d]),{d:`M${s(c+h*a)},${s(l+g*a)}L${s(u-h*o)},${s(d-g*o)}`,sx:c,sy:l,sdx:-h,sdy:-g,ex:u,ey:d,edx:h,edy:g,x0:c,y0:l,x1:u,y1:d,nx:n?-g:0,ny:n?h:0,lean:0,room:Math.abs(h)>Math.abs(g)?W:G,points:[c,l,u,d]}}var ye=216,be=64,xe=14,Se=12,Ce=W+re+24,we=88,Te=B+8,X=48,Z=16,Ee=10,De=new Map([[`person`,`person`],[`box`,`rect`],[`rounded`,`rect`],[`component`,`rect`],[`cylinder`,`cyl`],[`database`,`cyl`],[`db`,`cyl`],[`queue`,`h-cyl`],[`pipe`,`h-cyl`]]);function Oe(e){let t=De.get((e.shape??``).toLowerCase())??De.get((e.sprite??``).toLowerCase());if(t)return t;if(e.tags)for(let t of e.tags.split(`,`)){let e=De.get(t.trim().toLowerCase());if(e)return e}let n=e.kind;return n.endsWith(`person`)?`person`:n.endsWith(`_db`)?`cyl`:n.endsWith(`_queue`)?`h-cyl`:`rect`}function ke(e,t,n,r,i=ye){let a=Oe(e),s=a===`h-cyl`?36:0,c=a===`person`?ie:a===`cyl`?24:0,l=i-2*xe-s,u=[o(`«`+e.kind.replace(/_/g,` `)+`»`,!1,t,r-1,l),o(e.label,!1,t,n,l,1),o(e.techn?`[${e.techn}]`:void 0,!1,t,r,l),o(e.descr,!1,t,r,l)],d=0,f=u[3].height>0?4:0;for(let e of u)d=Math.max(d,e.width),f+=e.height;return{shape:e,form:a,labels:u,textH:f,x:0,y:0,w:Math.max(i,d+2*xe+s),h:Math.max(be,f+2*Se+c)}}function Ae(e,t,n,r,i){let a=0,o=0;for(let s=0;s<e.length;s+=t){let c=Math.min(e.length,s+t),l=0,u=0;for(let t=s;t<c;t++)u=Math.max(u,e[t].h);for(let t=s;t<c;t++){let r=e[t];r.x=l,r.y=o,i&&(r.h=u),l+=r.w+n}a=Math.max(a,l-n),o+=u+r}return[a,e.length>0?o-r:0]}function je(e,t,n,r,i,a){let s=i===void 0?Te:12,c=new Map;for(let a of e.boundaries){let e=i===void 0?4e3:Math.max(80,i-2*Z-2*Te*2),l=a.parent?[o(a.label,!1,t,n,e,1),o(a.type?`[${a.type}]`:void 0,!1,t,r,e),o(a.descr,!1,t,r,e)]:[],u=0,d=0;for(let e of l)u+=e.height,d=Math.max(d,e.width);c.set(a,{boundary:a,kids:[],nodes:[],labels:l,head:u>0?u+Ee+6+B:s,headW:d,headX:Z,x:0,y:0,w:0,h:0,form:`rect`})}let l=c.get(e.boundaries[0]);for(let e of c.values()){let t=e.boundary.parent;t&&c.get(t)?.kids.push(e)}let u=[l],d=new Map([[l.boundary,0]]);for(let e=0;e<u.length;e++)for(let t of u[e].kids)d.set(t.boundary,d.get(u[e].boundary)+1),u.push(t);for(let a of e.shapes)if(a.parent){let e=d.get(a.parent)??0,o=i===void 0?ye:Math.max(100,Math.min(ye,i-2*e*s-32));c.get(a.parent)?.nodes.push(ke(a,t,n,r,o))}let f=Math.max(1,e.shapeInRow),p=Math.max(1,e.boundaryInRow),m=new Map;for(let e=u.length-1;e>=0;e--){let t=u[e],n=i===void 0?Ce:a,r=(e,t,n)=>{if(i===void 0)return t;let r=1;for(let t of e)r=Math.max(r,t.w);return Math.max(1,Math.min(t,Math.floor((i+n-2*s)/(r+n))))},[o,c]=Ae(t.nodes,r(t.nodes,f,n),n,we,!0),[d,h]=Ae(t.kids,r(t.kids,p,X),X,X,!1),g=c>0&&h>0?X:0,_=t===l?0:s;m.set(t,c+g),t.w=Math.max(o,d,t.headW+2*Z-2*_)+2*_,t.h=(_&&t.head)+c+g+h+_}let h=new Map;for(let e of u){let t=e.x+(e===l?0:s),n=e.y+(e===l?0:e.head);for(let r of e.nodes)r.x+=t,r.y+=n,h.set(r.shape,r);for(let r of e.kids)r.x+=t,r.y+=n+m.get(e);e!==l&&h.set(e.boundary,e)}return{order:u,boxes:h}}var Me=7,Q=36,Ne=24,Pe=2e3,$=8,Fe=[.5,.4,.6,.3,.7,.2,.8],Ie=2e6;function Le(e,t,n){let r=[];return e&&r.push(`fill:`+e),t&&r.push(`stroke:`+t),n&&r.push(`color:`+n),a(r)}function Re(e,t,n,r,i){return t?m(e,p(t.includes(`¶ß`)?t.replace(/\ufb02\u00b0\u00b0?/g,`#`).replace(/\u00b6\u00df/g,`;`):t),n,r,i):e}function ze(e,t,n){return c(n,r=>{if(!r)return Be(e,t,n,!1)[0];let[i,a]=Be(e,t,n,!0,Q);for(let r=Q+Ne;a>0&&r<=Q+3*Ne;r+=Ne){let[o,s]=Be(e,t,n,!0,r);s<a&&([i,a]=[o,s])}return i})}function Be(a,c,p,m,_=Q){let v=p.fontSize??16,y=Math.round(v*.8125),x=p.measurer??b(p.fontFamily,p.fontFamilyMono),S=p.padding??8,C=[],{order:w,boxes:T}=je(a,x,v,y,m?Math.max(80,(p.maxWidth??320)-2*S):void 0,_),E=w[0],D=0,O=0,k=E.w,A=E.h,j=(e,t,n,r)=>{D=Math.min(D,e),O=Math.min(O,t),k=Math.max(k,n),A=Math.max(A,r)},M=[],N=new Map;for(let e of a.rels){let t=e.fromAttr?void 0:a.getC4Shape(e.from),n=e.toAttr?void 0:a.getC4Shape(e.to),r=t&&T.get(t),i=n&&T.get(n);if(!r||!i)throw new g(`C4 rel "${e.from}" -> "${e.to}" references an unknown shape or boundary`,`semantic`,{type:`c4`});M.push(r,i);let o=N.get(r);o||N.set(r,o=new Set),o.add(i)}let P=[],F=[];for(let e of w)for(let t of e.nodes)P.push(t),F.push(t.x+$,t.y+$,t.x+t.w-$,t.y+t.h-$);let I=a.rels.length*(P.length+w.length+3*a.rels.length)<=Ie,ee=(e,t,n,r)=>{let i=0;for(let a=0;a<F.length;a+=4){let o=Math.min(n,F[a+2])-Math.max(e,F[a]);if(o<=0)continue;let s=Math.min(r,F[a+3])-Math.max(t,F[a+1]);s>0&&(i+=o*s)}return i},te=e=>e?Math.max(-Pe,Math.min(Pe,e)):0,L=``,ne=u(`arrow_point`),R=new fe;for(let e of w)e!==E&&R.frame(e);let z=a.rels.map((e,n)=>{let i=M[n*2],a=M[n*2+1],o=Le(void 0,e.lineColor,void 0),s=o.stroke?t(o.stroke):`var(--_l)`,c=e.type===`birel`||e.type===`rel_b`,l=e.type!==`rel_b`,u=ve(i,a,i!==a&&N.get(a)?.has(i)===!0?Me:0,I?P:void 0,R,c?ne:0,l?ne:0);return j(Math.min(u.x0,u.x1),Math.min(u.y0,u.y1),Math.max(u.x0,u.x1),Math.max(u.y0,u.y1)),c&&I&&F.push(u.sx-8,u.sy-8,u.sx+8,u.sy+8),l&&I&&F.push(u.ex-8,u.ey-8,u.ex+8,u.ey+8),L+=`<g class="pele-edge" data-id="${r(e.from+`-`+e.to)}"${o.line}><path d="${u.d}"/>`+(c?d(`arrow_point`,u.sx,u.sy,u.sdx,u.sdy,s):``)+(l?d(`arrow_point`,u.ex,u.ey,u.edx,u.edy,s):``)+`</g>`,u});for(let e of w){if(!I||e.headW===0)continue;let t=e.y+Ee,n=e.y+e.head-B,r=1/0;for(let i of[Z,(e.w-e.headW)/2,e.w-Z-e.headW]){let a=0;for(let r of z)se(r.points,e.x+i-4,t,e.x+i+e.headW+4,n)&&a++;if(a<r&&(r=a,e.headX=i),a===0)break}F.push(e.x+e.headX-4,t,e.x+e.headX+e.headW+4,n)}let V=``;a.rels.forEach((e,t)=>{let n=z[t],c=e.from+`-`+e.to,l=Le(void 0,void 0,e.textColor),u=(a.c4Type===`C4Dynamic`?t+1+`: `:``)+e.label,d=o(u,!1,x,y,n.room),f=o(e.techn?`[${e.techn}]`:void 0,!1,x,y,n.room,2),h=Math.max(d.width,f.width)+re,g=d.height+f.height;if(g===0)return;let _=Math.abs(n.nx)*(h/2)+Math.abs(n.ny)*(g/2)+2,v=n.lean?Math.max(0,Math.min(n.lean,_-14)):_,b=n.nx*v+(m?0:te(e.offsetX)),S=n.ny*v+(m?0:te(e.offsetY)),w=.5;if(I){let e=1/0,t=b!==n.nx*v||S!==n.ny*v;for(let r=0;r<(t?2:1)&&e>0;r++){let t=r?n.nx*v:b,i=r?n.ny*v:S;for(let r of Fe){let a=n.x0+(n.x1-n.x0)*r+t,o=n.y0+(n.y1-n.y0)*r+i,s=ee(a-h/2,o-g/2,a+h/2,o+g/2);if(s<e&&(e=s,w=r,b=t,S=i),s===0)break}}}let T=n.x0+(n.x1-n.x0)*w+b,E=n.y0+(n.y1-n.y0)*w+S-g/2;I&&F.push(T-h/2,E,T+h/2,E+g),j(T-h/2,E,T+h/2,E+g),V+=`<g class="pele-edge-label" data-id="${r(c)}">`+(e.descr?`<title>${r(e.descr)}</title>`:``)+`<rect x="${s(T-h/2)}" y="${s(E)}" width="${s(h)}" height="${s(g)}" rx="3" fill="var(--_bg)"/>`+Re(i(d,T,E+d.height/2,l.text)+i(f,T,E+d.height+f.height/2,` class="pele-c4-techn" fill="var(--_m)"${l.text}`),e.link,c,C,p)+`</g>`});let H=``,U=``;for(let e of w){if(e!==E){let t=e.boundary,i=Le(t.bgColor,t.borderColor,t.fontColor),a=e.x+e.headX,o=e.y+Ee,c=h(e.labels[0],a,o,` class="pele-cluster-label" font-weight="var(--_hw)"${i.text}`);o+=e.labels[0].height,c+=h(e.labels[1],a,o,` class="pele-c4-type" font-size="${y}" fill="var(--_m)"${i.text}`),o+=e.labels[1].height,c+=h(e.labels[2],a,o,` class="pele-c4-descr" font-size="${y}" fill="var(--_m)"${i.text}`),H+=`<g class="pele-cluster pele-c4-${t.nodeType?`node`:`boundary`}" data-id="${r(t.alias)}"><rect x="${s(e.x)}" y="${s(e.y)}" width="${s(e.w)}" height="${s(e.h)}" fill="none" stroke="var(--_b)"${t.nodeType?``:` stroke-dasharray="6 4"`}${n(i.shape)}/>`+Re(c,t.link,t.alias,C,p)+`</g>`}for(let t of e.nodes){let e=t.shape,n=e.kind.startsWith(`external`),a=Le(e.bgColor,e.borderColor,e.fontColor),o=` stroke="var(--_b)"`+(n?` stroke-dasharray="4 3"`:``),{w:c,h:l,form:u,labels:d}=t,m=u===`h-cyl`?-oe(l)/2:0,h=u===`person`?ie/2:u===`cyl`?ae(c)/2:0,g=` fill="var(--_m)"${a.text}`,_=h-t.textH/2,v=i(d[0],m,_+d[0].height/2,` class="pele-c4-type" font-size="${y-1}"${g}`);_+=d[0].height,v+=i(d[1],m,_+d[1].height/2,` class="pele-label" font-weight="var(--_hw)"${a.text}`),_+=d[1].height,v+=i(d[2],m,_+d[2].height/2,` class="pele-c4-techn" font-size="${y}"${g}`),_+=d[2].height+4,v+=i(d[3],m,_+d[3].height/2,` class="pele-c4-descr" font-size="${y}"${a.text}`),U+=`<g class="pele-node pele-shape-${u} pele-c4-${e.kind}${n?` pele-c4-external`:``}" data-id="${r(e.alias)}" transform="translate(${s(t.x+c/2)},${s(t.y+l/2)})">`+Re(f(u,c,l,` fill="var(${n?`--_bg`:`--_s`})"${o}${a.shape}`,o+a.line)+v,e.link,e.alias,C,p)+`</g>`}}let W=o(a.title,!1,x,v,m?l(p):4e3,1),G=W.height>0?W.height+12:0,K=Math.max(k-D,W.width),q=Math.ceil(K+2*S),J=Math.ceil(A-O+G+2*S),Y=S-D+(K-(k-D))/2,ce=S+G-O;return[{svg:e(`c4`,q,J,v,p,a,i(W,q/2,S+W.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${s(Y)},${s(ce)})">`+(H?`<g class="pele-clusters">${H}</g>`:``)+(L?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${L}</g>`:``)+(U?`<g class="pele-nodes">${U}</g>`:``)+(V?`<g class="pele-edge-labels" font-size="${y}">${V}</g>`:``)+`</g>`),width:q,height:J,links:C},R.squeezed]}var Ve={type:`c4`,parse(e,t,n){let r=new D;return n&&(r.title=n),R(e,r),r},render:ze};export{Ve as c4};
@@ -1,2 +1,2 @@
1
- import{_ as e,f as t,i as n,o as r,u as i,x as a}from"./CX-xckzu.js";import{n as o,r as s}from"./DciMwFJ1.js";import{a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./BunrC_8P.js";import{PeleError as w,u as ee}from"./8wVGBFSs.js";function T(e,t){let n=new Map;for(let{label:t,value:r}of e.sections){if(r<0)throw new w(`"${t}" has invalid value: ${r}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,`semantic`,{type:`pie`});n.has(t)||n.set(t,r)}return{type:`pie`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
1
+ import{_ as e,f as t,i as n,o as r,u as i,x as a}from"./DfCZPwp1.js";import{n as o,r as s}from"./DciMwFJ1.js";import{a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./DX4bJJO0.js";import{PeleError as w,u as ee}from"./-2Meesge.js";function T(e,t){let n=new Map;for(let{label:t,value:r}of e.sections){if(r<0)throw new w(`"${t}" has invalid value: ${r}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,`semantic`,{type:`pie`});n.has(t)||n.set(t,r)}return{type:`pie`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
2
2
  `):void 0,showData:e.showData,sections:n}}function E(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function D(){let e=0,t=0,n=-1;return(r,i)=>{let a=r.charCodeAt(i)===45?i+1:i;if((a<e||a>=t)&&(e=a,t=E(r,a),n=-1,t>a&&r.charCodeAt(t)===46)){let e=E(r,t+1),i=e-t-1;i>0&&r.charCodeAt(e)!==46?n=e:i>1&&(n=e-1)}return t===a?-1:n>=0?n:r.charCodeAt(a)===48?r.charCodeAt(a+1)===46?-1:a+1:r.charCodeAt(t)===46?t-1>a?t-1:-1:t}}var O=[m(`showData`),m(`pie`),{name:`:`,pattern:`:`},{name:`NUMBER_PIE`,pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:D,first:`-0123456789`},c,S,y,g,h,C,b,v,x];function k(e){let t=new p(_(e,O,`pie`),O,`pie`),n={$type:`Pie`,showData:!1,sections:[]},r=()=>{if(t.kind!==-1)for(t.kind!==8&&t.fail(`a line break or the end of input`);t.kind===8;)t.i++};for(;t.kind===8;)t.i++;for(t.expect(1),n.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:n.accDescr=l(t.take()),r();break;case 5:n.accTitle=f(t.take()),r();break;case 6:n.title=u(t.take()),r();break;case 7:{let e=d(t.take());t.expect(2);let i=Number(t.expect(3));n.sections.push({$type:`PieSection`,label:e,value:i}),r();break}default:t.fail(`a section, a title, or a line break`)}return n}var A=120,j=12,M=26,N=32,P=28;function F(e,t){return e.pie?.[t]}function I(e,t){return`${a(Math.sin(e)*t)},${a(-Math.cos(e)*t)}`}function te(e,t,n,r){if(t-e>=Math.PI*2-1e-9){let e=(e,t)=>`M0,${a(-e)}A${a(e)},${a(e)} 0 1 ${t} 0,${a(e)}A${a(e)},${a(e)} 0 1 ${t} 0,${a(-e)}Z`;return e(n,1)+(r>0?e(r,0):``)}let i=+(t-e>Math.PI);return r<=0?`M0,0L${I(e,n)}A${a(n)},${a(n)} 0 ${i} 1 ${I(t,n)}Z`:`M${I(e,n)}A${a(n)},${a(n)} 0 ${i} 1 ${I(t,n)}L${I(t,r)}A${a(r)},${a(r)} 0 ${i} 0 ${I(e,r)}Z`}function L(e,t,n){return o(n,A*2,140,(r,i)=>R(e,t,n,r/2,i))}function R(o,c,l,u,d){let f=l.fontSize??16,p=Math.round(f*.875),m=l.measurer??ee(l.fontFamily,l.fontFamilyMono),h=l.padding??8,g=F(c,`textPosition`),_=typeof g==`number`&&g>=0&&g<=1?g:.75,v=F(c,`donutHole`),y=typeof v==`number`&&v>0&&v<=.9?v*u:0,b=String(F(c,`legendPosition`)??`right`),x=d&&(b===`left`||b===`right`)?`bottom`:b,S=[...o.sections],C=0;for(let[,e]of S)C+=e;let w=S.map(([e,t])=>i(o.showData?`${e} [${t}]`:e,!1,m,p,4e3)),T=0;for(let e of w)T=Math.max(T,e.width);T+=w.length>0?j+8:0;let E=w.length*M,D=i(o.title,!1,m,f,s(l),1),O=D.height>0?D.height+16:0,k=S.map(([,e])=>{let t=C>0?e/C:0;return t*100>=1&&(t*100).toFixed(0)!==`0`?t:0}),A=k.map(e=>e===0||e>=.5?!1:2*u*_*Math.sin(e*Math.PI)<m.width((e*100).toFixed(0)+`%`,p,0)+6),I=A.includes(!0)?P:0,L=x===`left`||x===`right`||x===`center`?x:``,R=x===`top`||x===`bottom`,z=(u+I)*2,B=z,V=z;L===`left`||L===`right`?(B+=T>0?N+T:0,V=Math.max(V,E)):R&&(B=Math.max(B,T),V+=E>0?20+E:0),B=Math.max(B,D.width);let H=h+(L===`left`?T+N+z/2:L===`right`?z/2:B/2),U=h+O,W=U+(x===`top`?E+20+z/2:R?z/2:V/2),G=``,K=``,q=``,J=0,Y=u+P/2,ne=[],re=(e,t,n)=>ne.every(r=>Math.abs(e-r.x)>=(n+r.width)/2+2||Math.abs(t-r.y)>=p+2);S.forEach(([e],r)=>{let i=k[r];if(i===0)return;let o=J+i*Math.PI*2;G+=`<path class="pele-slice" data-id="${n(e)}" d="${te(J,o,u,y)}" fill="${t(r)}"/>`;let s=(J+o)/2,c=(i*100).toFixed(0)+`%`;if(A[r]){let e=m.width(c,p,0),t=s;for(let n=0;n<360&&!re(Math.sin(t)*Y,-Math.cos(t)*Y,e);n++)t+=2/Y;let n=Math.sin(t)*Y,r=-Math.cos(t)*Y;ne.push({x:n,y:r,width:e}),q+=`<text x="${a(n)}" y="${a(r+p*.35)}">${c}</text>`}else{let e=u*_;K+=`<text x="${a(Math.sin(s)*e)}" y="${a(-Math.cos(s)*e+p*.35)}">${c}</text>`}J=o}),G===``&&(G=`<circle class="pele-slice" r="${u}" fill="none" stroke="var(--_b)"/>`);let X=``,Z,Q;L===`right`?(Z=H+z/2+N,Q=U+(V-E)/2):L===`left`?(Z=h,Q=U+(V-E)/2):L===`center`?(Z=H-T/2,Q=W-E/2):(Z=h+(B-T)/2,Q=x===`top`?U:U+z+20),w.forEach((e,i)=>{let o=Q+i*M+M/2;X+=`<g class="pele-legend-item" data-id="${n(S[i][0])}"><rect x="${a(Z)}" y="${a(o-j/2)}" width="${j}" height="${j}" rx="2" fill="${t(i)}"/>`+r(e,Z+j+8+e.width/2,o,``)+`</g>`});let $=Math.ceil(B+2*h),ie=Math.ceil(V+O+2*h),ae=r(D,$/2,h+D.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-slices" transform="translate(${a(H)},${a(W)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${G}</g>`+(K?`<g class="pele-slice-labels" transform="translate(${a(H)},${a(W)})" font-size="${p}" text-anchor="middle" fill="var(--_bg)">${K}</g>`:``)+(q?`<g class="pele-slice-labels" transform="translate(${a(H)},${a(W)})" font-size="${p}" text-anchor="middle">${q}</g>`:``)+(X?`<g class="pele-legend" font-size="${p}">${X}</g>`:``);return{svg:e(`pie`,$,ie,f,l,o,ae),width:$,height:ie,links:[]}}var z={type:`pie`,parse:(e,t,n)=>T(k(e),n),render:L};export{z as pie};
@@ -1,3 +1,3 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,i as a,m as o,o as s,p as c,r as l,s as u,t as d,u as f,v as p,x as m,y as h}from"./CX-xckzu.js";import{a as g,t as _}from"./DciMwFJ1.js";import{i as v,l as y}from"./DECNRCf2.js";import{t as b}from"./CoyQYage.js";import{a as x,r as S}from"./BN6xhG8e.js";import{t as C}from"./BZmnMkFw.js";import{n as w,r as ee}from"./B9YLdnR_.js";import{i as te,n as ne,r as T,t as re}from"./vk5Wkr31.js";import{d as ie,g as E,h as D,s as O,u as ae,y as k}from"./8wVGBFSs.js";function A(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}var oe=class{type=`er`;direction=`TB`;entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;claimed=new Set;addEntity(e,t=``){let n=this.entities.get(e);return n===void 0?(n={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:`default`,cssStyles:[]},this.entities.set(e,n)):!n.alias&&t&&(n.alias=t),n}addAttributes(e,t){let n=this.addEntity(e);for(let e=t.length-1;e>=0;e--){let r=t[e];r.keys??=[],r.comment??=``,n.attributes.push(r)}}addRelationship(e,t,n,r){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,a=this.subgraphLookup.has(n)?n:this.addEntity(n).id;this.relationships.push({entityA:i,roleA:t,entityB:a,relSpec:r})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssStyles.push(n);let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.cssStyles.push(e)}}addClass(e,t){for(let n of e){let e=this.classes.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e)),t)for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n)}}setClass(e,t){for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssClasses+=` `+n;let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.classes.push(e)}}addSubGraph(e,t,n){let r=e.text.trim(),i=new Set,a=[],o;for(let e of t.flat()){if(typeof e!=`string`){e?.stmt===`dir`&&(o=e.value);continue}let t=e.trim();t===``||i.has(t)||(i.add(t),this.claimed.has(e)||a.push(e))}for(let e of a)this.claimed.add(e);let s={id:r,nodes:a,title:(n.text||``).trim(),classes:[],cssStyles:[],dir:o,labelType:A(n.type)};return this.subgraphs.push(s),this.subgraphLookup.set(r,s),r}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{_ as e,a as t,b as n,c as r,d as i,i as a,m as o,o as s,p as c,r as l,s as u,t as d,u as f,v as p,x as m,y as h}from"./DfCZPwp1.js";import{a as g,t as _}from"./DciMwFJ1.js";import{i as v,l as y}from"./BLmF1B2i.js";import{t as b}from"./RFxekmX-.js";import{a as x,r as S}from"./Bt7VOT5H.js";import{t as C}from"./BZmnMkFw.js";import{n as w,r as ee}from"./tUSDgbpy.js";import{i as te,n as ne,r as T,t as re}from"./RlApGeew.js";import{d as ie,g as E,h as D,s as O,u as ae,y as k}from"./-2Meesge.js";function A(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}var oe=class{type=`er`;direction=`TB`;entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;claimed=new Set;addEntity(e,t=``){let n=this.entities.get(e);return n===void 0?(n={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:`default`,cssStyles:[]},this.entities.set(e,n)):!n.alias&&t&&(n.alias=t),n}addAttributes(e,t){let n=this.addEntity(e);for(let e=t.length-1;e>=0;e--){let r=t[e];r.keys??=[],r.comment??=``,n.attributes.push(r)}}addRelationship(e,t,n,r){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,a=this.subgraphLookup.has(n)?n:this.addEntity(n).id;this.relationships.push({entityA:i,roleA:t,entityB:a,relSpec:r})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssStyles.push(n);let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.cssStyles.push(e)}}addClass(e,t){for(let n of e){let e=this.classes.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e)),t)for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n)}}setClass(e,t){for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssClasses+=` `+n;let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.classes.push(e)}}addSubGraph(e,t,n){let r=e.text.trim(),i=new Set,a=[],o;for(let e of t.flat()){if(typeof e!=`string`){e?.stmt===`dir`&&(o=e.value);continue}let t=e.trim();t===``||i.has(t)||(i.add(t),this.claimed.has(e)||a.push(e))}for(let e of a)this.claimed.add(e);let s={id:r,nodes:a,title:(n.text||``).trim(),classes:[],cssStyles:[],dir:o,labelType:A(n.type)};return this.subgraphs.push(s),this.subgraphLookup.set(r,s),r}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}},j=`$end.INVALID.ER_DIAGRAM.EOF.NEWLINE.COLON.STYLE_SEPARATOR.BLOCK_START.BLOCK_STOP.SQS.SQE.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.END.SUBGRAPH.direction_tb.direction_bt.direction_rl.direction_lr.CLASSDEF.UNICODE_TEXT.STYLE_TEXT.COMMA.CLASS.STYLE.SEMI.NUM.BRKT.ENTITY_NAME.DECIMAL_NUM.ENTITY_ONE.ATTRIBUTE_WORD.ATTRIBUTE_KEY.COMMENT.ZERO_OR_ONE.ZERO_OR_MORE.ONE_OR_MORE.ONLY_ONE.MD_PARENT.NON_IDENTIFYING.IDENTIFYING.WORD.CHAR`.split(`.`),M=1,N=2,P=4,F=8,I=new Uint8Array(128);for(let e=0;e<128;e++){let t=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95,n=t&&(e<48||e>57);t&&(I[e]|=M|N|F),n&&(I[e]|=P)}for(let e of`-*`)I[e.charCodeAt(0)]|=M|N|F;I[46]|=M|F,I[42]|=P;for(let e of`[](),`)I[e.charCodeAt(0)]|=F;var L=/accTitle\s*:\s*/iy,R=/accDescr\s*:\s*/iy,z=/accDescr\s*\{\s*/iy,se=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],B=/direction/gi,V=/[\n\r\u2028\u2029]/g;function H(e,t){return e<128?(I[e]&t)!==0:e>=192||e===181}function U(e){let t=e.length,n=[],r=[],i=[],a=0,o=0,s=-2,c=0,l=-1,u=-2,d=-1,f=-1,p=-1,m=(t,a,s)=>{n.push(t),r.push(e.slice(a,s)),i.push(a),o=s},h=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),g=t=>{for(let n=0;n<t.length;n++){let r=t.charCodeAt(n),i=e.charCodeAt(o+n);if(i!==r&&(r<97||r>122||(i|32)!==r))return!1}return!0},_=t=>g(t)&&!E(e.charCodeAt(o+t.length)),v=t=>{let n=e.charCodeAt(t);return n>=65&&n<=90?n+32:n},y=n=>(V.lastIndex=n,V.test(e)?V.lastIndex-1:t),b=t=>{for(;k(e.charCodeAt(t));)t++;return t},x=()=>{if(s===-1||s<o&&(B.lastIndex=o,s=B.test(e)?B.lastIndex-9:-1,s===-1)||o<c||(l<o&&(l=y(o)),s>=l))return!1;for(let e=0;e<4;e++){let t=h(se[e],o);if(t>=0)return m(18+e,o,t),!0}return c=l,!1},S=()=>{let t=e.indexOf(`"`,o+1);if(t===-1){m(45,o,o+1);return}let n=t>o+1;for(let r=o+1;n&&r<t;r++){let t=e.charCodeAt(r);(t===37||t===92||t===13||t===10||t===11||t===8)&&(n=!1)}m(n?31:44,o,t+1)},C=t=>{let n=e.charCodeAt(o+1);if(n===43&&(t===49||t===48)){m(t===49?39:38,o,o+2);return}let r=b(o+1);if(e.charCodeAt(r)===46&&k(e.charCodeAt(r+1)))m(32,o,b(r+2));else{if(t===49){if(D(n)){let t=o+2;for(;D(e.charCodeAt(t));)t++;let n=e.charCodeAt(t);if(E(n)||n===34||n===39){m(40,o,o+1);return}}else if(n===45||n===46){let t=e.charCodeAt(o+2);if(t===45||t===46){m(40,o,o+1);return}}if(!E(n)){m(33,o,o+1);return}}m(29,o,r)}},w=t=>{let n=e.charCodeAt(o+1);switch(t){case 101:if(_(`erdiagram`))m(2,o,o+9);else if(_(`end`)){let t=o+3;for(;D(e.charCodeAt(t));)t++;m(16,o,t)}else return!1;return!0;case 115:if(_(`style`))a=6,m(27,o,o+5);else if(_(`subgraph`))m(17,o,o+8);else return!1;return!0;case 99:if(_(`classdef`))a=6,m(22,o,o+8);else if(_(`class`))m(26,o,o+5);else return!1;return!0;case 111:if(_(`one or zero`))m(37,o,o+11);else if(_(`one or more`)||_(`one or many`))m(39,o,o+11);else if(_(`one`))m(40,o,o+3);else if(_(`only one`))m(40,o,o+8);else if(n===124)m(37,o,o+2);else if(n===123)m(38,o,o+2);else if(_(`optionally to`))m(42,o,o+13);else return!1;return!0;case 122:if(_(`zero or one`))m(37,o,o+11);else if(_(`zero or more`)||_(`zero or many`))m(38,o,o+12);else return!1;return!0;case 109:if(g(`many(0)`))m(38,o,o+7);else if(g(`many(1)`))m(39,o,o+7);else if(_(`many`))m(38,o,o+4);else return!1;return!0;case 116:return _(`to`)?(m(43,o,o+2),!0):!1;case 117:return n!==46&&n!==45&&n!==124?!1:(m(41,o,o+1),!0);case 124:if(v(o+1)===111&&!E(e.charCodeAt(o+2)))m(37,o,o+2);else if(n===124)m(40,o,o+2);else if(n===123)m(39,o,o+2);else return!1;return!0;case 125:if(v(o+1)===111&&!E(e.charCodeAt(o+2)))m(38,o,o+2);else if(n===124)m(39,o,o+2);else return!1;return!0;case 46:return n!==46&&n!==45?!1:(m(42,o,o+2),!0);case 45:if(n===45)m(43,o,o+2);else if(n===46)m(42,o,o+2);else return!1;return!0}return!1},ee=t=>{let n;if((t===97||t===65)&&g(`acc`)){if((n=h(L,o))>=0){a=3,m(11,o,n);return}if((n=h(R,o))>=0){a=4,m(13,o,n);return}if((n=h(z,o))>=0){a=5,o=n;return}}if(!x()){switch(t){case 32:case 9:case 13:n=o+1;for(let t=e.charCodeAt(n);t===32||t===9||t===13;t=e.charCodeAt(n))n++;o=n;return;case 10:for(n=o+1;e.charCodeAt(n)===10;)n++;m(4,o,n);return;case 34:S();return;case 123:a=1,m(7,o,o+1);return;case 35:m(30,o,o+1);return;case 44:m(25,o,o+1);return;case 58:e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?m(6,o,o+3):m(5,o,o+1);return;case 91:m(9,o,o+1);return;case 93:m(10,o,o+1);return}if(k(t)){C(t);return}if(!w(t>=65&&t<=90?t+32:t)){if(t>=128||(I[t]&M)!==0){n=o+1;for(let t=e.charCodeAt(n);t>=128||(I[t]&M)!==0;t=e.charCodeAt(n))n++;m(23,o,n);return}m(45,o,o+1)}}},te=()=>{if(u===-1||u<o&&(u=e.indexOf(`~`,o),u===-1))return!1;if(p<o){let n=o;for(;n<t&&!D(e.charCodeAt(n));)n++;p=n}if(u>=p||(d<o&&(d=y(o),f=e.lastIndexOf(`~`,d-1)),f<=u))return!1;let n=f+1;for(;n<t&&!D(e.charCodeAt(n));)n++;return m(34,o,n),!0},ne=n=>{if(D(n)){for(o++;D(e.charCodeAt(o));)o++;return}let r=n|32;if((r===112||r===102||r===117)&&(e.charCodeAt(o+1)|32)==107&&!E(e.charCodeAt(o+2)))m(35,o,o+2);else if(!te()){if(H(n,P)){let n=o+1;for(;n<t&&H(e.charCodeAt(n),F);)n++;m(34,o,n);return}if(n===96){a=2,o++;return}if(n===34){let t=e.indexOf(`"`,o+1);if(t!==-1){m(36,o,t+1);return}}else if(n===125){a=0,m(8,o,o+1);return}m(45,o,o+1)}};for(;o<t;){let s=e.charCodeAt(o),c;switch(a){case 0:ee(s);break;case 1:ne(s);break;case 2:s===96?(a=1,o++):(c=e.indexOf("`",o),m(34,o,c===-1?t:c));break;case 3:case 4:c=e.indexOf(`
3
3
  `,o),m(a===3?12:14,o,c===-1?t:c),a=0;break;case 5:s===125?(a=0,o++):(c=e.indexOf(`}`,o),m(15,o,c===-1?t:c));break;case 6:if(s===10){for(c=o+1;e.charCodeAt(c)===10;)c++;a=0,m(4,o,c)}else if(D(s))for(o++;D(e.charCodeAt(o));)o++;else if(s===58)m(5,o,o+1);else if(s===44)m(25,o,o+1);else if(s===35)m(30,o,o+1);else if(s===59)m(28,o,o+1);else if(s>=128||(I[s]&N)!==0){c=o+1;for(let t=e.charCodeAt(c);t>=128||(I[t]&N)!==0;t=e.charCodeAt(c))c++;m(24,o,c)}else return n.push(1),r.push(``),i.push(o),{types:n,texts:r,starts:i}}}let T=a===0?3:a===3?12:a===4?14:a===5?15:-1;return T!==-1&&(n.push(T),r.push(``),i.push(t)),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var W=new Map([[37,`ZERO_OR_ONE`],[38,`ZERO_OR_MORE`],[39,`ONE_OR_MORE`],[40,`ONLY_ONE`],[41,`MD_PARENT`]]),ce=[`TB`,`BT`,`RL`,`LR`],G=`'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'`,le=`'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'`,K=`'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', `+G;function q(e,t){let{types:n,texts:r,starts:i}=U(e),a=0,o=t=>{let o=n[a];throw o===1?O(`er`,e,i[a],``,!0):O(`er`,e,i[a],`Expecting ${t}, got '${o===45?r[a]:j[o]}'`)},s=e=>(n[a]!==e&&o(`'${j[e]}'`),r[a++]),c=()=>{let e=n[a];e!==4&&e!==28&&e!==3&&o(`'EOF', 'NEWLINE', 'SEMI'`),a++},l=e=>e===23||e===31||e===29||e===32||e===33,u=()=>{let e=n[a];l(e)||o(G);let t=r[a++];return e===31?t.slice(1,-1):t},d=()=>{let e=[];for(;;){let t=n[a];if(t!==23&&t!==24&&o(`'UNICODE_TEXT', 'STYLE_TEXT'`),e.push(r[a++]),n[a]!==25)return e;a++}},f=e=>e===24||e===29||e===5||e===30,p=()=>{let e=[];for(;;){f(n[a])||o(`'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'`);let t=r[a++];for(;f(n[a]);)t+=r[a++];if(e.push(t),n[a]!==25)return e;a++}},m=()=>{let e=W.get(n[a++]),t=n[a];t!==43&&t!==42&&o(`'NON_IDENTIFYING', 'IDENTIFYING'`);let r=t===43?`IDENTIFYING`:`NON_IDENTIFYING`;a++;let i=W.get(n[a]);return i===void 0?o(le):(a++,{cardA:i,relType:r,cardB:e})},h=()=>{let e=n[a];e!==44&&e!==31&&e!==23&&o(`'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'`);let t=r[a++];return e===23?t:t.slice(1,-1)},g=e=>n[a]===45&&r[a]===e,_=()=>{let e=[];do{let t=s(34);g(`?`)&&(t+=r[a++]),n[a]!==34&&o(t.endsWith(`?`)?`'ATTRIBUTE_WORD'`:`'ATTRIBUTE_WORD', '?'`);let i={type:t,name:r[a++]};if(n[a]===35){let e=[r[a++]];for(;g(`,`);)a++,e.push(s(35));i.keys=e}n[a]===36&&(i.comment=r[a++].slice(1,-1)),e.push(i)}while(n[a]!==8);return e.reverse()},v=()=>{if(n[a]!==7)return;if(a++,n[a]===8){a++;return}let e=_();return a++,e},y=()=>{let e=u(),r=n[a];if(r===9){a++;let r=u();s(10);let i;n[a]===6&&(a++,i=d());let o=v();return t.addEntity(e,r),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]}let i;if(r===6&&(a++,i=d(),r=n[a]),W.has(r)){let r=m(),o=u(),c;n[a]===6&&(a++,c=d()),s(5);let l=h();return t.addEntity(e),t.addEntity(o),t.addRelationship(e,l,o,r),i&&t.setClass([e],i),c&&t.setClass([o],c),[e,o]}let o=v();return t.addEntity(e),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]};s(2);let b=[{id:``,title:``,list:[]}],x=b[0],S=!1;for(;;){let e=n[a];switch(e){case 4:a++;break;case 3:a++,S&&o(`'END', ${K}`);return;case 16:{S||o(K),a++;let e=t.addSubGraph({text:x.id},x.list,{text:x.title});b.pop(),x=b[b.length-1],S=b.length>1,S&&x.list.push(e);break}case 17:{a++;let e=u(),t=e;if(n[a]===9){for(a++,t=u();l(n[a]);)t+=` `+u();s(10)}c(),x={id:e,title:t,list:[]},b.push(x),S=!0;break}case 11:{a++;let e=s(12).trim();t.setAccTitle(e),S&&x.list.push(e);break}case 13:{a++;let e=s(14).trim();t.setAccDescription(e),S&&x.list.push(e);break}case 15:{let e=r[a++].trim();t.setAccDescription(e),S&&x.list.push(e);break}case 18:case 19:case 20:case 21:{a++;let n=ce[e-18];S?x.list.push({stmt:`dir`,value:n}):t.setDirection(n);break}case 22:{let e=r[a++],n=d(),i=p();c(),t.addClass(n,i),S&&x.list.push(e);break}case 26:{let e=r[a++],n=d();t.setClass(n,d()),S&&x.list.push(e);break}case 27:{let e=r[a++],n=d(),i=p();c(),t.addCssStyles(n,i),S&&x.list.push(e);break}default:{l(e)||o(S?`'END', ${K}`:K);let t=y();if(S)for(let e of t)x.list.push(e)}}}}var ue=[];function de(e){let t=[],n=[],r=e.subgraphs,i=t=>{let n=[];for(let r of t){let t=e.classes.get(r);if(t!==void 0){for(let e of t.styles)n.push(e.trim());for(let e of t.textStyles)n.push(e.trim())}}return n},a=new Map,o=new Set;for(let e=r.length-1;e>=0;e--){let t=r[e];o.add(t.id);for(let e of t.nodes)a.set(e,t.id)}for(let e=r.length-1;e>=0;e--){let n=r[e];t.push({id:n.id,label:n.title,alias:``,attributes:ue,isGroup:!0,parentId:a.get(n.id),cssStyles:n.cssStyles,cssCompiledStyles:i(n.classes),cssClasses:n.classes.join(` `),dir:n.dir,labelType:n.labelType})}let s=new Map;for(let[n,r]of e.entities)o.has(n)?s.set(r.id,n):t.push({id:r.id,label:r.label,alias:r.alias,attributes:r.attributes,isGroup:!1,parentId:a.get(n),cssStyles:r.cssStyles,cssCompiledStyles:i(r.cssClasses.split(` `)),cssClasses:r.cssClasses,dir:void 0,labelType:`markdown`});return e.relationships.forEach((e,t)=>{n.push({id:`id_${e.entityA}_${e.entityB}_${t}`,start:s.get(e.entityA)??e.entityA,end:s.get(e.entityB)??e.entityB,label:e.roleA,arrowTypeStart:e.relSpec.cardB.toLowerCase(),arrowTypeEnd:e.relSpec.cardA.toLowerCase(),pattern:e.relSpec.relType===`IDENTIFYING`?`solid`:`dashed`})}),{nodes:t,edges:n}}var J=18,fe=5,pe=6,me=10,he=3.5;function Y(e,t,n,r,i){let a=(e,a)=>m(t-r*e-i*a)+`,`+m(n-i*e+r*a),o=e=>`M${a(e,-fe)}L${a(e,fe)}`,s=`M${a(0,-pe)}L${a(me,0)}L${a(0,pe)}`,c=e=>`<circle class="pele-marker" cx="${m(t-r*e)}" cy="${m(n-i*e)}" r="${he}" fill="var(--_bg)"/>`,l=e=>`<path class="pele-marker" d="${e}"/>`;switch(e){case`only_one`:return l(o(6)+o(10));case`zero_or_one`:return l(o(6))+c(13.5);case`one_or_more`:return l(s+o(me+3.5));case`zero_or_more`:return l(s)+c(me+he+.5);case`md_parent`:return`<path class="pele-marker" d="M${a(0,0)}L${a(6,4)}L${a(12,0)}L${a(6,-4)}Z" fill="var(--_bg)"/>`}return``}var ge=48,_e=20,ve=64,X=20,Z=28,ye=38,be=96,xe=18,Se=12,Ce=9,we=12,Te=16,Ee=9,De=260,Oe=1e6,ke=[],Ae=18,je=14,Me=` fill="var(--_s)" stroke="var(--_b)"`;function Ne(e,t,n){let r=e.er?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function Q(e,n,i,l,u){let f=e.lines;if(f.length===0)return``;let g=f.length===1&&f[0].length===1?f[0][0]:void 0;if(g&&g.icon===void 0&&g.math===void 0&&g.style===0)return`<text${l} x="${m(n)}" y="${m(i)}">${t(g.text)}</text>`;let _=r(e),v=e.size*.35,y=i-v-e.lineHeight/2,b=``,x=``;for(let r=0;r<f.length;r++){let d=f[r],g=y+c(e,r);if(p(d)){x+=s(h(e,r),n+e.widths[r]/2,g,l,u);continue}i=g+v;let S=!1;for(let e of d)e.icon!==void 0&&(S=!0);let C=n,w=!1;for(let n of d){if(n.icon!==void 0){let t=e.size*1.1;x+=`<svg class="pele-icon" data-icon="${a(n.icon)}" x="${m(C)}" y="${m(i-e.size*.35-t/2)}" width="${m(t)}" height="${m(t)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${u?.(n.icon)??``}</svg>`}else if(n.text!==``){let e=S||!w?` x="${m(C)}" y="${m(i)}"`:``;b+=`<tspan${e}${o(n.style&~_)}>${t(n.text)}</tspan>`,w=!0}C+=n.width}}return`<text${d(l,_)} xml:space="preserve">${b}</text>${x}`}function $(e){let t=C(e);return t===e?e:t.replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Pe(e,t,n){return g(e.direction)?_(n,r=>Fe(e,t,n,r)):Fe(e,t,n,!1)}function Fe(r,o,c,d){let p=de(r),h=c.fontSize??16,g=Math.round(h*.875),_=c.measurer??ae(c.fontFamily,c.fontFamilyMono),C=c.padding??8,E=c.icons,D=new Map,O=[],k=[];p.nodes.forEach((e,t)=>D.set(e.id,t));let A=[],oe=[],j=[],M=new Map,N=[];for(let e of p.edges){let t=D.get(e.start),n=D.get(e.end);if(t===void 0||n===void 0)continue;let r=f(e.label,!0,_,g,200),i;if(t===n){i={label:r,band:0,at:0};let e=M.get(t);e?e.push(i):M.set(t,[i])}N.push(i),j.push(e),oe.push(r),A.push({src:t,dst:n,minlen:1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let P=e=>{let t=e;for(let e=0;e<p.nodes.length;e++){let e=p.nodes[t].parentId,n=e===void 0?void 0:D.get(e);if(n===void 0)break;let r=p.nodes[n].dir;if(r)return r===`LR`||r===`RL`;t=n}return r.direction===`LR`||r.direction===`RL`};for(let e=0;e<p.nodes.length;e++){let t=p.nodes[e],n=u(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),r=+!!n.bold|(n.italic?2:0),i=n.fontSize??h,a=n.fontSize??g,o=n.fontSize??Math.round(h*.75),s=t.isGroup?f(t.label,!0,_,i,4e3,r):f(t.alias||t.label,!0,_,i,240,r),c=M.get(e)??ke,l=c.length>0&&!t.isGroup&&P(e),d={node:t,style:n,label:s,w:0,h:0,headH:0,rows:[],cols:[],rowSize:a,keySize:o,below:l},m=0,v=0;for(let e of c)e.band=Math.max(ye,l?e.label.width+12:e.label.height+6),v+=e.band,m=Math.max(m,l?e.label.height:e.label.width);let y=Math.max(be,l?v+8:0),b;if(t.isGroup)b=re(0,0),b.isGroup=!0,b.dir=t.dir?T(t.dir):void 0,b.padX=X,b.padTop=d.label.height>0?d.label.height+16:X,b.padBottom=X,b.minW=Math.max(d.label.width+2*X-12,be);else{let e=Math.max(s.height,Math.round(i*1.5));if(t.attributes.length===0)d.w=Math.max(s.width+2*xe,y),d.h=Math.max(e+2*Se,l?0:v+8);else{let n=Math.round(a*1.5),i=[0,0,0,0];for(let e of t.attributes){let t=[f($(e.type),!0,_,a,Oe,r),f($(e.name),!0,_,a,Oe,r),f(e.keys.join(`, `),!1,_,o,Oe,r),f($(e.comment),!0,_,a,De,r)],s=n;for(let e=0;e<4;e++)t[e].width>i[e]&&(i[e]=t[e].width),t[e].height>s&&(s=t[e].height);d.rows.push({cells:t,h:s+Ee}),d.h+=s+Ee}let c=0,l=0;for(let e of i)e!==0&&(l+=e+(c>0?Te:0),c++);d.w=Math.max(l+2*we,s.width+2*xe,y);let u=c>0?(d.w-l-2*we)/c:0,p=we;for(let e of i)d.cols.push(p),e>0&&(p+=e+u+Te);d.headH=e+2*Ce,d.h+=d.headH}let n=c.length>0?2*(J+Z*.75+10+m):0;b=l?re(d.w,d.h+n):re(d.w+n,d.h)}b.seq=O.length,O.push(d),k.push(b)}p.nodes.forEach((e,t)=>{k[t].parent=e.parentId===void 0?-1:D.get(e.parentId)??-1});let F=te(k,A,d?`TB`:T(r.direction),{nodeSep:Ne(o,`nodeSpacing`,ge),edgeSep:_e,rankSep:Ne(o,`rankSpacing`,ve),portSep:24});Le(A,k,O);let I=F.width;for(let[e,t]of M){let n=k[e];if(!n.isGroup)continue;let r=0;for(let e of t)r=Math.max(r,e.label.width);I=Math.max(I,n.x+n.w/2+J+Z*.75+10+r)}let L=b(r.title,_,h,4e3),R=L.height>0?L.height+12:0,z=Math.max(I,L.width),se=C+(z-I)/2,B=C+R;ne(k,A,se,B);let V=Math.ceil(z+2*C),H=Math.ceil(F.height+R+2*C),U=[],W=new Map,ce=!1;for(let e of k)e.isGroup&&(ce=!0);if(ce)for(let e of A)ee(W,e.route);let G=``,le=``;for(let e=0;e<O.length;e++){let r=O[e],o=k[e],u=r.node,d=n(u.cssClasses.replace(/^default\s?/,``));if(o.isGroup){r.w=o.w,r.h=o.h;let e=o.x-o.w/2,t=o.y-o.h/2,n=w(o,r.label.width,W,X);G+=`<g class="pele-cluster${d}" data-id="${a(u.id)}"><rect x="${m(e)}" y="${m(t)}" width="${m(o.w)}" height="${m(o.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${i(r.style.shape)}/>`+s(r.label,n,t+8+r.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${r.style.text}`,E)+`</g>`;continue}let f=r.w,p=r.h,h=-f/2,g=-p/2,_=r.style.text,v=`x="${m(h)}" y="${m(g)}" width="${m(f)}" height="${m(p)}"`,y=s(r.label,0,r.rows.length>0?g+r.headH/2:0,` class="pele-label"${_}`,E),b=ie(u.alias||u.label);if(/ internal-link(?: |$)/.test(d+` `)&&y!==``&&c.links!==!1){let e=x(b,c),n=t(b);y=`<a class="internal-link"${e?` href="${n}"${S(c)}`:``} data-href="${n}">${y}</a>`,U.push({id:u.label,href:b,internal:!0})}let C;if(r.rows.length===0)C=`<rect ${v}${i(Me+r.style.shape)}/>`+y;else{let e=Math.round(r.rowSize*1.5),n=r.style.stroke?t(r.style.stroke):`var(--_b)`,a=``,o=``,s=g+r.headH;for(let t=0;t<r.rows.length;t++){let n=r.rows[t];if(t%2==0){let e=`x="${m(h)}" width="${m(f)}"`;t===r.rows.length-1?a+=`<rect ${e} y="${m(s)}" height="${m(n.h)}"${l}/><rect ${e} y="${m(s)}" height="${m(n.h/2)}"/>`:a+=`<rect ${e} y="${m(s)}" height="${m(n.h)}"/>`}let i=s+Ee/2+e/2+r.rowSize*.35,[c,u,d,p]=n.cells;o+=Q(c,h+r.cols[0],i,` class="pele-er-type" fill="var(--_m)"${_}`,E)+Q(u,h+r.cols[1],i,` class="pele-er-name"${_}`,E)+Q(d,h+r.cols[2],i,` class="pele-er-keys" font-size="${r.keySize}" fill="var(--_m)"${_}`,E)+Q(p,h+r.cols[3],i,` class="pele-er-comment" fill="var(--_m)"${_}`,E),s+=n.h}let c=m(g+r.headH);C=`<rect ${v}${i(Me+r.style.shape)}/><g class="pele-er-stripes" fill="var(--_bg)"${r.style.shape.includes(`fill:`)?` opacity="0.6"`:``}>${a}</g><path class="pele-er-divider" d="M${m(h)},${c}H${m(h+f)}" stroke="${n}"/><rect ${v} fill="none" stroke="var(--_b)"${i(r.style.line)}/>`+y+`<g class="pele-er-attributes" font-size="${r.rowSize}">${o}</g>`}le+=`<g class="pele-node pele-entity${d}" data-id="${a(u.label)}" transform="translate(${m(o.x)},${m(o.y)})">${C}</g>`}for(let[e,t]of M){let n=O[e],r=0;for(let e of t)r+=e.band;let i=Math.min(1,Math.max((n.below?n.w:n.h)-8,0)/r),a=-r*i/2;for(let e of t)e.band*=i,e.at=a+e.band/2,a+=e.band}let K=``,q=``;for(let e=0;e<A.length;e++){let t=A[e],n=j[e],r=oe[e],i,o,s,c=N[e];if(c){let e=k[t.src],a=O[t.src],l=Math.max(Math.min(c.band/2-6,13),1),u=J+Z*.75+6;if(a.below){let d=e.x+c.at,f=e.y+a.h/2,p=m(f+J),h=m(f+J+Z);i=`M${m(d-l)},${m(f)}V${p}C${m(d-l)},${h} ${m(d+l)},${h} ${m(d+l)},${p}V${m(f)}`,o=Y(n.arrowTypeStart,d-l,f,0,-1),s=Y(n.arrowTypeEnd,d+l,f,0,-1),t.labelX=d,t.labelY=f+u+r.height/2}else{let d=e.x+a.w/2,f=e.y+c.at,p=m(d+J),h=m(d+J+Z);i=`M${m(d)},${m(f-l)}H${p}C${h},${m(f-l)} ${h},${m(f+l)} ${p},${m(f+l)}H${m(d)}`,o=Y(n.arrowTypeStart,d,f-l,-1,0),s=Y(n.arrowTypeEnd,d,f+l,-1,0),t.labelX=d+u+r.width/2,t.labelY=f}}else{let e=Ie(t.route);if(e.length<6)continue;Re(e,0,O[t.src],k[t.src]),Re(e,e.length-3,O[t.dst],k[t.dst]);let r=Math.abs(e[e.length-3]-e[0]),a=Math.abs(e[e.length-2]-e[1]),c=e.length===6&&(r<.01||a<.01||Math.hypot(r,a)<=3*J)?0:J,l=y(e,void 0,c,c);i=c>0?`M${m(l.sx)},${m(l.sy)}L${l.d.slice(1)}L${m(l.ex)},${m(l.ey)}`:l.d,o=Y(n.arrowTypeStart,l.sx,l.sy,l.sdx,l.sdy),s=Y(n.arrowTypeEnd,l.ex,l.ey,l.edx,l.edy)}let l=n.pattern===`dashed`;if(K+=`<g class="pele-edge pele-er-${l?`non-identifying`:`identifying`}" data-id="${a(n.id)}"><path d="${i}"${l?` stroke-dasharray="4 3"`:``}/>`+o+s+`</g>`,r.width>0){let e=t.labelX,i=t.labelY;q+=v(n.id,r,e,i,``,E)}}return{svg:e(`er`,V,H,h,c,r,s(L,V/2,C+L.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(G?`<g class="pele-clusters">${G}</g>`:``)+(K?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${K}</g>`:``)+(q?`<g class="pele-edge-labels" font-size="${g}">${q}</g>`:``)+`<g class="pele-nodes">${le}</g>`),width:V,height:H,links:U}}function Ie(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,i=i=>Math.abs(t[r+i]-e[n+i])<.01&&Math.abs(e[n+i]-e[n+3+i])<.01;n+3<e.length&&(i(0)||i(1))||t.push(e[n],e[n+1],e[n+2])}return t}function Le(e,t,n){let r=new Map,i=(e,n,i,a)=>{let o=t[e],s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){if(i.length<2)continue;let r=e>>2,a=(e&1)==1,o=t[r].isGroup?t[r]:n[r],s=a?o.h:o.w,c=Math.max(Math.min(Ae,(s-2*je)/(i.length-1)),0),l=a?t[r].y:t[r].x;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++)i[e].route[i[e].at+ +!!a]=l+(e-(i.length-1)/2)*c}}function Re(e,t,n,r){if(r.isGroup)return;let i=e[t]-r.x,a=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(i)-r.w/2)<.5&&(e[t]-=Math.sign(i)*(r.w-n.w)/2),r.h!==n.h&&Math.abs(Math.abs(a)-r.h/2)<.5&&(e[t+1]-=Math.sign(a)*(r.h-n.h)/2)}var ze={type:`er`,math:!0,parse(e,t,n){let r=new oe;return n&&(r.title=n),q(e,r),r},render:Pe};export{ze as er};
@@ -0,0 +1,7 @@
1
+ import{$ as e,A as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,M as l,O as u,Q as d,S as f,V as p,W as m,X as h,Y as g,Z as _,a as v,at as y,c as b,ct as x,d as S,et as C,f as w,ft as T,g as E,h as ee,i as D,j as O,k,n as te,p as A,pt as j,rt as M,st as ne,tt as N,v as re,z as P}from"./Iqr2CudW.js";import{o as F,t as I}from"./DGmSCGD3.js";import"./xihTtKlq.js";import{D as ie,S as ae,a as oe,d as se,f as ce,h as le,j as ue,l as de,m as fe,n as pe,r as me,s as he,t as L,u as ge,x as _e,y as ve}from"./DktGnzDy.js";import{S as ye,_ as be,a as xe,b as Se,c as Ce,d as we,g as Te,h as Ee,i as De,m as Oe,n as ke,o as Ae,r as je,s as Me,t as Ne,u as Pe,v as Fe,x as Ie,y as Le}from"./CODXTnUW.js";import{i as Re}from"./F7HCRtmu.js";import{B as ze,D as R,E as Be,F as z,G as Ve,H as He,I as Ue,J as B,K as We,L as V,M as H,N as U,P as Ge,R as Ke,S as qe,W as Je,X as Ye,Y as Xe,at as Ze,ct as Qe,et as $e,it as et,lt as tt,mt as nt,n as rt,nt as it,rt as at,t as ot,ut as st,v as ct,w as lt,x as ut,y as dt}from"./BxTFtVqu.js";import{i as ft,l as pt,n as mt,o as ht,r as gt}from"./yxd8jSz3.js";var _t=2e7,vt=[`kit.js`,`chart.js`,`model.js`,`math.js`,`math.css`,`isorite.css`,`plain.css`,`kit.css`],yt=e=>e.replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&amp;/g,`&`);function bt(e,t){for(let n of e.matchAll(/<meta\b[^>]*>/gi)){let e=n[0];if((e.match(/\bname\s*=\s*["']([^"']*)["']/i)?.[1])?.toLowerCase()===t)return yt(e.match(/\bcontent\s*=\s*"([^"]*)"|\bcontent\s*=\s*'([^']*)'/i)?.slice(1).find(e=>e!==void 0)??``)}return null}function xt(e){return{title:yt(e.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1]?.trim()??``),description:bt(e,`description`)??``,author:bt(e,`author`)??``,date:bt(e,`date`)??``,kit:bt(e,`isorite:kit`),uses:(bt(e,`isorite:uses`)??``).split(/[\s,]+/).filter(Boolean)}}function St(e){let t=[];/<iso-chart[\s>]|\bPlot\.\w/.test(e)&&t.push(`chart`),/<iso-model[\s>]|<iso-chart3d[\s>]|\bTHREE\.\w/.test(e)&&t.push(`model`);let n=e.replace(/<script\b[\s\S]*?<\/script>/gi,``).replace(/<style\b[\s\S]*?<\/style>/gi,``);return(/<iso-math[\s>]|\biso\.math\(|\$\$[\s\S]+?\$\$|\\\(|\$(?=\S)[^$\n]+?(?<=\S)\$(?!\d)/.test(n)||/\biso\.math\(/.test(e))&&t.push(`math`),t}var Ct=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:; connect-src 'none'">`,wt=e=>e.replace(/<\/(script|style)/gi,`<\\/$1`),Tt=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);function Et(e,t,n={}){let r=n.look??`isorite`,i=n.ground??`lapis`,a=e.replace(/<link\b[^>]*\bhref\s*=\s*["'](?:\.\/)?kit\/[^"']*["'][^>]*>\s*/gi,``).replace(/<script\b[^>]*\bsrc\s*=\s*["'](?:\.\/)?kit\/[^"']*["'][^>]*>\s*<\/script>\s*/gi,``),o=Object.entries(n.data??{}).map(([e,t])=>typeof t==`string`?`<script type="text/plain" data-path="${Tt(e)}">${wt(t)}<\/script>`:`<script type="application/octet-stream" data-encoding="base64" data-path="${Tt(e)}">${Dt(t)}<\/script>`),s=St(a).map(e=>`${e===`math`?`<style>\n${wt(t[`math.css`])}\n</style>\n`:``}<script>\n${wt(t[`${e}.js`])}\n<\/script>`),c=[Ct,`<style data-look="isorite">\n${wt(t[`isorite.css`])}\n</style>`,`<style data-look="plain">\n${wt(t[`plain.css`])}\n</style>`,`<style>\n${wt(t[`kit.css`])}\n</style>`,...o,`<script>\n${wt(t[`kit.js`])}\n<\/script>`,...s].join(`
2
+ `);return(/<head\b[^>]*>/i.test(a)?a.replace(/<head\b[^>]*>/i,e=>`${e}\n${c}\n`):`<!doctype html><html><head><meta charset="utf-8">\n${c}\n</head><body>${a}</body></html>`).replace(/<html\b([^>]*)>/i,(e,t)=>`<html${t.replace(/\s+data-(?:look|ground)\s*=\s*("[^"]*"|'[^']*'|\S+)/gi,``)} data-look="${r}" data-ground="${i}">`)}function Dt(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}var Ot=class{note;#e=N([]);get entries(){return P(this.#e)}set entries(e){C(this.#e,e)}#t=N(null);get prompt(){return P(this.#t)}set prompt(e){C(this.#t,e)}#n=N(null);get asking(){return P(this.#n)}set asking(e){C(this.#n,e)}#r=N(null);get failed(){return P(this.#r)}set failed(e){C(this.#r,e)}get tier(){return Ee.tier}#i=N(null);get cursor(){return P(this.#i)}set cursor(e){C(this.#i,e)}#a=N(``);get busy(){return P(this.#a)}set busy(e){C(this.#a,e,!0)}#o=N(null);get editing(){return P(this.#o)}set editing(e){C(this.#o,e,!0)}stop=null;constructor(e){this.note=e}#s=M(()=>le(this.entries));get waiting(){return P(this.#s)}set waiting(e){C(this.#s,e)}#c=M(()=>this.waiting.filter(e=>e.form===`insert`));get proposals(){return P(this.#c)}set proposals(e){C(this.#c,e)}#l=M(()=>{let e=[],t=ve(this.note.text);for(let n of this.waiting)if(n.form===`rewrite`)for(let r of n.open??[]){let i=n.regions[r],a=de(this.note.text,i.old),o=a?this.note.text.slice(0,a.from).split(`
3
+ `).length-1:-1,s=t.find(e=>e.from<=o&&o<e.to);e.push({key:`r:${n.id}:${r}`,proposal:n,k:r,at:a,block:/\n/.test(i.old.text.trim())||/\n/.test(i.new.trim()),code:!!(s&&/^\s*(```|~~~)/.test(s.text))})}return e.sort((e,t)=>(e.at?.from??1/0)-(t.at?.from??1/0))});get changes(){return P(this.#l)}set changes(e){C(this.#l,e)}#u=M(()=>{try{let e=ae(this.note.text)[0];return{lines:e.split(`
4
+ `).length-1,chars:e.length}}catch{return{lines:0,chars:0}}});get head(){return P(this.#u)}set head(e){C(this.#u,e)}get foot(){return this.note.text.split(`
5
+ `).length}spans(e){return e.flatMap(e=>{let t=de(this.note.text,e);return t?[t]:[]})}placed(e){return ce(this.note.text,e)!==null}#d=M(()=>{let e=[];for(let t of this.proposals){let n=ce(this.note.text,t);e.push({key:`p:${t.id}`,line:n?.form===`insert`?n.line:this.foot})}this.changes.some(e=>!e.at)&&e.push({key:`lost`,line:this.foot}),this.asking&&e.push({key:`asking`,line:this.asking.line}),this.failed&&e.push({key:`failed`,line:this.failed.line}),this.prompt&&e.push({key:`prompt`,line:this.prompt.line});let t=this.changes.filter(e=>e.at);for(let n of t)n.block&&e.push({key:n.key,line:this.note.text.slice(0,n.at.to).split(`
6
+ `).length});return{blocks:e,picked:this.spans(this.prompt?.regions??this.asking?.regions??[]),old:t.map(e=>e.at),inline:t.filter(e=>!e.block).map(e=>({key:e.key,at:e.at.to}))}});get layout(){return P(this.#d)}set layout(e){C(this.#d,e)}async open(){this.stop=L.on(e=>this.hear(e));let e=L.iso;e?.start&&e.note===this.note.id&&(e.state===`reading`||e.state===`writing`)&&(this.hear(e.start),this.asking&&={...this.asking,text:e.text??``,steps:e.steps});try{this.entries=await L.api.journal(this.note.id)}catch{}}close(){this.stop?.()}hear(e){if(e.type===`journal`){if(e.id!==this.note.id||this.entries.some(t=>t.id===e.entry.id))return;this.entries=[...this.entries,e.entry];let t=e.entry.kind===`discard`||e.entry.kind===`change`?e.entry.proposal:void 0;t&&this.editing?.id===t&&(this.editing=null);return}if(e.type===`note-changed`||e.type===`record`||e.type===`agent-sent`||!(`note`in e)||e.note!==this.note.id)return;if(e.type===`iso-start`){if(this.asking&&!this.asking.request){this.asking={...this.asking,request:e.request};return}let t=this.foot;if(e.place.form===`insert`||e.place.form===`rewrite`){let n=ce(this.note.text,{form:`insert`,after:e.place.after,before:e.place.before});n?.form===`insert`&&(t=n.line)}this.asking={request:e.request,asked:e.asked,line:t,regions:e.place.form===`rewrite`?e.place.regions:[],text:``,steps:[]},this.failed=null,this.prompt=null;return}let t=this.asking;t&&t.request===e.request&&(e.type===`iso-text`?this.asking={...t,text:e.again?e.delta:t.text+e.delta}:e.type===`iso-step`?this.asking={...t,text:``,steps:[...t.steps,e.step]}:(e.type===`iso-failed`&&(this.failed={line:t.line,message:e.message}),this.asking=null))}promptAt(e,t){let n=ve(this.note.text).find(t=>t.from<=e&&e<t.to);this.failed=null,this.prompt={line:n?n.to:e,mode:`insert`,regions:[]},t&&t.to>t.from&&(this.setMode(`rewrite`),this.pick([t]))}promptHere(){let e=this.cursor;e?this.promptAt(e.line,e):this.promptAt(this.foot)}askAt(e,t){if(t&&t.to>t.from){this.promptAt(e,t);return}let n=ve(this.note.text).find(t=>t.from<=e&&e<t.to),r=n?.text.trim()??``;!n||!r||/^(```|~~~|\$\$|\|)/.test(r)?this.promptAt(e):(this.failed=null,this.prompt={line:n.to,mode:`insert`,regions:[]},this.ask(r))}askHere(){let e=this.cursor;e?this.askAt(e.line,e):this.promptAt(this.foot)}setMode(e){this.prompt&&={...this.prompt,mode:e}}get picking(){return this.prompt?.mode===`rewrite`}pick(e){let t=this.prompt;if(!t)return;let n=this.note.text,r=this.spans(t.regions);for(let t of e){let{from:e,to:i}=t;for(;e<i&&/\s/.test(n[e]);)e++;for(;i>e&&/\s/.test(n[i-1]);)i--;if(i<=e||e<this.head.chars)continue;let a=r.filter(t=>t.from<=i&&e<=t.to);r=[...r.filter(e=>!a.includes(e)),{from:Math.min(e,...a.map(e=>e.from)),to:Math.max(i,...a.map(e=>e.to))}]}r.sort((e,t)=>e.from-t.from),this.prompt={...t,regions:r.map(e=>fe(n,e.from,e.to))}}unpick(e){let t=this.prompt;if(!t)return;let n=t.regions.filter(t=>{let n=de(this.note.text,t);return!n||e<n.from||e>=n.to});n.length!==t.regions.length&&(this.prompt={...t,regions:n})}clearPicked(){this.prompt&&={...this.prompt,regions:[]}}setTier(e){Ee.setTier(e)}async ask(e){let t=this.prompt;if(!t||!e.trim()||this.asking||t.mode===`rewrite`&&!t.regions.length)return;let n=t.mode===`rewrite`?t.regions:[];this.prompt=null,this.failed=null,this.asking={request:``,asked:e,line:t.line,regions:n,text:``,steps:[]};try{await this.note.save();let r=se(this.note.text,t.line),i=Ee.of(this.note.id),a=Object.keys(i).length?{choice:i}:{},{request:o}=await L.api.ask(n.length?{note:this.note.id,form:`rewrite`,regions:n,after:r.after,before:r.before,asked:e,tier:this.tier,...a}:{note:this.note.id,...r,asked:e,tier:this.tier,...a});this.asking&&!this.asking.request&&(this.asking={...this.asking,request:o})}catch(e){this.asking=null,this.failed={line:t.line,message:e.message}}}async send(){if(this.asking)return``;this.failed=null,this.asking={request:``,asked:``,line:this.foot,regions:[],text:``,steps:[]};try{await this.note.save();let{request:e}=await L.api.ask({note:this.note.id,form:`note`,tier:this.tier});return this.asking&&!this.asking.request&&(this.asking={...this.asking,request:e}),e}catch(e){return this.asking=null,this.failed={line:this.foot,message:e.message},``}}halt(){let e=this.asking;if(!e)return;if(e.request){L.api.stop(e.request);return}let t=L.on(e=>{e.type===`iso-start`&&e.note===this.note.id&&(t(),L.api.stop(e.request))})}say(e,t){this.failed={line:e??this.foot,message:t.message}}lineOf(e){return this.layout.blocks.find(t=>t.key===`p:${e.id}`)?.line}edit(e){this.editing={id:e.id,text:e.text}}async done(e){let t=this.editing;if(t?.id===e.id)try{await L.api.revise(this.note.id,e.id,t.text),this.editing=null}catch(t){this.say(this.lineOf(e),t)}}async keep(e){this.busy=e.id;try{await this.note.save(),this.editing?.id===e.id&&await this.done(e),this.note.adopt(await L.api.keep(this.note.id,e.id))}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async discard(e){this.busy=e.id;try{await L.api.discard(this.note.id,e.id)}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async keepChange(e){this.busy=e.key;try{await this.note.save(),this.note.adopt(await L.api.keep(this.note.id,e.proposal.id,e.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}async discardChange(e){this.busy=e.key;try{await L.api.discard(this.note.id,e.proposal.id,e.k)}catch(e){this.say(void 0,e)}finally{this.busy=``}}async settleAll(e){this.busy=`all`;try{e&&await this.note.save();for(let t of[...this.changes].reverse())(!e||t.at)&&(e?this.note.adopt(await L.api.keep(this.note.id,t.proposal.id,t.k)):await L.api.discard(this.note.id,t.proposal.id,t.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}},kt=1500,At=e=>he(`isorite.draft.${e}`);function jt(e,t){try{if(t===void 0)return JSON.parse(localStorage.getItem(At(e))??`null`);t?localStorage.setItem(At(e),JSON.stringify(t)):localStorage.removeItem(At(e))}catch{}return null}var Mt=e=>typeof e==`string`?e:e==null?``:String(e),Nt=class{id;#e=N(`loading`);get loaded(){return P(this.#e)}set loaded(e){C(this.#e,e,!0)}#t=N(`saved`);get saving(){return P(this.#t)}set saving(e){C(this.#t,e,!0)}#n=N(``);get message(){return P(this.#n)}set message(e){C(this.#n,e,!0)}#r=N(``);get text(){return P(this.#r)}set text(e){C(this.#r,e,!0)}#i=N(void 0);get theirs(){return P(this.#i)}set theirs(e){C(this.#i,e)}#a=N(0);get revision(){return P(this.#a)}set revision(e){C(this.#a,e,!0)}base=``;saved=``;timer=null;inFlight=null;stop=null;constructor(e){this.id=e}#o=M(()=>{try{return ue(this.text)[0]??{}}catch{return null}});get meta(){return P(this.#o)}set meta(e){C(this.#o,e)}#s=M(()=>{let e=this.meta??{};return{title:Mt(e.title),type:Mt(e.type),description:Mt(e.description),tags:Array.isArray(e.tags)?e.tags.map(String).join(`, `):Mt(e.tags)}});get fields(){return P(this.#s)}set fields(e){C(this.#s,e)}#c=M(()=>{try{return ae(this.text)[2]}catch{return this.text}});get body(){return P(this.#c)}set body(e){C(this.#c,e)}async open(){try{let e=await L.api.readNote(this.id),t=jt(this.id);this.take(e),t&&t.text!==e.text&&(this.text=t.text,t.base===e.version?this.changed():(this.theirs=e,this.saving=`conflict`,jt(this.id,t))),this.loaded=`ready`,this.stop=L.on(e=>this.hear(e))}catch(e){this.loaded=e instanceof oe&&e.status===404?`missing`:`error`,this.message=e.message}}async close(){this.stop?.(),await this.save()}adopt(e){this.take(e)}async restore(e){await this.settle(),this.take(await L.api.restore(this.id,e,this.base))}async move(e){await this.settle();let t=await L.api.moveNote(this.id,e,this.base);return this.stop?.(),t.id}async setDone(e){await this.settle(),this.take(await L.api.setDone(this.id,e,this.base)),await L.refresh()}async remove(){await this.settle(),await L.api.deleteNote(this.id,this.base),this.stop?.()}async settle(){if(this.saving!==`saved`&&await this.save(),this.saving!==`saved`)throw Error(this.message||`the note could not be saved first`)}take(e){this.text=this.saved=e.text,this.base=e.version,this.theirs=void 0,this.saving=`saved`,this.message=``,jt(this.id,null),this.revision++}setText(e){e!==this.text&&(this.text=e,this.changed())}setBody(e){e!==this.body&&this.setText(_e(this.text,{},e))}setFields(e){let t={};for(let[n,r]of Object.entries(e)){let e=r.trim();t[n]=n===`tags`?e?e.split(`,`).map(e=>e.trim()).filter(Boolean):null:e||null}this.setMeta(t)}setMeta(e){try{this.setText(_e(this.text,e,null))}catch{}}changed(){jt(this.id,{base:this.base,text:this.text}),this.saving!==`conflict`&&(this.saving=`unsaved`,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.save()},kt))}save(){return this.timer&&=(clearTimeout(this.timer),null),this.inFlight=(this.inFlight??Promise.resolve()).then(()=>this.send()),this.inFlight}async send(){if(this.loaded!==`ready`||this.saving===`conflict`||this.text===this.saved)return;let e=this.text;this.saving=`saving`;try{let t=await L.api.saveNote(this.id,{base:this.base,text:e});this.base=t.version,this.saved=e,this.message=``,this.text===e?(this.saving=`saved`,jt(this.id,null)):this.changed()}catch(t){if(t instanceof oe&&t.status===409&&t.current!==void 0){if(t.current?.text===e)return this.take(t.current);this.theirs=t.current,this.saving=`conflict`}else this.saving=`failed`,this.message=t.message,this.timer=setTimeout(()=>{this.save()},5e3)}}hear(e){e.type===`note-changed`&&e.id===this.id&&e.version!==this.base&&e.version!==ge(this.text)&&this.saving===`saved`&&L.api.readNote(this.id).then(e=>{this.saving===`saved`&&e.version!==this.base&&this.take(e)},()=>void 0)}keepMine(){let e=this.theirs;return e===void 0?Promise.resolve():(this.theirs=void 0,this.saving=`unsaved`,e===null?L.api.createNote(this.id,this.text).then(e=>this.take(e),e=>{this.saving=`failed`,this.message=e.message}):(this.base=e.version,this.saved=e.text,this.save()))}keepTheirs(){this.theirs&&this.take(this.theirs)}},Pt=null;function Ft(){return Pt??=Promise.all(vt.map(async e=>{let t=await fetch(F(`/kit/${e}`));if(!t.ok)throw Error(`the kit's ${e} isn't there (${t.status}): build the app again`);return[e,await t.text()]})).then(e=>Object.fromEntries(e)).catch(e=>{throw Pt=null,e}),Pt}var It=e=>e.split(`/`).slice(0,-1).join(`/`);function Lt(e,t){let n=It(e).split(`/`).filter(Boolean);for(let e of t.replace(/^\.\//,``).split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!n.length)return null;n.pop()}else n.push(e)}return n.join(`/`)}async function Rt(e,t){let n=await e.file(t);if(!n)throw Error(`no artifact at ${t}`);let r=new TextDecoder().decode(n.bytes);return{html:r,manifest:xt(r)}}async function zt(e,t,n){let r={};for(let i of n){let n=Lt(t,i),a=n===null?null:await e.file(n);a&&(r[i]=/^(text\/|application\/(json|jsonl|x-ndjson))/.test(a.type)?new TextDecoder().decode(a.bytes):a.bytes)}return r}async function Bt(e,t){return Et(e,await Ft(),t)}function Vt(e,t,n,r,i){let a=(t,n=[])=>e.contentWindow?.postMessage({isorite:0,...t},`*`,n),o=async o=>{if(o.source!==e.contentWindow)return;let s=o.data;if(s&&s.isorite===0){if(s.type===`ready`){let e=i.current();a({type:`ground`,ground:e.ground}),a({type:`look`,look:e.look})}else if(s.type===`file`||s.type===`bytes`){let e=String(s.path??``);if(!r().includes(e)){a({type:`reply`,id:s.id,error:`${e} is not in the artifact's manifest (isorite:uses)`});return}let i=Lt(n,e);try{let n=i===null?null:await t.file(i);if(!n)a({type:`reply`,id:s.id,error:`${e}: no such file beside the artifact`});else if(s.type===`bytes`){let e=n.bytes.slice().buffer;a({type:`reply`,id:s.id,bytes:e},[e])}else a({type:`reply`,id:s.id,text:new TextDecoder().decode(n.bytes)})}catch(t){a({type:`reply`,id:s.id,error:`${e}: ${t.message}`})}}else s.type===`height`?i.onHeight(Number(s.height)||0):s.type===`error`?i.onError(String(s.message)):s.type===`open`&&i.onOpen(String(s.note))}};return addEventListener(`message`,o),{tell:a,stop:()=>removeEventListener(`message`,o)}}function Ht(e,t){let n=e.split(/[#?]/)[0].trim();if(!n||/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith(`//`)||!/\.html?$/i.test(n))return null;let r=n.startsWith(`/`)?n.slice(1):Lt(`${t}.md`,n);return r?decodeURI(r):null}function Ut(){let e=document.documentElement.dataset.ground;return e===`lapis`||e===`quartz`?e:matchMedia(`(prefers-color-scheme: light)`).matches?`quartz`:`lapis`}function Wt(e){let t=e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);return`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>${t}</title><meta name="isorite:kit" content="1"><meta name="isorite:uses" content="${t}"></head><body><iso-model src="${t}" height="440"></iso-model></body></html>`}var Gt=l(`<p class="problem svelte-klp1mb" role="alert"> </p>`),Kt=l(`<!> <iframe sandbox="allow-scripts" class="svelte-klp1mb"></iframe>`,1);function qt(n,r){x(r,!0);let a=D(r,`look`,3,`isorite`),c=N(void 0),l=N(480),f=N(``),p=N(e(Ut()));o(()=>{let e=new MutationObserver(()=>{C(p,Ut(),!0)});e.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-ground`]});let t=matchMedia(`(prefers-color-scheme: light)`),n=()=>{C(p,Ut(),!0)};return t.addEventListener(`change`,n),()=>{e.disconnect(),t.removeEventListener(`change`,n)}});let g=null;o(()=>P(c)?(g=Vt(P(c),L.api,r.path,()=>r.uses,{onHeight:e=>{C(l,Math.max(120,Math.min(2e4,Math.ceil(e)+4)),!0)},onError:e=>r.onerror?.(e),onOpen:e=>{Re.open(e.replace(/^\/+/,``).replace(/\.md$/,``))},current:()=>({ground:P(p),look:a()})}),()=>{g?.stop(),g=null}):void 0),o(()=>{if(!P(c))return;let e=P(c),t=r.html,n=s(()=>({look:a(),ground:P(p)}));C(f,``),Bt(t,n).then(t=>{e.srcdoc=t},e=>{C(f,e.message,!0)})}),o(()=>{g?.tell({type:`ground`,ground:P(p)})}),o(()=>{g?.tell({type:`look`,look:a()})});var v=Kt(),y=h(v),S=e=>{var n=Gt(),r=_(n,!0);m(()=>u(r,P(f))),t(e,n)};i(y,e=>{P(f)&&e(S)});var w=d(y,2);let T;b(w,e=>C(c,e),()=>P(c)),m(()=>{A(w,`title`,r.title),T=ee(w,``,T,{height:`${P(l)??``}px`})}),t(n,v),ne()}var Jt=l(`<span class="problem svelte-zlq7nn"> </span>`),Yt=l(`<span class="embed svelte-zlq7nn"><a class="name svelte-zlq7nn"><!> </a> <!> <!></span>`);function Xt(r,a){x(a,!0);let s=N(null),c=N(``),l=N(e([]));o(()=>{let e=a.path;Rt(L.api,e).then(e=>{C(s,e)},e=>{C(c,e.message,!0)})});var f=Yt(),p=g(f),h=g(p);we(h,{kind:`artifact`,size:11});var v=d(h,1,!0);j(p);var y=d(p,2),b=e=>{var n=Jt(),r=_(n,!0);m(()=>u(r,P(c))),t(e,n)},S=e=>{{let t=M(()=>P(s).manifest.title||a.path);qt(e,{get path(){return a.path},get html(){return P(s).html},get uses(){return P(s).manifest.uses},get title(){return P(t)},onerror:e=>{P(l).includes(e)||C(l,[...P(l),e],!0)}})}};i(y,e=>{P(c)?e(b):P(s)&&e(S,1)});var w=d(y,2);n(w,16,()=>P(l),e=>e,(e,n)=>{var r=Jt(),i=_(r,!0);m(()=>u(i,n)),t(e,r)}),j(f),m((e,t)=>{A(p,`href`,e),u(v,t)},[()=>me(a.path),()=>P(s)?.manifest.title||a.path.split(`/`).at(-1)]),t(r,f),ne()}var Zt=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=nn(e.state,n.from);return r.line?$t(e):r.block?tn(e):!1};function Qt(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var $t=Qt(cn,0),en=Qt(sn,0),tn=Qt((e,t)=>sn(e,t,on(t)),0);function nn(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var rn=50;function an(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-rn,r),o=e.sliceDoc(i,i+rn),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+rn),d=e.sliceDoc(i-rn,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function on(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function sn(e,t,n=t.selection.ranges){let r=n.map(e=>nn(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>an(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function cn(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=nn(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var ln=Je.define(),un=Je.define(),dn=Ye.define(),fn=Ye.define({combine(e){return Qe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),pn=at.define({create(){return An.empty},update(e,t){let n=t.state.facet(fn),r=t.annotation(ln);if(r){let i=W.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?bn(o,o.length,n.minDepth,i):Tn(o,t.startState.selection),new An(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(un);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Ze.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=W.fromTransaction(t),o=t.annotation(Ze.time),s=t.annotation(Ze.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new An(e.done.map(W.fromJSON),e.undone.map(W.fromJSON))}});function mn(e={}){return[pn,fn.of(e),z.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?gn:e.inputType==`historyRedo`?_n:null;return n?(e.preventDefault(),n(t)):!1}})]}function hn(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(pn,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var gn=hn(0,!1),_n=hn(1,!1),vn=hn(0,!0),yn=hn(1,!0),W=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&We.fromJSON(t.changes),[],t.mapped&&Ve.fromJSON(t.mapped),t.startSelection&&B.fromJSON(t.startSelection),t.selectionsAfter.map(B.fromJSON))}static fromTransaction(t,n){let r=G;for(let e of t.startState.facet(dn)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,G)}static selection(t){return new e(void 0,G,void 0,void 0,t)}};function bn(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function xn(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Sn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Cn(e,t){return e.length?t.length?e.concat(t):e:t}var G=[],wn=200;function Tn(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-wn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),bn(e,e.length-1,1e9,n.setSelAfter(r)))}return[W.selection([t])]}function En(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Dn(e,t){if(!e.length)return e;let n=e.length,r=G;for(;n;){let i=On(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[W.selection(r)]:G}function On(e,t,n){let r=Cn(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):G,n);if(!e.changes)return W.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new W(i,it.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var kn=/^(input\.type|delete)($|\.)/,An=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||kn.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,xn(s.changes,t.changes))||r==`input.type.compose`)?bn(o,o.length-1,i.minDepth,new W(t.changes.compose(s.changes),Cn(it.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,G)):bn(o,o.length,i.minDepth,t),new e(o,G,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:G;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Sn(a[a.length-1],t)?this:new e(Tn(this.done,t),this.undone,n,r)}addMapping(t){return new e(Dn(this.done,t),Dn(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:ln.of({side:e,rest:En(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?G:r.slice(0,r.length-1);return i.mapped&&(n=Dn(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:ln.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};An.empty=new An(G,G);var jn=[{key:`Mod-z`,run:gn,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:_n,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:_n,preventDefault:!0},{key:`Mod-u`,run:vn,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:yn,preventDefault:!0}];function Mn(e,t){return B.create(e.ranges.map(t),e.mainIndex)}function K(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function q({state:e,dispatch:t},n){let r=Mn(e.selection,n);return!r.eq(e.selection,!0)&&(t(K(e,r)),!0)}function Nn(e,t){return B.cursor(t?e.to:e.from)}function Pn(e,t){return q(e,n=>n.empty?e.moveByChar(n,t):Nn(n,t))}function J(e){return e.textDirectionAt(e.state.selection.main.head)==Ge.LTR}var Fn=e=>Pn(e,!J(e)),In=e=>Pn(e,J(e));function Ln(e,t){return q(e,n=>n.empty?e.moveByGroup(n,t):Nn(n,t))}var Rn=e=>Ln(e,!J(e)),zn=e=>Ln(e,J(e));typeof Intl<`u`&&Intl.Segmenter;function Bn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Vn(e,t,n){let r=R(e).resolveInner(t.head),i=n?nt.closedBy:nt.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Bn(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?lt(e,r.from,1):lt(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,B.cursor(s,n?-1:1)}var Hn=e=>q(e,t=>Vn(e.state,t,!J(e))),Un=e=>q(e,t=>Vn(e.state,t,J(e)));function Wn(e,t){return q(e,n=>{if(!n.empty)return Nn(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Gn=e=>Wn(e,!1),Kn=e=>Wn(e,!0);function qn(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(z.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Jn(e,t){let n=qn(e),{state:r}=e,i=Mn(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Nn(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=z.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(K(r,i),{effects:a}),!0}var Yn=e=>Jn(e,!1),Xn=e=>Jn(e,!0);function Y(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=B.cursor(r.from+n))}return i}var Zn=e=>q(e,t=>Y(e,t,!0)),Qn=e=>q(e,t=>Y(e,t,!1)),$n=e=>q(e,t=>Y(e,t,!J(e))),er=e=>q(e,t=>Y(e,t,J(e))),tr=e=>q(e,t=>e.moveToLineBoundary(t,!1,!1)),nr=e=>q(e,t=>e.moveToLineBoundary(t,!0,!1));function rr(e,t,n){let r=!1,i=Mn(e.selection,t=>{let i=lt(e,t.head,-1)||lt(e,t.head,1)||t.head>0&&lt(e,t.head-1,1)||t.head<e.doc.length&&lt(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?B.range(t.anchor,a):B.cursor(a)});return r?(t(K(e,i)),!0):!1}var ir=({state:e,dispatch:t})=>rr(e,t,!1);function X(e,t,n){let r=Mn(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=B.range(e.head,e.anchor));let r=n(e);return B.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(K(e.state,r)),!0)}function ar(e,t){return X(e,t,n=>e.moveByChar(n,t))}var or=e=>ar(e,!J(e)),sr=e=>ar(e,J(e));function cr(e,t){return X(e,t,n=>e.moveByGroup(n,t))}var lr=e=>cr(e,!J(e)),ur=e=>cr(e,J(e)),dr=e=>{let t=!J(e);return X(e,t,n=>Vn(e.state,n,t))},fr=e=>{let t=J(e);return X(e,t,n=>Vn(e.state,n,t))};function pr(e,t){return X(e,t,n=>e.moveVertically(n,t))}var mr=e=>pr(e,!1),hr=e=>pr(e,!0);function gr(e,t){return X(e,t,n=>e.moveVertically(n,t,qn(e).height))}var _r=e=>gr(e,!1),vr=e=>gr(e,!0),yr=e=>X(e,!0,t=>Y(e,t,!0)),br=e=>X(e,!1,t=>Y(e,t,!1)),xr=e=>{let t=!J(e);return X(e,t,n=>Y(e,n,t))},Sr=e=>{let t=J(e);return X(e,t,n=>Y(e,n,t))},Cr=e=>X(e,!1,t=>B.cursor(e.lineBlockAt(t.head).from)),wr=e=>X(e,!0,t=>B.cursor(e.lineBlockAt(t.head).to)),Tr=({state:e,dispatch:t})=>(t(K(e,{anchor:0})),!0),Er=({state:e,dispatch:t})=>(t(K(e,{anchor:e.doc.length})),!0),Dr=({state:e,dispatch:t})=>(t(K(e,{anchor:e.selection.main.anchor,head:0})),!0),Or=({state:e,dispatch:t})=>(t(K(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),kr=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Ar=({state:e,dispatch:t})=>{let n=Yr(e).map(({from:t,to:n})=>B.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:B.create(n),userEvent:`select`})),!0},jr=({state:e,dispatch:t})=>{let n=Mn(e.selection,t=>{let n=R(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return B.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(K(e,n)),!0)};function Mr(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(K(n,B.create(i,i.length-1))),!0)}var Nr=e=>Mr(e,!1),Pr=e=>Mr(e,!0),Fr=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=B.create([n.main]):n.main.empty||(r=B.create([B.cursor(n.main.head)])),r?(t(K(e,r)),!0):!1};function Ir(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Lr(e,o,!1)):o>i&&(n=`delete.forward`,o=Lr(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Lr(e,i,!1),a=Lr(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:B.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?z.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Lr(e,t,n){if(e instanceof z)for(let r of e.state.facet(z.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Rr=(e,t,n)=>Ir(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=tt(s,a.tabSize)%ct(a)||ct(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=st(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=st(o.text,c-o.from,!1,!1)+o.from);return c}),zr=e=>Rr(e,!1,!0),Br=e=>Rr(e,!0,!1),Vr=(e,t)=>Ir(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=st(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Hr=e=>Vr(e,!1),Ur=e=>Vr(e,!0),Wr=e=>Ir(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Gr=e=>Ir(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Kr=e=>Ir(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),qr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:et.of([``,``])},range:B.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Jr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:st(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:st(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:B.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Yr(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Xr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Yr(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(B.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(B.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:B.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Zr=({state:e,dispatch:t})=>Xr(e,t,!1),Qr=({state:e,dispatch:t})=>Xr(e,t,!0);function $r(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Yr(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var ei=({state:e,dispatch:t})=>$r(e,t,!1),ti=({state:e,dispatch:t})=>$r(e,t,!0),ni=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Yr(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=Mn(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function ri(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=R(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(nt.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var ii=oi(!1),ai=oi(!0);function oi(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&ri(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new rt(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=dt(s,r);for(c??=tt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,ut(t,c)];return o&&l.push(ut(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:et.of(l)},range:B.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function si(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:B.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var ci=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new rt(e,{overrideIndentation:e=>n[e]??-1}),i=si(e,(t,i,a)=>{let o=dt(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=ut(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},li=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(si(e,(t,n)=>{n.push({from:t.from,insert:e.facet(qe)})}),{userEvent:`input.indent`})),!0),ui=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(si(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=tt(r,e.tabSize),a=0,o=ut(e,Math.max(0,i-ct(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),di=e=>(e.setTabFocusMode(),!0),fi=[{key:`Ctrl-b`,run:Fn,shift:or,preventDefault:!0},{key:`Ctrl-f`,run:In,shift:sr},{key:`Ctrl-p`,run:Gn,shift:mr},{key:`Ctrl-n`,run:Kn,shift:hr},{key:`Ctrl-a`,run:tr,shift:Cr},{key:`Ctrl-e`,run:nr,shift:wr},{key:`Ctrl-d`,run:Br},{key:`Ctrl-h`,run:zr},{key:`Ctrl-k`,run:Wr},{key:`Ctrl-Alt-h`,run:Hr},{key:`Ctrl-o`,run:qr},{key:`Ctrl-t`,run:Jr},{key:`Ctrl-v`,run:Xn}],pi=[{key:`ArrowLeft`,run:Fn,shift:or,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Rn,shift:lr,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:$n,shift:xr,preventDefault:!0},{key:`ArrowRight`,run:In,shift:sr,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:zn,shift:ur,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:er,shift:Sr,preventDefault:!0},{key:`ArrowUp`,run:Gn,shift:mr,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Tr,shift:Dr},{mac:`Ctrl-ArrowUp`,run:Yn,shift:_r},{key:`ArrowDown`,run:Kn,shift:hr,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Er,shift:Or},{mac:`Ctrl-ArrowDown`,run:Xn,shift:vr},{key:`PageUp`,run:Yn,shift:_r},{key:`PageDown`,run:Xn,shift:vr},{key:`Home`,run:Qn,shift:br,preventDefault:!0},{key:`Mod-Home`,run:Tr,shift:Dr},{key:`End`,run:Zn,shift:yr,preventDefault:!0},{key:`Mod-End`,run:Er,shift:Or},{key:`Enter`,run:ii,shift:ii},{key:`Mod-a`,run:kr},{key:`Backspace`,run:zr,shift:zr,preventDefault:!0},{key:`Delete`,run:Br,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Hr,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Ur,preventDefault:!0},{mac:`Mod-Backspace`,run:Gr,preventDefault:!0},{mac:`Mod-Delete`,run:Kr,preventDefault:!0}].concat(fi.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),mi=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Hn,shift:dr},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Un,shift:fr},{key:`Alt-ArrowUp`,run:Zr},{key:`Shift-Alt-ArrowUp`,run:ei},{key:`Alt-ArrowDown`,run:Qr},{key:`Shift-Alt-ArrowDown`,run:ti},{key:`Mod-Alt-ArrowUp`,run:Nr},{key:`Mod-Alt-ArrowDown`,run:Pr},{key:`Escape`,run:Fr},{key:`Mod-Enter`,run:ai},{key:`Alt-l`,mac:`Ctrl-l`,run:Ar},{key:`Mod-i`,run:jr,preventDefault:!0},{key:`Mod-[`,run:ui},{key:`Mod-]`,run:li},{key:`Mod-Alt-\\`,run:ci},{key:`Shift-Mod-k`,run:ni},{key:`Shift-Mod-\\`,run:ir},{key:`Mod-/`,run:Zt},{key:`Alt-A`,mac:`Ctrl-A`,run:en},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:di}].concat(pi),hi={key:`Tab`,run:li,shift:ui},gi=Ye.define({combine:e=>e[0]??null}),_i=/^[ \t]*\[\[!([^\]\n]+)\]\][ \t]*$/,vi={question:`<path d="M8 2.5L13.5 8L8 13.5L2.5 8Z"/>`,problem:`<path d="M8 2.5l5.8 10.5H2.2z"/>`,note:`<rect x="3.5" y="2.5" width="9" height="11"/>`},yi=`<path d="M3 8.5l3 3 7-7"/>`,bi=class extends V{ref;found;at;constructor(e,t,n){super(),this.ref=e,this.found=t,this.at=n}eq(e){return e.ref===this.ref&&JSON.stringify(e.found)===JSON.stringify(this.found)&&e.at===this.at}toDOM(e){let t=this.found,n=document.createElement(`div`);n.className=`cm-lp-embed${t?` cm-lp-embed-${t.kind}`:` cm-lp-embed-broken`}${t?.done?` cm-lp-embed-done`:``}`,n.title=`[[!${this.ref}]]`;let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`viewBox`,`0 0 16 16`),r.setAttribute(`width`,`16`),r.setAttribute(`height`,`16`),r.setAttribute(`aria-hidden`,`true`),r.innerHTML=t?.done?yi:vi[t?.kind??`question`];let i=document.createElement(`span`);return i.textContent=t?t.title:this.ref,n.append(r,i),n.addEventListener(`mousedown`,n=>{n.preventDefault(),t&&!n.altKey?e.state.facet(gi)?.open(t.id):(e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus())}),n}ignoreEvent(){return!0}get estimatedHeight(){return 44}},xi=class extends V{kind;source;at;beneath;constructor(e,t,n,r){super(),this.kind=e,this.source=t,this.at=n,this.beneath=r}eq(e){return e.kind===this.kind&&e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-${this.kind}${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`div`);return n.className=`prose`,t.append(n),n.innerHTML=De(this.source),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}ignoreEvent(){return!0}get estimatedHeight(){return this.kind===`maths`?60:120}},Si=new WeakMap,Ci=class extends V{source;at;beneath;constructor(e,t,n){super(),this.source=e,this.at=t,this.beneath=n}eq(e){return e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-diagram${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`pre`);n.className=`cm-lp-diagram-src`,n.textContent=this.source;let r=document.createElement(`div`);return r.className=`diagram`,t.append(n,r),Si.set(t,{mounted:ke(r,this.source,()=>t.classList.add(`cm-lp-broken-diagram`)),source:this.source}),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}updateDOM(e){let t=Si.get(e);return!t||!this.beneath||!e.classList.contains(`cm-lp-beneath`)?!1:(t.source!==this.source&&(t.source=this.source,e.classList.remove(`cm-lp-broken-diagram`),e.querySelector(`.cm-lp-diagram-src`).textContent=this.source,t.mounted.then(e=>je(e,this.source))),!0)}ignoreEvent(){return!0}get estimatedHeight(){return 160}},wi=(e,t)=>t!==null&&e.sliceDoc(t.from,t.to).trim().split(/\s/)[0].toLowerCase()===`mermaid`;function Ti(e){let t=[],n=e.selection.ranges;R(e).iterate({enter:r=>{let i=null,a=``;if(r.name===`BlockMath`)i=`maths`,a=e.sliceDoc(r.from,r.to);else if(r.name===`Table`)i=`table`,a=e.sliceDoc(r.from,r.to);else if(r.name===`FencedCode`&&wi(e,r.node.getChild(`CodeInfo`))){let i=r.node.getChild(`CodeText`),a=i?e.sliceDoc(i.from,i.to):``,o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?a.trim()&&t.push(U.widget({widget:new Ci(a,r.from,!0),block:!0,side:1}).range(s)):t.push(U.replace({widget:new Ci(a,r.from,!1),block:!0}).range(o,s)),!1}else if(r.name===`Document`||r.name===`Blockquote`||/List|ListItem/.test(r.name))return;if(!i)return!1;let o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?i!==`table`&&a.trim()&&t.push(U.widget({widget:new xi(i,a,r.from,!0),block:!0,side:1}).range(s)):t.push(U.replace({widget:new xi(i,a,r.from,!1),block:!0}).range(o,s)),!1}});let r=e.facet(gi);if(r){let i=!1;for(let a=1;a<=e.doc.lines;a++){let o=e.doc.line(a);if(/^\s*(```|~~~)/.test(o.text)){i=!i;continue}let s=i?null:_i.exec(o.text);if(!s||n.some(e=>e.to>=o.from&&e.from<=o.to))continue;let c=s[1].trim();t.push(U.replace({widget:new bi(c,r.find(c),o.from),block:!0}).range(o.from,o.to))}}return U.set(t,!0)}var Ei=at.define({create:Ti,update(e,t){return t.docChanged||t.selection||R(t.startState)!==R(t.state)?Ti(t.state):e},provide:e=>z.decorations.from(e)}),Di=z.theme({".cm-lp-block":{padding:`0`,cursor:`text`},".cm-lp-block .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-block .prose":{maxWidth:`none`},".cm-lp-block .prose > :last-child, .cm-lp-block .table-wrap":{marginBottom:`0`},".cm-lp-block .katex-display":{margin:`0`},".cm-lp-diagram .diagram":{overflowX:`auto`,overflowY:`hidden`},".cm-lp-diagram-src":{display:`none`,margin:`0`,font:`13px/20px var(--font-mono)`,whiteSpace:`pre-wrap`,color:`var(--text-soft)`},".cm-lp-diagram.cm-lp-broken-diagram:not(.cm-lp-beneath) .cm-lp-diagram-src":{display:`block`},".cm-lp-beneath":{borderLeft:`2px solid var(--line)`,paddingLeft:`12px`,marginTop:`4px`,opacity:`.9`},".cm-lp-block:not(.cm-lp-beneath):hover":{outline:`1px dashed var(--line)`,outlineOffset:`2px`},".cm-lp-embed":{display:`flex`,alignItems:`center`,gap:`10px`,padding:`9px 12px`,border:`1px solid var(--rose)`,borderLeftWidth:`3px`,background:`var(--rose-soft)`,fontFamily:`var(--font-text)`,fontSize:`16px`,lineHeight:`1.45`,cursor:`pointer`},".cm-lp-embed svg":{flex:`none`,fill:`none`,stroke:`var(--rose)`,strokeWidth:`1.4`},".cm-lp-embed-problem":{borderColor:`var(--line-strong)`,background:`var(--ground-1)`},".cm-lp-embed-problem svg":{stroke:`var(--text-soft)`},".cm-lp-embed-done":{borderColor:`var(--malachite)`,background:`var(--malachite-soft)`},".cm-lp-embed-done svg":{stroke:`var(--malachite)`},".cm-lp-embed-broken":{borderStyle:`dashed`,borderColor:`var(--line-strong)`,background:`none`,color:`var(--text-faint)`},".cm-lp-embed-broken svg":{stroke:`var(--text-faint)`},".cm-lp-embed:hover":{borderColor:`var(--text-soft)`}});function Oi(e,t){let{state:n}=e,r=t.length;return e.dispatch(n.changeByRange(e=>{let i=n.sliceDoc(e.from-r,e.from),a=n.sliceDoc(e.to,e.to+r);return i===t&&a===t?{changes:[{from:e.from-r,to:e.from},{from:e.to,to:e.to+r}],range:B.range(e.from-r,e.to-r)}:{changes:[{from:e.from,insert:t},{from:e.to,insert:t}],range:B.range(e.from+r,e.to+r)}}),{scrollIntoView:!0,userEvent:`input`}),!0}function ki(e){let{state:t}=e,n=new Map;for(let e of t.selection.ranges)for(let r=e.from;r<=e.to;){let e=t.doc.lineAt(r);n.set(e.number,{from:e.from,text:e.text}),r=e.to+1}return[...n.values()]}function Ai(e){let t=ki(e).map(({from:e,text:t})=>{let n=/^(#{1,6}) /.exec(t),r=n?n[1].length:0,i=r>=3?``:`#`.repeat(r+1)+` `;return{from:e,to:e+(n?n[0].length:0),insert:i}});return e.dispatch({changes:t,scrollIntoView:!0,userEvent:`input`}),!0}function ji(e){let t=ki(e),n=t.every(({text:e})=>/^\s*[-*+] /.test(e)),r=t.map(({from:e,text:t})=>{if(n){let n=/^(\s*)[-*+] /.exec(t);return{from:e+n[1].length,to:e+n[0].length}}return{from:e+/^\s*/.exec(t)[0].length,insert:`- `}});return e.dispatch({changes:r,scrollIntoView:!0,userEvent:`input`}),!0}function Mi(e){let{state:t}=e,n=t.selection.main;if(n.empty)e.dispatch({changes:{from:n.from,insert:`[[]]`},selection:{anchor:n.from+2},userEvent:`input`});else{let r=t.sliceDoc(n.from,n.to);e.dispatch({changes:{from:n.from,to:n.to,insert:`[${r}]()`},selection:{anchor:n.from+r.length+3},userEvent:`input`})}return pt(e),!0}function Ni(e,t){switch(t){case`bold`:return Oi(e,`**`);case`italic`:return Oi(e,`*`);case`maths`:return Oi(e,`$`);case`heading`:return Ai(e);case`list`:return ji(e);case`link`:return Mi(e);case`undo`:return gn(e);case`redo`:return _n(e)}}var Pi=[{key:`Mod-b`,preventDefault:!0,run:e=>Ni(e,`bold`)},{key:`Mod-i`,preventDefault:!0,run:e=>Ni(e,`italic`)},{key:`Mod-k`,preventDefault:!0,run:e=>Ni(e,`link`)},{key:`Mod-Shift-m`,preventDefault:!0,run:e=>Ni(e,`maths`)},{key:`Mod-Shift-h`,preventDefault:!0,run:e=>Ni(e,`heading`)},{key:`Mod-Shift-8`,preventDefault:!0,run:e=>Ni(e,`list`)}],Fi=[`requires`,`uses`,`see also`];function Ii(e){if(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`#`))return null;let t=e.split(`#`)[0].split(`?`)[0];return/\.html?$/i.test(t)?`artifact`:/\.(png|jpe?g|gif|svg|webp|avif)$/i.test(t)?`image`:/\.md$/i.test(t)||t.endsWith(`/`)?`note`:null}function Li(e,t){let n=R(e);for(let r of[-1,1])for(let i=n.resolveInner(t,r);i;i=i.parent){if(i.name!==`Link`&&i.name!==`Image`)continue;let t=i.getChild(`URL`);if(!t)break;let n=e.sliceDoc(t.from,t.to),r=Ii(n);if(!r)return null;let a=i.getChild(`LinkTitle`),o=a?e.sliceDoc(a.from,a.to):null;return{from:i.from,to:i.to,embed:i.name===`Image`,url:n,urlTo:t.to,title:o===null?null:o.replace(/^["'(]|["')]$/g,``),titleFrom:a?a.from:t.to,titleTo:a?a.to:t.to,kind:r}}return null}var Ri=e=>e.kind===`note`||e.kind===`artifact`&&!e.embed;function zi(e,t,n){let r=[];return R(e).iterate({from:t,to:n,enter:i=>{if(i.name!==`Link`&&i.name!==`Image`)return;if(i.from<t||i.to>n)return!1;let a=Li(e,i.from+1);return a&&a.from===i.from&&Ri(a)&&r.push(a),!1}}),r}var Bi=(e,t)=>e.filter(e=>Z(e)!==t).map(e=>Ui(e,t)),Vi=e=>(e??``).trim().toLowerCase().replace(/[-_]/g,` `),Z=e=>Fi.includes(Vi(e.title))?Vi(e.title):Vi(e.title)===`seealso`?`see also`:null,Hi=e=>Vi(e.title)===`left`?`left`:`center`;function Ui(e,t){return t===null?{from:e.urlTo,to:e.titleTo,insert:``}:e.titleFrom===e.titleTo?{from:e.urlTo,insert:` "${t}"`}:{from:e.titleFrom,to:e.titleTo,insert:`"${t}"`}}function Wi(e,t){if(e.embed===t)return[];let n=[t?{from:e.from,insert:`!`}:{from:e.from,to:e.from+1,insert:``}];return e.title!==null&&(e.kind===`image`||Z(e)!==null)&&n.push(Ui(e,null)),n}var Q=(e,t)=>e.dispatch({changes:t,userEvent:`input.link`});function Gi(e){let t=[...Fi.map(t=>({label:t[0].toUpperCase()+t.slice(1),on:Z(e)===t,run:(e,n)=>Q(e,Ui(n,t)),hint:t===`requires`?`This note cannot be followed without it: it shapes the Atlas and the study order`:t===`uses`?`It draws on it: it shapes the Atlas`:`Related reading: shown, but it does not shape the Atlas`})),{label:`Unrated`,on:Z(e)===null,run:(e,t)=>Q(e,Ui(t,null)),hint:`No rating: counted as uses`}];if(e.kind===`note`)return t;let n=[{label:`Shown here`,on:e.embed,run:(e,t)=>Q(e,Wi(t,!0)),hint:e.kind===`image`?`The picture is shown in the note`:`The artifact is shown in the note, working`},{label:`Link`,on:!e.embed,run:(e,t)=>Q(e,Wi(t,!1)),hint:`A link to it; it opens on its own`}];return e.kind===`image`?e.embed?[...n,{label:`Centre`,on:Hi(e)===`center`,run:(e,t)=>Q(e,Ui(t,null)),hint:`In the middle, 80% of the text's width`},{label:`Left`,on:Hi(e)===`left`,run:(e,t)=>Q(e,Ui(t,`left`)),hint:`At the left, 80% of the text's width`}]:n:e.embed?n:[...n,...t]}function Ki(e){let t=t=>e.every(e=>Z(e)===t),n=e.length;return[...Fi.map(e=>({label:e[0].toUpperCase()+e.slice(1),on:t(e),run:t=>Q(t,Bi(zi(t.state,t.state.selection.main.from,t.state.selection.main.to),e)),hint:`Rate all ${n} links ${e}`})),{label:`Unrated`,on:t(null),run:e=>Q(e,Bi(zi(e.state,e.state.selection.main.from,e.state.selection.main.to),null)),hint:`Take the rating from all ${n} links`}]}function qi(e){let t=Z(e[0]),n=e.every(e=>Z(e)===t);return`${e.length} links, ${n?t??`unrated`:`mixed`}`}function Ji(e){return e.kind===`note`?Z(e)?Z(e)[0].toUpperCase()+Z(e).slice(1):`Unrated`:e.embed?e.kind===`image`?Hi(e)===`left`?`Shown, left`:`Shown, centre`:`Shown here`:Z(e)?`Link, ${Z(e)}`:`Link`}var Yi=(e,t)=>e===t||!!e&&!!t&&e.from===t.from&&e.to===t.to&&e.title===t.title&&e.embed===t.embed,Xi=class{view;layer;button;menu;leader;path;link=null;hover=null;many=[];open=!1;at=0;constructor(e){this.view=e,this.layer=document.createElement(`div`),this.layer.className=`cm-link-control`,this.layer.hidden=!0,this.leader=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this.leader.setAttribute(`class`,`cm-link-leader`),this.leader.setAttribute(`aria-hidden`,`true`),this.path=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),this.leader.append(this.path),this.button=document.createElement(`button`),this.button.type=`button`,this.button.className=`cm-link-button`,this.button.setAttribute(`aria-haspopup`,`menu`),this.button.addEventListener(`mousedown`,e=>e.preventDefault()),this.button.addEventListener(`click`,()=>this.toggle(!this.open,!1)),this.menu=document.createElement(`div`),this.menu.className=`cm-link-menu`,this.menu.setAttribute(`role`,`menu`),this.menu.hidden=!0,this.menu.tabIndex=-1,this.menu.addEventListener(`keydown`,e=>this.keys(e)),this.layer.append(this.leader,this.button,this.menu),e.dom.append(this.layer),e.dom.addEventListener(`mousemove`,this.onMove),e.dom.addEventListener(`mouseleave`,this.onLeave)}onMove=e=>{if(this.open||this.layer.contains(e.target))return;let t=this.view.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t===null?null:Li(this.view.state,t);Yi(n,this.hover)||(this.hover=n,this.view.requestMeasure(this.measure))};onLeave=e=>{this.open||this.layer.contains(e.relatedTarget)||this.hover&&(this.hover=null,this.view.requestMeasure(this.measure))};selected(){let e=this.view.state.selection.main;if(e.empty)return[];let t=zi(this.view.state,e.from,e.to);return t.length>=2?t:[]}current(){let e=this.view.state.selection.main,t=this.selected();return t.length?t[0]:Li(this.view.state,e.head)??(e.empty?this.hover:null)}update(e){e.docChanged&&(this.hover=null),(e.docChanged||e.selectionSet||e.geometryChanged||e.viewportChanged||e.focusChanged)&&this.view.requestMeasure(this.measure)}measure={key:`link-control`,read:e=>{let t=this.current();if(!t)return null;let n=this.selected(),r=e.dom.getBoundingClientRect(),i=e.contentDOM.getBoundingClientRect(),a=e.coordsAtPos(Math.max(t.from,t.to-1),1)??e.coordsAtPos(t.to,-1);if(n.length){let t=Math.max(r.top,0),i=Math.min(r.bottom,window.innerHeight);a=null;for(let r=n.length-1;r>=0&&!a;r--){let o=e.coordsAtPos(Math.max(n[r].from,n[r].to-1),1);o&&o.top>=t&&o.bottom<=i-34&&(a=o)}a??=e.coordsAtPos(Math.max(n[0].from,n[0].to-1),1)}return a?{l:t,many:n,x:a.right-r.left,y:(a.top+a.bottom)/2-r.top,right:i.right-r.left,width:r.width}:null},write:e=>{if(!e){this.link=null,this.many=[],this.layer.hidden=!0,this.toggle(!1,!1);return}let t=e.many.length?qi(e.many):Ji(e.l),n=!Yi(e.l,this.link)||e.many.length!==this.many.length||t!==this.button.textContent;this.link=e.l,this.many=e.many,this.layer.hidden=!1,this.button.textContent=t,this.button.title=e.many.length?`Rate all the selected links (Alt+L)`:`What this link is (Alt+L)`,this.button.setAttribute(`aria-label`,e.many.length?`${t}. Rate them all`:`This link: ${t}. Change it`);let r=this.button.offsetWidth||90,i=e.width-e.right>=r+20,a=i?e.right+14:Math.max(0,e.width-r-2),o=i?e.y-13:e.y+12;this.button.style.transform=`translate(${Math.round(a)}px, ${Math.round(o)}px)`,this.menu.style.transform=`translate(${Math.round(Math.min(a,e.width-250))}px, ${Math.round(o+30)}px)`;let s=a,c=o+13;this.path.setAttribute(`d`,i?`M${e.x+3} ${e.y} H${Math.max(e.x+3,s-3)}`:`M${e.x+3} ${e.y} V${c} H${s-3}`),n&&this.open&&(this.fill(),this.mark(this.at))}};fill(){let e=this.link;e&&this.menu.replaceChildren(...(this.many.length?Ki(this.many):Gi(e)).map((t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.tabIndex=-1,r.id=`cm-link-choice-${n}`,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`mousemove`,()=>this.mark(n)),r.setAttribute(`role`,`menuitemradio`),r.setAttribute(`aria-checked`,String(t.on)),r.title=t.hint,r.innerHTML=`<b></b><span></span>`,r.querySelector(`b`).textContent=t.label,r.querySelector(`span`).textContent=t.hint,r.addEventListener(`click`,()=>{let n=this.current()??e;t.run(this.view,n),this.toggle(!1,!0)}),r}))}toggle(e,t){if(e&&(this.link=this.current()??this.link,this.many=this.selected()),!e||this.link){if(this.open=e,this.menu.hidden=!e,this.layer.classList.toggle(`open`,e),this.button.setAttribute(`aria-expanded`,String(e)),e){this.fill();let e=[...this.menu.querySelectorAll(`button`)];this.mark(Math.max(0,e.findIndex(e=>e.getAttribute(`aria-checked`)===`true`))),this.menu.focus()}else t&&this.view.focus()}}mark(e){let t=[...this.menu.querySelectorAll(`button`)];this.at=t.length?(e+t.length)%t.length:0,t.forEach((e,t)=>e.classList.toggle(`on`,t===this.at)),this.menu.setAttribute(`aria-activedescendant`,t[this.at]?.id??``)}keys(e){let t=[...this.menu.querySelectorAll(`button`)],n=!0;if(e.key===`Escape`)this.toggle(!1,!0);else if(e.key===`Enter`||e.key===` `)t[this.at]?.click();else if(e.key===`ArrowDown`)this.mark(this.at+1);else if(e.key===`ArrowUp`)this.mark(this.at-1);else if(e.key===`Home`)this.mark(0);else if(e.key===`End`)this.mark(t.length-1);else if(e.key===`Tab`)this.toggle(!1,!0);else if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let r=t.findIndex(t=>t.textContent.toLowerCase().startsWith(e.key.toLowerCase()));r>=0?this.mark(r):n=!1}else n=!1;n&&(e.preventDefault(),e.stopPropagation())}destroy(){this.view.dom.removeEventListener(`mousemove`,this.onMove),this.view.dom.removeEventListener(`mouseleave`,this.onLeave),this.layer.remove()}},Zi=Ue.fromClass(Xi),Qi=e=>t=>{let n=Li(t.state,t.state.selection.main.head);return n?(e(t,n),!0):!1},$i=e=>t=>{let n=t.state.selection.main,r=n.empty?[]:zi(t.state,n.from,n.to);return r.length>=2?(Q(t,Bi(r,e)),!0):Qi((t,n)=>{Ri(n)&&Q(t,Ui(n,e))})(t)},ea=[{key:`Alt-l`,run:e=>{let t=e.plugin(Zi);return!t||!t.current()?!1:(t.toggle(!0,!1),!0)}},{key:`Alt-1`,run:$i(`requires`)},{key:`Alt-2`,run:$i(`uses`)},{key:`Alt-3`,run:$i(`see also`)},{key:`Alt-0`,run:$i(null)},{key:`Alt-e`,run:Qi((e,t)=>{t.kind!==`note`&&Q(e,Wi(t,!t.embed))})}],ta=[Zi,z.baseTheme({"&":{position:`relative`},".cm-link-control":{position:`absolute`,inset:`0`,pointerEvents:`none`,zIndex:`4`,overflow:`visible`},".cm-link-control[hidden]":{display:`none`},".cm-link-leader":{position:`absolute`,left:`0`,top:`0`,width:`100%`,height:`100%`,overflow:`visible`},".cm-link-leader path":{fill:`none`,stroke:`var(--lattice)`,strokeWidth:`1.75`,strokeDasharray:`.1 5`,strokeLinecap:`round`,opacity:`.7`},".cm-link-control:hover .cm-link-leader path, .cm-link-control:focus-within .cm-link-leader path, .cm-link-control.open .cm-link-leader path":{opacity:`1`,animation:`cm-link-run .6s linear infinite`},"@keyframes cm-link-run":{to:{strokeDashoffset:`-5.1`}},"@media (prefers-reduced-motion: reduce)":{".cm-link-leader path":{animation:`none !important`}},".cm-link-button":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,height:`26px`,padding:`0 9px`,font:`12.5px var(--font-ui)`,whiteSpace:`nowrap`,color:`var(--text)`,background:`var(--ground-1)`,border:`1px solid var(--lattice)`,cursor:`pointer`},".cm-link-button:hover, .cm-link-button[aria-expanded=true]":{background:`var(--lattice-soft)`},".cm-link-button:focus-visible":{outline:`2px solid var(--focus-ring)`,outlineOffset:`2px`},".cm-link-menu":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,width:`248px`,padding:`4px`,background:`var(--ground-1)`,border:`1px solid var(--line)`,display:`grid`,gap:`1px`},".cm-link-menu[hidden]":{display:`none`},".cm-link-menu button":{display:`grid`,gap:`1px`,textAlign:`left`,padding:`6px 8px 6px 24px`,background:`none`,border:`0`,color:`var(--text)`,font:`13.5px var(--font-ui)`,cursor:`pointer`,position:`relative`},".cm-link-menu button b":{fontWeight:`600`},".cm-link-menu button span":{fontSize:`12px`,color:`var(--text-faint)`,lineHeight:`1.3`},".cm-link-menu button[aria-checked=true]::before":{content:`"●"`,position:`absolute`,left:`8px`,top:`7px`,fontSize:`10px`,color:`var(--lattice)`},".cm-link-menu:focus":{outline:`none`},".cm-link-menu button.on":{background:`var(--lattice-soft)`},".cm-link-menu:focus-visible button.on":{outline:`2px solid var(--focus-ring)`,outlineOffset:`-2px`}}),ze.of(ea)];function na(e){return t=>{let n=t.matchBefore(/\[\[(?!!)[^\]\n]*$/);if(!n)return null;let r=e().map(e=>({label:e.title,detail:e.folder,apply:(t,n,r,i)=>{let a=`[${e.title}](/${e.id}.md)`,o=r-2,s=t.state.sliceDoc(i,i+2)===`]]`?i+2:i;t.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}})}}));return{from:n.from+2,options:r,filter:!0,validFor:/^[^\]\n]*$/}}}var ra=e=>e.split(`/`).at(-1).replace(/\.[^.]+$/,``).replace(/[-_]+/g,` `).trim(),ia=e=>/[\s()<>]/.test(e)?`<${e}>`:e;function aa(e,t){return async n=>{let r=n.matchBefore(/\[\[![^\]\n]*$/);if(!r)return null;let i=(e,t,n,r,i)=>{let a=t-3,o=e.state.sliceDoc(n,n+2)===`]]`?n+2:n;e.dispatch({changes:{from:a,to:o,insert:r},selection:i?{anchor:a+i[0],head:a+i[1]}:{anchor:a+r.length}})},a=t?.here()??``,o=a.includes(`/`)?a.slice(0,a.lastIndexOf(`/`)):``,s=(t?await t.pictures().catch(()=>[]):[]).map(e=>{let t=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``;return{label:e.path.split(`/`).at(-1),detail:t,picture:e,type:`picture`,boost:t===a?2:+(t===o),info:()=>ca(e),apply:(t,n,r,a)=>{let o=ra(e.path),s=`![${o}](/${ia(e.path)})`;i(t,r,a,s,[2,2+o.length])}}}),c=e().map(e=>e.id);for(let t of e())t.kind&&s.push({label:t.title,detail:t.kind,boost:-1,apply:(e,n,r,a)=>i(e,r,a,ie(t.id,c))});return t&&s.push({label:`Paste or drop a picture to add one`,type:`hint`,boost:-99,apply:()=>void 0}),{from:r.from+3,options:s,filter:!0,validFor:/^[^\]\n]*$/}}}function oa(e,t){return async n=>{let r=n.matchBefore(/\]\([^)\s]*$/);if(!r)return null;let i=t?await t.pictures().catch(()=>[]):[];return{from:r.from+2,options:[...e().map(e=>({label:`/${e.id}.md`,detail:e.title})),...i.map(e=>({label:`/${e.path}`,detail:`picture`,picture:e,type:`picture`,info:()=>ca(e)}))],validFor:/^[^)\s]*$/}}}function sa(e,t){e.alt=``,e.decoding=`async`,typeof t.src==`string`?e.src=t.src:t.src.then(t=>{t&&(e.src=t)})}function ca(e){let t=document.createElement(`div`);t.className=`cm-picture-preview`;let n=document.createElement(`img`);sa(n,e);let r=document.createElement(`div`);return r.className=`cm-picture-size`,r.textContent=e.width&&e.height?`${e.width} × ${e.height}`:``,t.append(n,r),t}function la(e,t=null){return mt({override:[aa(e,t),na(e),oa(e,t)],icons:!1,activateOnTyping:!0,addToOptions:[{position:20,render:e=>{if(!e.picture)return null;let t=document.createElement(`img`);return t.className=`cm-picture-thumb`,t.loading=`lazy`,sa(t,e.picture),t}}]})}var ua=36,da=92,fa=40,pa=/^\$\$([^$]*?[^\\])\$\$/,ma=/^\$((?:[^\s\\])|(?:\S.*?[^\s\\]))\$(?!\d)/,ha=/^\\\((.+?)\\\)/,ga=/^\$\$([^$]*?[^\\])\$\$(?:[ \t]*\([^)\s]+?\))?(?=[ \t]*(?:\n|$))/,_a=/^\\\[([\s\S]+?)\\\](?:[ \t]*\([^)$\r\n]+?\))?(?=[ \t]*(?:\n|$))/;function va(e,t,n){if(t===ua){if(n>e.offset&&e.char(n-1)===da)return-1;let t=e.slice(n,e.end),r=(t.charCodeAt(1)===ua?pa:ma).exec(t);return r?e.addElement(e.elt(`InlineMath`,n,n+r[0].length,[e.elt(`MathMark`,n,n+(r[0].startsWith(`$$`)?2:1)),e.elt(`MathMark`,n+r[0].length-(r[0].startsWith(`$$`)?2:1),n+r[0].length)])):-1}if(t===da&&e.char(n+1)===fa){let t=ha.exec(e.slice(n,e.end));if(!t)return-1;let r=n+t[0].length;return e.addElement(e.elt(`InlineMath`,n,r,[e.elt(`MathMark`,n,n+2),e.elt(`MathMark`,r-2,r)]))}return-1}var ya=2e4;function ba(e,t){let n=t.text.slice(t.pos),r=n.startsWith(`$$`)?ga:n.startsWith(`\\[`)?_a:null;if(!r)return!1;let i=e.lineStart+t.pos,a=e.input,o=r.exec(a.read(i,Math.min(a.length,i+ya)));if(!o)return!1;let s=i+o[0].length;for(;e.lineStart+t.text.length<s&&e.nextLine(););return e.addElement(e.elt(`BlockMath`,i,s)),e.nextLine(),!0}var xa={defineNodes:[{name:`InlineMath`,style:H.special(H.content)},{name:`BlockMath`,block:!0,style:H.special(H.content)},{name:`MathMark`,style:H.processingInstruction}],parseInline:[{name:`InlineMath`,parse:va,before:`Escape`}],parseBlock:[{name:`BlockMath`,parse:ba,before:`FencedCode`}]};function Sa(e){let t;return(t=/^\$\$([\s\S]*?)\$\$/.exec(e))||(t=/^\\\[([\s\S]*?)\\\]/.exec(e))?{tex:t[1],display:!0}:(t=/^\\\(([\s\S]*?)\\\)$/.exec(e))||(t=/^\$([\s\S]*?)\$$/.exec(e))?{tex:t[1],display:!1}:{tex:e,display:!1}}var Ca=class extends V{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-bullet`,e.textContent=`•`,e}},wa=class extends V{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-hr`,e}},Ta=class extends V{name;constructor(e){super(),this.name=e}eq(e){return e.name===this.name}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-lang`,e.textContent=this.name,e}},Ea=class extends V{source;constructor(e){super(),this.source=e}eq(e){return e.source===this.source}toDOM(){let e=document.createElement(`span`);e.className=`cm-lp-imaths`;let{tex:t,display:n}=Sa(this.source);return e.innerHTML=Pe.renderToString(t,{displayMode:n,throwOnError:!1}),e}},Da=class extends V{key;src;alt;left;constructor(e,t,n,r){super(),this.key=e,this.src=t,this.alt=n,this.left=r}eq(e){return e.key===this.key&&e.alt===this.alt&&e.left===this.left}toDOM(e){let t=document.createElement(`span`);t.className=this.left?`cm-lp-picture cm-lp-picture-left`:`cm-lp-picture`;let n=()=>{t.replaceChildren(),t.classList.add(`cm-lp-picture-broken`),t.textContent=this.key.replace(/^notes:/,``),t.title=this.key.startsWith(`code:`)?`not in the repository`:`not in the notes`,e.requestMeasure()},r=document.createElement(`img`);return r.alt=this.alt,this.alt&&(r.title=this.alt),r.loading=`lazy`,r.decoding=`async`,r.onload=()=>e.requestMeasure(),r.onerror=n,t.append(r),typeof this.src==`string`?r.src=this.src:this.src.then(e=>{e?r.src=e:n()}),t}ignoreEvent(){return!1}},Oa=class extends V{path;mount;constructor(e,t){super(),this.path=e,this.mount=t}eq(e){return e.path===this.path}stop=null;toDOM(e){let t=document.createElement(`span`);return t.className=`cm-lp-artifact`,this.stop=this.mount(t),new ResizeObserver(()=>e.requestMeasure()).observe(t),t}destroy(){this.stop?.(),this.stop=null}ignoreEvent(){return!0}},$=U.replace({}),ka=U.replace({widget:new Ca}),Aa=U.replace({widget:new wa}),ja=e=>U.mark({class:e}),Ma=e=>U.line({class:e});function Na(e,t){let n=new Set;if(!t)return n;for(let t of e.selection.ranges){let r=e.doc.lineAt(t.from).number,i=e.doc.lineAt(t.to).number;for(let e=r;e<=i;e++)n.add(e)}return n}function Pa(e){let{state:t}=e,n=Na(t,e.hasFocus),r=e=>n.has(t.doc.lineAt(e).number),i=[],a=(e,n,r)=>{for(let a=t.doc.lineAt(e).number,o=t.doc.lineAt(n).number;a<=o;a++)i.push(Ma(r).range(t.doc.line(a).from))},o=e.visibleRanges;if(o.length){let e=o[0].from,s=o[o.length-1].to,c=/^ {0,3}([-*_])(?: *\1){2,} *$/,l=t.doc.lineAt(e).number,u=t.doc.lineAt(s).number,d=e=>e>=1&&e<=t.doc.lines?t.doc.line(e).text:``;for(let e=l;e<=u;e++){let r=t.doc.line(e);if(r.length!==0||/Code|Math|HTML|Comment/.test(R(t).resolveInner(r.from,1).name))continue;let a=e>1&&t.doc.line(e-1).length===0&&!n.has(e),o=c.test(d(e-1))||c.test(d(e+1));i.push(Ma(a?`cm-lp-gap cm-lp-gap-more`:o?`cm-lp-gap cm-lp-gap-rule`:`cm-lp-gap`).range(r.from))}R(t).iterate({from:e,to:s,enter:e=>{let n=e.name,o=/^(?:ATX|Setext)Heading(\d)$/.exec(n);if(o)a(e.from,e.to,`cm-lp-h${o[1]}`);else switch(n){case`HeaderMark`:{if(r(e.from))break;if((e.node.parent?.name??``).startsWith(`SetextHeading`)){i.push($.range(t.doc.lineAt(e.from).from,e.to));break}let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;n>e.from&&i.push($.range(e.from,n));break}case`EmphasisMark`:case`StrikethroughMark`:r(e.from)||i.push($.range(e.from,e.to));break;case`Emphasis`:i.push(ja(`cm-lp-em`).range(e.from,e.to));break;case`StrongEmphasis`:i.push(ja(`cm-lp-strong`).range(e.from,e.to));break;case`Strikethrough`:i.push(ja(`cm-lp-strike`).range(e.from,e.to));break;case`InlineCode`:if(i.push(ja(`cm-lp-code`).range(e.from,e.to)),!r(e.from)){let t=e.node;for(let e=t.firstChild;e;e=e.nextSibling)e.name===`CodeMark`&&i.push($.range(e.from,e.to))}return!1;case`InlineMath`:return r(e.from)?i.push(ja(`cm-lp-mathsrc`).range(e.from,e.to)):i.push(U.replace({widget:new Ea(t.sliceDoc(e.from,e.to))}).range(e.from,e.to)),!1;case`BlockMath`:case`Table`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`Link`:{let n=e.node,a=[],o=!1;for(let e=n.firstChild;e;e=e.nextSibling)e.name===`LinkMark`&&a.push(e),e.name===`URL`&&(o=!0);let s=a[0],c=a[1],l=n.getChild(`URL`),u=l?t.sliceDoc(l.from,l.to):``,d=u.startsWith(`code:`),f=/^https?:/i.test(u),p=d?t.facet(La)(u)?`cm-lp-link cm-lp-codelink cm-lp-broken`:`cm-lp-link cm-lp-codelink`:f?`cm-lp-link cm-lp-weblink`:`cm-lp-link`;s&&c&&c.from>s.to&&i.push((d?U.mark({class:p,attributes:{title:t.facet(La)(u)?`${u.slice(5)}: not in the repository`:u.slice(5)}}):ja(p)).range(s.to,c.from)),!r(e.from)&&o&&s&&c&&(i.push($.range(s.from,s.to)),i.push($.range(c.from,e.to)));break}case`Image`:{let n=e.node,a=n.getChild(`URL`),o=n.getChildren(`LinkMark`),s=a?t.facet(Ia)(t.sliceDoc(a.from,a.to)):null;if(s&&o.length>=2){let t=new Oa(s.path,s.mount);return r(e.from)?i.push(U.widget({widget:t,side:1}).range(e.to)):i.push(U.replace({widget:t}).range(e.from,e.to)),!1}let c=a?t.facet(Fa)(t.sliceDoc(a.from,a.to)):null;if(!c||o.length<2)break;let l=n.getChild(`LinkTitle`),u=l?t.sliceDoc(l.from+1,l.to-1).trim().toLowerCase():``,d=new Da(c.key,c.src,t.sliceDoc(o[0].to,o[1].from),u===`left`);return r(e.from)?i.push(U.widget({widget:d,side:1}).range(e.to)):i.push(U.replace({widget:d}).range(e.from,e.to)),!1}case`ListMark`:{let n=t.sliceDoc(e.from,e.to);!r(e.from)&&/^[-*+]$/.test(n)?i.push(ka.range(e.from,e.to)):i.push(ja(`cm-lp-listmark`).range(e.from,e.to));break}case`TaskMarker`:i.push(ja(`cm-lp-task`).range(e.from,e.to));break;case`Blockquote`:a(e.from,e.to,`cm-lp-quote`);break;case`QuoteMark`:if(!r(e.from)){let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;i.push($.range(e.from,n))}break;case`HorizontalRule`:r(e.from)||(i.push(Aa.range(e.from,e.to)),a(e.from,e.to,`cm-lp-ruleline`));break;case`FencedCode`:{a(e.from,e.to,`cm-lp-codeblock`);let n=e.node,o=t.doc.lineAt(e.from),s=t.doc.lineAt(e.to),c=n.getChild(`CodeInfo`),l=n.lastChild?.name===`CodeMark`&&n.lastChild.from>=s.from?n.lastChild:null;if(!r(o.from)){i.push(Ma(`cm-lp-fence`).range(o.from));let e=c?t.sliceDoc(c.from,c.to).trim().split(/\s/)[0]:``;i.push((e?U.replace({widget:new Ta(e)}):$).range(o.from,o.to))}return l&&s.number>o.number&&!r(s.from)&&(i.push(Ma(`cm-lp-fence`).range(s.from)),s.to>s.from&&i.push($.range(s.from,s.to))),!1}case`CodeBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`HTMLBlock`:case`CommentBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1}}})}i.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide);let s=new $e;for(let e of i)s.add(e.from,e.to,e.value);return s.finish()}var Fa=Ye.define({combine:e=>e[0]??(()=>null)}),Ia=Ye.define({combine:e=>e[0]??(()=>null)}),La=Ye.define({combine:e=>e[0]??(()=>!1)}),Ra=Ue.fromClass(class{decorations;constructor(e){this.decorations=Pa(e)}update(e){(e.docChanged||e.viewportChanged||e.selectionSet||e.focusChanged||R(e.startState)!==R(e.state))&&(this.decorations=Pa(e.view))}},{decorations:e=>e.decorations}),za=z.theme({".cm-scroller":{fontFamily:`var(--font-text)`,fontSize:`var(--text-size)`,lineHeight:`1.55`},".cm-lp-gap":{lineHeight:`20px`},".cm-lp-gap-rule":{lineHeight:`10px`},".cm-lp-gap-more":{lineHeight:`4px`},".cm-lp-ruleline":{lineHeight:`12px`},".cm-content":{fontVariationSettings:`"opsz" 18`},".cm-lp-h1, .cm-lp-h2, .cm-lp-h3, .cm-lp-h4, .cm-lp-h5, .cm-lp-h6":{fontWeight:`600`,lineHeight:`1.3`,fontVariationSettings:`"opsz" 36`,paddingTop:`.5em !important`},".cm-lp-h1":{fontSize:`26px`},".cm-lp-artifact":{display:`block`,margin:`8px 0 12px`,fontFamily:`var(--font-ui)`,fontSize:`12px`,lineHeight:`1.4`},".cm-lp-h2":{fontSize:`22px`},".cm-lp-h3":{fontSize:`19px`},".cm-lp-h4":{fontSize:`17px`,fontWeight:`700`},".cm-lp-em":{fontStyle:`italic`},".cm-lp-strong":{fontWeight:`700`},".cm-lp-strike":{textDecoration:`line-through`},".cm-lp-code":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,background:`color-mix(in srgb, var(--text) 8%, transparent)`,padding:`.1em .2em`},".cm-lp-link":{color:`var(--lattice)`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-lp-weblink":{textDecorationStyle:`dotted`},".cm-lp-codelink":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,textDecoration:`none`,borderBottom:`1px solid color-mix(in srgb, var(--lattice) 50%, transparent)`},".cm-lp-broken":{color:`var(--rose)`,textDecoration:`line-through`,borderBottomColor:`transparent`},".cm-lp-picture":{display:`block`,margin:`6px auto`,width:`fit-content`,maxWidth:`100%`,lineHeight:`0`},".cm-lp-picture img":{display:`block`,maxWidth:`100%`,height:`auto`},".cm-lp-picture-left":{float:`left`,margin:`4px 16px 4px 0`,maxWidth:`50%`},".cm-lp-picture-broken":{display:`inline-block`,lineHeight:`1.4`,fontFamily:`var(--font-mono)`,fontSize:`.86em`,color:`var(--rose)`,textDecoration:`line-through`,border:`1px dashed color-mix(in srgb, var(--rose) 50%, transparent)`,padding:`6px 10px`,margin:`4px 0`},".cm-lp-bullet":{color:`var(--text-faint)`,display:`inline-block`,minWidth:`1ch`},".cm-lp-listmark, .cm-lp-task":{color:`var(--text-faint)`,fontFamily:`var(--font-mono)`},".cm-lp-quote":{borderLeft:`3px solid var(--lattice)`,paddingLeft:`14px !important`,color:`var(--text-soft)`},".cm-lp-codeblock":{fontFamily:`var(--font-mono)`,fontSize:`13px`,lineHeight:`20px`,background:`color-mix(in srgb, var(--line) 38%, transparent)`,borderLeft:`2px solid var(--line-strong)`,padding:`0 16px !important`},".cm-lp-codeblock.cm-lp-fence":{lineHeight:`12px`,position:`relative`},".cm-lp-lang":{position:`absolute`,top:`8px`,right:`12px`,fontFamily:`var(--font-ui)`,fontSize:`12px`,lineHeight:`16px`,color:`var(--text-faint)`,pointerEvents:`none`},".cm-lp-mathsrc":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,color:`var(--text-soft)`},".cm-lp-imaths .katex":{fontSize:`1.05em`},".cm-lp-imaths .katex-display":{margin:`0`,padding:`6px 0`},".cm-lp-imaths .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-hr":{display:`inline-block`,width:`100%`,borderTop:`1px solid var(--line)`,verticalAlign:`middle`}});function Ba(e){let t=e.split(`#`)[0];return t.startsWith(`/`)&&t.endsWith(`.md`)?t.slice(1,-3):null}function Va(e){let t=e.split(/[#?]/)[0];return t.startsWith(`/`)&&!t.startsWith(`//`)&&/\/[^/]*\.[^./]+$/.test(t)&&!t.endsWith(`.md`)?decodeURI(t.slice(1)):null}var Ha=it.define(),Ua=it.define(),Wa=[at.define({create:()=>U.none,update(e,t){for(let e of t.effects){if(!e.is(Ua))continue;let n=t.state.doc,r=e.value;if(!r)return U.none;let i=U.line({class:`cm-touched cm-touched-${r.who}`});return U.set([...new Set(r.lines)].filter(e=>e>=0&&e<n.lines&&n.line(e+1).text.trim()!==``).sort((e,t)=>e-t).map(e=>i.range(n.line(e+1).from)))}return t.docChanged?e.map(t.changes):e},provide:e=>z.decorations.from(e)}),z.theme({".cm-line.cm-touched-you":{background:`var(--lattice-soft)`,boxShadow:`-10px 0 0 var(--lattice-soft), -13px 0 0 var(--lattice), 10px 0 0 var(--lattice-soft)`},".cm-line.cm-touched-iso":{background:`var(--growth-soft)`,boxShadow:`-10px 0 0 var(--growth-soft), -13px 0 0 var(--growth), 10px 0 0 var(--growth-soft)`}})],Ga=it.define(),Ka=class extends V{key;mount;block;down=null;watch=null;constructor(e,t,n){super(),this.key=e,this.mount=t,this.block=n}eq(e){return e.key===this.key&&e.block===this.block}toDOM(e){let t=document.createElement(this.block?`div`:`span`);return t.className=this.block?`cm-overlay`:`cm-iso-change`,t.contentEditable=`false`,this.down=this.mount(t,this.key),this.watch=new ResizeObserver(()=>e.requestMeasure()),this.watch.observe(t),t}destroy(){this.watch?.disconnect(),this.watch=null,this.down?.(),this.down=null}ignoreEvent(){return!0}get estimatedHeight(){return this.block?120:-1}};function qa(e){return[at.define({create:()=>U.none,update(t,n){for(let t of n.effects){if(!t.is(Ha))continue;let r=n.state.doc;return U.set(t.value.map(t=>{let n=t.line>=r.lines,i=n?r.length:r.line(Math.max(1,t.line+1)).from;return U.widget({widget:new Ka(t.key,e,!0),block:!0,side:n?1:-1}).range(i)}),!0)}return n.docChanged?t.map(n.changes):t},provide:e=>z.decorations.from(e)}),at.define({create:()=>U.none,update(t,n){for(let t of n.effects){if(!t.is(Ga))continue;let r=n.state.doc.length,i=[];for(let e of t.value.marks){let t=Math.max(0,Math.min(r,e.from)),n=Math.max(0,Math.min(r,e.to));n>t&&i.push(U.mark({class:`cm-iso-${e.kind}`}).range(t,n))}for(let n of t.value.inline)i.push(U.widget({widget:new Ka(n.key,e,!1),side:1}).range(Math.max(0,Math.min(r,n.at))));return U.set(i,!0)}return n.docChanged?t.map(n.changes):t},provide:e=>z.decorations.from(e)}),z.theme({".cm-overlay":{cursor:`default`,userSelect:`text`,padding:`10px 0`,display:`flow-root`,whiteSpace:`normal`},".cm-iso-picked":{background:`var(--lattice-soft)`,boxShadow:`inset 0 -2px 0 var(--lattice)`,cursor:`pointer`},".cm-iso-old":{textDecoration:`line-through`,textDecorationColor:`var(--text-faint)`,color:`var(--text-faint)`},".cm-iso-old *":{color:`var(--text-faint) !important`},".cm-iso-change":{cursor:`default`},".cm-iso-by-iso":{background:`var(--growth-soft)`,boxShadow:`inset 0 -1.5px 0 var(--growth)`},".cm-iso-given":{textDecoration:`underline dashed var(--growth)`,textUnderlineOffset:`4px`,textDecorationThickness:`1.5px`}})]}function Ja(e){let t=e.split(`#`)[0].split(`?`)[0];return!t.startsWith(`/`)||t.startsWith(`//`)?null:t.endsWith(`.md`)?{id:decodeURIComponent(t.slice(1,-3)),folder:!1}:t.endsWith(`/`)&&t.length>1?{id:decodeURIComponent(t.slice(1,-1)),folder:!0}:null}var Ya=it.define(),Xa=U.mark({class:`cm-pointed`});function Za(e,t){if(!t)return U.none;let n=[];return R(e).iterate({enter:r=>{if(r.name!==`Link`)return;let i=Li(e,r.from+1);return i&&!i.embed&&i.from===r.from&&Ja(i.url)?.id===t&&n.push(Xa.range(i.from,i.to)),!1}}),U.set(n)}var Qa=at.define({create:()=>({id:``,marks:U.none}),update(e,t){let n=e.id;for(let e of t.effects)e.is(Ya)&&(n=e.value);return n!==e.id||n&&t.docChanged?{id:n,marks:Za(t.state,n)}:e},provide:e=>z.decorations.from(e,e=>e.marks)}),$a=z.theme({".cm-pointed":{backgroundColor:`var(--lattice-soft)`,boxShadow:`0 2px 0 var(--lattice)`}});function eo(e){if(!e)return[Qa,$a];let t=``,n=n=>{let r=n?`${n.folder?`d`:`n`}:${n.id}`:``;r!==t&&(t=r,e(n))};return[Qa,$a,z.domEventHandlers({pointermove(e,t){if(e.pointerType!==`mouse`)return!1;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:Li(t.state,r);return n(i&&!i.embed?Ja(i.url):null),!1},pointerleave(){return n(null),!1}})]}var to=z.theme({".cm-scroller":{fontFamily:`var(--font-mono)`,fontSize:`14px`,lineHeight:`1.6`}}),no=z.theme({"&":{color:`var(--text)`,backgroundColor:`transparent`,fontSize:`16px`},"&.cm-focused":{outline:`none`},".cm-scroller":{overflow:`visible`},".cm-content":{padding:`12px 0 40vh`,caretColor:`var(--lattice)`},".cm-line":{padding:`0 2px`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--lattice)`,borderLeftWidth:`2px`},".cm-selectionBackground":{backgroundColor:`color-mix(in srgb, var(--lattice) 22%, transparent) !important`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`color-mix(in srgb, var(--lattice) 40%, transparent) !important`},".cm-placeholder":{color:`var(--text-faint)`},".cm-tooltip-autocomplete":{background:`var(--ground-1)`,border:`1px solid var(--line-strong)`,fontFamily:`var(--font-ui)`,fontSize:`13px`},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:`var(--font-ui)`,maxHeight:`16em`},".cm-tooltip-autocomplete > ul > li":{padding:`6px 10px !important`,lineHeight:`1.3`},".cm-picture-thumb":{width:`32px`,height:`32px`,objectFit:`cover`,verticalAlign:`middle`,marginRight:`8px`,background:`var(--ground-2)`},".cm-tooltip-autocomplete > ul > li:has(.cm-picture-thumb)":{padding:`3px 10px !important`},".cm-picture-preview":{padding:`8px`},".cm-picture-preview img":{display:`block`,maxWidth:`240px`,maxHeight:`240px`},".cm-picture-size":{fontFamily:`var(--font-ui)`,fontSize:`12px`,color:`var(--text-faint)`,marginTop:`4px`},".cm-completionInfo":{background:`var(--ground-1)`,border:`1px solid var(--line-strong)`,padding:`0`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{background:`var(--lattice-soft)`,color:`var(--text)`},".cm-completionDetail":{color:`var(--text-faint)`,fontStyle:`normal`,marginLeft:`10px`}}),ro=ot.define([{tag:H.heading,fontWeight:`700`,color:`var(--text)`},{tag:H.strong,fontWeight:`700`},{tag:H.emphasis,fontStyle:`italic`},{tag:H.strikethrough,textDecoration:`line-through`},{tag:[H.link,H.url],color:`var(--lattice)`},{tag:[H.processingInstruction,H.punctuation,H.contentSeparator],color:`var(--text-faint)`},{tag:H.monospace,color:`var(--text-soft)`},{tag:H.quote,color:`var(--text-soft)`,fontStyle:`italic`}]);function io(e){let t=e.selection.main;return{line:e.doc.lineAt(t.to).number-1,from:t.from,to:t.to}}function ao(e){let t=e=>[...e??[]].filter(e=>e.type.startsWith(`image/`));return z.domEventHandlers({paste(n,r){let i=t(n.clipboardData?.files);return i.length?(n.preventDefault(),e(i,r.state.selection.main.head,!0),!0):!1},drop(n,r){let i=t(n.dataTransfer?.files);return i.length?(n.preventDefault(),e(i,r.posAtCoords({x:n.clientX,y:n.clientY})??r.state.selection.main.head,!1),!0):!1}})}function oo(e,t){let n=Xe.create({doc:t.doc,extensions:[mn(),Ke(),z.lineWrapping,Me({base:Ce,extensions:[xa],completeHTMLTags:!1,codeLanguages:Ae}),Be(ro),Be(xe),no,...t.source?[to]:[Ra,za,Ei,Di,ta,...t.embeds?[gi.of(t.embeds)]:[],...t.codeBroken?[La.of(t.codeBroken)]:[],...t.pictures?[Fa.of(t.pictures)]:[],...t.artifacts?[Ia.of(t.artifacts)]:[]],gt(),Xe.languageData.of(()=>[{closeBrackets:{brackets:[`(`,`[`]}}]),...t.mountOverlay?[qa(t.mountOverlay)]:[],Wa,eo(t.onPoint),...t.readOnly?[Xe.readOnly.of(!0),z.editable.of(!1)]:[],la(t.notes,t.pictureSource??null),...t.onPictures&&!t.readOnly?[ao(t.onPictures)]:[],He(t.placeholder??`Write the note here. # for a heading, [[ to link to another note, [[! to show a picture, $x$ for maths.`),z.contentAttributes.of({"aria-label":t.label,spellcheck:`true`,autocapitalize:`sentences`,autocorrect:`on`}),ze.of([{key:`Mod-s`,preventDefault:!0,run:()=>(t.onSave(),!0)},{key:`Mod-Enter`,preventDefault:!0,run:e=>(t.onAsk?.(io(e.state)),!!t.onAsk)},...Pi,...ft,...ht,hi,...mi,...jn]),z.domEventHandlers((()=>{let e=(e,n)=>{if(!t.picking?.())return;let r=e.state.selection,i=r.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to}));i.length?(t.onPick?.(i),setTimeout(()=>e.dispatch({selection:{anchor:Math.min(r.main.head,e.state.doc.length)}}),0)):n&&t.onUnpick?.(r.main.head)};return{mouseup:(t,n)=>(e(n,t.detail===1),!1),touchend:(t,n)=>(e(n,!1),!1),keyup:(t,n)=>(t.key===`Shift`&&e(n,!1),!1)}})()),z.domEventHandlers({mousedown(e,n){if(!t.onFollow||!(e.ctrlKey||e.metaKey)||e.button!==0)return!1;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:Li(n.state,r),a=i?i.embed?Va(i.url):Ba(i.url)??Va(i.url):null;return a!==null&&(e.preventDefault(),t.onFollow(a),!0)}}),z.updateListener.of(e=>{e.docChanged&&t.onChange(e.state.doc.toString()),t.onCursor&&(e.selectionSet||e.docChanged)&&t.onCursor(io(e.state))})]});return new z({state:n,parent:e})}function so(e,t){if(t===e.state.doc.toString())return;let n=Math.min(e.state.selection.main.head,t.length);e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},selection:{anchor:n}})}var co=l(`<p class="same svelte-18j5w6l">This picture is already in the notes as <code> </code>.</p>`),lo=l(`<code> </code> is taken: Enter makes it <code> </code>`,1),uo=l(`<code> </code>`),fo=l(`<label class="svelte-18j5w6l"><span class="svelte-18j5w6l">name</span> <span class="name svelte-18j5w6l"><input class="field mono svelte-18j5w6l" spellcheck="false" autocomplete="off" aria-label="Its name"/><span class="ext svelte-18j5w6l"> </span></span></label> <p><!></p>`,1),po=l(`<button class="btn" type="button"> </button>`),mo=l(`<div class="picture-name svelte-18j5w6l" role="dialog" aria-label="Name the picture" tabindex="-1"><img alt="" class="svelte-18j5w6l"/> <div class="fields svelte-18j5w6l"><!> <label class="svelte-18j5w6l"><span class="svelte-18j5w6l">what it shows</span> <input class="field" placeholder="Iso reads this, not the picture" aria-label="What it shows" autocomplete="off"/></label> <div class="actions svelte-18j5w6l"><!> <button class="btn" type="button">Cancel</button> <button class="btn primary" type="button"> </button></div></div></div>`);function ho(n,r){x(r,!0);let a=M(()=>({"image/png":`png`,"image/jpeg":`jpg`,"image/gif":`gif`,"image/webp":`webp`,"image/svg+xml":`svg`,"image/avif":`avif`})[r.file.type]??`png`),o=N(e(r.suggested)),s=N(``),l=N(!1),f=N(void 0),p,v=M(()=>Ie(P(o))||`picture`),y=M(()=>`${r.folder?r.folder+`/`:``}${P(v)}.${P(a)}`),D=M(()=>r.taken(P(y))),O=M(()=>{for(let e=2;;e++)if(!r.taken(`${r.folder?r.folder+`/`:``}${P(v)}-${e}.${P(a)}`))return`${P(v)}-${e}`}),k=M(()=>r.same!==null&&!P(l));te(()=>{P(f)?(P(f).focus(),P(f).select()):p.focus()});function re(e){e.key===`Escape`?(e.preventDefault(),r.onDone(null)):e.key===`Enter`&&(e.preventDefault(),F())}function F(){if(!P(k)&&P(D)){C(o,P(O),!0);return}let e=P(k)?r.same:P(y);r.onDone({path:e,alt:P(s).trim()||ra(e),save:!P(k)})}var I=mo();let ie;var ae=g(I),oe=d(ae,2),se=g(oe),ce=e=>{var n=co(),i=d(g(n)),a=_(i,!0);T(),j(n),m(()=>u(a,r.same)),t(e,n)},le=e=>{var n=fo(),r=h(n),s=d(g(r),2),c=g(s);w(c),b(c,e=>C(f,e),()=>P(f));var l=d(c),p=_(l);j(s),j(r);var v=d(r,2);let x;var T=g(v),ee=e=>{var n=lo(),r=h(n),i=_(r,!0),o=d(r,2),s=_(o);m(()=>{u(i,P(y)),u(s,`${P(O)??``}.${P(a)??``}`)}),t(e,n)},k=e=>{var n=uo(),r=_(n,!0);m(()=>u(r,P(y))),t(e,n)};i(T,e=>{P(D)?e(ee):e(k,-1)}),j(v),m(()=>{u(p,`.${P(a)??``}`),x=E(v,1,`path svelte-18j5w6l`,null,x,{taken:P(D)})}),S(c,()=>P(o),e=>C(o,e)),t(e,n)};i(se,e=>{P(k)?e(ce):e(le,-1)});var ue=d(se,2),de=d(g(ue),2);w(de),b(de,e=>p=e,()=>p),j(ue);var fe=d(ue,2),pe=g(fe),me=e=>{var n=po(),r=_(n,!0);m(()=>u(r,P(l)?`Use the one there`:`Save a copy`)),c(`click`,n,()=>{C(l,!P(l)),P(l)&&requestAnimationFrame(()=>{P(f)?.focus(),P(f)?.select()})}),t(e,n)};i(pe,e=>{r.same!==null&&e(me)});var he=d(pe,2),L=d(he,2),ge=_(L,!0);j(fe),j(oe),j(I),m(()=>{ie=ee(I,``,ie,{left:`${r.at.left??``}px`,top:`${r.at.top??``}px`}),A(ae,`src`,r.src),u(ge,P(k)?`Show it`:`Save`)}),c(`keydown`,I,re),S(de,()=>P(s),e=>C(s,e)),c(`click`,he,()=>r.onDone(null)),c(`click`,L,F),t(n,I),ne()}a([`keydown`,`click`]);var go=l(`<span class="soft picked svelte-192cp36" role="status"> </span>`),_o=l(`<div class="between svelte-192cp36"><!> <div class="ask svelte-192cp36"><i class="dia open svelte-192cp36" aria-hidden="true"></i> <textarea rows="1" aria-label="Ask Iso" class="svelte-192cp36"></textarea></div> <div class="foot svelte-192cp36"><span class="grow"></span> <button class="link faint svelte-192cp36" type="button">cancel</button> <button class="btn primary" type="button">ask Iso</button></div></div>`),vo=l(`<div class="prose said svelte-192cp36"></div>`),yo=l(`<span class="faint"> </span>`),bo=l(`<div class="between working svelte-192cp36" aria-live="polite"><!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="soft doing svelte-192cp36"> <!></span> <span class="grow"></span> <button class="link svelte-192cp36" type="button">stop</button></div></div>`),xo=l(`<div class="between stopped svelte-192cp36" role="alert"><p class="bad svelte-192cp36"> </p> <div class="foot svelte-192cp36"><span class="grow"></span><button class="link svelte-192cp36" type="button">dismiss</button></div></div>`),So=l(`<p class="soft lost svelte-192cp36"><span class="strike svelte-192cp36"> </span> </p>`),Co=l(`<div class="between stopped svelte-192cp36"><p class="label"> </p> <!> <div class="foot svelte-192cp36"><span class="grow"></span><button class="btn remove" type="button">remove</button></div></div>`),wo=l(`<p class="label">The place this was written for is no longer in the note, so it is shown here. Keeping it adds it at the end.</p>`),To=l(`<textarea class="revision svelte-192cp36" aria-label="Iso's text, to edit"></textarea>`),Eo=l(`<p class="label"> </p>`),Do=l(`<button class="btn edit" type="button">done</button>`),Oo=l(`<button class="btn edit" type="button">edit</button>`),ko=l(`<div class="between svelte-192cp36"><!> <!> <!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="grow"></span> <button class="btn keep" type="button">keep</button> <!> <button class="btn remove" type="button">remove</button></div></div>`);function Ao(e,r){x(r,!0);let a=D(r,`iso`,7),s=M(()=>r.key.startsWith(`p:`)?a().proposals.find(e=>e.id===r.key.slice(2)):void 0),l=M(()=>P(s)&&a().editing?.id===P(s).id?a().editing:null),v=M(()=>!!P(s)&&a().busy===P(s)?.id),w=M(()=>a().changes.filter(e=>!e.at)),T=N(``),E=N(void 0);o(()=>{r.key===`prompt`&&p().then(()=>P(E)?.focus())});let ee=M(()=>a().asking?.steps.at(-1)?.said??``),k=M(()=>(a().asking?.regions.length??0)>0),te=M(()=>a().prompt?.mode===`rewrite`),F=M(()=>a().prompt?.regions.length??0),I=M(()=>!!P(T).trim()&&(!P(te)||P(F)>0));function ie(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),a().ask(P(T))):e.key===`Escape`&&(e.preventDefault(),a().prompt=null)}var ae=O(),oe=h(ae),se=e=>{var n=_o(),r=g(n),o=e=>{var n=go(),r=_(n,!0);m(()=>u(r,P(F)===0?`select text in the note to rewrite`:`rewriting ${P(F)} ${P(F)===1?`passage`:`passages`} · select more, or click one to drop it`)),t(e,n)};i(r,e=>{P(te)&&e(o)});var s=d(r,2),l=d(g(s),2);y(l),b(l,e=>C(E,e),()=>P(E)),j(s);var f=d(s,2),p=d(g(f),2),h=d(p,2);j(f),j(n),m(()=>{A(l,`placeholder`,P(te)?`how should Iso rewrite it?`:`what should Iso write here?`),h.disabled=!P(I)}),c(`keydown`,l,ie),S(l,()=>P(T),e=>C(T,e)),c(`click`,p,()=>a().prompt=null),c(`click`,h,()=>a().ask(P(T))),t(e,n)},ce=e=>{var n=bo(),r=g(n),o=e=>{var n=vo();f(n,()=>De(a().asking.text),!0),j(n),re(n,(e,t)=>Ne?.(e,t),()=>a().asking.text),t(e,n)};i(r,e=>{a().asking.text&&!P(k)&&e(o)});var s=d(r,2),l=d(g(s),2),p=g(l,!0),h=d(p),v=e=>{var n=yo(),r=_(n);m(()=>u(r,`· ${P(ee)??``}`)),t(e,n)};i(h,e=>{P(ee)&&e(v)}),j(l);var y=d(l,4);j(s),j(n),m(()=>u(p,a().asking.text?P(k)?`Iso is rewriting`:`Iso is writing`:`Iso is thinking`)),c(`click`,y,()=>a().halt()),t(e,n)},le=e=>{var n=xo(),r=g(n),i=_(r,!0),o=d(r,2),s=d(g(o));j(o),j(n),m(()=>u(i,a().failed.message)),c(`click`,s,()=>a().failed=null),t(e,n)},ue=e=>{var r=Co(),i=g(r),o=_(i),s=d(i,2);n(s,17,()=>P(w),e=>e.key,(e,n)=>{var r=So(),i=g(r),a=_(i,!0),o=d(i);j(r),m((e,t)=>{u(a,e),u(o,` → ${t??``}`)},[()=>P(n).proposal.regions[P(n).k].old.text.trim(),()=>P(n).proposal.regions[P(n).k].new.trim()||`(taken out)`]),t(e,r)});var l=d(s,2),f=d(g(l));j(l),j(r),m(()=>u(o,`${P(w).length===1?`One change Iso offered is`:`${P(w).length} changes Iso offered are`} for text that is no longer in the note as it was, so ${P(w).length===1?`it`:`they`} cannot be kept.`)),c(`click`,f,()=>{for(let e of P(w))a().discardChange(e)}),t(e,r)},de=e=>{var n=ko(),r=g(n),o=e=>{var n=wo();t(e,n)},p=M(()=>!a().placed(P(s)));i(r,e=>{P(p)&&e(o)});var h=d(r,2),b=e=>{var n=To();y(n),m(e=>A(n,`rows`,e),[()=>Math.max(3,P(l).text.split(`
7
+ `).length+1)]),S(n,()=>P(l).text,e=>P(l).text=e),t(e,n)},x=e=>{var n=vo();f(n,()=>De(P(s).text),!0),j(n),re(n,(e,t)=>Ne?.(e,t),()=>({given:P(s).text,copy:!0})),t(e,n)};i(h,e=>{P(l)?e(b):e(x,-1)});var C=d(h,2),w=e=>{var n=Eo(),r=_(n,!0);m(()=>u(r,P(s).notice)),t(e,n)};i(C,e=>{P(s).notice&&e(w)});var T=d(C,2),E=d(g(T),4),ee=d(E,2),D=e=>{var n=Do();c(`click`,n,()=>a().done(P(s))),t(e,n)},O=e=>{var n=Oo();m(()=>n.disabled=P(v)),c(`click`,n,()=>a().edit(P(s))),t(e,n)};i(ee,e=>{P(l)?e(D):e(O,-1)});var k=d(ee,2);j(T),j(n),m(()=>{A(n,`data-proposal`,P(s).id),E.disabled=P(v),k.disabled=P(v)}),c(`click`,E,()=>a().keep(P(s))),c(`click`,k,()=>a().discard(P(s))),t(e,n)};i(oe,e=>{r.key===`prompt`?e(se):r.key===`asking`&&a().asking?e(ce,1):r.key===`failed`&&a().failed?e(le,2):r.key===`lost`&&P(w).length?e(ue,3):P(s)&&e(de,4)}),t(e,ae),ne()}a([`keydown`,`click`]);var jo=l(`<span class="label who svelte-1o10yjh"> </span>`),Mo=l(`<!> <span class="act svelte-1o10yjh"><button class="keep svelte-1o10yjh" type="button" aria-label="Keep this change">keep</button><button class="remove svelte-1o10yjh" type="button" aria-label="Remove this change">remove</button></span>`,1),No=l(`<span class="gone svelte-1o10yjh">the passage above is taken out</span>`),Po=l(`<pre class="new svelte-1o10yjh"> </pre>`),Fo=l(`<div class="new prose svelte-1o10yjh"></div>`),Io=l(`<div><!> <div class="foot svelte-1o10yjh"><i class="dia svelte-1o10yjh" aria-hidden="true"></i><span class="label">in place of the lines struck through above</span><span class="grow"></span><!></div></div>`),Lo=l(`<span class="new svelte-1o10yjh"></span>`),Ro=l(`<span class="gone svelte-1o10yjh">taken out</span>`),zo=l(`<span class="change svelte-1o10yjh"><!> <!></span>`);function Bo(e,n){x(n,!0);let r=e=>{var r=Mo(),o=h(r),l=e=>{var n=jo(),r=_(n,!0);m(()=>{A(n,`title`,P(a)?.proposal.asked),u(r,P(v))}),t(e,n)};i(o,e=>{P(v)&&e(l)});var f=d(o,2),p=g(f),y=d(p);j(f),m(()=>{p.disabled=P(s),y.disabled=P(s)}),c(`click`,p,()=>P(a)&&n.iso.keepChange(P(a))),c(`click`,y,()=>P(a)&&n.iso.discardChange(P(a))),t(e,r)},a=M(()=>n.iso.changes.find(e=>e.key===n.key)),o=M(()=>P(a)?P(a).proposal.regions[P(a).k].new:``),s=M(()=>n.iso.busy===n.key||n.iso.busy===`all`),l=M(()=>De(P(o).trim())),p=M(()=>P(l).replace(/^<p>([\s\S]*)<\/p>\s*$/,`$1`)),v=M(()=>P(a)?ye(P(a).proposal.who):``);var y=O(),b=h(y),S=e=>{var s=Io();let c;var p=g(s),h=e=>{var n=No();t(e,n)},v=M(()=>!P(o).trim()),y=e=>{var n=Po(),r=_(n,!0);m(e=>u(r,e),[()=>P(o).replace(/^\n+|\s+$/g,``)]),t(e,n)},b=e=>{var n=Fo();f(n,()=>P(l),!0),j(n),re(n,(e,t)=>Ne?.(e,t),()=>P(l)),t(e,n)};i(p,e=>{P(v)?e(h):P(a).code?e(y,1):e(b,-1)});var x=d(p,2),S=d(g(x),3);r(S),j(x),j(s),m(()=>{c=E(s,1,`change block svelte-1o10yjh`,null,c,{code:P(a).code}),A(s,`data-change`,n.key)}),t(e,s)},C=e=>{var a=zo(),s=g(a),c=e=>{var n=Lo();f(n,()=>P(p),!0),j(n),t(e,n)},l=M(()=>P(o).trim()),u=e=>{var n=Ro();t(e,n)};i(s,e=>{P(l)?e(c):e(u,-1)});var h=d(s,2);r(h),j(a),m(()=>A(a,`data-change`,n.key)),t(e,a)};i(b,e=>{P(a)?.block?e(S):P(a)&&e(C,1)}),t(e,y),ne()}a([`click`]);var Vo=l(`<p class="said svelte-hrl8lz" role="status"> </p>`),Ho=l(`<div></div> <!> <!>`,1);function Uo(e,n){x(n,!0);let a=D(n,`iso`,7),c=D(n,`touched`,3,null),l=D(n,`lens`,19,()=>[]),f,p=N(void 0),g=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/avif`],y=N(null),S=N(null),w,T=e=>{C(S,e,!0),clearTimeout(w),w=setTimeout(()=>C(S,null),8e3)};async function ee(e,t,r){if(!P(p)||P(y))return;let i=n.note.id,a=!i.startsWith(`@`),o=i.startsWith(`@understanding/`)?i.slice(15):null,s=a?i:o??`pictures`,c=e=>a&&e.startsWith(`${i}/`)?ia(e.slice(i.lastIndexOf(`/`)+1)):`/${ia(e)}`,l=[];try{l=await L.api.pictures()}catch{}let u=new Set(l.map(e=>e.path));for(let n of e){if(!g.includes(n.type)){T(`${n.name||`That`} isn't a picture isorite keeps: png, jpg, gif, webp, svg and avif are.`);continue}if(n.size>2e7){T(`${n.name||`That picture`} is larger than isorite takes (${_t/1e6} MB).`);continue}let e=new Uint8Array(await n.arrayBuffer()),i=await be(e),a=l.find(e=>e.sha256===i)?.path??null,o=URL.createObjectURL(n),d=P(p),m=d.coordsAtPos(Math.min(t,d.state.doc.length)),h=f.getBoundingClientRect(),_=await new Promise(e=>{C(y,{file:n,src:o,folder:s,same:a,onDone:e,suggested:r||!n.name?Fe():Ie(n.name)||`picture`,taken:e=>u.has(e),at:{left:Math.max(16,Math.min(m?.left??h.left,innerWidth-476)),top:Math.min((m?.bottom??h.top)+6,innerHeight-220)}})});if(C(y,null),URL.revokeObjectURL(o),!_)continue;if(_.save)try{let t=await L.api.savePicture(_.path,e);l.push(t),u.add(t.path)}catch(e){T(`It wasn't saved: ${e.message}`);continue}let v=`![${_.alt.replace(/[[\]]/g,``)}](${c(_.path)})`;d.dispatch({changes:{from:t,insert:v},selection:{anchor:t+v.length}}),t+=v.length}P(p).focus()}let O=M(()=>n.source||!a()?{lines:0,chars:0}:a().head),A=M(()=>{if(!a())return{blocks:[],marks:[],inline:[]};let e=e=>t=>({kind:e,from:t.from-P(O).chars,to:t.to-P(O).chars});return{blocks:a().layout.blocks.map(e=>({key:e.key,line:Math.max(0,e.line-P(O).lines)})).sort((e,t)=>e.line-t.line),marks:[...a().layout.picked.map(e(`picked`)),...a().layout.old.map(e(`old`)),...l().map(t=>e(t.kind)(t))].filter(e=>e.to>0),inline:a().layout.inline.map(e=>({key:e.key,at:e.at-P(O).chars})).filter(e=>e.at>=0)}});te(()=>{let e=oo(f,{doc:n.source?n.note.text:n.note.body,source:n.source,label:n.source?`The note's file`:`The note`,notes:()=>L.listing.notes.filter(e=>e.id!==n.note.id).map(e=>({id:e.id,title:e.title,folder:e.dir,...e.kind?{kind:e.kind}:{}})),onPictures:(e,t,n)=>{ee(e,t,n)},pictureSource:{pictures:async()=>(await L.api.pictures()).map(e=>({path:e.path,width:e.width,height:e.height,src:Se(L.api,{path:e.path,from:`notes`})})),here:()=>n.note.id},onChange:e=>n.source?n.note.setText(e):n.note.setBody(e),onSave:()=>{n.note.save()},onFollow:e=>{I(me(e))},embeds:{find:pe,open:e=>{I(me(e))}},onPoint:e=>Oe.set(`note`,e?{...e,who:`you`}:null),codeBroken:e=>L.listing.notes.find(e=>e.id===n.note.id)?.broken?.includes(e)??!1,pictures:e=>{let t=Le(e,n.note.id);return t?{key:`${t.from}:${t.path}`,src:Se(L.api,t)}:null},artifacts:e=>{let t=Ht(e,n.note.id);return t?{path:t,mount:e=>{let n=r(Xt,{target:e,props:{path:t}});return()=>{k(n)}}}:null},...a()?{onAsk:e=>{let t=n.note.text.slice(e.from+P(O).chars,e.to+P(O).chars).trim();t&&Te.add({kind:`passage`,id:n.note.id,title:n.note.fields.title||n.note.id,text:t}),Re.to(`iso`),requestAnimationFrame(()=>document.getElementById(`iso-box`)?.focus())},onCursor:e=>{a().cursor={line:e.line+P(O).lines,from:e.from+P(O).chars,to:e.to+P(O).chars}},picking:()=>a().picking,onPick:e=>a().pick(e.map(e=>({from:e.from+P(O).chars,to:e.to+P(O).chars}))),onUnpick:e=>a().unpick(e+P(O).chars),mountOverlay:(e,t)=>{let n=r(t.startsWith(`r:`)?Bo:Ao,{target:e,props:{iso:a(),key:t}});return()=>{k(n)}}}:{placeholder:s(()=>n.placeholder)??`Write what you understand, what you do not, and what you want from Iso. [[ links a note it should rest on.`}});return C(p,e),()=>{e.destroy(),Oe.set(`note`,null)}}),o(()=>{n.note.revision,s(()=>{P(p)&&so(P(p),n.source?n.note.text:n.note.body)})}),o(()=>{let e=c(),t=P(O).lines;P(p)&&P(p).dispatch({effects:Ua.of(e?{who:e.who,lines:e.lines.map(e=>e-t)}:null)})}),o(()=>{let e=Oe.onAtlas;P(p)&&P(p).dispatch({effects:Ya.of(e)})}),o(()=>{let{blocks:e,marks:t,inline:n}=P(A);P(p)&&P(p).dispatch({effects:[Ha.of(e),Ga.of({marks:t,inline:n})]})});var j=Ho(),re=h(j);let F;b(re,e=>f=e,()=>f);var ie=d(re,2),ae=e=>{ho(e,v(()=>P(y)))};i(ie,e=>{P(y)&&e(ae)});var oe=d(ie,2),se=e=>{var n=Vo(),r=_(n,!0);m(()=>u(r,P(S))),t(e,n)};i(oe,e=>{P(S)&&e(se)}),m(()=>F=E(re,1,`editor svelte-hrl8lz`,null,F,{source:n.source})),t(e,j),ne()}export{qt as a,Ut as c,Lt as d,Nt as f,Ua as i,Rt as l,oo as n,zt as o,Ot as p,so as r,Bt as s,Uo as t,Wt as u};
@@ -1,2 +1,2 @@
1
- import{_ as e,o as t,u as n}from"./CX-xckzu.js";import{a as r,c as i,d as a,g as o,h as s,i as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./BunrC_8P.js";import{u as _}from"./8wVGBFSs.js";function v(e,t){return{type:`info`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
1
+ import{_ as e,o as t,u as n}from"./DfCZPwp1.js";import{a as r,c as i,d as a,g as o,h as s,i as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./DX4bJJO0.js";import{u as _}from"./-2Meesge.js";function v(e,t){return{type:`info`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
2
2
  `):void 0}}var y=[c(`showInfo`),c(`info`),r,h,f,l,g,p,d,m];function b(e){let t=new s(u(e,y,`info`),y,`info`),n={$type:`Info`};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let e=t.kind;if(e===2?n.accDescr=i(t.take()):e===3?n.accTitle=o(t.take()):e===4?n.title=a(t.take()):t.fail(`a title or the end of input`),t.kind===-1)break;for(t.kind!==5&&t.fail(`a line break or the end of input`);t.kind===5;)t.i++}return n}var x=`1.10.0`;function S(r,i,a){let o=a.fontSize??16,s=a.measurer??_(a.fontFamily,a.fontFamilyMono),c=a.padding??8,l=n(r.title,!1,s,o,4e3,1),u=l.height>0?l.height+8:0,d=n(`Pele v${x}`,!1,s,o,4e3),f=Math.ceil(Math.max(l.width,d.width)+2*c),p=Math.ceil(u+d.height+2*c),m=t(l,f/2,c+l.height/2,` class="pele-title" font-weight="var(--_tw)"`)+t(d,f/2,c+u+d.height/2,` class="pele-version" fill="var(--_m)"`);return{svg:e(`info`,f,p,o,a,r,m),width:f,height:p,links:[]}}var C={type:`info`,parse:(e,t,n)=>v(b(e),n),render:S};export{C as info};