dorkos 0.81.0 → 0.83.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 (99) hide show
  1. package/README.md +4 -0
  2. package/dist/bin/cli.js +8980 -3197
  3. package/dist/client/assets/{AboutPage-CG2PlGB9.js → AboutPage-BCPZr0Kt.js} +1 -1
  4. package/dist/client/assets/{AppearancePage-uc6vrPjQ.js → AppearancePage-CJfCCSBv.js} +1 -1
  5. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CZ9OxU7F.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Rg6hvlIh.js} +1 -1
  6. package/dist/client/assets/{BlintzCanvas-C0dWt42q.js → BlintzCanvas-CUSuHP_Q.js} +23 -23
  7. package/dist/client/assets/{CanvasCsvContent-DpTj502y.js → CanvasCsvContent-B3gnlTxe.js} +1 -1
  8. package/dist/client/assets/{CanvasFileContent-BfbMK0ME.js → CanvasFileContent-C2PyVniO.js} +2 -2
  9. package/dist/client/assets/{CanvasModel3dContent-BjkWZBVq.js → CanvasModel3dContent-BU77_Cf0.js} +2 -2
  10. package/dist/client/assets/{CodeMirrorDiff-BtkeZDXX.js → CodeMirrorDiff-Dsell_F0.js} +1 -1
  11. package/dist/client/assets/{CodeMirrorEditor-C2mjcn0M.js → CodeMirrorEditor-DW4-Dilh.js} +1 -1
  12. package/dist/client/assets/ConnectionAccessLists-C6PZsSaI.js +1 -0
  13. package/dist/client/assets/ConnectionsPage-d1mpye9j.js +1 -0
  14. package/dist/client/assets/{ConventionPage-CGoZt1nC.js → ConventionPage-Dto1Cfs1.js} +3 -3
  15. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-Dl7G5M5j.js → FloatingTanStackRouterDevtools-CqogiFob-B8JWq1xE.js} +1 -1
  16. package/dist/client/assets/HandlePage-D9x_OTks.js +1 -0
  17. package/dist/client/assets/{LexicalField-CCu1Ihg3.js → LexicalField-BymSjNLW.js} +1 -1
  18. package/dist/client/assets/{ManagesPage-c1KIJkFC.js → ManagesPage-D0ykMsYy.js} +1 -1
  19. package/dist/client/assets/{Model3dViewer-BO0fwX9g.js → Model3dViewer-DpzkRmRI.js} +1 -1
  20. package/dist/client/assets/NamePage-zm23PjaF.js +1 -0
  21. package/dist/client/assets/{NotificationsPage-BVSSDb9i.js → NotificationsPage-C4Ol8NO6.js} +1 -1
  22. package/dist/client/assets/PermissionsPage-BEtP78wl.js +1 -0
  23. package/dist/client/assets/{PersonalityPopover-CI9kf81k.js → PersonalityPopover-xJuTkLLJ.js} +1 -1
  24. package/dist/client/assets/PhotoPage-DlqgNQWM.js +1 -0
  25. package/dist/client/assets/{RoomsPage-B7s1XM1i.js → RoomsPage-CeB_8k-m.js} +1 -1
  26. package/dist/client/assets/{RunsOnPopover-LTrQIz4S.js → RunsOnPopover-DT6aWGUP.js} +1 -1
  27. package/dist/client/assets/{SessionsPage-FLHcXJLg.js → SessionsPage-CoZhOOr9.js} +2 -2
  28. package/dist/client/assets/SkillsPage-C8bahTTW.js +1 -0
  29. package/dist/client/assets/{TasksPage-CjTt9J5n.js → TasksPage-CuFN--Cj.js} +1 -1
  30. package/dist/client/assets/ToolsPage-C5cJiedq.js +2 -0
  31. package/dist/client/assets/{TopologyGraph-CRAGEuPI.js → TopologyGraph-3rXK5QTB.js} +2 -2
  32. package/dist/client/assets/{agent-browser-DH-qe6tt.js → agent-browser-DaDOSH9H.js} +1 -1
  33. package/dist/client/assets/{highlighted-body-KPVGNVTW-CKyNuC2a.js → highlighted-body-KPVGNVTW-CGXZGdzv.js} +1 -1
  34. package/dist/client/assets/{index-BmHCO7JA.js → index-3xtUyFwf.js} +1 -1
  35. package/dist/client/assets/{index-Cn5LkLHK.js → index-4zzP7Qsj.js} +1 -1
  36. package/dist/client/assets/{index-CugRpUpy.js → index-B2AJ6tkg.js} +1 -1
  37. package/dist/client/assets/{index-C_H8Na06.js → index-B9qRpVKa.js} +3 -3
  38. package/dist/client/assets/index-BMR65QI4.js +1658 -0
  39. package/dist/client/assets/{index-CWuLOWsu.js → index-BabO0TEf.js} +2 -2
  40. package/dist/client/assets/{index-CoJiX2o7.js → index-Bco5PCIk.js} +1 -1
  41. package/dist/client/assets/{index-UTvS0wz6.js → index-Bg2WUou4.js} +1 -1
  42. package/dist/client/assets/{index-CCa_zFfO.js → index-BiKxY3b6.js} +1 -1
  43. package/dist/client/assets/{index-CGYDEGb1.js → index-C4yxotik.js} +1 -1
  44. package/dist/client/assets/index-C9o2w5d_.js +1 -0
  45. package/dist/client/assets/{index-_r_3OCOV.js → index-CUDguphz.js} +1 -1
  46. package/dist/client/assets/{index-DBsoxmLK.js → index-CUXXDUxt.js} +1 -1
  47. package/dist/client/assets/{index-O1R1Ir-o.js → index-CXeb3CZh.js} +1 -1
  48. package/dist/client/assets/{index-BVkt7309.js → index-Cc8vG2jf.js} +1 -1
  49. package/dist/client/assets/{index-DN2SO8dj.js → index-Ce4ArSsI.js} +1 -1
  50. package/dist/client/assets/{index-9FBdK--F.js → index-CemK6fUn.js} +1 -1
  51. package/dist/client/assets/{index-BL-LFVsO.js → index-Ck1VEXu0.js} +1 -1
  52. package/dist/client/assets/{index-BPl8DTOI.js → index-D4OPDslu.js} +1 -1
  53. package/dist/client/assets/index-D9vFzXJR.js +1 -0
  54. package/dist/client/assets/{index-CPiL-M1V.js → index-DPpw-DKV.js} +1 -1
  55. package/dist/client/assets/{index-Bq1ocT_z.js → index-DQdV5YDl.js} +1 -1
  56. package/dist/client/assets/{index-B0rpOocp.js → index-DT376l6b.js} +3 -3
  57. package/dist/client/assets/index-DZ-SO2sz.css +1 -0
  58. package/dist/client/assets/{index-D-nXANER.js → index-DdpxcyXN.js} +1 -1
  59. package/dist/client/assets/{index-BhMgFrop.js → index-FOgsYoCt.js} +1 -1
  60. package/dist/client/assets/{index-BGLRcYYE.js → index-MUbvQBCQ.js} +1 -1
  61. package/dist/client/assets/{index-hnccffr-.js → index-Rf5Yz119.js} +1 -1
  62. package/dist/client/assets/index-Ygg0URfB.js +1 -0
  63. package/dist/client/assets/{index-CT4uhPjz.js → index-bR1UztQC.js} +1 -1
  64. package/dist/client/assets/{index-0R0NT72V.js → index-dDcguWyg.js} +1 -1
  65. package/dist/client/assets/{index-Z0979U-2.js → index-i6WvrE1p.js} +1 -1
  66. package/dist/client/assets/{index-BHz_iLMm.js → index-oU5xA1N3.js} +3 -3
  67. package/dist/client/assets/{index-D2P8UWWS.js → index-pBoKYStL.js} +1 -1
  68. package/dist/client/assets/{index-CgTvuqsz.js → index-rJuQe7Pl.js} +1 -1
  69. package/dist/client/assets/{index-37p1_k_N.js → index-z0vAkUHY.js} +1 -1
  70. package/dist/client/assets/{index-C6itZC0I.js → index-zrZDQvuW.js} +11 -11
  71. package/dist/client/assets/{room-files-source-BmK7_zzB.js → room-files-source-BXF5daqI.js} +2 -2
  72. package/dist/client/assets/{soul-file-0ee-EflV.js → soul-file-C1wnpxhH.js} +1 -1
  73. package/dist/client/assets/{use-mesh-update-D1KVLTOA.js → use-mesh-update-CZIA8V07.js} +1 -1
  74. package/dist/client/assets/{use-personality-commit-KFutjy9j.js → use-personality-commit-OViAsTwD.js} +1 -1
  75. package/dist/client/index.html +5 -4
  76. package/dist/drizzle/0107_productive_peter_parker.sql +5 -0
  77. package/dist/drizzle/0108_magical_morph.sql +2 -0
  78. package/dist/drizzle/0109_aspiring_union_jack.sql +5 -0
  79. package/dist/drizzle/0110_ambiguous_wendigo.sql +1 -0
  80. package/dist/drizzle/meta/0107_snapshot.json +8966 -0
  81. package/dist/drizzle/meta/0108_snapshot.json +8980 -0
  82. package/dist/drizzle/meta/0109_snapshot.json +8987 -0
  83. package/dist/drizzle/meta/0110_snapshot.json +8994 -0
  84. package/dist/drizzle/meta/_journal.json +28 -0
  85. package/dist/server/index.js +105552 -89583
  86. package/dist/server/index.js.map +2 -2
  87. package/package.json +3 -4
  88. package/dist/client/assets/ConnectionAccessLists-CrvGcp6D.js +0 -1
  89. package/dist/client/assets/ConnectionsPage-C2q7w1vY.js +0 -1
  90. package/dist/client/assets/HandlePage-DbVA5ABk.js +0 -1
  91. package/dist/client/assets/NamePage-Cvksm2Vr.js +0 -1
  92. package/dist/client/assets/PhotoPage-DOvne6fS.js +0 -1
  93. package/dist/client/assets/SkillsPage-loa1-bcL.js +0 -1
  94. package/dist/client/assets/ToolsPage-DMnjLq2L.js +0 -2
  95. package/dist/client/assets/index-BaITIF12.js +0 -1
  96. package/dist/client/assets/index-Criu5f4m.js +0 -1
  97. package/dist/client/assets/index-D9FWq0Sm.css +0 -1
  98. package/dist/client/assets/index-DRBI-tjH.js +0 -1
  99. package/dist/client/assets/index-DyAjYNxU.js +0 -1636
@@ -1,4 +1,4 @@
1
- var Fy=Object.defineProperty;var Am=r=>{throw TypeError(r)};var Hy=(r,e,t)=>e in r?Fy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var We=(r,e,t)=>Hy(r,typeof e!="symbol"?e+"":e,t),Nu=(r,e,t)=>e.has(r)||Am("Cannot "+t);var C=(r,e,t)=>(Nu(r,e,"read from private field"),t?t.call(r):e.get(r)),P=(r,e,t)=>e.has(r)?Am("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),I=(r,e,t,n)=>(Nu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),ui=(r,e,t)=>(Nu(r,e,"access private method"),t);import{gt as Nm,gu as _y,gv as qy,gw as Ed,gx as $y,gy as jy,gz as Vy,r as B,gA as I4,gn as Ll,gB as Dd,gC as Od,gD as Qi,gE as Em,gF as Wy,gG as Uy,gH as Vh,gI as Ki,gJ as qr,dk as Ky,gK as f0,gL as wr,gM as Gy,gN as Yy,gO as Dm,gP as Gs,gQ as Jy,gR as p0,j as z,ad as Xy,ag as Zy}from"./index-DyAjYNxU.js";import{aw as Qy,ax as e7,ab as t7,ac as r7,ad as n7,ae as i7,af as o7,ag as z4,ah as s7,q as P0,ai as a7,aj as L4,ar as l7,ak as c7,al as u7,am as d7,an as h7,ao as f7,ap as p7,aq as m7,Z as Wh,a4 as g7,a5 as B4,a6 as y7,a7 as v7,a8 as b7,a9 as w7,aa as x7,E as ta,as as k7,t as rt,at as S7,n as C7,C as Om}from"./index-BHz_iLMm.js";const M7={}.hasOwnProperty;function P4(r,e){let t=-1,n;if(e.extensions)for(;++t<e.extensions.length;)P4(r,e.extensions[t]);for(n in e)if(M7.call(e,n))switch(n){case"extensions":break;case"unsafe":{Rm(r[n],e[n]);break}case"join":{Rm(r[n],e[n]);break}case"handlers":{T7(r[n],e[n]);break}default:r.options[n]=e[n]}return r}function Rm(r,e){e&&r.push(...e)}function T7(r,e){e&&Object.assign(r,e)}const A7=[N7];function N7(r,e,t,n){if(e.type==="code"&&Nm(e,n)&&(r.type==="list"||r.type===e.type&&Nm(r,n)))return!1;if("spread"in t&&typeof t.spread=="boolean")return r.type==="paragraph"&&(r.type===e.type||e.type==="definition"||e.type==="heading"&&_y(e,n))?void 0:t.spread?1:0}const di=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],E7=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
1
+ var Fy=Object.defineProperty;var Am=r=>{throw TypeError(r)};var Hy=(r,e,t)=>e in r?Fy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var We=(r,e,t)=>Hy(r,typeof e!="symbol"?e+"":e,t),Nu=(r,e,t)=>e.has(r)||Am("Cannot "+t);var C=(r,e,t)=>(Nu(r,e,"read from private field"),t?t.call(r):e.get(r)),P=(r,e,t)=>e.has(r)?Am("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),I=(r,e,t,n)=>(Nu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),ui=(r,e,t)=>(Nu(r,e,"access private method"),t);import{gu as Nm,gv as _y,gw as qy,gx as Ed,gy as jy,gz as $y,gA as Vy,r as B,gB as I4,go as Ll,gC as Dd,gD as Od,gE as Qi,gF as Em,gG as Wy,gH as Uy,gI as qr,gJ as Vh,gK as Ki,dn as Ky,gL as f0,gM as wr,gN as Gy,gO as Yy,gP as Dm,gQ as Gs,gR as Jy,gS as p0,j as z,ag as Xy,aj as Zy}from"./index-BMR65QI4.js";import{aw as Qy,ax as e7,ab as t7,ac as r7,ad as n7,ae as i7,af as o7,ag as z4,ah as s7,q as P0,ai as a7,aj as L4,ar as l7,ak as c7,al as u7,am as d7,an as h7,ao as f7,ap as p7,aq as m7,Z as Wh,a4 as g7,a5 as B4,a6 as y7,a7 as v7,a8 as b7,a9 as w7,aa as x7,E as ta,as as k7,t as rt,at as S7,n as C7,C as Om}from"./index-oU5xA1N3.js";const M7={}.hasOwnProperty;function P4(r,e){let t=-1,n;if(e.extensions)for(;++t<e.extensions.length;)P4(r,e.extensions[t]);for(n in e)if(M7.call(e,n))switch(n){case"extensions":break;case"unsafe":{Rm(r[n],e[n]);break}case"join":{Rm(r[n],e[n]);break}case"handlers":{T7(r[n],e[n]);break}default:r.options[n]=e[n]}return r}function Rm(r,e){e&&r.push(...e)}function T7(r,e){e&&Object.assign(r,e)}const A7=[N7];function N7(r,e,t,n){if(e.type==="code"&&Nm(e,n)&&(r.type==="list"||r.type===e.type&&Nm(r,n)))return!1;if("spread"in t&&typeof t.spread=="boolean")return r.type==="paragraph"&&(r.type===e.type||e.type==="definition"||e.type==="heading"&&_y(e,n))?void 0:t.spread?1:0}const di=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],E7=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
2
2
  `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:di},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
3
3
  ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:di},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
4
4
  *])`},{character:"*",inConstruct:"phrasing",notInConstruct:di},{atBreak:!0,character:"+",after:`(?:[ \r
@@ -14,28 +14,28 @@ var Fy=Object.defineProperty;var Am=r=>{throw TypeError(r)};var Hy=(r,e,t)=>e in
14
14
 
15
15
  `}return`
16
16
 
17
- `}const L7=/\r?\n|\r/g;function B7(r,e){const t=[];let n=0,i=0,o;for(;o=L7.exec(r);)s(r.slice(n,o.index)),t.push(o[0]),n=o.index+o[0].length,i++;return s(r.slice(n)),t.join("");function s(a){t.push(e(a,i,!a))}}function P7(r,e,t){const n=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={};let a=-1;for(;++a<r.unsafe.length;){const u=r.unsafe[a];if(!$y(r.stack,u))continue;const d=r.compilePattern(u);let h;for(;h=d.exec(n);){const f="before"in u||!!u.atBreak,m="after"in u,y=h.index+(f?h[1].length:0);i.includes(y)?(s[y].before&&!f&&(s[y].before=!1),s[y].after&&!m&&(s[y].after=!1)):(i.push(y),s[y]={before:f,after:m})}}i.sort(F7);let l=t.before?t.before.length:0;const c=n.length-(t.after?t.after.length:0);for(a=-1;++a<i.length;){const u=i[a];u<l||u>=c||u+1<c&&i[a+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||i[a-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(l!==u&&o.push(Im(n.slice(l,u),"\\")),l=u,/[!-/:-@[-`{-~]/.test(n.charAt(u))&&(!t.encode||!t.encode.includes(n.charAt(u)))?o.push("\\"):(o.push(Ed(n.charCodeAt(u))),l++))}return o.push(Im(n.slice(l,c),t.after)),o.join("")}function F7(r,e){return r-e}function Im(r,e){const t=/\\(?=[!-/:-@[-`{-~])/g,n=[],i=[],o=r+e;let s=-1,a=0,l;for(;l=t.exec(o);)n.push(l.index);for(;++s<n.length;)a!==n[s]&&i.push(r.slice(a,n[s])),i.push("\\"),a=n[s];return i.push(r.slice(a)),i.join("")}function H7(r){const e=r||{},t=e.now||{};let n=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:l,current:s,shift:a};function s(){return{now:{line:i,column:o},lineShift:n}}function a(c){n+=c}function l(c){const u=c||"",d=u.split(/\r?\n|\r/g),h=d[d.length-1];return i+=d.length-1,o=d.length===1?o+h.length:1+h.length+n,u}}function _7(r,e){const t=e||{},n={associationId:D7,containerPhrasing:V7,containerFlow:W7,createTracker:H7,compilePattern:O7,enter:o,handlers:{...Vy},handle:void 0,indentLines:B7,indexStack:[],join:[...A7],options:{},safe:U7,stack:[],unsafe:[...E7]};P4(n,t),n.options.tightDefinitions&&n.join.push(j7),n.handle=jy("type",{invalid:q7,unknown:$7,handlers:n.handlers});let i=n.handle(r,void 0,n,{before:`
17
+ `}const L7=/\r?\n|\r/g;function B7(r,e){const t=[];let n=0,i=0,o;for(;o=L7.exec(r);)s(r.slice(n,o.index)),t.push(o[0]),n=o.index+o[0].length,i++;return s(r.slice(n)),t.join("");function s(a){t.push(e(a,i,!a))}}function P7(r,e,t){const n=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={};let a=-1;for(;++a<r.unsafe.length;){const u=r.unsafe[a];if(!jy(r.stack,u))continue;const d=r.compilePattern(u);let h;for(;h=d.exec(n);){const f="before"in u||!!u.atBreak,m="after"in u,y=h.index+(f?h[1].length:0);i.includes(y)?(s[y].before&&!f&&(s[y].before=!1),s[y].after&&!m&&(s[y].after=!1)):(i.push(y),s[y]={before:f,after:m})}}i.sort(F7);let l=t.before?t.before.length:0;const c=n.length-(t.after?t.after.length:0);for(a=-1;++a<i.length;){const u=i[a];u<l||u>=c||u+1<c&&i[a+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||i[a-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(l!==u&&o.push(Im(n.slice(l,u),"\\")),l=u,/[!-/:-@[-`{-~]/.test(n.charAt(u))&&(!t.encode||!t.encode.includes(n.charAt(u)))?o.push("\\"):(o.push(Ed(n.charCodeAt(u))),l++))}return o.push(Im(n.slice(l,c),t.after)),o.join("")}function F7(r,e){return r-e}function Im(r,e){const t=/\\(?=[!-/:-@[-`{-~])/g,n=[],i=[],o=r+e;let s=-1,a=0,l;for(;l=t.exec(o);)n.push(l.index);for(;++s<n.length;)a!==n[s]&&i.push(r.slice(a,n[s])),i.push("\\"),a=n[s];return i.push(r.slice(a)),i.join("")}function H7(r){const e=r||{},t=e.now||{};let n=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:l,current:s,shift:a};function s(){return{now:{line:i,column:o},lineShift:n}}function a(c){n+=c}function l(c){const u=c||"",d=u.split(/\r?\n|\r/g),h=d[d.length-1];return i+=d.length-1,o=d.length===1?o+h.length:1+h.length+n,u}}function _7(r,e){const t=e||{},n={associationId:D7,containerPhrasing:V7,containerFlow:W7,createTracker:H7,compilePattern:O7,enter:o,handlers:{...Vy},handle:void 0,indentLines:B7,indexStack:[],join:[...A7],options:{},safe:U7,stack:[],unsafe:[...E7]};P4(n,t),n.options.tightDefinitions&&n.join.push($7),n.handle=$y("type",{invalid:q7,unknown:j7,handlers:n.handlers});let i=n.handle(r,void 0,n,{before:`
18
18
  `,after:`
19
19
  `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
20
- `),i;function o(s){return n.stack.push(s),a;function a(){n.stack.pop()}}}function q7(r){throw new Error("Cannot handle value `"+r+"`, expected node")}function $7(r){const e=r;throw new Error("Cannot handle unknown node `"+e.type+"`")}function j7(r,e){if(r.type==="definition"&&r.type===e.type)return 0}function V7(r,e){return R7(r,this,e)}function W7(r,e){return I7(r,this,e)}function U7(r,e){return P7(this,r,e)}var Cc=B.createContext({});function K7(){const{dom:r,editor:e,setLoading:t,editorFactory:n}=B.useContext(Cc),i=B.useRef(null);return B.useEffect(()=>{const o=i.current;if(!n||!o)return;r.current=o;const s=n(o);if(s)return t(!0),s.create().then(a=>{e.current=a}).finally(()=>{t(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}},[r,e,n,t]),i}var G7=()=>{const r=K7();return I4.createElement("div",{"data-milkdown-root":!0,ref:r})},Y7=({children:r})=>{const e=B.useRef(void 0),[t,n]=B.useState(void 0),i=B.useRef(void 0),[o,s]=B.useState(!0),a=B.useMemo(()=>({loading:o,dom:e,editor:i,setLoading:s,editorFactory:t,setEditorFactory:n}),[o,t]);return I4.createElement(Cc.Provider,{value:a},r)};function J7(r,e=[]){const t=B.useContext(Cc),n=B.useCallback(r,e);return B.useLayoutEffect(()=>{t.setEditorFactory(()=>n)},[t,n]),{loading:t.loading,get:()=>t.editor.current}}function X7(){const r=B.useContext(Cc),e=B.useCallback(()=>r.editor.current,[r.editor]);return[r.loading,e]}function Z7(r){return typeof r=="object"&&!!r}function Q7(r){return r.nodeType===1}function ev(r){return Q7(r)&&r.namespaceURI==="http://www.w3.org/1999/xhtml"}function F4(r){return Z7(r)&&r.nodeType===1&&typeof r.nodeName=="string"}let m0=0,tv=2**53-1;function rv(){return m0++,m0>=tv&&(m0=1),m0}function Mc(){return String(rv())}function H4(r,e){if(r.type!=="childList")return!1;for(const t of r.removedNodes)if(t===e)return!0;return!1}var Ua,Rd,x4,nv=(x4=class{constructor({mark:r,view:e,inline:t,options:n}){P(this,Ua);this.contentRef=i=>{i&&this.contentDOM&&F4(i)&&i.firstChild!==this.contentDOM&&i.appendChild(this.contentDOM)},this.shouldIgnoreMutation=i=>!this.dom||!this.contentDOM?!0:i.type==="selection"?!1:this.contentDOM===i.target&&i.type==="attributes"?!0:!(this.contentDOM.contains(i.target)||H4(i,this.contentDOM)),this.ignoreMutation=i=>{if(!this.dom||!this.contentDOM)return!0;let o;const s=this.options.ignoreMutation;return s&&(o=s(i)),typeof o!="boolean"&&(o=this.shouldIgnoreMutation(i)),o},this.destroy=()=>{var i,o;(o=(i=this.options).destroy)==null||o.call(i),this.dom.remove(),this.contentDOM.remove()},this.key=Mc(),this.mark=r,this.view=e,this.inline=t,this.options=n,this.dom=this.createDOM(n.as),this.contentDOM=this.createContentDOM(n.contentAs),this.dom.setAttribute("data-mark-view-root","true"),this.contentDOM.setAttribute("data-mark-view-content","true"),this.contentDOM.style.whiteSpace="inherit"}createDOM(r){return ui(this,Ua,Rd).call(this,r)}createContentDOM(r){return ui(this,Ua,Rd).call(this,r)}get component(){return this.options.component}},Ua=new WeakSet,Rd=function(r){const{inline:e,mark:t}=this;return r?typeof r=="string"?document.createElement(r):typeof r=="function"?r(t):r:document.createElement(e?"span":"div")},x4),ki,Ka,Id,k4,iv=(k4=class{constructor({node:r,view:e,getPos:t,decorations:n,innerDecorations:i,options:o}){P(this,Ka);P(this,ki);I(this,ki,!1),this.selected=!1,this.contentRef=s=>{s&&this.contentDOM&&F4(s)&&s.firstChild!==this.contentDOM&&s.appendChild(this.contentDOM)},this.selectNode=()=>{var s,a;this.selected=!0,(a=(s=this.options).selectNode)==null||a.call(s)},this.deselectNode=()=>{var s,a;this.selected=!1,(a=(s=this.options).deselectNode)==null||a.call(s)},this.shouldUpdate=s=>s.type===this.node.type,this.update=(s,a,l)=>{var u,d,h,f;const c=((d=(u=this.options).update)==null?void 0:d.call(u,s,a,l))??this.shouldUpdate(s);return this.node=s,this.decorations=a,this.innerDecorations=l,c&&((f=(h=this.options).onUpdate)==null||f.call(h)),c},this.shouldIgnoreMutation=s=>!this.dom||!this.contentDOM||(this.dom.contains(this.contentDOM)&&I(this,ki,!1),this.node.isLeaf||this.node.isAtom)?!0:s.type==="selection"?!1:this.contentDOM===s.target&&s.type==="attributes"?!0:this.contentDOM.contains(s.target)?!1:H4(s,this.contentDOM)?(I(this,ki,!0),!1):!(C(this,ki)&&this.dom.contains(s.target)),this.ignoreMutation=s=>{if(!this.dom||!this.contentDOM)return!0;let a;const l=this.options.ignoreMutation;return l&&(a=l(s)),typeof a!="boolean"&&(a=this.shouldIgnoreMutation(s)),a},this.destroy=()=>{var s,a,l;(a=(s=this.options).destroy)==null||a.call(s),this.dom.remove(),(l=this.contentDOM)==null||l.remove()},this.setAttrs=s=>{const a=this.getPos();if(typeof a=="number")return this.view.dispatch(this.view.state.tr.setNodeMarkup(a,void 0,{...this.node.attrs,...s}))},this.key=Mc(),this.node=r,this.view=e,this.getPos=t,this.decorations=n,this.innerDecorations=i,this.options=o,this.dom=this.createDOM(o.as),this.contentDOM=r.isLeaf?null:this.createContentDOM(o.contentAs),this.dom.setAttribute("data-node-view-root","true"),this.contentDOM&&(this.contentDOM.setAttribute("data-node-view-content","true"),this.contentDOM.style.whiteSpace="inherit"),this.setSelection=o.setSelection,this.stopEvent=o.stopEvent}createDOM(r){return ui(this,Ka,Id).call(this,r)}createContentDOM(r){return ui(this,Ka,Id).call(this,r)}get component(){return this.options.component}},ki=new WeakMap,Ka=new WeakSet,Id=function(r){const{node:e}=this;return r?typeof r=="string"?document.createElement(r):typeof r=="function"?r(e):r:document.createElement(e.isInline?"span":"div")},k4),ov=class{constructor(r){this.key=Mc(),this.view=r.view,this.options=r.options}get component(){return this.options.component}get root(){var e,t;let r=(t=(e=this.options).root)==null?void 0:t.call(e,this.view.dom);return r||(r=this.view.dom.parentElement??document.body),r}update(r,e){var t,n;this.view=r,this.prevState=e,(n=(t=this.options).update)==null||n.call(t,r,e)}destroy(){var r,e;(e=(r=this.options).destroy)==null||e.call(r)}},kc,_4,S4,sv=(S4=class{constructor({pos:r,spec:e,options:t}){P(this,kc);this.key=Mc(),this.pos=r,this.options=t,this.spec=e,this.dom=ui(this,kc,_4).call(this,t.as),this.dom.setAttribute("data-widget-view-root","true")}bind(r,e){this.view=r,this.getPos=e}get component(){return this.options.component}},kc=new WeakSet,_4=function(r){return typeof r=="string"?document.createElement(r):r},S4);function ot(r){this.content=r}ot.prototype={constructor:ot,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),o=n.content.slice();return i==-1?o.push(t||r,e):(o[i+1]=e,t&&(o[i]=t)),new ot(o)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ot(t)},addToStart:function(r,e){return new ot([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new ot(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),o=n.find(r);return i.splice(o==-1?i.length:o,0,e,t),new ot(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=ot.from(r),r.size?new ot(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=ot.from(r),r.size?new ot(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=ot.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};ot.from=function(r){if(r instanceof ot)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new ot(e)};function q4(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),o=e.child(n);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){let s=i.text,a=o.text,l=0;for(;s[l]==a[l];l++)t++;return l&&l<s.length&&l<a.length&&V4(s.charCodeAt(l-1))&&j4(s.charCodeAt(l))&&t--,t}if(i.content.size||o.content.size){let s=q4(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function $4(r,e,t,n){for(let i=r.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:n};let s=r.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){t-=l,n-=l;continue}if(!s.sameMarkup(a))return{a:t,b:n};if(s.isText&&s.text!=a.text){let c=s.text,u=a.text,d=c.length,h=u.length;for(;d>0&&h>0&&c[d-1]==u[h-1];)d--,h--,t--,n--;return d&&h&&d<c.length&&V4(c.charCodeAt(d-1))&&j4(c.charCodeAt(d))&&(t++,n++),{a:t,b:n}}if(s.content.size||a.content.size){let c=$4(s.content,a.content,t-1,n-1);if(c)return c}t-=l,n-=l}}function j4(r){return r>=56320&&r<57344}function V4(r){return r>=55296&&r<56320}class H{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,o){for(let s=0,a=0;a<t;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&n(l,i+a,o||null,s)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),n,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let o="",s=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(s?s=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new H(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),n.push(a),i+=a.nodeSize),s=l}return new H(n,i)}cutByIndex(e,t){return e==t?H.empty:e==0&&t==this.content.length?this:new H(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new H(i,o)}addToStart(e){return new H([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new H(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return q4(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return $4(this,e,t,n)}findIndex(e){if(e==0)return g0(0,e);if(e==this.size)return g0(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),o=n+i.nodeSize;if(o>=e)return o==e?g0(t+1,o):g0(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return H.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return H.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return H.empty;let t,n=0;for(let i=0;i<e.length;i++){let o=e[i];n+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new H(t||e,n)}static from(e){if(!e)return H.empty;if(e instanceof H)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new H([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}H.empty=new H([],0);const Eu={index:0,offset:0};function g0(r,e){return Eu.index=r,Eu.offset=e,Eu}function ec(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!ec(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!ec(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class fe{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ec(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return fe.none;if(e instanceof fe)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}}fe.none=[];class Ma extends Error{}let Y=class wo{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=U4(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new wo(n,this.openStart,this.openEnd)}removeBetween(e,t){return new wo(W4(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return wo.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new wo(H.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new wo(e,n,i)}};Y.empty=new Y(H.empty,0,0);function W4(r,e,t){let{index:n,offset:i}=r.findIndex(e),o=r.maybeChild(n),{index:s,offset:a}=r.findIndex(t);if(i==e||o.isText){if(a!=t&&!r.child(s).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=s)throw new RangeError("Removing non-flat range");return r.replaceChild(n,o.copy(W4(o.content,e-i-1,t-i-1)))}function U4(r,e,t,n,i,o){let{index:s,offset:a}=r.findIndex(e),l=r.maybeChild(s);if(a==e||l.isText)return o&&n<=0&&i<=0&&!o.canReplace(s,s,t)?null:r.cut(0,e).append(t).append(r.cut(e));let c=U4(l.content,e-a-1,t,s==0?n-1:0,s==r.childCount-1?i-1:0,l);return c&&r.replaceChild(s,l.copy(c))}function av(r,e,t){if(t.openStart>r.depth)throw new Ma("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Ma("Inconsistent open depths");return K4(r,e,t,0)}function K4(r,e,t,n){let i=r.index(n),o=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let s=K4(r,e,t,n+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let s=r.parent,a=s.content;return Pi(s,a.cut(0,r.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=lv(t,r);return Pi(o,Y4(r,s,a,e,n))}else return Pi(o,tc(r,e,n))}function G4(r,e){if(!e.type.compatibleContent(r.type))throw new Ma("Cannot join "+e.type.name+" onto "+r.type.name)}function zd(r,e,t){let n=r.node(t);return G4(n,e.node(t)),n}function Bi(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function da(r,e,t,n){let i=(e||r).node(t),o=0,s=e?e.index(t):i.childCount;r&&(o=r.index(t),r.depth>t?o++:r.textOffset&&(Bi(r.nodeAfter,n),o++));for(let a=o;a<s;a++)Bi(i.child(a),n);e&&e.depth==t&&e.textOffset&&Bi(e.nodeBefore,n)}function Pi(r,e){if(!r.type.validContent(e))throw new Ma("Invalid content for node "+r.type.name);return r.copy(e)}function Y4(r,e,t,n,i){let o=r.depth>i&&zd(r,e,i+1),s=n.depth>i&&zd(t,n,i+1),a=[];return da(null,r,i,a),o&&s&&e.index(i)==t.index(i)?(G4(o,s),Bi(Pi(o,Y4(r,e,t,n,i+1)),a)):(o&&Bi(Pi(o,tc(r,e,i+1)),a),da(e,t,i,a),s&&Bi(Pi(s,tc(t,n,i+1)),a)),da(n,null,i,a),new H(a)}function tc(r,e,t){let n=[];if(da(null,r,t,n),r.depth>t){let i=zd(r,e,t+1);Bi(Pi(i,tc(r,e,t+1)),n)}return da(e,null,t,n),new H(n)}function lv(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(H.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class Ta{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=n.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return fe.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let a=n;n=i,i=a}let o=n.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!i||!n[o].isInSet(i.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new J4(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,o=t;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(n.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new Ta(t,n,o)}static resolveCached(e,t){let n=zm.get(e);if(n)for(let o=0;o<n.elts.length;o++){let s=n.elts[o];if(s.pos==t)return s}else zm.set(e,n=new cv);let i=n.elts[n.i]=Ta.resolve(e,t);return n.i=(n.i+1)%uv,i}}class cv{constructor(){this.elts=[],this.i=0}}const uv=12,zm=new WeakMap;class J4{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const dv=Object.create(null);let mn=class Ld{constructor(e,t,n,i=fe.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||H.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ec(this.attrs,t||e.defaultAttrs||dv)&&fe.sameSet(this.marks,n||fe.none)}copy(e=null){return e==this.content?this:new Ld(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ld(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Y.empty;let i=this.resolve(e),o=this.resolve(t),s=n?0:i.sharedDepth(t),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new Y(c,i.depth-s,o.depth-s)}replace(e,t,n){return av(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return Ta.resolveCached(this,e)}resolveNoCache(e){return Ta.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),X4(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=H.empty,i=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(n),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=fe.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!fe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=H.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,n);return o.type.checkAttrs(o.attrs),o}};mn.prototype.text=void 0;let hv=class Bd extends mn{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):X4(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bd(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function X4(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Gi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new fv(e,t);if(n.next==null)return Gi.empty;let i=Z4(n);n.next&&n.err("Unexpected trailing text");let o=wv(bv(i));return xv(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let o=t;i&&o<n;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function o(s,a){let l=s.matchFragment(e,n);if(l&&(!t||l.validEnd))return H.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let h=o(d,a.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(n.push({match:a.contentMatch,type:a,via:i}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let o=i+(n.validEnd?"*":" ")+" ";for(let s=0;s<n.next.length;s++)o+=(s?", ":"")+n.next[s].type.name+"->"+e.indexOf(n.next[s].next);return o}).join(`
20
+ `),i;function o(s){return n.stack.push(s),a;function a(){n.stack.pop()}}}function q7(r){throw new Error("Cannot handle value `"+r+"`, expected node")}function j7(r){const e=r;throw new Error("Cannot handle unknown node `"+e.type+"`")}function $7(r,e){if(r.type==="definition"&&r.type===e.type)return 0}function V7(r,e){return R7(r,this,e)}function W7(r,e){return I7(r,this,e)}function U7(r,e){return P7(this,r,e)}var Cc=B.createContext({});function K7(){const{dom:r,editor:e,setLoading:t,editorFactory:n}=B.useContext(Cc),i=B.useRef(null);return B.useEffect(()=>{const o=i.current;if(!n||!o)return;r.current=o;const s=n(o);if(s)return t(!0),s.create().then(a=>{e.current=a}).finally(()=>{t(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}},[r,e,n,t]),i}var G7=()=>{const r=K7();return I4.createElement("div",{"data-milkdown-root":!0,ref:r})},Y7=({children:r})=>{const e=B.useRef(void 0),[t,n]=B.useState(void 0),i=B.useRef(void 0),[o,s]=B.useState(!0),a=B.useMemo(()=>({loading:o,dom:e,editor:i,setLoading:s,editorFactory:t,setEditorFactory:n}),[o,t]);return I4.createElement(Cc.Provider,{value:a},r)};function J7(r,e=[]){const t=B.useContext(Cc),n=B.useCallback(r,e);return B.useLayoutEffect(()=>{t.setEditorFactory(()=>n)},[t,n]),{loading:t.loading,get:()=>t.editor.current}}function X7(){const r=B.useContext(Cc),e=B.useCallback(()=>r.editor.current,[r.editor]);return[r.loading,e]}function Z7(r){return typeof r=="object"&&!!r}function Q7(r){return r.nodeType===1}function ev(r){return Q7(r)&&r.namespaceURI==="http://www.w3.org/1999/xhtml"}function F4(r){return Z7(r)&&r.nodeType===1&&typeof r.nodeName=="string"}let m0=0,tv=2**53-1;function rv(){return m0++,m0>=tv&&(m0=1),m0}function Mc(){return String(rv())}function H4(r,e){if(r.type!=="childList")return!1;for(const t of r.removedNodes)if(t===e)return!0;return!1}var Ua,Rd,x4,nv=(x4=class{constructor({mark:r,view:e,inline:t,options:n}){P(this,Ua);this.contentRef=i=>{i&&this.contentDOM&&F4(i)&&i.firstChild!==this.contentDOM&&i.appendChild(this.contentDOM)},this.shouldIgnoreMutation=i=>!this.dom||!this.contentDOM?!0:i.type==="selection"?!1:this.contentDOM===i.target&&i.type==="attributes"?!0:!(this.contentDOM.contains(i.target)||H4(i,this.contentDOM)),this.ignoreMutation=i=>{if(!this.dom||!this.contentDOM)return!0;let o;const s=this.options.ignoreMutation;return s&&(o=s(i)),typeof o!="boolean"&&(o=this.shouldIgnoreMutation(i)),o},this.destroy=()=>{var i,o;(o=(i=this.options).destroy)==null||o.call(i),this.dom.remove(),this.contentDOM.remove()},this.key=Mc(),this.mark=r,this.view=e,this.inline=t,this.options=n,this.dom=this.createDOM(n.as),this.contentDOM=this.createContentDOM(n.contentAs),this.dom.setAttribute("data-mark-view-root","true"),this.contentDOM.setAttribute("data-mark-view-content","true"),this.contentDOM.style.whiteSpace="inherit"}createDOM(r){return ui(this,Ua,Rd).call(this,r)}createContentDOM(r){return ui(this,Ua,Rd).call(this,r)}get component(){return this.options.component}},Ua=new WeakSet,Rd=function(r){const{inline:e,mark:t}=this;return r?typeof r=="string"?document.createElement(r):typeof r=="function"?r(t):r:document.createElement(e?"span":"div")},x4),ki,Ka,Id,k4,iv=(k4=class{constructor({node:r,view:e,getPos:t,decorations:n,innerDecorations:i,options:o}){P(this,Ka);P(this,ki);I(this,ki,!1),this.selected=!1,this.contentRef=s=>{s&&this.contentDOM&&F4(s)&&s.firstChild!==this.contentDOM&&s.appendChild(this.contentDOM)},this.selectNode=()=>{var s,a;this.selected=!0,(a=(s=this.options).selectNode)==null||a.call(s)},this.deselectNode=()=>{var s,a;this.selected=!1,(a=(s=this.options).deselectNode)==null||a.call(s)},this.shouldUpdate=s=>s.type===this.node.type,this.update=(s,a,l)=>{var u,d,h,f;const c=((d=(u=this.options).update)==null?void 0:d.call(u,s,a,l))??this.shouldUpdate(s);return this.node=s,this.decorations=a,this.innerDecorations=l,c&&((f=(h=this.options).onUpdate)==null||f.call(h)),c},this.shouldIgnoreMutation=s=>!this.dom||!this.contentDOM||(this.dom.contains(this.contentDOM)&&I(this,ki,!1),this.node.isLeaf||this.node.isAtom)?!0:s.type==="selection"?!1:this.contentDOM===s.target&&s.type==="attributes"?!0:this.contentDOM.contains(s.target)?!1:H4(s,this.contentDOM)?(I(this,ki,!0),!1):!(C(this,ki)&&this.dom.contains(s.target)),this.ignoreMutation=s=>{if(!this.dom||!this.contentDOM)return!0;let a;const l=this.options.ignoreMutation;return l&&(a=l(s)),typeof a!="boolean"&&(a=this.shouldIgnoreMutation(s)),a},this.destroy=()=>{var s,a,l;(a=(s=this.options).destroy)==null||a.call(s),this.dom.remove(),(l=this.contentDOM)==null||l.remove()},this.setAttrs=s=>{const a=this.getPos();if(typeof a=="number")return this.view.dispatch(this.view.state.tr.setNodeMarkup(a,void 0,{...this.node.attrs,...s}))},this.key=Mc(),this.node=r,this.view=e,this.getPos=t,this.decorations=n,this.innerDecorations=i,this.options=o,this.dom=this.createDOM(o.as),this.contentDOM=r.isLeaf?null:this.createContentDOM(o.contentAs),this.dom.setAttribute("data-node-view-root","true"),this.contentDOM&&(this.contentDOM.setAttribute("data-node-view-content","true"),this.contentDOM.style.whiteSpace="inherit"),this.setSelection=o.setSelection,this.stopEvent=o.stopEvent}createDOM(r){return ui(this,Ka,Id).call(this,r)}createContentDOM(r){return ui(this,Ka,Id).call(this,r)}get component(){return this.options.component}},ki=new WeakMap,Ka=new WeakSet,Id=function(r){const{node:e}=this;return r?typeof r=="string"?document.createElement(r):typeof r=="function"?r(e):r:document.createElement(e.isInline?"span":"div")},k4),ov=class{constructor(r){this.key=Mc(),this.view=r.view,this.options=r.options}get component(){return this.options.component}get root(){var e,t;let r=(t=(e=this.options).root)==null?void 0:t.call(e,this.view.dom);return r||(r=this.view.dom.parentElement??document.body),r}update(r,e){var t,n;this.view=r,this.prevState=e,(n=(t=this.options).update)==null||n.call(t,r,e)}destroy(){var r,e;(e=(r=this.options).destroy)==null||e.call(r)}},kc,_4,S4,sv=(S4=class{constructor({pos:r,spec:e,options:t}){P(this,kc);this.key=Mc(),this.pos=r,this.options=t,this.spec=e,this.dom=ui(this,kc,_4).call(this,t.as),this.dom.setAttribute("data-widget-view-root","true")}bind(r,e){this.view=r,this.getPos=e}get component(){return this.options.component}},kc=new WeakSet,_4=function(r){return typeof r=="string"?document.createElement(r):r},S4);function ot(r){this.content=r}ot.prototype={constructor:ot,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),o=n.content.slice();return i==-1?o.push(t||r,e):(o[i+1]=e,t&&(o[i]=t)),new ot(o)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ot(t)},addToStart:function(r,e){return new ot([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new ot(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),o=n.find(r);return i.splice(o==-1?i.length:o,0,e,t),new ot(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=ot.from(r),r.size?new ot(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=ot.from(r),r.size?new ot(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=ot.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};ot.from=function(r){if(r instanceof ot)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new ot(e)};function q4(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),o=e.child(n);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){let s=i.text,a=o.text,l=0;for(;s[l]==a[l];l++)t++;return l&&l<s.length&&l<a.length&&V4(s.charCodeAt(l-1))&&$4(s.charCodeAt(l))&&t--,t}if(i.content.size||o.content.size){let s=q4(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function j4(r,e,t,n){for(let i=r.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:n};let s=r.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){t-=l,n-=l;continue}if(!s.sameMarkup(a))return{a:t,b:n};if(s.isText&&s.text!=a.text){let c=s.text,u=a.text,d=c.length,h=u.length;for(;d>0&&h>0&&c[d-1]==u[h-1];)d--,h--,t--,n--;return d&&h&&d<c.length&&V4(c.charCodeAt(d-1))&&$4(c.charCodeAt(d))&&(t++,n++),{a:t,b:n}}if(s.content.size||a.content.size){let c=j4(s.content,a.content,t-1,n-1);if(c)return c}t-=l,n-=l}}function $4(r){return r>=56320&&r<57344}function V4(r){return r>=55296&&r<56320}class H{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,o){for(let s=0,a=0;a<t;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&n(l,i+a,o||null,s)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),n,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let o="",s=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(s?s=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new H(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),n.push(a),i+=a.nodeSize),s=l}return new H(n,i)}cutByIndex(e,t){return e==t?H.empty:e==0&&t==this.content.length?this:new H(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new H(i,o)}addToStart(e){return new H([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new H(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return q4(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return j4(this,e,t,n)}findIndex(e){if(e==0)return g0(0,e);if(e==this.size)return g0(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),o=n+i.nodeSize;if(o>=e)return o==e?g0(t+1,o):g0(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return H.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return H.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return H.empty;let t,n=0;for(let i=0;i<e.length;i++){let o=e[i];n+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new H(t||e,n)}static from(e){if(!e)return H.empty;if(e instanceof H)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new H([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}H.empty=new H([],0);const Eu={index:0,offset:0};function g0(r,e){return Eu.index=r,Eu.offset=e,Eu}function ec(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!ec(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!ec(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class fe{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ec(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return fe.none;if(e instanceof fe)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}}fe.none=[];class Ma extends Error{}let Y=class wo{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=U4(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new wo(n,this.openStart,this.openEnd)}removeBetween(e,t){return new wo(W4(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return wo.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new wo(H.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new wo(e,n,i)}};Y.empty=new Y(H.empty,0,0);function W4(r,e,t){let{index:n,offset:i}=r.findIndex(e),o=r.maybeChild(n),{index:s,offset:a}=r.findIndex(t);if(i==e||o.isText){if(a!=t&&!r.child(s).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=s)throw new RangeError("Removing non-flat range");return r.replaceChild(n,o.copy(W4(o.content,e-i-1,t-i-1)))}function U4(r,e,t,n,i,o){let{index:s,offset:a}=r.findIndex(e),l=r.maybeChild(s);if(a==e||l.isText)return o&&n<=0&&i<=0&&!o.canReplace(s,s,t)?null:r.cut(0,e).append(t).append(r.cut(e));let c=U4(l.content,e-a-1,t,s==0?n-1:0,s==r.childCount-1?i-1:0,l);return c&&r.replaceChild(s,l.copy(c))}function av(r,e,t){if(t.openStart>r.depth)throw new Ma("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Ma("Inconsistent open depths");return K4(r,e,t,0)}function K4(r,e,t,n){let i=r.index(n),o=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let s=K4(r,e,t,n+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let s=r.parent,a=s.content;return Pi(s,a.cut(0,r.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=lv(t,r);return Pi(o,Y4(r,s,a,e,n))}else return Pi(o,tc(r,e,n))}function G4(r,e){if(!e.type.compatibleContent(r.type))throw new Ma("Cannot join "+e.type.name+" onto "+r.type.name)}function zd(r,e,t){let n=r.node(t);return G4(n,e.node(t)),n}function Bi(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function da(r,e,t,n){let i=(e||r).node(t),o=0,s=e?e.index(t):i.childCount;r&&(o=r.index(t),r.depth>t?o++:r.textOffset&&(Bi(r.nodeAfter,n),o++));for(let a=o;a<s;a++)Bi(i.child(a),n);e&&e.depth==t&&e.textOffset&&Bi(e.nodeBefore,n)}function Pi(r,e){if(!r.type.validContent(e))throw new Ma("Invalid content for node "+r.type.name);return r.copy(e)}function Y4(r,e,t,n,i){let o=r.depth>i&&zd(r,e,i+1),s=n.depth>i&&zd(t,n,i+1),a=[];return da(null,r,i,a),o&&s&&e.index(i)==t.index(i)?(G4(o,s),Bi(Pi(o,Y4(r,e,t,n,i+1)),a)):(o&&Bi(Pi(o,tc(r,e,i+1)),a),da(e,t,i,a),s&&Bi(Pi(s,tc(t,n,i+1)),a)),da(n,null,i,a),new H(a)}function tc(r,e,t){let n=[];if(da(null,r,t,n),r.depth>t){let i=zd(r,e,t+1);Bi(Pi(i,tc(r,e,t+1)),n)}return da(e,null,t,n),new H(n)}function lv(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(H.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class Ta{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=n.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return fe.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let a=n;n=i,i=a}let o=n.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!i||!n[o].isInSet(i.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new J4(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,o=t;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(n.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new Ta(t,n,o)}static resolveCached(e,t){let n=zm.get(e);if(n)for(let o=0;o<n.elts.length;o++){let s=n.elts[o];if(s.pos==t)return s}else zm.set(e,n=new cv);let i=n.elts[n.i]=Ta.resolve(e,t);return n.i=(n.i+1)%uv,i}}class cv{constructor(){this.elts=[],this.i=0}}const uv=12,zm=new WeakMap;class J4{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const dv=Object.create(null);let mn=class Ld{constructor(e,t,n,i=fe.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||H.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ec(this.attrs,t||e.defaultAttrs||dv)&&fe.sameSet(this.marks,n||fe.none)}copy(e=null){return e==this.content?this:new Ld(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ld(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Y.empty;let i=this.resolve(e),o=this.resolve(t),s=n?0:i.sharedDepth(t),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new Y(c,i.depth-s,o.depth-s)}replace(e,t,n){return av(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return Ta.resolveCached(this,e)}resolveNoCache(e){return Ta.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),X4(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=H.empty,i=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(n),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=fe.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!fe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=H.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,n);return o.type.checkAttrs(o.attrs),o}};mn.prototype.text=void 0;let hv=class Bd extends mn{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):X4(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bd(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function X4(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Gi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new fv(e,t);if(n.next==null)return Gi.empty;let i=Z4(n);n.next&&n.err("Unexpected trailing text");let o=wv(bv(i));return xv(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let o=t;i&&o<n;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function o(s,a){let l=s.matchFragment(e,n);if(l&&(!t||l.validEnd))return H.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let h=o(d,a.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(n.push({match:a.contentMatch,type:a,via:i}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let o=i+(n.validEnd?"*":" ")+" ";for(let s=0;s<n.next.length;s++)o+=(s?", ":"")+n.next[s].type.name+"->"+e.indexOf(n.next[s].next);return o}).join(`
21
21
  `)}}Gi.empty=new Gi(!0);class fv{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Z4(r){let e=[];do e.push(pv(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function pv(r){let e=[];do e.push(mv(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function mv(r){let e=vv(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=gv(r,e);else break;return e}function Lm(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function gv(r,e){let t=Lm(r),n=t;return r.eat(",")&&(r.next!="}"?n=Lm(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function yv(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function vv(r){if(r.eat("(")){let e=Z4(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=yv(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function bv(r){let e=[[]];return i(o(r,0),t()),e;function t(){return e.push([])-1}function n(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=t())}else if(s.type=="star"){let l=t();return n(a,l),i(o(s.expr,l),l),[n(l)]}else if(s.type=="plus"){let l=t();return i(o(s.expr,a),l),i(o(s.expr,l),l),[n(l)]}else{if(s.type=="opt")return[n(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let u=t();i(o(s.expr,l),u),l=u}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=t();n(l,u),i(o(s.expr,l),u),l=u}return[n(l)]}else{if(s.type=="name")return[n(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Q4(r,e){return e-r}function Bm(r,e){let t=[];return n(e),t.sort(Q4);function n(i){let o=r[i];if(o.length==1&&!o[0].term)return n(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&t.indexOf(l)==-1&&n(l)}}}function wv(r){let e=Object.create(null);return t(Bm(r,0));function t(n){let i=[];n.forEach(s=>{r[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<i.length;u++)i[u][0]==a&&(c=i[u][1]);Bm(r,l).forEach(u=>{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[n.join(",")]=new Gi(n.indexOf(r.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(Q4);o.next.push({type:i[s][0],next:e[a.join(",")]||t(a)})}return o}}function xv(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),n.indexOf(c)==-1&&n.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function e2(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function t2(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let o=r[n];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function r2(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${n}`);for(let i in r)r[i].validate&&r[i].validate(e[i])}function n2(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Sv(r,n,e[n]);return t}let rc=class i2{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=n2(e,n.attrs),this.defaultAttrs=e2(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Gi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:t2(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new mn(this,this.computeAttrs(e),H.from(t),fe.setFrom(n))}createChecked(e=null,t,n){return t=H.from(t),this.checkContent(t),new mn(this,this.computeAttrs(e),t,fe.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=H.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(H.empty,!0);return o?new mn(this,e,t.append(o),fe.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){r2(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:fe.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,s)=>n[o]=new i2(o,t,s));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function kv(r,e,t){let n=t.split("|");return i=>{let o=i===null?"null":typeof i;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${o}`)}}class Sv{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?kv(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Tc{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=n2(e,i.attrs),this.excluded=null;let o=e2(this.attrs);this.instance=o?new fe(this,o):null}create(e=null){return!e&&this.instance?this.instance:new fe(this,t2(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((o,s)=>n[o]=new Tc(o,i++,t,s)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){r2(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Cv{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ot.from(e.nodes),t.marks=ot.from(e.marks||{}),this.nodes=rc.compile(this.spec.nodes,this),this.marks=Tc.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=n[s]||(n[s]=Gi.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?Pm(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Pm(this,s.split(" "))}this.nodeFromJSON=i=>mn.fromJSON(this,i),this.markFromJSON=i=>fe.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof rc){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new hv(n,n.defaultAttrs,e,fe.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Pm(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],o=r.marks[i],s=o;if(o)t.push(o);else for(let a in r.marks){let l=r.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function Mv(r){return r.tag!=null}function Tv(r){return r.style!=null}class Yi{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(Mv(i))this.tags.push(i);else if(Tv(i)){let o=/[^=]*/.exec(i.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let n=new Hm(this,t,!1);return n.addAll(e,fe.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Hm(this,t,!0);return n.addAll(e,fe.none,t.from,t.to),Y.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(Ev(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,n,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!n.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(s.getAttrs){let l=s.getAttrs(t);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let t=[];function n(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let a=t[s];if((a.priority==null?50:a.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{n(s=_m(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{n(s=_m(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yi(e,Yi.schemaRules(e)))}}const o2={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Av={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},s2={ol:!0,ul:!0},Aa=1,Pd=2,ha=4;function Fm(r,e,t){return e!=null?(e?Aa:0)|(e==="full"?Pd:0):r&&r.whitespace=="pre"?Aa|Pd:t&~ha}class y0{constructor(e,t,n,i,o,s){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=s,this.content=[],this.activeMarks=fe.none,this.match=o||(s&ha?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(H.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Aa)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=H.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(H.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!o2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Hm{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Fm(null,t.preserveWhitespace,0)|(n?ha:0);i?o=new y0(i.type,i.attrs,fe.none,!0,t.topMatch||i.type.contentMatch,s):n?o=new y0(null,null,fe.none,!0,null,s):o=new y0(e.schema.topNodeType,null,fe.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,o=i.options&Pd?"full":this.localPreserveWS||(i.options&Aa)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,`
22
22
  `);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=n.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(s.text(a[l]),t,!/\S/.test(a[l]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;s2.hasOwnProperty(s)&&this.parser.normalizeLists&&Nv(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Av.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(o2.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=l&&l.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
23
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=n.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,n,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let l=this.enter(s,t.attrs||null,n,t.preserveWhitespace);l&&(o=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,t,n,i){let o=n||0;for(let s=n?e.childNodes[n]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,n){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(n)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=fe.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):qm(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,n,i){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,i)),o}enterInner(e,t,n,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=Fm(e,o,s.options);s.options&ha&&s.content.length==0&&(a|=ha);let l=fe.none;return n=n.filter(c=>(s.type?s.type.allowsMarkType(c.type):qm(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new y0(e,t,l,i,null,a)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Aa)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:n&&l>=o?n.node(l-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function Nv(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&s2.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Ev(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function _m(r){let e={};for(let t in r)e[t]=r[t];return e}function qm(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class eo{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=v0(t).createDocumentFragment());let i=n,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],u=this.serializeMark(c,s.isInline,t);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),n}serializeNodeInner(e,t){if(e.isText)return v0(t).createTextNode(e.text);let{dom:n,contentDOM:i}=F0(v0(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&F0(v0(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:F0(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new eo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=$m(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return $m(e.marks)}}function $m(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function v0(r){return r.document||window.document}const jm=new WeakMap;function Dv(r){let e=jm.get(r);return e===void 0&&jm.set(r,e=Ov(r)),e}function Ov(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function F0(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=Dv(n))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let a,l=t?r.createElementNS(t,i):r.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?l.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof h=="string")l.appendChild(r.createTextNode(h));else{let{dom:f,contentDOM:m}=F0(r,h,t,n);if(l.appendChild(f),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const a2=65535,l2=Math.pow(2,16);function Rv(r,e){return r+e*l2}function Vm(r){return r&a2}function Iv(r){return(r-(r&a2))/l2}const c2=1,u2=2,H0=4,d2=8;class Fd{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&d2)>0}get deletedBefore(){return(this.delInfo&(c2|H0))>0}get deletedAfter(){return(this.delInfo&(u2|H0))>0}get deletedAcross(){return(this.delInfo&H0)>0}}class $t{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&$t.empty)return $t.empty}recover(e){let t=0,n=Vm(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Iv(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],u=this.ranges[a+s],d=l+c;if(e<=d){let h=c?e==l?-1:e==d?1:t:t,f=l+i+(h<0?0:u);if(n)return f;let m=e==(t<0?l:d)?null:Rv(a/3,e-l),y=e==l?u2:e==d?c2:H0;return(t<0?e!=l:e!=d)&&(y|=d2),new Fd(f,y,m)}i+=u-c}return n?e+i:new Fd(e+i,0,null)}touches(e,t){let n=0,i=Vm(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?n:0);if(l>e)break;let c=this.ranges[a+o],u=l+c;if(e<=u&&a==i*3)return!0;n+=this.ranges[a+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+n];e(a,a+c,l,l+u),o+=u-c}}invert(){return new $t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?$t.empty:new $t(e<0?[0,-e,0]:[0,0,e])}}$t.empty=new $t([]);class Na{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Na(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new Na;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return n?e:new Fd(e,i,null)}}const Du=Object.create(null);class pt{getMap(){return $t.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Du[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Du)throw new RangeError("Duplicate use of step JSON ID "+e);return Du[e]=t,t.prototype.jsonID=e,t}}class Ge{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ge(e,null)}static fail(e){return new Ge(null,e)}static fromReplace(e,t,n,i){try{return Ge.ok(e.replace(t,n,i))}catch(o){if(o instanceof Ma)return Ge.fail(o.message);throw o}}}function Uh(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let o=r.child(i);o.content.size&&(o=o.copy(Uh(o.content,e,o))),o.isInline&&(o=e(o,t,i)),n.push(o)}return H.fromArray(n)}class cn extends pt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new Y(Uh(t.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ge.fromReplace(e,this.from,this.to,o)}invert(){return new Br(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new cn(t.pos,n.pos,this.mark)}merge(e){return e instanceof cn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new cn(t.from,t.to,e.markFromJSON(t.mark))}}pt.jsonID("addMark",cn);class Br extends pt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Y(Uh(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ge.fromReplace(e,this.from,this.to,n)}invert(){return new cn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Br(t.pos,n.pos,this.mark)}merge(e){return e instanceof Br&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Br(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Br(t.from,t.to,e.markFromJSON(t.mark))}}pt.jsonID("removeMark",Br);class Vn extends pt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Vn(this.pos,t.marks[i]);return new Vn(this.pos,this.mark)}}return new Ji(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Vn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Vn(t.pos,e.markFromJSON(t.mark))}}pt.jsonID("addNodeMark",Vn);class Ji extends pt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Vn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ji(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ji(t.pos,e.markFromJSON(t.mark))}}pt.jsonID("removeNodeMark",Ji);class Ke extends pt{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Hd(e,this.from,this.to)?Ge.fail("Structure replace would overwrite content"):Ge.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $t([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ke(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&Ke.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new Ke(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ke)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ke(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ke(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(t.from,t.to,Y.fromJSON(e,t.slice),!!t.structure)}}Ke.MAP_BIAS=1;pt.jsonID("replace",Ke);class dt extends pt{constructor(e,t,n,i,o,s,a=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(Hd(e,this.from,this.gapFrom)||Hd(e,this.gapTo,this.to)))return Ge.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ge.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Ge.fromReplace(e,this.from,this.to,n):Ge.fail("Content does not fit in gap")}getMap(){return new $t([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new dt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||o>n.pos?null:new dt(t.pos,n.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new dt(t.from,t.to,t.gapFrom,t.gapTo,Y.fromJSON(e,t.slice),t.insert,!!t.structure)}}pt.jsonID("replaceAround",dt);function Hd(r,e,t){let n=r.resolve(e),i=t-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,i--;if(i>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function zv(r,e,t,n){let i=[],o=[],s,a;r.doc.nodesBetween(e,t,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let h=Math.max(c,e),f=Math.min(c+l.nodeSize,t),m=n.addToSet(d);for(let y=0;y<d.length;y++)d[y].isInSet(m)||(s&&s.to==h&&s.mark.eq(d[y])?s.to=f:i.push(s=new Br(h,f,d[y])));a&&a.to==h?a.to=f:o.push(a=new cn(h,f,n))}}),i.forEach(l=>r.step(l)),o.forEach(l=>r.step(l))}function Lv(r,e,t,n){let i=[],o=0;r.doc.nodesBetween(e,t,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(n instanceof Tc){let c=s.marks,u;for(;u=n.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(s.marks)&&(l=[n]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,t);for(let u=0;u<l.length;u++){let d=l[u],h;for(let f=0;f<i.length;f++){let m=i[f];m.step==o-1&&d.eq(i[f].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:d,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>r.step(new Br(s.from,s.to,s.style)))}function Kh(r,e,t,n=t.contentMatch,i=!0){let o=r.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,d=n.matchType(c.type);if(!d)s.push(new Ke(a,u,Y.empty));else{n=d;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||r.step(new Br(a,u,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,f=/\r?\n|\r/g,m;for(;h=f.exec(c.text);)m||(m=new Y(H.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new Ke(a+h.index,a+h.index+h[0].length,m))}}a=u}if(!n.validEnd){let l=n.fillBefore(H.empty,!0);r.replace(a,a,new Y(l,0,0))}for(let l=s.length-1;l>=0;l--)r.step(s[l])}function Bv(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Ac(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,o=0;;--n){let s=r.$from.node(n),a=r.$from.index(n)+i,l=r.$to.indexAfter(n)-o;if(n<r.depth&&s.canReplace(a,l,t))return n;if(n==0||s.type.spec.isolating||!Bv(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function Pv(r,e,t){let{$from:n,$to:i,depth:o}=e,s=n.before(o+1),a=i.after(o+1),l=s,c=a,u=H.empty,d=0;for(let m=o,y=!1;m>t;m--)y||n.index(m)>0?(y=!0,u=H.from(n.node(m).copy(u)),d++):l--;let h=H.empty,f=0;for(let m=o,y=!1;m>t;m--)y||i.after(m+1)<i.end(m)?(y=!0,h=H.from(i.node(m).copy(h)),f++):c++;r.step(new dt(l,c,s,a,new Y(u.append(h),d,f),u.size-d,!0))}function Gh(r,e,t=null,n=r){let i=Fv(r,e),o=i&&Hv(n,e);return o?i.map(Wm).concat({type:e,attrs:t}).concat(o.map(Wm)):null}function Wm(r){return{type:r,attrs:null}}function Fv(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(n,i,s)?o:null}function Hv(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.child(n),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=n;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:s}function _v(r,e,t){let n=H.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let a=t[s].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=H.from(t[s].type.create(t[s].attrs,n))}let i=e.start,o=e.end;r.step(new dt(i,o,i,o,new Y(n,0,0),t.length,!0))}function qv(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(n,l)&&$v(r.doc,r.mapping.slice(o).map(a),n)){let c=null;if(n.schema.linebreakReplacement){let f=n.whitespace=="pre",m=!!n.contentMatch.matchType(n.schema.linebreakReplacement);f&&!m?c=!1:!f&&m&&(c=!0)}c===!1&&f2(r,s,a,o),Kh(r,r.mapping.slice(o).map(a,1),n,void 0,c===null);let u=r.mapping.slice(o),d=u.map(a,1),h=u.map(a+s.nodeSize,1);return r.step(new dt(d,h,d+1,h-1,new Y(H.from(n.create(l,null,s.marks)),0,0),1,!0)),c===!0&&h2(r,s,a,o),!1}})}function h2(r,e,t,n){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=r.mapping.slice(n).map(t+1+o+s.index);r.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function f2(r,e,t,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=r.mapping.slice(n).map(t+1+o);r.replaceWith(s,s+1,e.type.schema.text(`
24
- `))}})}function $v(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function jv(r,e,t,n,i){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,i||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new dt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Y(H.from(s),0,0),1,!0))}function fa(r,e,t=1,n){let i=r.resolve(e),o=i.depth-t,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let d=i.node(c),h=i.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),m=n&&n[u+1];m&&(f=f.replaceChild(0,m.type.create(m.attrs)));let y=n&&n[u]||d;if(!d.canReplace(h+1,d.childCount)||!y.type.validContent(f))return!1}let a=i.indexAfter(o),l=n&&n[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function Vv(r,e,t=1,n){let i=r.doc.resolve(e),o=H.empty,s=H.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){o=H.from(i.node(a).copy(o));let u=n&&n[c];s=H.from(u?u.type.create(u.attrs,s):i.node(a).copy(s))}r.step(new Ke(e,e,new Y(o.append(s),t,t),!0))}function Bl(r,e){let t=r.resolve(e),n=t.index();return Uv(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Wv(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function Uv(r,e){return!!(r&&e&&!r.isLeaf&&Wv(r,e))}function Kv(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,o=r.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);u&&!d?n=!1:!u&&d&&(n=!0)}let a=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);f2(r,u.node(),u.before(),a)}s.inlineContent&&Kh(r,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let l=r.mapping.slice(a),c=l.map(e-t);if(r.step(new Ke(c,l.map(e+t,-1),Y.empty,!0)),n===!0){let u=r.doc.resolve(c);h2(r,u.node(),u.before(),r.steps.length)}return r}function Gv(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let o=n.index(i);if(n.node(i).canReplaceWith(o,o,t))return n.before(i+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let o=n.indexAfter(i);if(n.node(i).canReplaceWith(o,o,t))return n.after(i+1);if(o<n.node(i).childCount)return null}return null}function Yv(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let a=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,l=n.index(s)+(a>0?1:0),c=n.node(s),u=!1;if(o==1)u=c.canReplace(l,l,i);else{let d=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?n.pos:a<0?n.before(s+1):n.after(s+1)}return null}function Nc(r,e,t=e,n=Y.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),o=r.resolve(t);return p2(i,o,n)?new Ke(e,t,n):new Jv(i,o,n).fit()}function p2(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Jv{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=H.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=H.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new Y(o,s,a);return e>-1?new dt(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Ke(n.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=Ou(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(H.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:a,parent:o,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:a,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Ou(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Ou(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new Y(ra(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Y(ra(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let s=this.unplaced,a=n?n.content:s.content,l=s.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[t];if(i){for(let y=0;y<i.childCount;y++)u.push(i.child(y));d=d.matchFragment(i)}let f=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let y=a.child(c),x=d.matchType(y.type);if(!x)break;c++,(c>1||l==0||y.content.size)&&(d=x,u.push(m2(y.mark(h.allowedMarks(y.marks)),c==1?l:0,c==a.childCount?f:-1)))}let m=c==a.childCount;m||(f=-1),this.placed=na(this.placed,t,H.from(u)),this.frontier[t].match=d,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=a;y<f;y++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=m?e==0?Y.empty:new Y(ra(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new Y(ra(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ru(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Ru(e,t,i,n,o);if(s){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=Ru(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=na(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=na(this.placed,this.depth,H.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(H.empty,!0);t.childCount&&(this.placed=na(this.placed,this.frontier.length,t))}}function ra(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(ra(r.firstChild.content,e-1,t)))}function na(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(na(r.lastChild.content,e-1,t)))}function Ou(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function m2(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,m2(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(H.empty,!0)))),r.copy(n)}function Ru(r,e,t,n,i){let o=r.node(e),s=i?r.indexAfter(e):r.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let a=n.fillBefore(o.content,!0,s);return a&&!Xv(t,o.content,s)?a:null}function Xv(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Zv(r){return r.spec.defining||r.spec.definingForContent}function Qv(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),o=r.doc.resolve(t);if(p2(i,o,n))return r.step(new Ke(e,t,n));let s=y2(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,f=i.pos-1;h>0;h--,f--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==f&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],u=n.openStart;for(let h=n.content,f=0;;f++){let m=h.firstChild;if(c.push(m),f==n.openStart)break;h=m.content}for(let h=u-1;h>=0;h--){let f=c[h],m=Zv(f.type);if(m&&!f.sameMarkup(i.node(Math.abs(a)-1)))u=h;else if(m||!f.type.isTextblock)break}for(let h=n.openStart;h>=0;h--){let f=(h+u+1)%(n.openStart+1),m=c[f];if(m)for(let y=0;y<s.length;y++){let x=s[(y+l)%s.length],b=!0;x<0&&(b=!1,x=-x);let S=i.node(x-1),A=i.index(x-1);if(S.canReplaceWith(A,A,m.type,m.marks))return r.replace(i.before(x),b?o.after(x):t,new Y(g2(n.content,0,n.openStart,f),f,n.openEnd))}}let d=r.steps.length;for(let h=s.length-1;h>=0&&(r.replace(e,t,n),!(r.steps.length>d));h--){let f=s[h];f<0||(e=i.before(f),t=o.after(f))}}function g2(r,e,t,n,i){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(g2(o.content,e+1,t,n,o)))}if(e>n){let o=i.contentMatchAt(0),s=o.fillBefore(r).append(r);r=s.append(o.matchFragment(s).fillBefore(H.empty,!0))}return r}function e8(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=Gv(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new Y(H.from(n),0,0))}function t8(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let s=n.sharedDepth(t),a=!1;for(let l=n.depth;l>s;l--)n.node(l).type.spec.isolating&&(a=!0);for(let l=i.depth;l>s;l--)i.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=n.depth;l>0&&e==n.start(l);l--)e=n.before(l);for(let l=i.depth;l>0&&t==i.start(l);l--)t=i.before(l);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let o=y2(n,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||n.node(a).type.contentMatch.validEnd)return r.delete(n.start(a),i.end(a));if(a>0&&(l||n.node(a-1).canReplace(n.index(a-1),i.indexAfter(a-1))))return r.delete(n.before(a),i.after(a))}for(let s=1;s<=n.depth&&s<=i.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&i.end(s)-t!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return r.delete(n.before(s),t);r.delete(e,t)}function y2(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let o=r.start(i);if(o<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Eo extends pt{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(i),0,t.isLeaf?0:1))}getMap(){return $t.empty}invert(e){return new Eo(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Eo(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Eo(t.pos,t.attr,t.value)}}pt.jsonID("attr",Eo);class Ea extends pt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Ge.ok(n)}getMap(){return $t.empty}invert(e){return new Ea(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ea(t.attr,t.value)}}pt.jsonID("docAttr",Ea);let vs=class extends Error{};vs=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};vs.prototype=Object.create(Error.prototype);vs.prototype.constructor=vs;vs.prototype.name="TransformError";class v2{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Na}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vs(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Y.empty){let i=Nc(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new Y(H.from(n),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Qv(this,e,t,n),this}replaceRangeWith(e,t,n){return e8(this,e,t,n),this}deleteRange(e,t){return t8(this,e,t),this}lift(e,t){return Pv(this,e,t),this}join(e,t=1){return Kv(this,e,t),this}wrap(e,t){return _v(this,e,t),this}setBlockType(e,t=e,n,i=null){return qv(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return jv(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new Eo(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ea(e,t)),this}addNodeMark(e,t){return this.step(new Vn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof fe)t.isInSet(n.marks)&&this.step(new Ji(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Ji(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,t=1,n){return Vv(this,e,t,n),this}addMark(e,t,n){return zv(this,e,t,n),this}removeMark(e,t,n){return Lv(this,e,t,n),this}clearIncompatible(e,t,n){return Kh(this,e,t,n),this}}const Iu=Object.create(null);class ue{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new b2(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Y.empty){let n=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],u=e.mapping.slice(o);e.replaceRange(u.map(l.pos),u.map(c.pos),a?Y.empty:t),a==0&&Gm(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(n),c=l.map(s.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Gm(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new Q(e):xo(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?xo(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):xo(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Rt(e.node(0))}static atStart(e){return xo(e,e,0,0,1)||new Rt(e)}static atEnd(e){return xo(e,e,e.content.size,e.childCount,-1)||new Rt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Iu[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Iu)throw new RangeError("Duplicate use of selection JSON ID "+e);return Iu[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class b2{constructor(e,t){this.$from=e,this.$to=t}}let Um=!1;function Km(r){!Um&&!r.parent.inlineContent&&(Um=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class Q extends ue{constructor(e,t=e){Km(e),Km(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return ue.near(n);let i=e.resolve(t.map(this.anchor));return new Q(i.parent.inlineContent?i:n,n)}replace(e,t=Y.empty){if(super.replace(e,t),t==Y.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ec(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let o=ue.findFrom(t,n,!0)||ue.findFrom(t,-n,!0);if(o)t=o.$head;else return ue.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(ue.findFrom(e,-n,!0)||ue.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new Q(e,t)}}ue.jsonID("text",Q);class Ec{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ec(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class re extends ue{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return n?ue.near(o):new re(o)}content(){return new Y(H.from(this.node),0,0)}eq(e){return e instanceof re&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Yh(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new re(e.resolve(t.anchor))}static create(e,t){return new re(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}re.prototype.visible=!1;ue.jsonID("node",re);class Yh{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Ec(n,n):new Yh(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&re.isSelectable(n)?new re(t):ue.near(t)}}class Rt extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==Y.empty){e.delete(0,e.doc.content.size);let n=ue.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Rt(e)}map(e){return new Rt(e)}eq(e){return e instanceof Rt}getBookmark(){return r8}}ue.jsonID("all",Rt);const r8={map(){return this},resolve(r){return new Rt(r)}};function xo(r,e,t,n,i,o=!1){if(e.inlineContent)return Q.create(r,t);for(let s=n-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&re.isSelectable(a))return re.create(r,t-(i<0?a.nodeSize:0))}else{let l=xo(r,a,t+i,i<0?a.childCount:0,i,o);if(l)return l}t+=a.nodeSize*i}return null}function Gm(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof Ke||i instanceof dt))return;let o=r.mapping.maps[n],s;o.forEach((a,l,c,u)=>{s==null&&(s=u)}),r.setSelection(ue.near(r.doc.resolve(s),t))}const Ym=1,b0=2,Jm=4;class n8 extends v2{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ym)&~b0,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ym)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=b0,this}ensureMarks(e){return fe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&b0)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~b0,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||fe.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(ue.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Jm,this}get scrolledIntoView(){return(this.updated&Jm)>0}}function Xm(r,e){return!e||!r?r:r.bind(e)}class ia{constructor(e,t,n){this.name=e,this.init=Xm(t.init,n),this.apply=Xm(t.apply,n)}}const i8=[new ia("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new ia("selection",{init(r,e){return r.selection||ue.atStart(e.doc)},apply(r){return r.selection}}),new ia("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new ia("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class zu{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=i8.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new ia(n.key,n.spec.state,n))})}}class bi{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,u=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,n);if(u&&n.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),o=!0}i&&(i[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new bi(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let o=n[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new n8(this)}static create(e){let t=new zu(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new bi(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new zu(this.schema,e.plugins),n=t.fields,i=new bi(t);for(let o=0;o<n.length;o++){let s=n[o].name;i[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],o=i.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new zu(e.schema,e.plugins),o=new bi(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=mn.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=ue.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){o[s.name]=c.fromJSON.call(l,e,t[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function w2(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=w2(i,e,{})),t[n]=i}return t}class Ce{constructor(e){this.spec=e,this.props={},e.props&&w2(e.props,this,this.props),this.key=e.key?e.key.key:x2("plugin")}getState(e){return e[this.key]}}const Lu=Object.create(null);function x2(r){return r in Lu?r+"$"+ ++Lu[r]:(Lu[r]=0,r+"$")}class Me{constructor(e="key"){this.key=x2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const st=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},bs=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let _d=null;const Zr=function(r,e,t){let n=_d||(_d=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},o8=function(){_d=null},Xi=function(r,e,t,n){return t&&(Zm(r,e,t,n,-1)||Zm(r,e,t,n,1))},s8=/^(img|br|input|textarea|hr)$/i;function Zm(r,e,t,n,i){for(var o;;){if(r==t&&e==n)return!0;if(e==(i<0?0:ir(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Pl(r)||s8.test(r.nodeName)||r.contentEditable=="false")return!1;e=st(r)+(i<0?0:1),r=s}else if(r.nodeType==1){let s=r.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else r=s,e=i<0?ir(r):0}else return!1}}function ir(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function a8(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=ir(r)}else if(r.parentNode&&!Pl(r))e=st(r),r=r.parentNode;else return null}}function l8(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Pl(r))e=st(r)+1,r=r.parentNode;else return null}}function c8(r,e,t){for(let n=e==0,i=e==ir(r);n||i;){if(r==t)return!0;let o=st(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,i=i&&o==ir(r)}}function Pl(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Dc=function(r){return r.focusNode&&Xi(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function yi(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function u8(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function d8(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(ir(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(ir(n.startContainer),n.startOffset)}}}const $r=typeof navigator<"u"?navigator:null,Qm=typeof document<"u"?document:null,ti=$r&&$r.userAgent||"",qd=/Edge\/(\d+)/.exec(ti),k2=/MSIE \d/.exec(ti),$d=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ti),It=!!(k2||$d||qd),Un=k2?document.documentMode:$d?+$d[1]:qd?+qd[1]:0,sr=!It&&/gecko\/(\d+)/i.test(ti);sr&&+(/Firefox\/(\d+)/.exec(ti)||[0,0])[1];const jd=!It&&/Chrome\/(\d+)/.exec(ti),at=!!jd,S2=jd?+jd[1]:0,ft=!It&&!!$r&&/Apple Computer/.test($r.vendor),ws=ft&&(/Mobile\/\w+/.test(ti)||!!$r&&$r.maxTouchPoints>2),nr=ws||($r?/Mac/.test($r.platform):!1),C2=$r?/Win/.test($r.platform):!1,un=/Android \d/.test(ti),Fl=!!Qm&&"webkitFontSmoothing"in Qm.documentElement.style,h8=Fl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function f8(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Yr(r,e){return typeof r=="number"?r:r[e]}function p8(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function e1(r,e,t){if(!Vd(e)&&e.left==0)return;let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let s=t||r.dom;s;){if(s.nodeType!=1){s=bs(s);continue}let a=s,l=a==o.body,c=l?f8(o):p8(a),u=0,d=0;if(e.top<c.top+Yr(n,"top")?d=-(c.top-e.top+Yr(i,"top")):e.bottom>c.bottom-Yr(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Yr(i,"top")-c.top:e.bottom-c.bottom+Yr(i,"bottom")),e.left<c.left+Yr(n,"left")?u=-(c.left-e.left+Yr(i,"left")):e.right>c.right-Yr(n,"right")&&(u=e.right-c.right+Yr(i,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,m=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let y=a.scrollLeft-f,x=a.scrollTop-m;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:bs(s)}}function m8(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=r.root.elementFromPoint(o,s);if(!a||a==r.dom||!r.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){n=a,i=l.top;break}}return{refDOM:n,refTop:i,stack:M2(r.dom)}}function M2(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=bs(n));return e}function g8({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;T2(t,n==0?0:n-e)}function T2(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:o}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let yo=null;function y8(r){if(r.setActive)return r.setActive();if(yo)return r.focus(yo);let e=M2(r);r.focus(yo==null?{get preventScroll(){return yo={preventScroll:!0},!0}}:void 0),yo||(yo=!1,T2(e,0))}function A2(r,e){let t,n=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let u=r.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Zr(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let m=h[f];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let y=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(y<n){t=u,n=y,i=y&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&y&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!t&&l&&(t=l,i=c,n=0),t&&t.nodeType==3?v8(t,i):!t||n&&t.nodeType==1?{node:r,offset:o}:A2(t,i)}function v8(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let o=0;o<t;o++){n.setEnd(r,o+1),n.setStart(r,o);let s=On(n,1);if(s.top!=s.bottom&&Jh(e,s)){i={node:r,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function Jh(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function b8(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function w8(r,e,t){let{node:n,offset:i}=A2(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return r.docView.posFromDOM(n,i,o)}function x8(r,e,t,n){let i=-1;for(let o=e,s=!1;o!=r.dom;){let a=r.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>n.left||l.top>n.top?i=a.posBefore:(!s&&l.right<n.left||l.bottom<n.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?n.top<(l.top+l.bottom)/2:n.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function N2(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=r.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Jh(e,c))return N2(s,e,c)}}if((o=(o+1)%n)==i)break}return r}function k8(r,e){let t=r.dom.ownerDocument,n,i=0,o=d8(t,e.left,e.top);o&&({node:n,offset:i}=o);let s=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),a;if(!s||!r.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=r.dom.getBoundingClientRect();if(!Jh(e,c)||(s=N2(r.dom,e,c),!s))return null}if(ft)for(let c=s;n&&c;c=bs(c))c.draggable&&(n=void 0);if(s=b8(s,e),n){if(sr&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let u=n.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Fl&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?a=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(a=x8(r,n,i,e))}a==null&&(a=w8(r,s,e));let l=r.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Vd(r){return r.top<r.bottom||r.left<r.right}function On(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Vd(n))return n}return Array.prototype.find.call(t,Vd)||r.getBoundingClientRect()}const S8=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function E2(r,e,t){let{node:n,offset:i,atom:o}=r.docView.domFromPos(e,t<0?-1:1),s=Fl||sr;if(n.nodeType==3)if(s&&(S8.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let l=On(Zr(n,i,i),t);if(sr&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=On(Zr(n,i-1,i-1),-1);if(c.top==l.top){let u=On(Zr(n,i,i+1),-1);if(u.top!=l.top)return Ys(u,u.left<c.left)}}return l}else{let l=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==n.nodeValue.length?(l--,u=1):t<0?l--:c++,Ys(On(Zr(n,l,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==ir(n))){let l=n.childNodes[i-1];if(l.nodeType==1)return Bu(l.getBoundingClientRect(),!1)}if(o==null&&i<ir(n)){let l=n.childNodes[i];if(l.nodeType==1)return Bu(l.getBoundingClientRect(),!0)}return Bu(n.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==ir(n))){let l=n.childNodes[i-1],c=l.nodeType==3?Zr(l,ir(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Ys(On(c,1),!1)}if(o==null&&i<ir(n)){let l=n.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Zr(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Ys(On(c,-1),!0)}return Ys(On(n.nodeType==3?Zr(n):n,-t),t>=0)}function Ys(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function Bu(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function D2(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function C8(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return D2(r,e,()=>{let{node:o}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=r.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=E2(r,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Zr(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const M8=/[\u0590-\u08ac]/;function T8(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,o=!i,s=i==n.parent.content.size,a=r.domSelection();return a?!M8.test(n.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:D2(r,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=r.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let f=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:m,focusOffset:y}=r.domSelectionRange(),x=m&&!f.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==y;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),x}):n.pos==n.start()||n.pos==n.end()}let t1=null,r1=null,n1=!1;function A8(r,e,t){return t1==e&&r1==t?n1:(t1=e,r1=t,n1=t=="up"||t=="down"?C8(r,e,t):T8(r,e,t))}const ar=0,i1=1,wi=2,kr=3;class Hl{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ar,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>st(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],a=o+s.size;if(a>e||s instanceof R2){i=e-o;break}o=a}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof O2&&o.side>=0;n--);if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?st(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?st(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let u=s+l.border;if(e>=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=s;for(let d=a;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=st(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let u=a+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=st(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let f=0,m=0;f<this.children.length;f++){let y=this.children[f],x=m+y.size;if(o>m&&s<x)return y.setSelection(e-m-y.border,t-m-y.border,n,i);m=x}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),d=!1;if((sr||ft)&&e==t){let{node:f,offset:m}=a;if(f.nodeType==3){if(d=!!(m&&f.nodeValue[m-1]==`
25
- `),d&&m==f.nodeValue.length)for(let y=f,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(a=l={node:x.parentNode,offset:st(x)+1});break}let b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=f.childNodes[m-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(sr&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||d&&ft)&&Xi(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Xi(l.node,l.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(d&&sr)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let m=a;a=l,l=m}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let a=n+o.border,l=s-o.border;if(e>=a&&t<=l){this.dirty=e==n||t==s?wi:i1,e==a&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=kr:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wi:kr}n=s}this.dirty=wi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?wi:i1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class O2 extends Hl{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ar&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class N8 extends Hl{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Kn extends Hl{constructor(e,t,n,i,o){super(e,[],n,i),this.mark=t,this.spec=o}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=eo.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Kn(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&kr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=kr&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ar){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ar}}slice(e,t,n){let i=Kn.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=Ud(o,t,s,n)),e>0&&(o=Ud(o,0,e,n));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Gn extends Hl{constructor(e,t,n,i,o,s,a){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=a}static create(e,t,n,i,o,s){let a=o.nodeViews[t.type.name],l,c=a&&a(t,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},n,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=eo.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let h=u;return u=L2(u,n,t),c?l=new E8(e,t,n,i,u,d||null,h,c):t.isText?new Oc(e,t,n,i,u,h):new Gn(e,t,n,i,u,d||null,h)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));n?t.contentElement=n:t.getContent=()=>H.empty}}return t}matchesNode(e,t,n){return this.dirty==ar&&e.eq(this.node)&&nc(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new O8(this,s&&s.node,e);z8(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?fe.none:this.node.child(u).marks,n,e,u),l.placeWidget(c,e,i)},(c,u,d,h)=>{l.syncToMarks(c.marks,n,e,h);let f;l.findNodeMatch(c,u,d,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(f=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,u,d,f,e)||l.updateNextNode(c,u,d,e,h,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],n,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==wi)&&(s&&this.protectLocalComposition(e,s),I2(this.contentDOM,this.children,e),ws&&L8(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof Q)||n<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=B8(this.node.content,s,n-t,i-t);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new N8(this,o,t,i);e.input.compositionNodes.push(s),this.children=Ud(this.children,n,n+i.length,e,s)}update(e,t,n,i){return this.dirty==kr||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ar}updateOuterDeco(e){if(nc(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=z2(this.dom,this.nodeDOM,Wd(this.outerDeco,this.node,t),Wd(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function o1(r,e,t,n,i){L2(n,e,r);let o=new Gn(void 0,r,e,t,n,n,n);return o.contentDOM&&o.updateChildren(i,0),o}class Oc extends Gn{constructor(e,t,n,i,o,s){super(e,t,n,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==kr||this.dirty!=ar&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ar||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ar,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new Oc(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=kr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class R2 extends Hl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ar&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class E8 extends Gn{constructor(e,t,n,i,o,s,a,l){super(e,t,n,i,o,s,a),this.spec=l}update(e,t,n,i){if(this.dirty==kr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function I2(r,e,t){let n=r.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==r){for(;a!=n;)n=s1(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(a,n);if(s instanceof Kn){let l=n?n.previousSibling:r.lastChild;I2(s.contentDOM,s.children,t),n=l?l.nextSibling:r.firstChild}}for(;n;)n=s1(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const pa=function(r){r&&(this.nodeName=r)};pa.prototype=Object.create(null);const xi=[new pa];function Wd(r,e,t){if(r.length==0)return xi;let n=t?xi[0]:new pa,i=[n];for(let o=0;o<r.length;o++){let s=r[o].type.attrs;if(s){s.nodeName&&i.push(n=new pa(s.nodeName));for(let a in s){let l=s[a];l!=null&&(t&&i.length==1&&i.push(n=new pa(e.isInline?"span":"div")),a=="class"?n.class=(n.class?n.class+" ":"")+l:a=="style"?n.style=(n.style?n.style+";":"")+l:a!="nodeName"&&(n[a]=l))}}}return i}function z2(r,e,t,n){if(t==xi&&n==xi)return e;let i=e;for(let o=0;o<n.length;o++){let s=n[o],a=t[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=r&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=xi[0]),i=l}D8(i,a||xi[0],s)}return i}function D8(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)i.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<i.length;o++)n.indexOf(i[o])==-1&&r.classList.add(i[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function L2(r,e,t){return z2(r,r,xi,Wd(e,t,r.nodeType!=1))}function nc(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function s1(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class O8{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=R8(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=ar,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){l=u;break}}if(l<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Kn&&u.dirty!=kr&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Kn.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==kr&&s.dom==s.contentDOM&&(s.dirty=wi),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Gn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let u=l.dom,d,h=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=kr&&nc(t,l.outerDeco));if(!h&&l.update(e,t,n,i))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(l,e,t,n,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=wi,d.updateChildren(i,s+1),d.dirty=ar),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!nc(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Gn.create(this.top,t,n,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,n,i,o){let s=Gn.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new O2(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Kn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Oc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ft||at)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new R2(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function R8(r,e){let t=e,n=t.children.length,i=r.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(n){let c=t.children[n-1];if(c instanceof Kn)t=c,n=c.children.length;else{a=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=r.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function I8(r,e){return r.type.side-e.type.side}function z8(r,e,t,n){let i=e.locals(r),o=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let u,d;for(;s<i.length&&i[s].to==o;){let x=i[s++];x.widget&&(u?(d||(d=[u])).push(x):u=x)}if(u)if(d){d.sort(I8);for(let x=0;x<d.length;x++)t(d[x],c,!!l)}else t(u,c,!!l);let h,f;if(l)f=-1,h=l,l=null;else if(c<r.childCount)f=c,h=r.child(c++);else break;for(let x=0;x<a.length;x++)a[x].to<=o&&a.splice(x--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let x=m;s<i.length&&i[s].from<x&&(x=i[s].from);for(let b=0;b<a.length;b++)a[b].to<x&&(x=a[b].to);x<m&&(l=h.cut(x-o),h=h.cut(0,x-o),m=x,f=-1)}else for(;s<i.length&&i[s].to<m;)s++;let y=h.isInline&&!h.isLeaf?a.filter(x=>!x.inline):a.slice();n(h,y,e.forChild(o,h),f),o=m}}function L8(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function B8(r,e,t,n){for(let i=0,o=0;i<r.childCount&&o<=n;){let s=r.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<r.childCount;){let c=r.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=t){if(o>=n&&l.slice(n-e.length-a,n-a)==e)return n-e.length;let c=a<n?l.lastIndexOf(e,n-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==n&&l.length>=n+e.length-a&&l.slice(n-a,n-a+e.length)==e)return n}}return-1}function Ud(r,e,t,n,i){let o=[];for(let s=0,a=0;s<r.length;s++){let l=r[s],c=a,u=a+=l.size;c>=t||u<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,n)),i&&(o.push(i),i=void 0),u>t&&o.push(l.slice(t-c,l.size,n)))}return o}function Xh(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let a=n.resolve(s),l,c;if(Dc(t)){for(l=s;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&re.isSelectable(d)&&i.parent&&!(d.isInline&&c8(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new re(s==h?a:n.resolve(h))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,h=s;for(let f=0;f<t.rangeCount;f++){let m=t.getRangeAt(f);d=Math.min(d,r.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,r.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,s]=h==r.state.selection.anchor?[h,d]:[d,h],a=n.resolve(s)}else l=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let u=n.resolve(l);if(!c){let d=e=="pointer"||r.state.selection.head<a.pos&&!o?1:-1;c=Zh(r,u,a,d)}return c}function B2(r){return r.editable?r.hasFocus():F2(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function gn(r,e=!1){let t=r.state.selection;if(P2(r,t),!B2(r))return;let n=r.input.mouseDown;if(!e&&at&&n){let i=r.domSelectionRange(),o=r.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Xi(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&n.delaySelUpdate()){r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)F8(r);else{let{anchor:i,head:o}=t,s,a;a1&&!(t instanceof Q)&&(t.$from.parent.inlineContent||(s=l1(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=l1(r,t.to))),r.docView.setSelection(i,o,r,e),a1&&(s&&c1(s),a&&c1(a)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&P8(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}const a1=ft||at&&S2<63;function l1(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ft&&i&&i.contentEditable=="false")return Pu(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Pu(i);if(o)return Pu(o)}}function Pu(r){return r.contentEditable="true",ft&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function c1(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function P8(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!B2(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function F8(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,st(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&It&&Un<=11&&(t.disabled=!0,t.disabled=!1)}function P2(r,e){if(e instanceof re){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(u1(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else u1(r)}function u1(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Zh(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||Q.between(e,t,n)}function d1(r){return r.editable&&!r.hasFocus()?!1:F2(r)}function F2(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function H8(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Xi(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Kd(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),o=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return o&&ue.findFrom(o,e)}function Rn(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function h1(r,e,t){let n=r.state.selection;if(n instanceof Q)if(t.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=r.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Rn(r,new Q(n.$anchor,s))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Kd(r.state,e);return i&&i instanceof re?Rn(r,i):!1}else if(!(nr&&t.indexOf("m")>-1)){let i=n.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=r.docView.descAt(a))&&!s.contentDOM?re.isSelectable(o)?Rn(r,new re(e<0?r.state.doc.resolve(i.pos-o.nodeSize):i)):Fl?Rn(r,new Q(r.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof re&&n.node.isInline)return Rn(r,new Q(e>0?n.$to:n.$from));{let i=Kd(r.state,e);return i?Rn(r,i):!1}}}function ic(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function ma(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function vo(r,e){return e<0?_8(r):q8(r)}function _8(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,o,s=!1;for(sr&&t.nodeType==1&&n<ic(t)&&ma(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(t.nodeType!=1)break;{let a=t.childNodes[n-1];if(ma(a,-1))i=t,o=--n;else if(a.nodeType==3)t=a,n=t.nodeValue.length;else break}}else{if(H2(t))break;{let a=t.previousSibling;for(;a&&ma(a,-1);)i=t.parentNode,o=st(a),a=a.previousSibling;if(a)t=a,n=ic(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}s?Gd(r,t,n):i&&Gd(r,i,o)}function q8(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=ic(t),o,s;for(;;)if(n<i){if(t.nodeType!=1)break;let a=t.childNodes[n];if(ma(a,1))o=t,s=++n;else break}else{if(H2(t))break;{let a=t.nextSibling;for(;a&&ma(a,1);)o=a.parentNode,s=st(a)+1,a=a.nextSibling;if(a)t=a,n=0,i=ic(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}o&&Gd(r,o,s)}function H2(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function $8(r,e){for(;r&&e==r.childNodes.length&&!Pl(r);)e=st(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function j8(r,e){for(;r&&!e&&!Pl(r);)e=st(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Gd(r,e,t){if(e.nodeType!=3){let o,s;(s=$8(e,t))?(e=s,t=0):(o=j8(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(Dc(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&gn(r)},50)}function f1(r,e){let t=r.state.doc.resolve(e);if(!(at||C2)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function p1(r,e,t){let n=r.state.selection;if(n instanceof Q&&!n.empty||t.indexOf("s")>-1||nr&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let s=Kd(r.state,e);if(s&&s instanceof re)return Rn(r,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=n instanceof Rt?ue.near(s,e):ue.findFrom(s,e);return a?Rn(r,a):!1}return!1}function m1(r,e){if(!(r.state.selection instanceof Q))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=r.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),r.dispatch(s),!0}return!1}function g1(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function V8(r){if(!ft||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;g1(r,n,"true"),setTimeout(()=>g1(r,n,"false"),20)}return!1}function W8(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function U8(r,e){let t=e.keyCode,n=W8(e);if(t==8||nr&&t==72&&n=="c")return m1(r,-1)||vo(r,-1);if(t==46&&!e.shiftKey||nr&&t==68&&n=="c")return m1(r,1)||vo(r,1);if(t==13||t==27)return!0;if(t==37||nr&&t==66&&n=="c"){let i=t==37?f1(r,r.state.selection.from)=="ltr"?-1:1:-1;return h1(r,i,n)||vo(r,i)}else if(t==39||nr&&t==70&&n=="c"){let i=t==39?f1(r,r.state.selection.from)=="ltr"?1:-1:1;return h1(r,i,n)||vo(r,i)}else{if(t==38||nr&&t==80&&n=="c")return p1(r,-1,n)||vo(r,-1);if(t==40||nr&&t==78&&n=="c")return V8(r)||p1(r,1,n)||vo(r,1);if(n==(nr?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Qh(r,e){r.someProp("transformCopied",f=>{e=f(e,r)});let t=[],{content:n,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,o--;let f=n.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),n=f.content}let s=r.someProp("clipboardSerializer")||eo.fromSchema(r.state.schema),a=W2(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=V2[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let m=a.createElement(u[f]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let h=r.someProp("clipboardTextSerializer",f=>f(e,r))||e.content.textBetween(0,e.content.size,`
23
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=n.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,n,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let l=this.enter(s,t.attrs||null,n,t.preserveWhitespace);l&&(o=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,t,n,i){let o=n||0;for(let s=n?e.childNodes[n]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,n){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(n)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=fe.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):qm(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,n,i){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,i)),o}enterInner(e,t,n,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=Fm(e,o,s.options);s.options&ha&&s.content.length==0&&(a|=ha);let l=fe.none;return n=n.filter(c=>(s.type?s.type.allowsMarkType(c.type):qm(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new y0(e,t,l,i,null,a)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Aa)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:n&&l>=o?n.node(l-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function Nv(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&s2.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Ev(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function _m(r){let e={};for(let t in r)e[t]=r[t];return e}function qm(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class eo{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=v0(t).createDocumentFragment());let i=n,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],u=this.serializeMark(c,s.isInline,t);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),n}serializeNodeInner(e,t){if(e.isText)return v0(t).createTextNode(e.text);let{dom:n,contentDOM:i}=F0(v0(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&F0(v0(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:F0(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new eo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=jm(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return jm(e.marks)}}function jm(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function v0(r){return r.document||window.document}const $m=new WeakMap;function Dv(r){let e=$m.get(r);return e===void 0&&$m.set(r,e=Ov(r)),e}function Ov(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function F0(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=Dv(n))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let a,l=t?r.createElementNS(t,i):r.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?l.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof h=="string")l.appendChild(r.createTextNode(h));else{let{dom:f,contentDOM:m}=F0(r,h,t,n);if(l.appendChild(f),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const a2=65535,l2=Math.pow(2,16);function Rv(r,e){return r+e*l2}function Vm(r){return r&a2}function Iv(r){return(r-(r&a2))/l2}const c2=1,u2=2,H0=4,d2=8;class Fd{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&d2)>0}get deletedBefore(){return(this.delInfo&(c2|H0))>0}get deletedAfter(){return(this.delInfo&(u2|H0))>0}get deletedAcross(){return(this.delInfo&H0)>0}}class jt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&jt.empty)return jt.empty}recover(e){let t=0,n=Vm(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Iv(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],u=this.ranges[a+s],d=l+c;if(e<=d){let h=c?e==l?-1:e==d?1:t:t,f=l+i+(h<0?0:u);if(n)return f;let m=e==(t<0?l:d)?null:Rv(a/3,e-l),y=e==l?u2:e==d?c2:H0;return(t<0?e!=l:e!=d)&&(y|=d2),new Fd(f,y,m)}i+=u-c}return n?e+i:new Fd(e+i,0,null)}touches(e,t){let n=0,i=Vm(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?n:0);if(l>e)break;let c=this.ranges[a+o],u=l+c;if(e<=u&&a==i*3)return!0;n+=this.ranges[a+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+n];e(a,a+c,l,l+u),o+=u-c}}invert(){return new jt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?jt.empty:new jt(e<0?[0,-e,0]:[0,0,e])}}jt.empty=new jt([]);class Na{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Na(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new Na;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return n?e:new Fd(e,i,null)}}const Du=Object.create(null);class pt{getMap(){return jt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Du[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Du)throw new RangeError("Duplicate use of step JSON ID "+e);return Du[e]=t,t.prototype.jsonID=e,t}}class Ge{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ge(e,null)}static fail(e){return new Ge(null,e)}static fromReplace(e,t,n,i){try{return Ge.ok(e.replace(t,n,i))}catch(o){if(o instanceof Ma)return Ge.fail(o.message);throw o}}}function Uh(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let o=r.child(i);o.content.size&&(o=o.copy(Uh(o.content,e,o))),o.isInline&&(o=e(o,t,i)),n.push(o)}return H.fromArray(n)}class cn extends pt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new Y(Uh(t.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ge.fromReplace(e,this.from,this.to,o)}invert(){return new Br(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new cn(t.pos,n.pos,this.mark)}merge(e){return e instanceof cn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new cn(t.from,t.to,e.markFromJSON(t.mark))}}pt.jsonID("addMark",cn);class Br extends pt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Y(Uh(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ge.fromReplace(e,this.from,this.to,n)}invert(){return new cn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Br(t.pos,n.pos,this.mark)}merge(e){return e instanceof Br&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Br(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Br(t.from,t.to,e.markFromJSON(t.mark))}}pt.jsonID("removeMark",Br);class Vn extends pt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Vn(this.pos,t.marks[i]);return new Vn(this.pos,this.mark)}}return new Ji(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Vn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Vn(t.pos,e.markFromJSON(t.mark))}}pt.jsonID("addNodeMark",Vn);class Ji extends pt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Vn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ji(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ji(t.pos,e.markFromJSON(t.mark))}}pt.jsonID("removeNodeMark",Ji);class Ke extends pt{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Hd(e,this.from,this.to)?Ge.fail("Structure replace would overwrite content"):Ge.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new jt([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ke(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&Ke.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new Ke(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ke)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ke(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ke(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(t.from,t.to,Y.fromJSON(e,t.slice),!!t.structure)}}Ke.MAP_BIAS=1;pt.jsonID("replace",Ke);class dt extends pt{constructor(e,t,n,i,o,s,a=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(Hd(e,this.from,this.gapFrom)||Hd(e,this.gapTo,this.to)))return Ge.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ge.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Ge.fromReplace(e,this.from,this.to,n):Ge.fail("Content does not fit in gap")}getMap(){return new jt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new dt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||o>n.pos?null:new dt(t.pos,n.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new dt(t.from,t.to,t.gapFrom,t.gapTo,Y.fromJSON(e,t.slice),t.insert,!!t.structure)}}pt.jsonID("replaceAround",dt);function Hd(r,e,t){let n=r.resolve(e),i=t-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,i--;if(i>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function zv(r,e,t,n){let i=[],o=[],s,a;r.doc.nodesBetween(e,t,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let h=Math.max(c,e),f=Math.min(c+l.nodeSize,t),m=n.addToSet(d);for(let y=0;y<d.length;y++)d[y].isInSet(m)||(s&&s.to==h&&s.mark.eq(d[y])?s.to=f:i.push(s=new Br(h,f,d[y])));a&&a.to==h?a.to=f:o.push(a=new cn(h,f,n))}}),i.forEach(l=>r.step(l)),o.forEach(l=>r.step(l))}function Lv(r,e,t,n){let i=[],o=0;r.doc.nodesBetween(e,t,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(n instanceof Tc){let c=s.marks,u;for(;u=n.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(s.marks)&&(l=[n]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,t);for(let u=0;u<l.length;u++){let d=l[u],h;for(let f=0;f<i.length;f++){let m=i[f];m.step==o-1&&d.eq(i[f].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:d,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>r.step(new Br(s.from,s.to,s.style)))}function Kh(r,e,t,n=t.contentMatch,i=!0){let o=r.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,d=n.matchType(c.type);if(!d)s.push(new Ke(a,u,Y.empty));else{n=d;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||r.step(new Br(a,u,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,f=/\r?\n|\r/g,m;for(;h=f.exec(c.text);)m||(m=new Y(H.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new Ke(a+h.index,a+h.index+h[0].length,m))}}a=u}if(!n.validEnd){let l=n.fillBefore(H.empty,!0);r.replace(a,a,new Y(l,0,0))}for(let l=s.length-1;l>=0;l--)r.step(s[l])}function Bv(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Ac(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,o=0;;--n){let s=r.$from.node(n),a=r.$from.index(n)+i,l=r.$to.indexAfter(n)-o;if(n<r.depth&&s.canReplace(a,l,t))return n;if(n==0||s.type.spec.isolating||!Bv(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function Pv(r,e,t){let{$from:n,$to:i,depth:o}=e,s=n.before(o+1),a=i.after(o+1),l=s,c=a,u=H.empty,d=0;for(let m=o,y=!1;m>t;m--)y||n.index(m)>0?(y=!0,u=H.from(n.node(m).copy(u)),d++):l--;let h=H.empty,f=0;for(let m=o,y=!1;m>t;m--)y||i.after(m+1)<i.end(m)?(y=!0,h=H.from(i.node(m).copy(h)),f++):c++;r.step(new dt(l,c,s,a,new Y(u.append(h),d,f),u.size-d,!0))}function Gh(r,e,t=null,n=r){let i=Fv(r,e),o=i&&Hv(n,e);return o?i.map(Wm).concat({type:e,attrs:t}).concat(o.map(Wm)):null}function Wm(r){return{type:r,attrs:null}}function Fv(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(n,i,s)?o:null}function Hv(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.child(n),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=n;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:s}function _v(r,e,t){let n=H.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let a=t[s].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=H.from(t[s].type.create(t[s].attrs,n))}let i=e.start,o=e.end;r.step(new dt(i,o,i,o,new Y(n,0,0),t.length,!0))}function qv(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(n,l)&&jv(r.doc,r.mapping.slice(o).map(a),n)){let c=null;if(n.schema.linebreakReplacement){let f=n.whitespace=="pre",m=!!n.contentMatch.matchType(n.schema.linebreakReplacement);f&&!m?c=!1:!f&&m&&(c=!0)}c===!1&&f2(r,s,a,o),Kh(r,r.mapping.slice(o).map(a,1),n,void 0,c===null);let u=r.mapping.slice(o),d=u.map(a,1),h=u.map(a+s.nodeSize,1);return r.step(new dt(d,h,d+1,h-1,new Y(H.from(n.create(l,null,s.marks)),0,0),1,!0)),c===!0&&h2(r,s,a,o),!1}})}function h2(r,e,t,n){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=r.mapping.slice(n).map(t+1+o+s.index);r.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function f2(r,e,t,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=r.mapping.slice(n).map(t+1+o);r.replaceWith(s,s+1,e.type.schema.text(`
24
+ `))}})}function jv(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function $v(r,e,t,n,i){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,i||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new dt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Y(H.from(s),0,0),1,!0))}function fa(r,e,t=1,n){let i=r.resolve(e),o=i.depth-t,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let d=i.node(c),h=i.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),m=n&&n[u+1];m&&(f=f.replaceChild(0,m.type.create(m.attrs)));let y=n&&n[u]||d;if(!d.canReplace(h+1,d.childCount)||!y.type.validContent(f))return!1}let a=i.indexAfter(o),l=n&&n[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function Vv(r,e,t=1,n){let i=r.doc.resolve(e),o=H.empty,s=H.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){o=H.from(i.node(a).copy(o));let u=n&&n[c];s=H.from(u?u.type.create(u.attrs,s):i.node(a).copy(s))}r.step(new Ke(e,e,new Y(o.append(s),t,t),!0))}function Bl(r,e){let t=r.resolve(e),n=t.index();return Uv(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Wv(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function Uv(r,e){return!!(r&&e&&!r.isLeaf&&Wv(r,e))}function Kv(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,o=r.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);u&&!d?n=!1:!u&&d&&(n=!0)}let a=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);f2(r,u.node(),u.before(),a)}s.inlineContent&&Kh(r,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let l=r.mapping.slice(a),c=l.map(e-t);if(r.step(new Ke(c,l.map(e+t,-1),Y.empty,!0)),n===!0){let u=r.doc.resolve(c);h2(r,u.node(),u.before(),r.steps.length)}return r}function Gv(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let o=n.index(i);if(n.node(i).canReplaceWith(o,o,t))return n.before(i+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let o=n.indexAfter(i);if(n.node(i).canReplaceWith(o,o,t))return n.after(i+1);if(o<n.node(i).childCount)return null}return null}function Yv(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let a=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,l=n.index(s)+(a>0?1:0),c=n.node(s),u=!1;if(o==1)u=c.canReplace(l,l,i);else{let d=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?n.pos:a<0?n.before(s+1):n.after(s+1)}return null}function Nc(r,e,t=e,n=Y.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),o=r.resolve(t);return p2(i,o,n)?new Ke(e,t,n):new Jv(i,o,n).fit()}function p2(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Jv{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=H.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=H.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new Y(o,s,a);return e>-1?new dt(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Ke(n.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=Ou(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(H.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:a,parent:o,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:a,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Ou(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Ou(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new Y(ra(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Y(ra(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let s=this.unplaced,a=n?n.content:s.content,l=s.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[t];if(i){for(let y=0;y<i.childCount;y++)u.push(i.child(y));d=d.matchFragment(i)}let f=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let y=a.child(c),x=d.matchType(y.type);if(!x)break;c++,(c>1||l==0||y.content.size)&&(d=x,u.push(m2(y.mark(h.allowedMarks(y.marks)),c==1?l:0,c==a.childCount?f:-1)))}let m=c==a.childCount;m||(f=-1),this.placed=na(this.placed,t,H.from(u)),this.frontier[t].match=d,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=a;y<f;y++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=m?e==0?Y.empty:new Y(ra(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new Y(ra(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ru(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Ru(e,t,i,n,o);if(s){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=Ru(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=na(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=na(this.placed,this.depth,H.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(H.empty,!0);t.childCount&&(this.placed=na(this.placed,this.frontier.length,t))}}function ra(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(ra(r.firstChild.content,e-1,t)))}function na(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(na(r.lastChild.content,e-1,t)))}function Ou(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function m2(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,m2(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(H.empty,!0)))),r.copy(n)}function Ru(r,e,t,n,i){let o=r.node(e),s=i?r.indexAfter(e):r.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let a=n.fillBefore(o.content,!0,s);return a&&!Xv(t,o.content,s)?a:null}function Xv(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Zv(r){return r.spec.defining||r.spec.definingForContent}function Qv(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),o=r.doc.resolve(t);if(p2(i,o,n))return r.step(new Ke(e,t,n));let s=y2(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,f=i.pos-1;h>0;h--,f--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==f&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],u=n.openStart;for(let h=n.content,f=0;;f++){let m=h.firstChild;if(c.push(m),f==n.openStart)break;h=m.content}for(let h=u-1;h>=0;h--){let f=c[h],m=Zv(f.type);if(m&&!f.sameMarkup(i.node(Math.abs(a)-1)))u=h;else if(m||!f.type.isTextblock)break}for(let h=n.openStart;h>=0;h--){let f=(h+u+1)%(n.openStart+1),m=c[f];if(m)for(let y=0;y<s.length;y++){let x=s[(y+l)%s.length],b=!0;x<0&&(b=!1,x=-x);let S=i.node(x-1),A=i.index(x-1);if(S.canReplaceWith(A,A,m.type,m.marks))return r.replace(i.before(x),b?o.after(x):t,new Y(g2(n.content,0,n.openStart,f),f,n.openEnd))}}let d=r.steps.length;for(let h=s.length-1;h>=0&&(r.replace(e,t,n),!(r.steps.length>d));h--){let f=s[h];f<0||(e=i.before(f),t=o.after(f))}}function g2(r,e,t,n,i){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(g2(o.content,e+1,t,n,o)))}if(e>n){let o=i.contentMatchAt(0),s=o.fillBefore(r).append(r);r=s.append(o.matchFragment(s).fillBefore(H.empty,!0))}return r}function e8(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=Gv(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new Y(H.from(n),0,0))}function t8(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let s=n.sharedDepth(t),a=!1;for(let l=n.depth;l>s;l--)n.node(l).type.spec.isolating&&(a=!0);for(let l=i.depth;l>s;l--)i.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=n.depth;l>0&&e==n.start(l);l--)e=n.before(l);for(let l=i.depth;l>0&&t==i.start(l);l--)t=i.before(l);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let o=y2(n,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||n.node(a).type.contentMatch.validEnd)return r.delete(n.start(a),i.end(a));if(a>0&&(l||n.node(a-1).canReplace(n.index(a-1),i.indexAfter(a-1))))return r.delete(n.before(a),i.after(a))}for(let s=1;s<=n.depth&&s<=i.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&i.end(s)-t!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return r.delete(n.before(s),t);r.delete(e,t)}function y2(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let o=r.start(i);if(o<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Eo extends pt{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ge.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return Ge.fromReplace(e,this.pos,this.pos+1,new Y(H.from(i),0,t.isLeaf?0:1))}getMap(){return jt.empty}invert(e){return new Eo(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Eo(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Eo(t.pos,t.attr,t.value)}}pt.jsonID("attr",Eo);class Ea extends pt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Ge.ok(n)}getMap(){return jt.empty}invert(e){return new Ea(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ea(t.attr,t.value)}}pt.jsonID("docAttr",Ea);let vs=class extends Error{};vs=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};vs.prototype=Object.create(Error.prototype);vs.prototype.constructor=vs;vs.prototype.name="TransformError";class v2{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Na}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vs(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Y.empty){let i=Nc(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new Y(H.from(n),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Qv(this,e,t,n),this}replaceRangeWith(e,t,n){return e8(this,e,t,n),this}deleteRange(e,t){return t8(this,e,t),this}lift(e,t){return Pv(this,e,t),this}join(e,t=1){return Kv(this,e,t),this}wrap(e,t){return _v(this,e,t),this}setBlockType(e,t=e,n,i=null){return qv(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return $v(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new Eo(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ea(e,t)),this}addNodeMark(e,t){return this.step(new Vn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof fe)t.isInSet(n.marks)&&this.step(new Ji(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Ji(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,t=1,n){return Vv(this,e,t,n),this}addMark(e,t,n){return zv(this,e,t,n),this}removeMark(e,t,n){return Lv(this,e,t,n),this}clearIncompatible(e,t,n){return Kh(this,e,t,n),this}}const Iu=Object.create(null);class ue{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new b2(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Y.empty){let n=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],u=e.mapping.slice(o);e.replaceRange(u.map(l.pos),u.map(c.pos),a?Y.empty:t),a==0&&Gm(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(n),c=l.map(s.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Gm(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new Q(e):xo(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?xo(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):xo(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Rt(e.node(0))}static atStart(e){return xo(e,e,0,0,1)||new Rt(e)}static atEnd(e){return xo(e,e,e.content.size,e.childCount,-1)||new Rt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Iu[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Iu)throw new RangeError("Duplicate use of selection JSON ID "+e);return Iu[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class b2{constructor(e,t){this.$from=e,this.$to=t}}let Um=!1;function Km(r){!Um&&!r.parent.inlineContent&&(Um=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class Q extends ue{constructor(e,t=e){Km(e),Km(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return ue.near(n);let i=e.resolve(t.map(this.anchor));return new Q(i.parent.inlineContent?i:n,n)}replace(e,t=Y.empty){if(super.replace(e,t),t==Y.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ec(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let o=ue.findFrom(t,n,!0)||ue.findFrom(t,-n,!0);if(o)t=o.$head;else return ue.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(ue.findFrom(e,-n,!0)||ue.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new Q(e,t)}}ue.jsonID("text",Q);class Ec{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ec(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class re extends ue{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return n?ue.near(o):new re(o)}content(){return new Y(H.from(this.node),0,0)}eq(e){return e instanceof re&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Yh(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new re(e.resolve(t.anchor))}static create(e,t){return new re(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}re.prototype.visible=!1;ue.jsonID("node",re);class Yh{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Ec(n,n):new Yh(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&re.isSelectable(n)?new re(t):ue.near(t)}}class Rt extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==Y.empty){e.delete(0,e.doc.content.size);let n=ue.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Rt(e)}map(e){return new Rt(e)}eq(e){return e instanceof Rt}getBookmark(){return r8}}ue.jsonID("all",Rt);const r8={map(){return this},resolve(r){return new Rt(r)}};function xo(r,e,t,n,i,o=!1){if(e.inlineContent)return Q.create(r,t);for(let s=n-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&re.isSelectable(a))return re.create(r,t-(i<0?a.nodeSize:0))}else{let l=xo(r,a,t+i,i<0?a.childCount:0,i,o);if(l)return l}t+=a.nodeSize*i}return null}function Gm(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof Ke||i instanceof dt))return;let o=r.mapping.maps[n],s;o.forEach((a,l,c,u)=>{s==null&&(s=u)}),r.setSelection(ue.near(r.doc.resolve(s),t))}const Ym=1,b0=2,Jm=4;class n8 extends v2{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ym)&~b0,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ym)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=b0,this}ensureMarks(e){return fe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&b0)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~b0,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||fe.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(ue.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Jm,this}get scrolledIntoView(){return(this.updated&Jm)>0}}function Xm(r,e){return!e||!r?r:r.bind(e)}class ia{constructor(e,t,n){this.name=e,this.init=Xm(t.init,n),this.apply=Xm(t.apply,n)}}const i8=[new ia("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new ia("selection",{init(r,e){return r.selection||ue.atStart(e.doc)},apply(r){return r.selection}}),new ia("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new ia("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class zu{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=i8.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new ia(n.key,n.spec.state,n))})}}class bi{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,u=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,n);if(u&&n.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),o=!0}i&&(i[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new bi(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let o=n[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new n8(this)}static create(e){let t=new zu(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new bi(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new zu(this.schema,e.plugins),n=t.fields,i=new bi(t);for(let o=0;o<n.length;o++){let s=n[o].name;i[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],o=i.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new zu(e.schema,e.plugins),o=new bi(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=mn.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=ue.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){o[s.name]=c.fromJSON.call(l,e,t[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function w2(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=w2(i,e,{})),t[n]=i}return t}class Ce{constructor(e){this.spec=e,this.props={},e.props&&w2(e.props,this,this.props),this.key=e.key?e.key.key:x2("plugin")}getState(e){return e[this.key]}}const Lu=Object.create(null);function x2(r){return r in Lu?r+"$"+ ++Lu[r]:(Lu[r]=0,r+"$")}class Me{constructor(e="key"){this.key=x2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const st=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},bs=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let _d=null;const Zr=function(r,e,t){let n=_d||(_d=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},o8=function(){_d=null},Xi=function(r,e,t,n){return t&&(Zm(r,e,t,n,-1)||Zm(r,e,t,n,1))},s8=/^(img|br|input|textarea|hr)$/i;function Zm(r,e,t,n,i){for(var o;;){if(r==t&&e==n)return!0;if(e==(i<0?0:ir(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Pl(r)||s8.test(r.nodeName)||r.contentEditable=="false")return!1;e=st(r)+(i<0?0:1),r=s}else if(r.nodeType==1){let s=r.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else r=s,e=i<0?ir(r):0}else return!1}}function ir(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function a8(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=ir(r)}else if(r.parentNode&&!Pl(r))e=st(r),r=r.parentNode;else return null}}function l8(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Pl(r))e=st(r)+1,r=r.parentNode;else return null}}function c8(r,e,t){for(let n=e==0,i=e==ir(r);n||i;){if(r==t)return!0;let o=st(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,i=i&&o==ir(r)}}function Pl(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Dc=function(r){return r.focusNode&&Xi(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function yi(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function u8(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function d8(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(ir(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(ir(n.startContainer),n.startOffset)}}}const jr=typeof navigator<"u"?navigator:null,Qm=typeof document<"u"?document:null,ti=jr&&jr.userAgent||"",qd=/Edge\/(\d+)/.exec(ti),k2=/MSIE \d/.exec(ti),jd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ti),It=!!(k2||jd||qd),Un=k2?document.documentMode:jd?+jd[1]:qd?+qd[1]:0,sr=!It&&/gecko\/(\d+)/i.test(ti);sr&&+(/Firefox\/(\d+)/.exec(ti)||[0,0])[1];const $d=!It&&/Chrome\/(\d+)/.exec(ti),at=!!$d,S2=$d?+$d[1]:0,ft=!It&&!!jr&&/Apple Computer/.test(jr.vendor),ws=ft&&(/Mobile\/\w+/.test(ti)||!!jr&&jr.maxTouchPoints>2),nr=ws||(jr?/Mac/.test(jr.platform):!1),C2=jr?/Win/.test(jr.platform):!1,un=/Android \d/.test(ti),Fl=!!Qm&&"webkitFontSmoothing"in Qm.documentElement.style,h8=Fl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function f8(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Yr(r,e){return typeof r=="number"?r:r[e]}function p8(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function e1(r,e,t){if(!Vd(e)&&e.left==0)return;let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let s=t||r.dom;s;){if(s.nodeType!=1){s=bs(s);continue}let a=s,l=a==o.body,c=l?f8(o):p8(a),u=0,d=0;if(e.top<c.top+Yr(n,"top")?d=-(c.top-e.top+Yr(i,"top")):e.bottom>c.bottom-Yr(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Yr(i,"top")-c.top:e.bottom-c.bottom+Yr(i,"bottom")),e.left<c.left+Yr(n,"left")?u=-(c.left-e.left+Yr(i,"left")):e.right>c.right-Yr(n,"right")&&(u=e.right-c.right+Yr(i,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,m=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let y=a.scrollLeft-f,x=a.scrollTop-m;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:bs(s)}}function m8(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=r.root.elementFromPoint(o,s);if(!a||a==r.dom||!r.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){n=a,i=l.top;break}}return{refDOM:n,refTop:i,stack:M2(r.dom)}}function M2(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=bs(n));return e}function g8({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;T2(t,n==0?0:n-e)}function T2(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:o}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let yo=null;function y8(r){if(r.setActive)return r.setActive();if(yo)return r.focus(yo);let e=M2(r);r.focus(yo==null?{get preventScroll(){return yo={preventScroll:!0},!0}}:void 0),yo||(yo=!1,T2(e,0))}function A2(r,e){let t,n=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let u=r.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Zr(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let m=h[f];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let y=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(y<n){t=u,n=y,i=y&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&y&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!t&&l&&(t=l,i=c,n=0),t&&t.nodeType==3?v8(t,i):!t||n&&t.nodeType==1?{node:r,offset:o}:A2(t,i)}function v8(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let o=0;o<t;o++){n.setEnd(r,o+1),n.setStart(r,o);let s=On(n,1);if(s.top!=s.bottom&&Jh(e,s)){i={node:r,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function Jh(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function b8(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function w8(r,e,t){let{node:n,offset:i}=A2(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return r.docView.posFromDOM(n,i,o)}function x8(r,e,t,n){let i=-1;for(let o=e,s=!1;o!=r.dom;){let a=r.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>n.left||l.top>n.top?i=a.posBefore:(!s&&l.right<n.left||l.bottom<n.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?n.top<(l.top+l.bottom)/2:n.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function N2(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=r.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Jh(e,c))return N2(s,e,c)}}if((o=(o+1)%n)==i)break}return r}function k8(r,e){let t=r.dom.ownerDocument,n,i=0,o=d8(t,e.left,e.top);o&&({node:n,offset:i}=o);let s=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),a;if(!s||!r.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=r.dom.getBoundingClientRect();if(!Jh(e,c)||(s=N2(r.dom,e,c),!s))return null}if(ft)for(let c=s;n&&c;c=bs(c))c.draggable&&(n=void 0);if(s=b8(s,e),n){if(sr&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let u=n.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Fl&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?a=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(a=x8(r,n,i,e))}a==null&&(a=w8(r,s,e));let l=r.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Vd(r){return r.top<r.bottom||r.left<r.right}function On(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Vd(n))return n}return Array.prototype.find.call(t,Vd)||r.getBoundingClientRect()}const S8=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function E2(r,e,t){let{node:n,offset:i,atom:o}=r.docView.domFromPos(e,t<0?-1:1),s=Fl||sr;if(n.nodeType==3)if(s&&(S8.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let l=On(Zr(n,i,i),t);if(sr&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=On(Zr(n,i-1,i-1),-1);if(c.top==l.top){let u=On(Zr(n,i,i+1),-1);if(u.top!=l.top)return Ys(u,u.left<c.left)}}return l}else{let l=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==n.nodeValue.length?(l--,u=1):t<0?l--:c++,Ys(On(Zr(n,l,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==ir(n))){let l=n.childNodes[i-1];if(l.nodeType==1)return Bu(l.getBoundingClientRect(),!1)}if(o==null&&i<ir(n)){let l=n.childNodes[i];if(l.nodeType==1)return Bu(l.getBoundingClientRect(),!0)}return Bu(n.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==ir(n))){let l=n.childNodes[i-1],c=l.nodeType==3?Zr(l,ir(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Ys(On(c,1),!1)}if(o==null&&i<ir(n)){let l=n.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Zr(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Ys(On(c,-1),!0)}return Ys(On(n.nodeType==3?Zr(n):n,-t),t>=0)}function Ys(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function Bu(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function D2(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function C8(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return D2(r,e,()=>{let{node:o}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=r.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=E2(r,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Zr(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const M8=/[\u0590-\u08ac]/;function T8(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,o=!i,s=i==n.parent.content.size,a=r.domSelection();return a?!M8.test(n.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:D2(r,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=r.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let f=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:m,focusOffset:y}=r.domSelectionRange(),x=m&&!f.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==y;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),x}):n.pos==n.start()||n.pos==n.end()}let t1=null,r1=null,n1=!1;function A8(r,e,t){return t1==e&&r1==t?n1:(t1=e,r1=t,n1=t=="up"||t=="down"?C8(r,e,t):T8(r,e,t))}const ar=0,i1=1,wi=2,kr=3;class Hl{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ar,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>st(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],a=o+s.size;if(a>e||s instanceof R2){i=e-o;break}o=a}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof O2&&o.side>=0;n--);if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?st(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?st(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let u=s+l.border;if(e>=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=s;for(let d=a;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=st(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let u=a+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=st(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let f=0,m=0;f<this.children.length;f++){let y=this.children[f],x=m+y.size;if(o>m&&s<x)return y.setSelection(e-m-y.border,t-m-y.border,n,i);m=x}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),d=!1;if((sr||ft)&&e==t){let{node:f,offset:m}=a;if(f.nodeType==3){if(d=!!(m&&f.nodeValue[m-1]==`
25
+ `),d&&m==f.nodeValue.length)for(let y=f,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(a=l={node:x.parentNode,offset:st(x)+1});break}let b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=f.childNodes[m-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(sr&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||d&&ft)&&Xi(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Xi(l.node,l.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(d&&sr)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let m=a;a=l,l=m}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let a=n+o.border,l=s-o.border;if(e>=a&&t<=l){this.dirty=e==n||t==s?wi:i1,e==a&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=kr:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wi:kr}n=s}this.dirty=wi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?wi:i1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class O2 extends Hl{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ar&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class N8 extends Hl{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Kn extends Hl{constructor(e,t,n,i,o){super(e,[],n,i),this.mark=t,this.spec=o}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=eo.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Kn(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&kr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=kr&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ar){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ar}}slice(e,t,n){let i=Kn.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=Ud(o,t,s,n)),e>0&&(o=Ud(o,0,e,n));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Gn extends Hl{constructor(e,t,n,i,o,s,a){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=a}static create(e,t,n,i,o,s){let a=o.nodeViews[t.type.name],l,c=a&&a(t,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},n,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=eo.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let h=u;return u=L2(u,n,t),c?l=new E8(e,t,n,i,u,d||null,h,c):t.isText?new Oc(e,t,n,i,u,h):new Gn(e,t,n,i,u,d||null,h)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));n?t.contentElement=n:t.getContent=()=>H.empty}}return t}matchesNode(e,t,n){return this.dirty==ar&&e.eq(this.node)&&nc(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new O8(this,s&&s.node,e);z8(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?fe.none:this.node.child(u).marks,n,e,u),l.placeWidget(c,e,i)},(c,u,d,h)=>{l.syncToMarks(c.marks,n,e,h);let f;l.findNodeMatch(c,u,d,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(f=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,u,d,f,e)||l.updateNextNode(c,u,d,e,h,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],n,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==wi)&&(s&&this.protectLocalComposition(e,s),I2(this.contentDOM,this.children,e),ws&&L8(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof Q)||n<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=B8(this.node.content,s,n-t,i-t);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new N8(this,o,t,i);e.input.compositionNodes.push(s),this.children=Ud(this.children,n,n+i.length,e,s)}update(e,t,n,i){return this.dirty==kr||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ar}updateOuterDeco(e){if(nc(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=z2(this.dom,this.nodeDOM,Wd(this.outerDeco,this.node,t),Wd(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function o1(r,e,t,n,i){L2(n,e,r);let o=new Gn(void 0,r,e,t,n,n,n);return o.contentDOM&&o.updateChildren(i,0),o}class Oc extends Gn{constructor(e,t,n,i,o,s){super(e,t,n,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==kr||this.dirty!=ar&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ar||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ar,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new Oc(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=kr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class R2 extends Hl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ar&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class E8 extends Gn{constructor(e,t,n,i,o,s,a,l){super(e,t,n,i,o,s,a),this.spec=l}update(e,t,n,i){if(this.dirty==kr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function I2(r,e,t){let n=r.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==r){for(;a!=n;)n=s1(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(a,n);if(s instanceof Kn){let l=n?n.previousSibling:r.lastChild;I2(s.contentDOM,s.children,t),n=l?l.nextSibling:r.firstChild}}for(;n;)n=s1(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const pa=function(r){r&&(this.nodeName=r)};pa.prototype=Object.create(null);const xi=[new pa];function Wd(r,e,t){if(r.length==0)return xi;let n=t?xi[0]:new pa,i=[n];for(let o=0;o<r.length;o++){let s=r[o].type.attrs;if(s){s.nodeName&&i.push(n=new pa(s.nodeName));for(let a in s){let l=s[a];l!=null&&(t&&i.length==1&&i.push(n=new pa(e.isInline?"span":"div")),a=="class"?n.class=(n.class?n.class+" ":"")+l:a=="style"?n.style=(n.style?n.style+";":"")+l:a!="nodeName"&&(n[a]=l))}}}return i}function z2(r,e,t,n){if(t==xi&&n==xi)return e;let i=e;for(let o=0;o<n.length;o++){let s=n[o],a=t[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=r&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=xi[0]),i=l}D8(i,a||xi[0],s)}return i}function D8(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)i.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<i.length;o++)n.indexOf(i[o])==-1&&r.classList.add(i[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function L2(r,e,t){return z2(r,r,xi,Wd(e,t,r.nodeType!=1))}function nc(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function s1(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class O8{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=R8(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=ar,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){l=u;break}}if(l<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Kn&&u.dirty!=kr&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Kn.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==kr&&s.dom==s.contentDOM&&(s.dirty=wi),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Gn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let u=l.dom,d,h=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=kr&&nc(t,l.outerDeco));if(!h&&l.update(e,t,n,i))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(l,e,t,n,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=wi,d.updateChildren(i,s+1),d.dirty=ar),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!nc(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Gn.create(this.top,t,n,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,n,i,o){let s=Gn.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new O2(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Kn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Oc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ft||at)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new R2(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function R8(r,e){let t=e,n=t.children.length,i=r.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(n){let c=t.children[n-1];if(c instanceof Kn)t=c,n=c.children.length;else{a=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=r.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function I8(r,e){return r.type.side-e.type.side}function z8(r,e,t,n){let i=e.locals(r),o=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let u,d;for(;s<i.length&&i[s].to==o;){let x=i[s++];x.widget&&(u?(d||(d=[u])).push(x):u=x)}if(u)if(d){d.sort(I8);for(let x=0;x<d.length;x++)t(d[x],c,!!l)}else t(u,c,!!l);let h,f;if(l)f=-1,h=l,l=null;else if(c<r.childCount)f=c,h=r.child(c++);else break;for(let x=0;x<a.length;x++)a[x].to<=o&&a.splice(x--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let x=m;s<i.length&&i[s].from<x&&(x=i[s].from);for(let b=0;b<a.length;b++)a[b].to<x&&(x=a[b].to);x<m&&(l=h.cut(x-o),h=h.cut(0,x-o),m=x,f=-1)}else for(;s<i.length&&i[s].to<m;)s++;let y=h.isInline&&!h.isLeaf?a.filter(x=>!x.inline):a.slice();n(h,y,e.forChild(o,h),f),o=m}}function L8(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function B8(r,e,t,n){for(let i=0,o=0;i<r.childCount&&o<=n;){let s=r.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<r.childCount;){let c=r.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=t){if(o>=n&&l.slice(n-e.length-a,n-a)==e)return n-e.length;let c=a<n?l.lastIndexOf(e,n-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==n&&l.length>=n+e.length-a&&l.slice(n-a,n-a+e.length)==e)return n}}return-1}function Ud(r,e,t,n,i){let o=[];for(let s=0,a=0;s<r.length;s++){let l=r[s],c=a,u=a+=l.size;c>=t||u<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,n)),i&&(o.push(i),i=void 0),u>t&&o.push(l.slice(t-c,l.size,n)))}return o}function Xh(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let a=n.resolve(s),l,c;if(Dc(t)){for(l=s;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&re.isSelectable(d)&&i.parent&&!(d.isInline&&c8(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new re(s==h?a:n.resolve(h))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,h=s;for(let f=0;f<t.rangeCount;f++){let m=t.getRangeAt(f);d=Math.min(d,r.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,r.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,s]=h==r.state.selection.anchor?[h,d]:[d,h],a=n.resolve(s)}else l=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let u=n.resolve(l);if(!c){let d=e=="pointer"||r.state.selection.head<a.pos&&!o?1:-1;c=Zh(r,u,a,d)}return c}function B2(r){return r.editable?r.hasFocus():F2(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function gn(r,e=!1){let t=r.state.selection;if(P2(r,t),!B2(r))return;let n=r.input.mouseDown;if(!e&&at&&n){let i=r.domSelectionRange(),o=r.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Xi(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&n.delaySelUpdate()){r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)F8(r);else{let{anchor:i,head:o}=t,s,a;a1&&!(t instanceof Q)&&(t.$from.parent.inlineContent||(s=l1(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=l1(r,t.to))),r.docView.setSelection(i,o,r,e),a1&&(s&&c1(s),a&&c1(a)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&P8(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}const a1=ft||at&&S2<63;function l1(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ft&&i&&i.contentEditable=="false")return Pu(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Pu(i);if(o)return Pu(o)}}function Pu(r){return r.contentEditable="true",ft&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function c1(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function P8(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!B2(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function F8(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,st(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&It&&Un<=11&&(t.disabled=!0,t.disabled=!1)}function P2(r,e){if(e instanceof re){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(u1(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else u1(r)}function u1(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Zh(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||Q.between(e,t,n)}function d1(r){return r.editable&&!r.hasFocus()?!1:F2(r)}function F2(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function H8(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Xi(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Kd(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),o=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return o&&ue.findFrom(o,e)}function Rn(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function h1(r,e,t){let n=r.state.selection;if(n instanceof Q)if(t.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=r.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Rn(r,new Q(n.$anchor,s))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Kd(r.state,e);return i&&i instanceof re?Rn(r,i):!1}else if(!(nr&&t.indexOf("m")>-1)){let i=n.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=r.docView.descAt(a))&&!s.contentDOM?re.isSelectable(o)?Rn(r,new re(e<0?r.state.doc.resolve(i.pos-o.nodeSize):i)):Fl?Rn(r,new Q(r.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof re&&n.node.isInline)return Rn(r,new Q(e>0?n.$to:n.$from));{let i=Kd(r.state,e);return i?Rn(r,i):!1}}}function ic(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function ma(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function vo(r,e){return e<0?_8(r):q8(r)}function _8(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,o,s=!1;for(sr&&t.nodeType==1&&n<ic(t)&&ma(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(t.nodeType!=1)break;{let a=t.childNodes[n-1];if(ma(a,-1))i=t,o=--n;else if(a.nodeType==3)t=a,n=t.nodeValue.length;else break}}else{if(H2(t))break;{let a=t.previousSibling;for(;a&&ma(a,-1);)i=t.parentNode,o=st(a),a=a.previousSibling;if(a)t=a,n=ic(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}s?Gd(r,t,n):i&&Gd(r,i,o)}function q8(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=ic(t),o,s;for(;;)if(n<i){if(t.nodeType!=1)break;let a=t.childNodes[n];if(ma(a,1))o=t,s=++n;else break}else{if(H2(t))break;{let a=t.nextSibling;for(;a&&ma(a,1);)o=a.parentNode,s=st(a)+1,a=a.nextSibling;if(a)t=a,n=0,i=ic(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}o&&Gd(r,o,s)}function H2(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function j8(r,e){for(;r&&e==r.childNodes.length&&!Pl(r);)e=st(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function $8(r,e){for(;r&&!e&&!Pl(r);)e=st(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Gd(r,e,t){if(e.nodeType!=3){let o,s;(s=j8(e,t))?(e=s,t=0):(o=$8(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(Dc(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&gn(r)},50)}function f1(r,e){let t=r.state.doc.resolve(e);if(!(at||C2)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function p1(r,e,t){let n=r.state.selection;if(n instanceof Q&&!n.empty||t.indexOf("s")>-1||nr&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let s=Kd(r.state,e);if(s&&s instanceof re)return Rn(r,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=n instanceof Rt?ue.near(s,e):ue.findFrom(s,e);return a?Rn(r,a):!1}return!1}function m1(r,e){if(!(r.state.selection instanceof Q))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=r.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),r.dispatch(s),!0}return!1}function g1(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function V8(r){if(!ft||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;g1(r,n,"true"),setTimeout(()=>g1(r,n,"false"),20)}return!1}function W8(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function U8(r,e){let t=e.keyCode,n=W8(e);if(t==8||nr&&t==72&&n=="c")return m1(r,-1)||vo(r,-1);if(t==46&&!e.shiftKey||nr&&t==68&&n=="c")return m1(r,1)||vo(r,1);if(t==13||t==27)return!0;if(t==37||nr&&t==66&&n=="c"){let i=t==37?f1(r,r.state.selection.from)=="ltr"?-1:1:-1;return h1(r,i,n)||vo(r,i)}else if(t==39||nr&&t==70&&n=="c"){let i=t==39?f1(r,r.state.selection.from)=="ltr"?1:-1:1;return h1(r,i,n)||vo(r,i)}else{if(t==38||nr&&t==80&&n=="c")return p1(r,-1,n)||vo(r,-1);if(t==40||nr&&t==78&&n=="c")return V8(r)||p1(r,1,n)||vo(r,1);if(n==(nr?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Qh(r,e){r.someProp("transformCopied",f=>{e=f(e,r)});let t=[],{content:n,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,o--;let f=n.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),n=f.content}let s=r.someProp("clipboardSerializer")||eo.fromSchema(r.state.schema),a=W2(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=V2[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let m=a.createElement(u[f]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let h=r.someProp("clipboardTextSerializer",f=>f(e,r))||e.content.textBetween(0,e.content.size,`
26
26
 
27
27
  `);return{dom:l,text:h,slice:e}}function _2(r,e,t,n,i){let o=i.parent.type.spec.code,s,a;if(!t&&!e)return null;let l=!!e&&(n||o||!t);if(l){if(r.someProp("transformPastedText",h=>{e=h(e,o||n,r)}),o)return a=new Y(H.from(r.state.schema.text(e.replace(/\r\n?/g,`
28
- `))),0,0),r.someProp("transformPasted",h=>{a=h(a,r,!0)}),a;let d=r.someProp("clipboardTextParser",h=>h(e,i,n,r));if(d)a=d;else{let h=i.marks(),{schema:f}=r.state,m=eo.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=s.appendChild(document.createElement("p"));y&&x.appendChild(m.serializeNode(f.text(y,h)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),s=J8(t),Fl&&X8(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(r.someProp("clipboardParser")||r.someProp("domParser")||Yi.fromSchema(r.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!K8.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Z8(y1(a,+u[1],+u[2]),u[4]);else if(a=Y.maxOpen(G8(a.content,i),!0),a.openStart||a.openEnd){let d=0,h=0;for(let f=a.content.firstChild;d<a.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=a.content.lastChild;h<a.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);a=y1(a,d,h)}return r.someProp("transformPasted",d=>{a=d(a,r,l)}),a}const K8=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function G8(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(r.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&$2(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=j2(s[s.length-1],o.length));let u=q2(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return H.from(s)}return r}function q2(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,H.from(r));return r}function $2(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let o=$2(r,e,t,n.lastChild,i+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(H.from(q2(t,r,i+1))))}}function j2(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,j2(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(H.empty,!0);return r.copy(t.append(n))}function Yd(r,e,t,n,i,o){let s=e<0?r.firstChild:r.lastChild,a=s.content;return r.childCount>1&&(o=0),i<n-1&&(a=Yd(a,e,t,n,i+1,o)),i>=t&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(H.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,s.copy(a))}function y1(r,e,t){return e<r.openStart&&(r=new Y(Yd(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new Y(Yd(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const V2={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function W2(){return document.implementation.createHTMLDocument("title")}let Js=null;function Y8(r){let e=window.trustedTypes;if(!e)return r;if(!Js){if(Js=e.defaultPolicy)try{return Js.createHTML(r)}catch{}Js=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Js.createHTML(r)}function J8(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=W2(),n=t.body,i=/<([a-z][^>\s]+)/i.exec(r),o;if((o=i&&V2[i[1].toLowerCase()])&&(r=o.map(s=>"<"+s+">").join("")+r+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Y8(r),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;for(let s=0;s<t.styleSheets.length;s++){let a=t.styleSheets[s];for(let l=0;l<a.rules.length;l++){let c=a.rules[l];if(c instanceof CSSStyleRule){let u=n.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return n}function X8(r){let e=r.querySelectorAll(at?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Z8(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:o,openEnd:s}=r;for(let a=n.length-2;a>=0;a-=2){let l=t.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;try{l.checkAttrs(n[a+1])}catch{break}i=H.from(l.create(n[a+1],i)),o++,s++}return new Y(i,o,s)}const kt={},St={},Q8={touchstart:!0,touchmove:!0};class eb{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function tb(r){for(let e in kt){let t=kt[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{nb(r,n)&&!ef(r,n)&&(r.editable||!(n.type in St))&&t(r,n)},Q8[e]?{passive:!0}:void 0)}ft&&r.dom.addEventListener("input",()=>null),Jd(r)}function dn(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function rb(r){r.input.mouseDown&&r.input.mouseDown.done(),r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Jd(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ef(r,n))})}function ef(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function nb(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ib(r,e){!ef(r,e)&&kt[e.type]&&(r.editable||!(e.type in St))&&kt[e.type](r,e)}St.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Y2(r)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(un&&at&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),ws&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,yi(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||U8(r,t)?t.preventDefault():dn(r,"key")};St.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};St.keypress=(r,e)=>{let t=e;if(Y2(r)||!t.charCode||t.ctrlKey&&!t.altKey||nr&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof Q)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),o=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i,o))&&r.dispatch(o()),t.preventDefault()}};function _l(r){return{left:r.clientX,top:r.clientY}}function ob(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function tf(r,e,t,n,i){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(r.someProp(e,a=>s>o.depth?a(r,t,o.nodeAfter,o.before(s),i,!0):a(r,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function ql(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function sb(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&re.isSelectable(n)?(ql(r,new re(t)),!0):!1}function ab(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof re&&(n=t.node);let o=r.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(re.isSelectable(a)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(ql(r,re.create(r.state.doc,i)),!0):!1}function lb(r,e,t,n,i){return tf(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(i?ab(r,t):sb(r,t))}function cb(r,e,t,n){return tf(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function ub(r,e,t,n){return tf(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||db(r,t,n)}function db(r,e,t){if(t.button!=0)return!1;let n=U2(r,e,!0),i=r.state.doc;return n?(ql(r,n),n instanceof Q&&i.eq(r.state.doc)&&(r.input.mouseDown=new fb(r,n)),!0):!1}function U2(r,e,t){let n=r.state.doc;if(e==-1)return n.inlineContent?Q.create(n,0,n.content.size):null;let i=n.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)return Q.create(n,a+1,a+1+s.content.size);if(t&&re.isSelectable(s))return re.create(n,a)}return null}function rf(r){return oc(r)}const K2=nr?"metaKey":"ctrlKey";kt.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=rf(r),i=Date.now(),o="singleClick";i-r.input.lastClick.time<500&&ob(t,r.input.lastClick)&&!t[K2]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button},r.input.mouseDown&&r.input.mouseDown.done();let s=r.posAtCoords(_l(t));s&&(o=="singleClick"?r.input.mouseDown=new hb(r,s,t,!!n):(o=="doubleClick"?cb:ub)(r,s.pos,s.inside,t)?t.preventDefault():dn(r,"pointer"))};class G2{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class hb extends G2{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[K2],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}const a=i?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof re&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&sr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),dn(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||gn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(_l(e))),this.updateAllowDefault(e),this.allowDefault||!t?dn(this.view,"pointer"):lb(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ft&&this.mightDrag&&!this.mightDrag.node.isAtom||at&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ql(this.view,ue.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):dn(this.view,"pointer")}move(e){this.updateAllowDefault(e),dn(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class fb extends G2{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),dn(this.view,"pointer");let t=this.view.posAtCoords(_l(e)),n=t&&U2(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,o=this.startSelection,[s,a]=n.from<o.from?[o.to,n.from]:[o.from,n.to];ql(this.view,Q.create(i,s,a))}}kt.touchstart=r=>{r.input.lastTouch=Date.now(),rf(r),dn(r,"pointer")};kt.touchmove=r=>{r.input.lastTouch=Date.now(),dn(r,"pointer")};kt.contextmenu=r=>rf(r);function Y2(r,e){return r.composing?!0:ft&&Math.abs(Date.now()-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const pb=un?5e3:-1;St.compositionstart=St.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||at&&C2&&mb(r)))r.markCursor=r.state.storedMarks||t.marks(),oc(r,!0),r.markCursor=null;else if(oc(r,!e.selection.empty),sr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,o=n.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=r.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}r.input.composing=!0}J2(r,pb)};function mb(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}St.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now(),r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,J2(r,20))};function J2(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>oc(r),e))}function X2(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function gb(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=a8(e.focusNode,e.focusOffset),n=l8(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function oc(r,e=!1){if(!(un&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),X2(r),e||r.docView&&r.docView.dirty){let t=Xh(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function yb(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const Da=It&&Un<15||ws&&h8<604;kt.copy=St.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let o=Da?null:t.clipboardData,s=n.content(),{dom:a,text:l}=Qh(r,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):yb(r,a),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vb(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function bb(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Oa(r,n.value,null,i,e):Oa(r,n.textContent,n.innerHTML,i,e)},50)}function Oa(r,e,t,n,i){let o=_2(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",l=>l(r,i,o||Y.empty)))return!0;if(!o)return!1;let s=vb(o),a=s?r.state.tr.replaceSelectionWith(s,n):r.state.tr.replaceSelection(o);return r.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Z2(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}St.paste=(r,e)=>{let t=e;if(r.composing&&!un)return;let n=Da?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Oa(r,Z2(n),n.getData("text/html"),i,t)?t.preventDefault():bb(r,t)};class Q2{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const wb=nr?"altKey":"ctrlKey";function e5(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[wb]}kt.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,o=i.empty?null:r.posAtCoords(_l(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof re?i.to-1:i.to))){if(n&&n.mightDrag)s=re.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(s=re.create(r.state.doc,d.posBefore))}}let a=(s||r.state.selection).content(),{dom:l,text:c,slice:u}=Qh(r,a);(!t.dataTransfer.files.length||!at||S2>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Da?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Da||t.dataTransfer.setData("text/plain",c),r.dragging=new Q2(u,e5(r,t),s)};kt.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};St.dragover=St.dragenter=(r,e)=>e.preventDefault();St.drop=(r,e)=>{try{xb(r,e,r.dragging)}finally{r.dragging=null}};function xb(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(_l(e));if(!n)return;let i=r.state.doc.resolve(n.pos),o=t&&t.slice;o?r.someProp("transformPasted",f=>{o=f(o,r,!1)}):o=_2(r,Z2(e.dataTransfer),Da?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&e5(r,e));if(r.someProp("handleDrop",f=>f(r,e,o||Y.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Yv(r.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=r.state.tr;if(s){let{node:f}=t;f?f.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(d))return;let h=l.doc.resolve(c);if(u&&re.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new re(h));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,x,b)=>f=b),l.setSelection(Zh(r,h,l.doc.resolve(f)))}r.focus(),r.dispatch(l.setMeta("uiEvent","drop"))}kt.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&gn(r)},20))};kt.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};kt.beforeinput=(r,e)=>{if(un&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,yi(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in St)kt[r]=St[r];function Ra(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class sc{constructor(e,t){this.toDOM=e,this.spec=t||Fi,this.side=this.spec.side||0}map(e,t,n,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new qe(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof sc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ra(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Yn{constructor(e,t){this.attrs=e,this.spec=t||Fi}map(e,t,n,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new qe(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Yn&&Ra(this.attrs,e.attrs)&&Ra(this.spec,e.spec)}static is(e){return e.type instanceof Yn}destroy(){}}class nf{constructor(e,t){this.attrs=e,this.spec=t||Fi}map(e,t,n,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new qe(o.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(n)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof nf&&Ra(this.attrs,e.attrs)&&Ra(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new qe(e,e,new sc(t,n))}static inline(e,t,n,i){return new qe(e,t,new Yn(n,i))}static node(e,t,n,i){return new qe(e,t,new nf(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yn}get widget(){return this.type instanceof sc}}const ko=[],Fi={};class Se{constructor(e,t){this.local=e.length?e:ko,this.children=t.length?t:ko}static create(e,t){return t.length?ac(t,e,0,Fi):ut}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&n.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,t-a,n,i+a,o)}}map(e,t,n){return this==ut||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Fi)}mapInner(e,t,n,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,i);l&&l.type.valid(t,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?kb(this.children,s||[],e,t,n,i,o):s?new Se(s.sort(Hi),ko):ut}add(e,t){return t.length?this==ut?Se.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,o=0;e.forEach((a,l)=>{let c=l+n,u;if(u=r5(t,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,u,c+1):i.splice(o,0,l,l+a.nodeSize,ac(u,a,c+1,Fi)),o+=3}});let s=t5(o?n5(t):t,-n);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Se(s.length?this.local.concat(s).sort(Hi):this.local,i||this.children)}remove(e){return e.length==0||this==ut?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let o=0;o<n.length;o+=3){let s,a=n[o]+t,l=n[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,a+1);c!=ut?n[o+2]=c:(n.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new Se(i,n):ut}forChild(e,t){if(this==ut)return this;if(t.isLeaf)return Se.empty;let n,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(n=this.children[a+2]);break}let o=e+1,s=o+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof Yn){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let a=new Se(i.sort(Hi),ko);return n?new Ln([a,n]):a}return n||ut}eq(e){if(this==e)return!0;if(!(e instanceof Se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return of(this.localsInner(e))}localsInner(e){if(this==ut)return ko;if(e.inlineContent||!this.local.some(Yn.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Yn||t.push(this.local[n]);return t}forEachSet(e){e(this)}}Se.empty=new Se([],[]);Se.removeOverlap=of;const ut=Se.empty;class Ln{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,Fi));return Ln.from(n)}forChild(e,t){if(t.isLeaf)return Se.empty;let n=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=ut&&(o instanceof Ln?n=n.concat(o.members):n.push(o))}return Ln.from(n)}eq(e){if(!(e instanceof Ln)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?of(n?t:t.sort(Hi)):ko}static from(e){switch(e.length){case 0:return ut;case 1:return e[0];default:return new Ln(e.every(t=>t instanceof Se)?e:e.reduce((t,n)=>t.concat(n instanceof Se?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function kb(r,e,t,n,i,o,s){let a=r.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((h,f,m,y)=>{let x=y-m-(f-h);for(let b=0;b<a.length;b+=3){let S=a[b+1];if(S<0||h>S+u-d)continue;let A=a[b]+u-d;f>=A?a[b+1]=h<=A?-2:-1:h>=u&&x&&(a[b]+=x,a[b+1]+=x)}d+=x}),u=t.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=t.map(r[c]+o),d=u-i;if(d<0||d>=n.content.size){l=!0;continue}let h=t.map(r[c+1]+o,-1),f=h-i,{index:m,offset:y}=n.content.findIndex(d),x=n.maybeChild(m);if(x&&y==d&&y+x.nodeSize==f){let b=a[c+2].mapInner(t,x,u+1,r[c]+o+1,s);b!=ut?(a[c]=d,a[c+1]=f,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Sb(a,r,e,t,i,o,s),u=ac(c,n,0,s);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<a.length&&a[h]<f;)h+=3;a.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Se(e.sort(Hi),a)}function t5(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new qe(i.from+e,i.to+e,i.type))}return t}function Sb(r,e,t,n,i,o,s){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(n,i,c);d?t.push(d):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<r.length;l+=3)r[l+1]==-1&&a(r[l+2],e[l]+o+1);return t}function r5(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let o=0,s;o<r.length;o++)(s=r[o])&&s.from>t&&s.to<n&&((i||(i=[])).push(s),r[o]=null);return i}function n5(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function ac(r,e,t,n){let i=[],o=!1;e.forEach((a,l)=>{let c=r5(r,a,l+t);if(c){o=!0;let u=ac(c,a,t+l+1,n);u!=ut&&i.push(l,l+a.nodeSize,u)}});let s=t5(o?n5(r):r,-t).sort(Hi);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(n.onRemove&&n.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new Se(s,i):ut}function Hi(r,e){return r.from-e.from||r.to-e.to}function of(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[i]=o.copy(o.from,n.to),v1(e,i+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),v1(e,i,n.copy(o.from,n.to)));break}}}return e}function v1(r,e,t){for(;e<r.length&&Hi(t,r[e])>0;)e++;r.splice(e,0,t)}function Fu(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=ut&&e.push(n)}),r.cursorWrapper&&e.push(Se.create(r.state.doc,[r.cursorWrapper.deco])),Ln.from(e)}const Cb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Mb=It&&Un<=11;class Tb{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ab{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Tb,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);It&&Un<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ft&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Mb&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Cb)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(d1(this.view)){if(this.suppressingSelectionUpdates)return gn(this.view);if(It&&Un<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=bs(o))t.add(o);for(let o=e.anchorNode;o;o=bs(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&d1(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],l);d&&(o=o<0?d.from:Math.min(d.from,o),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||at&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(sr&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||Db(e,d)!=f)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dc(n)&&(c=Xh(e))&&c.eq(ue.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gn(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Nb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ob(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gn(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(It&&Un<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?st(i)+1:0,a=n.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?st(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let b1=new WeakMap,w1=!1;function Nb(r){if(!b1.has(r)&&(b1.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=sr,w1)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),w1=!0}}function x1(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=r.domAtPos(r.state.selection.anchor);return Xi(s.node,s.offset,i,o)&&([t,n,i,o]=[i,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}}function Eb(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return x1(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?x1(r,t):null}function Db(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Ob(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),n==o&&r.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Rb(r,e,t,n){let{node:i,fromOffset:o,toOffset:s,from:a,to:l}=r.docView.parseRange(e,t),c=r.domSelectionRange(),u,d=c.anchorNode;if(d&&r.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],Dc(c)||u.push({node:c.focusNode,offset:c.focusOffset})),at&&r.input.lastKeyCode===8)for(let b=s;b>o;b--){let S=i.childNodes[b-1],A=S.pmViewDesc;if(S.nodeName=="BR"&&!A){s=b;break}if(!A||A.size)break}let h=r.state.doc,f=r.someProp("domParser")||Yi.fromSchema(r.state.schema),m=h.resolve(a),y=null,x=f.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Ib(n),context:m});if(u&&u[0].pos!=null){let b=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=b),y={anchor:b+a,head:S+a}}return{doc:x,sel:y,from:a,to:l}}const Ib=r=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(r);if(e.nodeName=="BR"&&e.parentNode){if(ft&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||ft&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},zb=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Lb(r,e,t,n,i){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let N=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,$=Xh(r,N);if($&&!r.state.selection.eq($)){if(at&&un&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",ne=>ne(r,yi(13,"Enter"))))return;let K=r.state.tr.setSelection($);N=="pointer"?K.setMeta("pointer",!0):N=="key"&&K.scrollIntoView(),o&&K.setMeta("composition",o),r.dispatch(K)}return}let s=r.state.doc.resolve(e),a=s.sharedDepth(t);e=s.before(a+1),t=r.state.doc.resolve(t).after(a+1);let l=r.state.selection,c=Rb(r,e,t,i),u=r.state.doc,d=u.slice(c.from,c.to),h,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(h=r.state.selection.to,f="end"):(h=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let m=Fb(d.content,c.doc.content,c.from,h,f);if(m&&r.input.domChangeCount++,(ws&&r.input.lastIOSEnter>Date.now()-225||un)&&i.some(N=>N.nodeType==1&&!zb.test(N.nodeName))&&(!m||m.endA>=m.endB)&&r.someProp("handleKeyDown",N=>N(r,yi(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!m)if(n&&l instanceof Q&&!l.empty&&l.$head.sameParent(l.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=k1(r,r.state.doc,c.sel);if(N&&!N.eq(r.state.selection)){let $=r.state.tr.setSelection(N);o&&$.setMeta("composition",o),r.dispatch($)}}return}r.state.selection.from<r.state.selection.to&&m.start==m.endB&&r.state.selection instanceof Q&&(m.start>r.state.selection.from&&m.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?m.start=r.state.selection.from:m.endA<r.state.selection.to&&m.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(m.endB+=r.state.selection.to-m.endA,m.endA=r.state.selection.to)),It&&Un<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let y=c.doc.resolveNoCache(m.start-c.from),x=c.doc.resolveNoCache(m.endB-c.from),b=u.resolve(m.start),S=y.sameParent(x)&&y.parent.inlineContent&&b.end()>=m.endA;if((ws&&r.input.lastIOSEnter>Date.now()-225&&(!S||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&y.pos<c.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(c.doc.textBetween(y.pos,x.pos,"","")))&&r.someProp("handleKeyDown",N=>N(r,yi(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>m.start&&Pb(u,m.start,m.endA,y,x)&&r.someProp("handleKeyDown",N=>N(r,yi(8,"Backspace")))){un&&at&&r.domObserver.suppressSelectionUpdates();return}at&&m.endB==m.start&&(r.input.lastChromeDelete=Date.now()),un&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,x=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(N){return N(r,yi(13,"Enter"))})},20));let A=m.start,D=m.endA,O=N=>{let $=N||r.state.tr.replace(A,D,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let K=k1(r,$.doc,c.sel);K&&!(at&&r.composing&&K.empty&&(m.start!=m.endB||r.input.lastChromeDelete<Date.now()-100)&&(K.head==A||K.head==$.mapping.map(D)-1)||It&&K.empty&&K.head==A)&&$.setSelection(K)}return o&&$.setMeta("composition",o),$.scrollIntoView()},L;if(S)if(y.pos==x.pos){It&&Un<=11&&y.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>gn(r),20));let N=O(r.state.tr.delete(A,D)),$=u.resolve(m.start).marksAcross(u.resolve(m.endA));$&&N.ensureMarks($),r.dispatch(N)}else if(m.endA==m.endB&&(L=Bb(y.parent.content.cut(y.parentOffset,x.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let N=O(r.state.tr);L.type=="add"?N.addMark(A,D,L.mark):N.removeMark(A,D,L.mark),r.dispatch(N)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let N=y.parent.textBetween(y.parentOffset,x.parentOffset),$=()=>O(r.state.tr.insertText(N,A,D));r.someProp("handleTextInput",K=>K(r,A,D,N,$))||r.dispatch($())}else r.dispatch(O());else r.dispatch(O())}function k1(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Zh(r,e.resolve(t.anchor),e.resolve(t.head))}function Bb(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,o=n,s,a,l;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=u=>u.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(H.from(c).eq(r))return{mark:a,type:s}}function Pb(r,e,t,n,i){if(t-e<=i.pos-n.pos||Hu(n,!0,!1)<i.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let a=o.nodeAfter;return a!=null&&t==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=r.resolve(Hu(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Hu(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function Hu(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Fb(r,e,t,n,i){let o=r.findDiffStart(e,t),s=t+r.size,a=t+e.size;if(o==null)return null;let{a:l,b:c}=r.findDiffEnd(e,s,a);if(i=="end"){let u=Math.max(0,o-Math.min(l,c));n-=l+u-o}if(l<o&&s<a){let u=n<=o&&n>=l?o-n:0;o-=u,c=o+(c-l),l=o}else if(c<o){let u=n<=o&&n>=c?o-n:0;o-=u,l=o+(l-c),c=o}return{start:o,endA:l,endB:c}}class i5{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new eb,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(A1),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=M1(this),C1(this),this.nodeViews=T1(this),this.docView=o1(this.state.doc,S1(this),Fu(this),this.dom,this),this.domObserver=new Ab(this,(n,i,o,s)=>Lb(this,n,i,o,s)),this.domObserver.start(),tb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Jd(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(A1),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(X2(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=T1(this);_b(f,this.nodeViews)&&(this.nodeViews=f,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Jd(this),this.editable=M1(this),C1(this);let l=Fu(this),c=S1(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(i.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&m8(this);if(s){this.domObserver.stop();let f=d&&(It||at)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Hb(i.selection,e.selection);if(d){let y=at?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gb(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=o1(e.doc,c,l,this.dom,this)),y&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}let m=this.input.mouseDown;f||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&H8(this)&&m.delaySelUpdate())?gn(this,f):(P2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&g8(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof re){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&e1(this,t.getBoundingClientRect(),e)}else e1(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new Q2(e.slice,e.move,i<0?void 0:re.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=t?t(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(It){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&y8(this.dom),gn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return k8(this,e)}coordsAtPos(e,t=1){return E2(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return A8(this,t||this.state,e)}pasteHTML(e,t){return Oa(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Oa(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Qh(this,e)}destroy(){this.docView&&(rb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,o8())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ib(this,e)}domSelectionRange(){let e=this.domSelection();return e?ft&&this.root.nodeType===11&&u8(this.dom.ownerDocument)==this.dom&&Eb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}i5.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function S1(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[qe.node(0,r.state.doc.content.size,e)]}function C1(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:qe.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function M1(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Hb(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function T1(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function _b(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function A1(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const qb=B.createContext({contentRef:()=>{},view:null,mark:null}),$b=B.createContext(r=>{throw new Error("No ProsemirrorAdapterProvider detected, maybe you need to wrap the component with the Editor with ProsemirrorAdapterProvider?")});var jb=class extends nv{constructor(...r){super(...r),this.context={contentRef:this.contentRef,view:this.view,mark:this.mark},this.updateContext=()=>{Object.assign(this.context,{mark:this.mark})}}},Vb=class extends jb{constructor(...r){super(...r),this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(qb.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function Wb(r,e,t){return function(i){return function(s,a,l){const c=new t({mark:s,view:a,inline:l,options:{...i,destroy(){var u;(u=i.destroy)==null||u.call(i),e(c)}}});return r(c,!1),c}}}function Ub(r,e){return B.useMemo(()=>Wb(r,e,Vb),[r,e])}const o5=B.createContext({contentRef:()=>{},view:null,getPos:()=>0,setAttrs:()=>{},node:null,selected:!1,decorations:[],innerDecorations:null}),Es=()=>B.useContext(o5),s5=B.createContext(r=>{throw new Error("No ProsemirrorAdapterProvider detected, maybe you need to wrap the component with the Editor with ProsemirrorAdapterProvider?")}),Kb=()=>B.useContext(s5);var Gb=class extends iv{constructor(...r){super(...r),this.context={contentRef:this.contentRef,view:this.view,getPos:this.getPos,setAttrs:this.setAttrs,node:this.node,selected:this.selected,decorations:this.decorations,innerDecorations:this.innerDecorations},this.updateContext=()=>{Object.assign(this.context,{node:this.node,selected:this.selected,decorations:this.decorations,innerDecorations:this.innerDecorations})}}},Yb=class extends Gb{constructor(...r){super(...r),this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(o5.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function Jb(r,e,t){return function(i){return function(s,a,l,c,u){const d=new t({node:s,view:a,getPos:l,decorations:c,innerDecorations:u,options:{...i,onUpdate(){var h;(h=i.onUpdate)==null||h.call(i),r(d)},selectNode(){var h;(h=i.selectNode)==null||h.call(i),r(d)},deselectNode(){var h;(h=i.deselectNode)==null||h.call(i),r(d)},destroy(){var h;(h=i.destroy)==null||h.call(i),e(d)}}});return r(d,!1),d}}}function Xb(r,e){return B.useMemo(()=>Jb(r,e,Yb),[r,e])}const a5=B.createContext({view:null}),Zb=()=>B.useContext(a5),l5=B.createContext(r=>{throw new Error("out of scope")}),Qb=()=>B.useContext(l5);var ew=class extends ov{constructor(...r){super(...r),this.context={view:this.view,prevState:this.prevState},this.updateContext=()=>{Object.assign(this.context,{view:this.view,prevState:this.prevState})},this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(a5.Provider,{value:this.context},B.createElement(e,null)),this.root,this.key)}}};function tw(r,e){return B.useCallback(t=>n=>{const i=new ew({view:n,options:{...t,update:(o,s)=>{var a;(a=t.update)==null||a.call(t,o,s),r(i)},destroy:()=>{var o;(o=t.destroy)==null||o.call(t),e(i)}}});return r(i,!1),i},[e,r])}function rw(r,e){const[t,n]=r,i=e.key,o=B.createElement(B.Fragment,{key:i},e.render()),s=t.indexOf(i);if(s===-1)return[[...t,i],[...n,o]];{const a=[...n];return a[s]=o,[t,a]}}function nw(r,e){const[t,n]=r,i=t.indexOf(e.key);if(i===-1)return r;const o=[...t],s=[...n];return o.splice(i,1),s.splice(i,1),[o,s]}function iw(){const[r,e]=B.useState([[],[]]),t=B.useRef(!1);B.useLayoutEffect(()=>(t.current=!0,()=>{t.current=!1}),[]);const n=B.useCallback(i=>{t.current?Ll.flushSync(i):i()},[]);return{render:()=>r[1],renderReactRenderer:B.useCallback((i,o=!0)=>{n(()=>(o&&i.updateContext(),e(s=>rw(s,i))))},[n]),removeReactRenderer:B.useCallback(i=>{n(()=>e(o=>nw(o,i)))},[n])}}const ow=B.createContext({view:null,getPos:()=>{}}),sw=B.createContext(r=>{throw new Error("out of scope")});var aw=class extends sv{constructor(...r){super(...r),this.context={view:this.view,getPos:this.getPos,spec:this.spec},this.updateContext=()=>{Object.assign(this.context,{view:this.view,getPos:this.getPos,spec:this.spec})},this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(ow.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function lw(r,e){return B.useCallback(t=>(n,i={})=>{const o=new aw({pos:n,options:t}),s={...i,destroy:a=>{var l;(l=i.destroy)==null||l.call(i,a),e(o)}};return o.spec=s,qe.widget(n,(a,l)=>(o.bind(a,l),r(o),o.dom),s)},[e,r])}const cw=({children:r})=>{const{renderReactRenderer:e,removeReactRenderer:t,render:n}=iw(),i=Xb(e,t),o=Ub(e,t),s=tw(e,t),a=lw(e,t);return B.createElement(s5.Provider,{value:i},B.createElement($b.Provider,{value:o},B.createElement(l5.Provider,{value:s},B.createElement(sw.Provider,{value:a},B.createElement(B.Fragment,{key:1},r),B.createElement(B.Fragment,{key:2},n())))))};var Ut=(function(r){return r.docTypeError="docTypeError",r.contextNotFound="contextNotFound",r.timerNotFound="timerNotFound",r.ctxCallOutOfScope="ctxCallOutOfScope",r.createNodeInParserFail="createNodeInParserFail",r.stackOverFlow="stackOverFlow",r.parserMatchError="parserMatchError",r.serializerMatchError="serializerMatchError",r.getAtomFromSchemaFail="getAtomFromSchemaFail",r.expectDomTypeError="expectDomTypeError",r.callCommandBeforeEditorView="callCommandBeforeEditorView",r.missingRootElement="missingRootElement",r.missingNodeInSchema="missingNodeInSchema",r.missingMarkInSchema="missingMarkInSchema",r.ctxNotBind="ctxNotBind",r.missingYjsDoc="missingYjsDoc",r.aiProviderError="aiProviderError",r.aiBuildContextError="aiBuildContextError",r})({}),Kt=class extends Error{constructor(r,e,t){super(e,t),this.name="MilkdownError",this.code=r,(t==null?void 0:t.cause)!==void 0&&(this.cause=t.cause)}},uw=(r,e)=>typeof e=="function"?"[Function]":e,Rc=r=>JSON.stringify(r,uw);function dw(r){return new Kt(Ut.docTypeError,`Doc type error, unsupported type: ${Rc(r)}`)}function hw(r){return new Kt(Ut.contextNotFound,`Context "${r}" not found, do you forget to inject it?`)}function fw(r){return new Kt(Ut.timerNotFound,`Timer "${r}" not found, do you forget to record it?`)}function Ic(){return new Kt(Ut.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function pw(r,e,t){const n=`Cannot create node for ${"name"in r?r.name:r}`,i=s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},o=[["[Description]",n],["[Attributes]",e],["[Content]",(t??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[a,l])=>{const c=`${a}: ${i(l)}.`;return s.concat(c)},[]);return new Kt(Ut.createNodeInParserFail,o.join(`
29
- `))}function c5(){return new Kt(Ut.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function mw(r){return new Kt(Ut.parserMatchError,`Cannot match target parser for node: ${Rc(r)}.`)}function gw(r){return new Kt(Ut.serializerMatchError,`Cannot match target serializer for node: ${Rc(r)}.`)}function yw(r,e){return new Kt(Ut.getAtomFromSchemaFail,`Cannot get ${r}: ${e} from schema.`)}function Vr(r){return new Kt(Ut.expectDomTypeError,`Expect to be a dom, but get: ${Rc(r)}.`)}function _u(){return new Kt(Ut.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function u5(r){return new Kt(Ut.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${r}" in schema.`)}function vw(r){return new Kt(Ut.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`)}var d5=class{constructor(){this.sliceMap=new Map,this.get=r=>{const e=typeof r=="string"?[...this.sliceMap.values()].find(t=>t.type.name===r):this.sliceMap.get(r.id);if(!e){const t=typeof r=="string"?r:r.name;throw hw(t)}return e},this.remove=r=>{const e=typeof r=="string"?[...this.sliceMap.values()].find(t=>t.type.name===r):this.sliceMap.get(r.id);e&&this.sliceMap.delete(e.type.id)},this.has=r=>typeof r=="string"?[...this.sliceMap.values()].some(e=>e.type.name===r):this.sliceMap.has(r.id)}},gr,tn,zo,C4,bw=(C4=class{constructor(r,e,t){P(this,gr);P(this,tn);P(this,zo);I(this,gr,[]),I(this,zo,()=>{C(this,gr).forEach(n=>n(C(this,tn)))}),this.set=n=>{I(this,tn,n),C(this,zo).call(this)},this.get=()=>C(this,tn),this.update=n=>{I(this,tn,n(C(this,tn))),C(this,zo).call(this)},this.type=t,I(this,tn,e),r.set(t.id,this)}on(r){return C(this,gr).push(r),()=>{I(this,gr,C(this,gr).filter(e=>e!==r))}}once(r){const e=this.on(t=>{r(t),e()});return e}off(r){I(this,gr,C(this,gr).filter(e=>e!==r))}offAll(){I(this,gr,[])}},gr=new WeakMap,tn=new WeakMap,zo=new WeakMap,C4),ww=class{constructor(r,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=r,this._typeInfo=()=>{throw Ic()}}create(r,e=this._defaultValue){return new bw(r,e,this)}},me=(r,e)=>new ww(r,e),Ga,Ya,Ja,Si,Lo,Pn,Bo,Po,Fo,M4,xw=(M4=class{constructor(r,e,t){P(this,Ga);P(this,Ya);P(this,Ja);P(this,Si);P(this,Lo);P(this,Pn);P(this,Bo);P(this,Po);P(this,Fo);I(this,Si,new Set),I(this,Lo,new Set),I(this,Pn,new Map),I(this,Bo,new Map),this.read=()=>({metadata:C(this,Ga),injectedSlices:[...C(this,Si)].map(n=>({name:typeof n=="string"?n:n.name,value:C(this,Po).call(this,n)})),consumedSlices:[...C(this,Lo)].map(n=>({name:typeof n=="string"?n:n.name,value:C(this,Po).call(this,n)})),recordedTimers:[...C(this,Pn)].map(([n,{duration:i}])=>({name:n.name,duration:i,status:C(this,Fo).call(this,n)})),waitTimers:[...C(this,Bo)].map(([n,{duration:i}])=>({name:n.name,duration:i,status:C(this,Fo).call(this,n)}))}),this.onRecord=n=>{C(this,Pn).set(n,{start:Date.now(),duration:0})},this.onClear=n=>{C(this,Pn).delete(n)},this.onDone=n=>{const i=C(this,Pn).get(n);i&&(i.duration=Date.now()-i.start)},this.onWait=(n,i)=>{const o=Date.now();i.finally(()=>{C(this,Bo).set(n,{duration:Date.now()-o})}).catch(console.error)},this.onInject=n=>{C(this,Si).add(n)},this.onRemove=n=>{C(this,Si).delete(n)},this.onUse=n=>{C(this,Lo).add(n)},I(this,Po,n=>C(this,Ya).get(n).get()),I(this,Fo,n=>C(this,Ja).get(n).status),I(this,Ya,r),I(this,Ja,e),I(this,Ga,t)}},Ga=new WeakMap,Ya=new WeakMap,Ja=new WeakMap,Si=new WeakMap,Lo=new WeakMap,Pn=new WeakMap,Bo=new WeakMap,Po=new WeakMap,Fo=new WeakMap,M4),rn,nn,Xa,tr,Ho,kw=(Ho=class{constructor(e,t,n){P(this,rn);P(this,nn);P(this,Xa);P(this,tr);this.produce=i=>i&&Object.keys(i).length?new Ho(C(this,rn),C(this,nn),{...i}):this,this.inject=(i,o)=>{var a;const s=i.create(C(this,rn).sliceMap);return o!=null&&s.set(o),(a=C(this,tr))==null||a.onInject(i),this},this.remove=i=>{var o;return C(this,rn).remove(i),(o=C(this,tr))==null||o.onRemove(i),this},this.record=i=>{var o;return i.create(C(this,nn).store),(o=C(this,tr))==null||o.onRecord(i),this},this.clearTimer=i=>{var o;return C(this,nn).remove(i),(o=C(this,tr))==null||o.onClear(i),this},this.isInjected=i=>C(this,rn).has(i),this.isRecorded=i=>C(this,nn).has(i),this.use=i=>{var o;return(o=C(this,tr))==null||o.onUse(i),C(this,rn).get(i)},this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>C(this,nn).get(i),this.done=i=>{var o;this.timer(i).done(),(o=C(this,tr))==null||o.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=C(this,tr))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},I(this,rn,e),I(this,nn,t),I(this,Xa,n),n&&I(this,tr,new xw(e,t,n))}get meta(){return C(this,Xa)}get inspector(){return C(this,tr)}},rn=new WeakMap,nn=new WeakMap,Xa=new WeakMap,tr=new WeakMap,Ho),Sw=class{constructor(){this.store=new Map,this.get=r=>{const e=this.store.get(r.id);if(!e)throw fw(r.name);return e},this.remove=r=>{this.store.delete(r.id)},this.has=r=>this.store.has(r.id)}},_o,Fn,qo,on,$o,Za,T4,Cw=(T4=class{constructor(r,e){P(this,_o);P(this,Fn);P(this,qo);P(this,on);P(this,$o);P(this,Za);I(this,_o,null),I(this,Fn,null),I(this,on,"pending"),this.start=()=>(C(this,_o)??I(this,_o,new Promise((t,n)=>{I(this,Fn,i=>{i instanceof CustomEvent&&i.detail.id===C(this,qo)&&(I(this,on,"resolved"),C(this,$o).call(this),i.stopImmediatePropagation(),t())}),C(this,Za).call(this,()=>{C(this,on)==="pending"&&I(this,on,"rejected"),C(this,$o).call(this),n(new Error(`Timing ${this.type.name} timeout.`))}),I(this,on,"pending"),addEventListener(this.type.name,C(this,Fn))})),C(this,_o)),this.done=()=>{const t=new CustomEvent(this.type.name,{detail:{id:C(this,qo)}});dispatchEvent(t)},I(this,$o,()=>{C(this,Fn)&&removeEventListener(this.type.name,C(this,Fn))}),I(this,Za,t=>{setTimeout(()=>{t()},this.type.timeout)}),I(this,qo,Symbol(e.name)),this.type=e,r.set(e.id,this)}get status(){return C(this,on)}},_o=new WeakMap,Fn=new WeakMap,qo=new WeakMap,on=new WeakMap,$o=new WeakMap,Za=new WeakMap,T4),Mw=class{constructor(r,e=3e3){this.create=t=>new Cw(t,this),this.id=Symbol(`Timer-${r}`),this.name=r,this.timeout=e}},Wr=(r,e=3e3)=>new Mw(r,e);function Xd(r){const e=this;e.compiler=t;function t(n){return _7(n,{...e.data("settings"),...r,extensions:e.data("toMarkdownExtensions")||[]})}}const sf=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function h5(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const f5=(r,e,t)=>{let n=h5(r,t);if(!n)return!1;let i=af(n);if(!i){let s=n.blockRange(),a=s&&Ac(s);return a==null?!1:(e&&e(r.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(y5(r,i,e,-1))return!0;if(n.parent.content.size==0&&(xs(o,"end")||re.isSelectable(o)))for(let s=n.depth;;s--){let a=Nc(r.doc,n.before(s),n.after(s),Y.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=r.tr.step(a);l.setSelection(xs(o,"end")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):re.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Tw=(r,e,t)=>{let n=h5(r,t);if(!n)return!1;let i=af(n);return i?Aw(r,i,e):!1};function Aw(r,e,t){let n=e.nodeBefore,i=n,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Nc(r.doc,o,l,Y.empty);if(!c||c.from!=o||c instanceof Ke&&c.slice.size>=l-o)return!1;if(t){let u=r.tr.step(c);u.setSelection(Q.create(u.doc,o)),t(u.scrollIntoView())}return!0}function xs(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const p5=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=af(n)}let s=o&&o.nodeBefore;return!s||!re.isSelectable(s)?!1:(e&&e(r.tr.setSelection(re.create(r.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function af(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Nw(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Ew=(r,e,t)=>{let n=Nw(r,t);if(!n)return!1;let i=m5(n);if(!i)return!1;let o=i.nodeAfter;if(y5(r,i,e,1))return!0;if(n.parent.content.size==0&&(xs(o,"start")||re.isSelectable(o))){let s=Nc(r.doc,n.before(),n.after(),Y.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=r.tr.step(s);a.setSelection(xs(o,"start")?ue.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):re.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Dw=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=m5(n)}let s=o&&o.nodeAfter;return!s||!re.isSelectable(s)?!1:(e&&e(r.tr.setSelection(re.create(r.doc,o.pos)).scrollIntoView()),!0)};function m5(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Ow=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
30
- `).scrollIntoView()),!0)};function lf(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const g5=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=lf(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=t.after(),l=r.tr.replaceWith(a,a,s.createAndFill());l.setSelection(ue.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Rw=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof Rt||n.parent.inlineContent||i.parent.inlineContent)return!1;let o=lf(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,a=r.tr.insert(s,o.createAndFill());a.setSelection(Q.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},Iw=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(fa(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Ac(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function zw(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof re&&e.selection.node.isBlock)return!n.parentOffset||!fa(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let f=n.depth;;f--)if(n.node(f).isBlock){l=n.end(f)==n.pos+(n.depth-f),c=n.start(f)==n.pos-(n.depth-f),a=lf(n.node(f-1).contentMatchAt(n.indexAfter(f-1))),o.unshift(l&&a?{type:a}:null),s=f;break}else{if(f==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof Q||e.selection instanceof Rt)&&u.deleteSelection();let d=u.mapping.map(n.pos),h=fa(u.doc,d,o.length,o);if(h||(o[0]=a?{type:a}:null,h=fa(u.doc,d,o.length,o)),!h)return!1;if(u.split(d,o.length,o),!l&&c&&n.node(s).type!=a){let f=u.mapping.map(n.before(s)),m=u.doc.resolve(f);a&&n.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(n.before(s)),a)}return t&&t(u.scrollIntoView()),!0}}const Lw=zw(),Bw=(r,e)=>(e&&e(r.tr.setSelection(new Rt(r.doc))),!0);function Pw(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,o=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Bl(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function y5(r,e,t,n){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&Pw(r,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(t){let f=e.pos+o.nodeSize,m=H.empty;for(let b=s.length-1;b>=0;b--)m=H.from(s[b].create(null,m));m=H.from(i.copy(m));let y=r.tr.step(new dt(e.pos-1,f,e.pos,f,new Y(m,1,0),s.length,!0)),x=y.doc.resolve(f+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Bl(y.doc,x.pos)&&y.join(x.pos),t(y.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&l?null:ue.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&Ac(d);if(h!=null&&h>=e.depth)return t&&t(r.tr.lift(d,h).scrollIntoView()),!0;if(c&&xs(o,"start",!0)&&xs(i,"end")){let f=i,m=[];for(;m.push(f),!f.isTextblock;)f=f.lastChild;let y=o,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,y.content)){if(t){let b=H.empty;for(let A=m.length-1;A>=0;A--)b=H.from(m[A].copy(b));let S=r.tr.step(new dt(e.pos-m.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new Y(b,m.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function v5(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(Q.create(e.doc,r<0?i.start(o):i.end(o)))),!0):!1}}const Fw=v5(-1),Hw=v5(1);function cf(r,e=null){return function(t,n){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&Gh(s,r,e);return a?(n&&n(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Ia(r,e=null){return function(t,n){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=t.selection.ranges[o];t.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(r,e)))if(l.type==r)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,r)}})}if(!i)return!1;if(n){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[s];o.setBlockType(a,l,r,e)}n(o.scrollIntoView())}return!0}}function _w(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],a=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,s.pos,(l,c)=>{if(a)return!1;a=l.inlineContent&&l.type.allowsMarkType(t)}),a)return!0}return!1}function zc(r,e=null,t){return function(n,i){let{empty:o,$cursor:s,ranges:a}=n.selection;if(o&&!s||!_w(n.doc,a,r))return!1;if(i)if(s)r.isInSet(n.storedMarks||s.marks())?i(n.tr.removeStoredMark(r)):i(n.tr.addStoredMark(r.create(e)));else{let l,c=n.tr;l=!a.some(u=>n.doc.rangeHasMark(u.$from.pos,u.$to.pos,r));for(let u=0;u<a.length;u++){let{$from:d,$to:h}=a[u];if(!l)c.removeMark(d.pos,h.pos,r);else{let f=d.pos,m=h.pos,y=d.nodeAfter,x=h.nodeBefore,b=y&&y.isText?/^\s*/.exec(y.text)[0].length:0,S=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;f+b<m&&(f+=b,m-=S),c.addMark(f,m,r.create(e))}}i(c.scrollIntoView())}return!0}}function Ds(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}let qu=Ds(sf,f5,p5),N1=Ds(sf,Ew,Dw);const Qr={Enter:Ds(Ow,Rw,Iw,Lw),"Mod-Enter":g5,Backspace:qu,"Mod-Backspace":qu,"Shift-Backspace":qu,Delete:N1,"Mod-Delete":N1,"Mod-a":Bw},b5={"Ctrl-h":Qr.Backspace,"Alt-Backspace":Qr["Mod-Backspace"],"Ctrl-d":Qr.Delete,"Ctrl-Alt-Backspace":Qr["Mod-Delete"],"Alt-Delete":Qr["Mod-Delete"],"Alt-d":Qr["Mod-Delete"],"Ctrl-a":Fw,"Ctrl-e":Hw};for(let r in Qr)b5[r]=Qr[r];const qw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,$w=qw?b5:Qr;class zt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?jw(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function jw(r){return function(e,t,n,i){let o=r;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),n+=s;let a=n-i;a>0&&(o=t[0].slice(s-a,s)+o,n=i)}return e.tr.insertText(o,n,i)}}const Vw=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let i=t[n],o;if(i.spec.isInputRules&&(o=i.getState(r))){if(e){let s=r.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l--)s.step(a.steps[l].invert(a.docs[l]));if(o.text){let l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,r.schema.text(o.text,l))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new zt(/--$/,"—",{inCodeMark:!1});new zt(/\.\.\.$/,"…",{inCodeMark:!1});new zt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new zt(/"$/,"”",{inCodeMark:!1});new zt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new zt(/'$/,"’",{inCodeMark:!1});function uf(r,e,t=null,n){return new zt(r,(i,o,s,a)=>{let l=t instanceof Function?t(o):t,c=i.tr.delete(s,a),u=c.doc.resolve(s),d=u.blockRange(),h=d&&Gh(d,e,l);if(!h)return null;c.wrap(d,h);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Bl(c.doc,s-1)&&(!n||n(o,f))&&c.join(s-1),c})}function df(r,e,t=null){return new zt(r,(n,i,o,s)=>{let a=n.doc.resolve(o),l=t instanceof Function?t(i):t;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),e)?n.tr.delete(o,s).setBlockType(o,o,e,l):null})}const Jn=typeof navigator<"u"?navigator:null,E1=typeof document<"u"?document:null,ri=Jn&&Jn.userAgent||"",Zd=/Edge\/(\d+)/.exec(ri),w5=/MSIE \d/.exec(ri),Qd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ri),Lc=!!(w5||Qd||Zd),Ww=w5?document.documentMode:Qd?+Qd[1]:Zd?+Zd[1]:0,x5=!Lc&&/gecko\/(\d+)/i.test(ri),Uw=x5&&+(/Firefox\/(\d+)/.exec(ri)||[0,0])[1],eh=!Lc&&/Chrome\/(\d+)/.exec(ri),k5=!!eh,Kw=eh?+eh[1]:0,S5=!Lc&&!!Jn&&/Apple Computer/.test(Jn.vendor),C5=S5&&(/Mobile\/\w+/.test(ri)||!!Jn&&Jn.maxTouchPoints>2),Gw=C5||(Jn?/Mac/.test(Jn.platform):!1),M5=/Android \d/.test(ri),T5=!!E1&&"webkitFontSmoothing"in E1.documentElement.style,Yw=T5?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var w0=Object.freeze({__proto__:null,android:M5,chrome:k5,chrome_version:Kw,gecko:x5,gecko_version:Uw,ie:Lc,ie_version:Ww,ios:C5,mac:Gw,safari:S5,webkit:T5,webkit_version:Yw});function $u(r,e,t,n,i,o){if(r.composing)return!1;const s=r.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+n;for(let c of i){const u=c,d=u.match.exec(l),h=d&&d[0]&&u.handler(s,d,e-(d[0].length-n.length),t);if(h)return u.undoable!==!1&&h.setMeta(o,{transform:h,from:e,to:t,text:n}),r.dispatch(h),!0}return!1}const Jw=new Me("MILKDOWN_CUSTOM_INPUTRULES");function Xw({rules:r}){const e=new Ce({key:Jw,isInputRules:!0,state:{init(){return null},apply(t,n){const i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,i,o){return $u(t,n,i,o,r,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:n}=t.state.selection;n&&$u(t,n.pos,n.pos,"",r,e)}),!1),keydown:(t,n)=>!(M5&&k5&&n.key==="Enter")||t.composing?!1:t.someProp("handleKeyDown",i=>i(t,n))?(n.preventDefault(),!0):!1},handleKeyDown(t,n){if(n.key!=="Enter")return!1;const{$cursor:i}=t.state.selection;return i?$u(t,i.pos,i.pos,`
31
- `,r,e):!1}}});return e}function A5(r){return r.some(e=>e.type.spec.code)}function D1(r,e,t){if(e>=t)return!1;let n=!1;return r.doc.nodesBetween(e,t,i=>(i.isInline&&A5(i.marks)&&(n=!0),!n)),n}function Zw(r,e){var t;return A5((t=r.storedMarks)!=null?t:r.doc.resolve(e).marks())}function $l(r,e,t={}){return new zt(r,(n,i,o,s)=>{var a,l,c,u;const{tr:d}=n,h=i.length;let f=i[h-1],m=i[0],y=[],x;const b={group:f,fullMatch:m,start:o,end:s},S=(a=t.updateCaptured)==null?void 0:a.call(t,b);if(Object.assign(b,S),{group:f,fullMatch:m,start:o,end:s}=b,m===null||(f==null?void 0:f.trim())==="")return null;if(f){const A=m.search(/\S/),D=o+m.indexOf(f),O=D+f.length,L=D1(n,o+A,D),N=O<s&&D1(n,O,s);if(L||N||Zw(n,s))return null;y=(l=d.storedMarks)!=null?l:[],O<s&&d.delete(O,s),D>o&&d.delete(o+A,D),x=o+A+f.length;const $=(c=t.getAttr)==null?void 0:c.call(t,i);d.addMark(o,x,e.create($)),d.setStoredMarks(y),(u=t.beforeDispatch)==null||u.call(t,{match:i,start:o,end:s,tr:d})}return d})}function Qw(r,e,t={}){return new zt(r,(n,i,o,s)=>{var a,l,c;const{tr:u}=n;let d=i[1],h=i[0];const f={group:d,fullMatch:h,start:o,end:s},m=(a=t.updateCaptured)==null?void 0:a.call(t,f);if(Object.assign(f,m),{group:d,fullMatch:h,start:o,end:s}=f,h===null||!d||d.trim()==="")return null;const y=(l=t.getAttr)==null?void 0:l.call(t,i),x=e.createAndFill(y);return x&&(u.replaceRangeWith(e.isBlock?u.doc.resolve(o).before():o,s,x),(c=t.beforeDispatch)==null||c.call(t,{match:[h,d],start:o,end:s,tr:u})),u})}var e9=Object.defineProperty,t9=Object.defineProperties,r9=Object.getOwnPropertyDescriptors,O1=Object.getOwnPropertySymbols,n9=Object.prototype.hasOwnProperty,i9=Object.prototype.propertyIsEnumerable,R1=(r,e,t)=>e in r?e9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o9=(r,e)=>{for(var t in e||(e={}))n9.call(e,t)&&R1(r,t,e[t]);if(O1)for(var t of O1(e))i9.call(e,t)&&R1(r,t,e[t]);return r},s9=(r,e)=>t9(r,r9(e));function I1(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function Bc(r,e,t){const i=r.state.doc.content.size,o=I1(e,0,i),s=I1(t,0,i),a=r.coordsAtPos(o),l=r.coordsAtPos(s,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),h=Math.max(a.right,l.right),f=h-d,m=u-c,b={top:c,bottom:u,left:d,right:h,width:f,height:m,x:d,y:c};return s9(o9({},b),{toJSON:()=>b})}function N5(r){return Object.assign(Object.create(r),r).setTime(Date.now())}function a9(r,e){return Array.isArray(r)&&r.includes(e.type)||e.type===r}function l9(r){if(r.content.childCount===1){const e=r.content.firstChild;if((e==null?void 0:e.type.name)==="text"&&e.marks.length===0)return e;if((e==null?void 0:e.type.name)==="paragraph"&&e.childCount===1){const t=e.firstChild;if((t==null?void 0:t.type.name)==="text"&&t.marks.length===0)return t}}return!1}function Fr(r){return e=>{for(let t=e.depth;t>0;t-=1){const n=e.node(t);if(r(n)){const i=e.before(t),o=e.after(t);return{from:i,to:o,node:n}}}}}function c9(r,e){return Fr(t=>t.type===e)(r)}function u9(r,e){const t=e.nodes[r];if(!t)throw yw("node",r);return t}function E5(r){return e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(r(n))return{pos:e.before(t),start:e.start(t),depth:t,node:n}}}}function d9(r){return e=>E5(r)(e.$from)}function h9(r,e){if(!(r instanceof re))return;const{node:t,$from:n}=r;if(a9(e,t))return{node:t,pos:n.pos,start:n.start(n.depth),depth:n.depth}}const D5=(r,e)=>{const{selection:t,doc:n}=r;if(t instanceof re)return{hasNode:t.node.type===e,pos:t.from,target:t.node};const{from:i,to:o}=t;let s=!1,a=-1,l=null;return n.nodesBetween(i,o,(c,u)=>l?!1:c.type===e?(s=!0,a=u,l=c,!1):!0),{hasNode:s,pos:a,target:l}},f9=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),p9=typeof navigator<"u"&&/Win/.test(navigator.platform);function m9(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))f9?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function g9(r){let e=Object.create(null);for(let t in r)e[m9(t)]=r[t];return e}function ju(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function y9(r){return new Ce({props:{handleKeyDown:hf(r)}})}function hf(r){let e=g9(r);return function(t,n){let i=Qy(n),o,s=e[ju(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let a=e[ju(i,n,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(p9&&n.ctrlKey&&n.altKey)&&(o=e7[n.keyCode])&&o!=i){let a=e[ju(o,n)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var O5=class{},R5=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=r=>{var e;(e=this.top())==null||e.push(r)},this.open=r=>{this.elements.push(r)},this.close=()=>{const r=this.elements.pop();if(!r)throw c5();return r}}},v9=class I5 extends O5{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new I5(e,t,n)}},yr,jo,Qa,el,tl,Vo,Wo,Vi,b9=(Vi=class extends R5{constructor(t){super();P(this,yr);P(this,jo);P(this,Qa);P(this,el);P(this,tl);P(this,Vo);P(this,Wo);I(this,yr,fe.none),I(this,jo,n=>n.isText),I(this,Qa,(n,i)=>{if(C(this,jo).call(this,n)&&C(this,jo).call(this,i)&&fe.sameSet(n.marks,i.marks))return this.schema.text(n.text+i.text,n.marks)}),I(this,el,n=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(n));if(!i)throw mw(n);return i}),I(this,tl,n=>{const i=C(this,el).call(this,n);i.spec.parseMarkdown.runner(this,n,i)}),this.injectRoot=(n,i,o)=>(this.openNode(i,o),this.next(n.children),this),this.openNode=(n,i)=>(this.open(v9.create(n,[],i)),this),I(this,Vo,()=>{I(this,yr,fe.none);const n=this.close();return C(this,Wo).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>{try{C(this,Vo).call(this)}catch(n){console.error(n)}return this},I(this,Wo,(n,i,o)=>{const s=n.createAndFill(i,o,C(this,yr));if(!s)throw pw(n,i,o);return this.push(s),s}),this.addNode=(n,i,o)=>{try{C(this,Wo).call(this,n,i,o)}catch(s){console.error(s)}return this},this.openMark=(n,i)=>{const o=n.create(i);return I(this,yr,o.addToSet(C(this,yr))),this},this.closeMark=n=>(I(this,yr,n.removeFromSet(C(this,yr))),this),this.addText=n=>{try{const i=this.top();if(!i)throw c5();const o=i.pop(),s=this.schema.text(n,C(this,yr));if(!o)return i.push(s),this;const a=C(this,Qa).call(this,o,s);return a?(i.push(a),this):(i.push(o,s),this)}catch(i){return console.error(i),this}},this.build=()=>{let n;do n=C(this,Vo).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(i=>C(this,tl).call(this,i)),this),this.toDoc=()=>this.build(),this.run=(n,i)=>{const o=n.runSync(n.parse(i),i);return this.next(o),this},this.schema=t}},yr=new WeakMap,jo=new WeakMap,Qa=new WeakMap,el=new WeakMap,tl=new WeakMap,Vo=new WeakMap,Wo=new WeakMap,Vi.create=(t,n)=>{const i=new Vi(t);return o=>(i.run(n,o),i.toDoc())},Vi),Wi,z1=(Wi=class extends O5{constructor(e,t,n,i={}){super(),this.type=e,this.children=t,this.value=n,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>{var o;return(o=this.children)==null?void 0:o.pop()}}},Wi.create=(e,t,n,i={})=>new Wi(e,t,n,i),Wi),w9=r=>Object.prototype.hasOwnProperty.call(r,"size"),vt,Uo,rl,nl,il,ol,Ko,Go,sl,al,Ci,Hn,ll,Yo,Ui,x9=(Ui=class extends R5{constructor(t){super();P(this,vt);P(this,Uo);P(this,rl);P(this,nl);P(this,il);P(this,ol);P(this,Ko);P(this,Go);P(this,sl);P(this,al);P(this,Ci);P(this,Hn);P(this,ll);P(this,Yo);I(this,vt,[]),I(this,Uo,n=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(n));if(!i)throw gw(n.type);return i}),I(this,rl,n=>C(this,Uo).call(this,n).spec.toMarkdown.runner(this,n)),I(this,nl,(n,i)=>C(this,Uo).call(this,n).spec.toMarkdown.runner(this,n,i)),I(this,il,n=>{const i=a=>a.type.spec.priority??50,o=[...n].sort((a,l)=>i(a)-i(l)),s=[];return C(this,vt).forEach(({mark:a})=>{const l=o.findIndex(c=>c.eq(a));l>=0&&s.push(...o.splice(l,1))}),s.concat(o)}),I(this,ol,n=>{const i=n==null?void 0:n.marks;let o=0;for(;o<C(this,vt).length;){const{mark:s,spanning:a}=C(this,vt)[o];if(a&&(i!=null&&i.some(l=>l.eq(s))))o++;else break}for(let s=C(this,vt).length-1;s>=o;s--)C(this,Yo).call(this,C(this,vt)[s].mark)}),I(this,Ko,(n,i)=>{C(this,il).call(this,n.marks).every(o=>!C(this,nl).call(this,o,n))&&C(this,rl).call(this,n),C(this,ol).call(this,i)}),I(this,Go,n=>{const{children:i}=n;return i&&(n.children=i.reduce((o,s,a)=>{if(a===0)return[s];const l=o.at(-1);if(l&&l.isMark&&s.isMark){const{children:c,...u}=s,{children:d,...h}=l;if(s.type===l.type&&c&&d&&JSON.stringify(u)===JSON.stringify(h)){const f={...h,children:[...d,...c]};return o.slice(0,-1).concat(C(this,Go).call(this,f))}}return o.concat(s)},[])),n}),I(this,sl,n=>{const i={...n.props,type:n.type};return n.children&&(i.children=n.children),n.value&&(i.value=n.value),i}),this.openNode=(n,i,o)=>(this.open(z1.create(n,void 0,i,o)),this),I(this,al,(n,i)=>{let o="",s="";const a=n.children;if(a){const c=a[0],u=a.at(-1);if(u&&u.type==="text"&&u.value.endsWith(" ")){const d=u.value,h=d.trimEnd();s=d.slice(h.length),u.value=h}if(c&&c.type==="text"&&c.value.startsWith(" ")){const d=c.value,h=d.trimStart();o=d.slice(0,d.length-h.length),c.value=h}}o.length&&C(this,Hn).call(this,"text",void 0,o);const l=i();return s.length&&C(this,Hn).call(this,"text",void 0,s),l}),I(this,Ci,(n=!1)=>{const i=this.close(),o=()=>C(this,Hn).call(this,i.type,i.children,i.value,i.props);return n?C(this,al).call(this,i,o):o()}),this.closeNode=()=>(C(this,Ci).call(this),this),I(this,Hn,(n,i,o,s)=>{const a=z1.create(n,i,o,s),l=C(this,Go).call(this,C(this,sl).call(this,a));return this.push(l),l}),this.addNode=(n,i,o,s)=>(C(this,Hn).call(this,n,i,o,s),this),I(this,ll,(n,i,o,s)=>C(this,vt).some(a=>a.mark.eq(n))?this:(C(this,vt).push({mark:n,spanning:o==null}),this.openNode(i,o,{...s,isMark:!0}))),I(this,Yo,n=>{let i=-1;for(let o=C(this,vt).length-1;o>=0;o--)if(C(this,vt)[o].mark.eq(n)){i=o;break}i<0||(C(this,vt).splice(i,1),C(this,Ci).call(this,!0))}),this.withMark=(n,i,o,s)=>(C(this,ll).call(this,n,i,o,s),this),this.closeMark=n=>(C(this,Yo).call(this,n),this),this.build=()=>{let n=null;do n=C(this,Ci).call(this);while(this.size());return n},this.next=n=>w9(n)?(n.forEach((i,o,s)=>{C(this,Ko).call(this,i,n.maybeChild(s+1)??void 0)}),this):(C(this,Ko).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(I(this,vt,[]),this.next(n),this),this.schema=t}},vt=new WeakMap,Uo=new WeakMap,rl=new WeakMap,nl=new WeakMap,il=new WeakMap,ol=new WeakMap,Ko=new WeakMap,Go=new WeakMap,sl=new WeakMap,al=new WeakMap,Ci=new WeakMap,Hn=new WeakMap,ll=new WeakMap,Yo=new WeakMap,Ui.create=(t,n)=>{const i=new Ui(t);return o=>(i.run(o),i.toString(n))},Ui);function wn(r,e){return r.meta={package:"@milkdown/core",group:"System",...e},r}var z5={text:(r,e,t,n)=>{const i=r.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...n,encode:[]})},strong:(r,e,t,n)=>{const i=r.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(n);let a=s.move(i+i);return a+=s.move(t.containerPhrasing(r,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(r,e,t,n)=>{const i=r.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(n);let a=s.move(i);return a+=s.move(t.containerPhrasing(r,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},ge=me({},"editorView"),oa=me({},"editorState"),Vu=me([],"initTimer"),th=me({},"editor"),za=me([],"inputRules"),vn=me([],"prosePlugins"),La=me([],"remarkPlugins"),Ba=me([],"nodeView"),Pa=me([],"markView"),_i=me(Dd().use(Od).use(Xd),"remark"),ga=me({handlers:z5,encode:[]},"remarkStringifyOptions"),_0=Wr("ConfigReady");function k9(r){const e=t=>(t.record(_0),async()=>(await r(t),t.done(_0),()=>{t.clearTimer(_0)}));return wn(e,{displayName:"Config"}),e}var qi=Wr("InitReady");function S9(r){const e=t=>(t.inject(th,r).inject(vn,[]).inject(La,[]).inject(za,[]).inject(Ba,[]).inject(Pa,[]).inject(ga,{handlers:z5,encode:[]}).inject(_i,Dd().use(Od).use(Xd)).inject(Vu,[_0]).record(qi),async()=>{await t.waitTimers(Vu);const n=t.get(ga);return t.set(_i,Dd().use(Od).use(Xd,n)),t.done(qi),()=>{t.remove(th).remove(vn).remove(La).remove(za).remove(Ba).remove(Pa).remove(ga).remove(_i).remove(Vu).clearTimer(qi)}});return wn(e,{displayName:"Init"}),e}var xt=Wr("SchemaReady"),Wu=me([],"schemaTimer"),Sr=me({},"schema"),ya=me([],"nodes"),va=me([],"marks");function L1(r){var e;return{...r,parseDOM:(e=r.parseDOM)==null?void 0:e.map(t=>({priority:r.priority,...t}))}}var L5=r=>(r.inject(Sr,{}).inject(ya,[]).inject(va,[]).inject(Wu,[qi]).record(xt),async()=>{await r.waitTimers(Wu);const e=r.get(_i),t=r.get(La).reduce((s,a)=>s.use(a.plugin,a.options),e);r.set(_i,t);const n=Object.fromEntries(r.get(ya).map(([s,a])=>[s,L1(a)])),i=Object.fromEntries(r.get(va).map(([s,a])=>[s,L1(a)])),o=new Cv({nodes:n,marks:i});return r.set(Sr,o),r.done(xt),()=>{r.remove(Sr).remove(ya).remove(va).remove(Wu).clearTimer(xt)}});wn(L5,{displayName:"Schema"});var Mi,rr,A4,B5=(A4=class{constructor(){P(this,Mi);P(this,rr);I(this,Mi,new d5),I(this,rr,null),this.setCtx=r=>{I(this,rr,r)},this.chain=()=>{if(C(this,rr)==null)throw _u();const r=C(this,rr),e=[],t=this.get.bind(this),n={run:()=>{const o=Ds(...e),s=r.get(ge);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),n),pipe:i.bind(this)};function i(o,s){const a=t(o);return e.push(a(s)),n}return n}}get ctx(){return C(this,rr)}create(r,e){const t=r.create(C(this,Mi).sliceMap);return t.set(e),t}get(r){return C(this,Mi).get(r).get()}remove(r){return C(this,Mi).remove(r)}call(r,e){if(C(this,rr)==null)throw _u();const t=this.get(r)(e),n=C(this,rr).get(ge);return t(n.state,n.dispatch,n)}inline(r){if(C(this,rr)==null)throw _u();const e=C(this,rr).get(ge);return r(e.state,e.dispatch,e)}},Mi=new WeakMap,rr=new WeakMap,A4);function C9(r="cmdKey"){return me((()=>()=>!1),r)}var ee=me(new B5,"commands"),Uu=me([xt],"commandsTimer"),ba=Wr("CommandsReady"),P5=r=>{const e=new B5;return e.setCtx(r),r.inject(ee,e).inject(Uu,[xt]).record(ba),async()=>(await r.waitTimers(Uu),r.done(ba),()=>{r.remove(ee).remove(Uu).clearTimer(ba)})};wn(P5,{displayName:"Commands"});function M9(r){return r.Backspace=Ds(Vw,sf,Tw,p5),r}var Ti,At,N4,F5=(N4=class{constructor(){P(this,Ti);P(this,At);I(this,Ti,null),I(this,At,[]),this.setCtx=r=>{I(this,Ti,r)},this.add=r=>(C(this,At).push(r),()=>{I(this,At,C(this,At).filter(e=>e!==r))}),this.addObjectKeymap=r=>{const e=[];return Object.entries(r).forEach(([t,n])=>{if(typeof n=="function"){const i={key:t,onRun:()=>n};C(this,At).push(i),e.push(()=>{I(this,At,C(this,At).filter(o=>o!==i))})}else C(this,At).push(n),e.push(()=>{I(this,At,C(this,At).filter(i=>i!==n))})}),()=>{e.forEach(t=>t())}},this.addBaseKeymap=()=>{const r=M9($w);return this.addObjectKeymap(r)},this.build=()=>{const r={};return C(this,At).forEach(e=>{r[e.key]=[...r[e.key]||[],e]}),Object.fromEntries(Object.entries(r).map(([e,t])=>{const n=t.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,a)=>{const l=C(this,Ti);if(l==null)throw Ic();const c=n.map(u=>u.onRun(l));return Ds(...c)(o,s,a)}]}))}}get ctx(){return C(this,Ti)}},Ti=new WeakMap,At=new WeakMap,N4),lc=me(new F5,"keymap"),Ku=me([xt],"keymapTimer"),wa=Wr("KeymapReady"),T9=r=>{const e=new F5;return e.setCtx(r),r.inject(lc,e).inject(Ku,[xt]).record(wa),async()=>(await r.waitTimers(Ku),r.done(wa),()=>{r.remove(lc).remove(Ku).clearTimer(wa)})},q0=Wr("ParserReady"),H5=(()=>{throw Ic()}),Do=me(H5,"parser"),Gu=me([],"parserTimer"),_5=r=>(r.inject(Do,H5).inject(Gu,[xt]).record(q0),async()=>{await r.waitTimers(Gu);const e=r.get(_i),t=r.get(Sr);return r.set(Do,b9.create(t,e)),r.done(q0),()=>{r.remove(Do).remove(Gu).clearTimer(q0)}});wn(_5,{displayName:"Parser"});var xa=Wr("SerializerReady"),Yu=me([],"serializerTimer"),q5=(()=>{throw Ic()}),ka=me(q5,"serializer"),$5=r=>(r.inject(ka,q5).inject(Yu,[xt]).record(xa),async()=>{await r.waitTimers(Yu);const e=r.get(_i),t=r.get(Sr);return r.set(ka,x9.create(t,e)),r.done(xa),()=>{r.remove(ka).remove(Yu).clearTimer(xa)}});wn($5,{displayName:"Serializer"});var $0=me("","defaultValue"),j0=me(r=>r,"stateOptions"),Ju=me([],"editorStateTimer"),V0=Wr("EditorStateReady");function A9(r,e,t){if(typeof r=="string")return e(r);if(r.type==="html")return Yi.fromSchema(t).parse(r.dom);if(r.type==="json")return mn.fromJSON(t,r.value);throw dw(r)}var N9=new Me("MILKDOWN_STATE_TRACKER"),j5=r=>(r.inject($0,"").inject(oa,{}).inject(j0,e=>e).inject(Ju,[q0,xa,ba,wa]).record(V0),async()=>{await r.waitTimers(Ju);const e=r.get(Sr),t=r.get(Do),n=r.get(za),i=r.get(j0),o=r.get(vn),s=A9(r.get($0),t,e),a=r.get(lc),l=a.addBaseKeymap(),c=[...o,new Ce({key:N9,state:{init:()=>{},apply:(h,f,m,y)=>{r.set(oa,y)}}}),Xw({rules:n}),y9(a.build())];r.set(vn,c);const u=i({schema:e,doc:s,plugins:c}),d=bi.create(u);return r.set(oa,d),r.done(V0),()=>{l(),r.remove($0).remove(oa).remove(j0).remove(Ju).clearTimer(V0)}});wn(j5,{displayName:"EditorState"});var Fa=me([],"pasteRule"),Xu=me([xt],"pasteRuleTimer"),W0=Wr("PasteRuleReady"),V5=r=>(r.inject(Fa,[]).inject(Xu,[xt]).record(W0),async()=>(await r.waitTimers(Xu),r.done(W0),()=>{r.remove(Fa).remove(Xu).clearTimer(W0)}));wn(V5,{displayName:"PasteRule"});var U0=Wr("EditorViewReady"),Zu=me([],"editorViewTimer"),Sa=me({},"editorViewOptions"),K0=me(null,"root"),rh=me(null,"rootDOM"),nh=me({},"rootAttrs");function E9(r,e){const t=document.createElement("div");t.className="milkdown",r.appendChild(t),e.set(rh,t);const n=e.get(nh);return Object.entries(n).forEach(([i,o])=>t.setAttribute(i,o)),t}function D9(r){r.classList.add("editor"),r.setAttribute("role","textbox")}var O9=new Me("MILKDOWN_VIEW_CLEAR"),W5=r=>(r.inject(K0,document.body).inject(ge,{}).inject(Sa,{}).inject(rh,null).inject(nh,{}).inject(Zu,[V0,W0]).record(U0),async()=>{await r.wait(qi);const e=r.get(K0)||document.body,t=typeof e=="string"?document.querySelector(e):e;r.update(vn,l=>[new Ce({key:O9,view:c=>{const u=t?E9(t,r):void 0;return(()=>{if(u&&t){const h=c.dom;t.replaceChild(u,h),u.appendChild(h)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(c.dom,u)),u==null||u.remove()}}}}),...l]),await r.waitTimers(Zu);const n=r.get(oa),i=r.get(Sa),o=Object.fromEntries(r.get(Ba)),s=Object.fromEntries(r.get(Pa)),a=new i5(t,{state:n,nodeViews:o,markViews:s,transformPasted:(l,c,u)=>(r.get(Fa).sort((d,h)=>(h.priority??50)-(d.priority??50)).map(d=>d.run).forEach(d=>{l=d(l,c,u)}),l),...i});return D9(a.dom),r.set(ge,a),r.done(U0),()=>{a==null||a.destroy(),r.remove(K0).remove(ge).remove(Sa).remove(rh).remove(nh).remove(Zu).clearTimer(U0)}});wn(W5,{displayName:"EditorView"});var R9=(function(r){return r.Idle="Idle",r.OnCreate="OnCreate",r.Created="Created",r.OnDestroy="OnDestroy",r.Destroyed="Destroyed",r})({}),Ai,qt,sn,Jo,cl,ul,Nt,an,Ni,dl,Ei,Xo,hl,_n,Zo,Qo,I9=(Qo=class{constructor(){P(this,Ai);P(this,qt);P(this,sn);P(this,Jo);P(this,cl);P(this,ul);P(this,Nt);P(this,an);P(this,Ni);P(this,dl);P(this,Ei);P(this,Xo);P(this,hl);P(this,_n);P(this,Zo);I(this,Ai,!1),I(this,qt,"Idle"),I(this,sn,[]),I(this,Jo,()=>{}),I(this,cl,new d5),I(this,ul,new Sw),I(this,Nt,new Map),I(this,an,new Map),I(this,Ni,new kw(C(this,cl),C(this,ul))),I(this,dl,()=>{const e=k9(async n=>{await Promise.all(C(this,sn).map(i=>Promise.resolve(i(n))))}),t=[L5,_5,$5,P5,T9,V5,j5,W5,S9(this),e];C(this,Ei).call(this,t,C(this,an))}),I(this,Ei,(e,t)=>{e.forEach(n=>{const i=C(this,Ni).produce(C(this,Ai)?n.meta:void 0),o=n(i);t.set(n,{ctx:i,handler:o,cleanup:void 0})})}),I(this,Xo,(e,t=!1)=>Promise.all([e].flat().map(async n=>{var o;const i=(o=C(this,Nt).get(n))==null?void 0:o.cleanup;return t?C(this,Nt).delete(n):C(this,Nt).set(n,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i}))),I(this,hl,async()=>{await Promise.all([...C(this,an).entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),C(this,an).clear()}),I(this,_n,e=>{I(this,qt,e),C(this,Jo).call(this,e)}),I(this,Zo,e=>[...e.entries()].map(async([t,n])=>{const{ctx:i,handler:o}=n;if(!o)return;const s=await o();e.set(t,{ctx:i,handler:o,cleanup:s})})),this.enableInspector=(e=!0)=>(I(this,Ai,e),this),this.onStatusChange=e=>(I(this,Jo,e),this),this.config=e=>(C(this,sn).push(e),this),this.removeConfig=e=>(I(this,sn,C(this,sn).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(n=>{C(this,Nt).set(n,{ctx:void 0,handler:void 0,cleanup:void 0})}),C(this,qt)==="Created"&&C(this,Ei).call(this,t,C(this,Nt)),this},this.remove=async e=>C(this,qt)==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await C(this,Xo).call(this,[e].flat(),!0),this),this.create=async()=>C(this,qt)==="OnCreate"?this:(C(this,qt)==="Created"&&await this.destroy(),C(this,_n).call(this,"OnCreate"),C(this,dl).call(this),C(this,Ei).call(this,[...C(this,Nt).keys()],C(this,Nt)),await Promise.all([C(this,Zo).call(this,C(this,an)),C(this,Zo).call(this,C(this,Nt))].flat()),C(this,_n).call(this,"Created"),this),this.destroy=async(e=!1)=>C(this,qt)==="Destroyed"||C(this,qt)==="OnDestroy"?this:C(this,qt)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&I(this,sn,[]),C(this,_n).call(this,"OnDestroy"),await C(this,Xo).call(this,[...C(this,Nt).keys()],e),await C(this,hl).call(this),C(this,_n).call(this,"Destroyed"),this),this.action=e=>e(C(this,Ni)),this.inspect=()=>C(this,Ai)?[...C(this,an).values(),...C(this,Nt).values()].map(({ctx:e})=>{var t;return(t=e==null?void 0:e.inspector)==null?void 0:t.read()}).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Qo}get ctx(){return C(this,Ni)}get status(){return C(this,qt)}},Ai=new WeakMap,qt=new WeakMap,sn=new WeakMap,Jo=new WeakMap,cl=new WeakMap,ul=new WeakMap,Nt=new WeakMap,an=new WeakMap,Ni=new WeakMap,dl=new WeakMap,Ei=new WeakMap,Xo=new WeakMap,hl=new WeakMap,_n=new WeakMap,Zo=new WeakMap,Qo);function U5(r,e,t){const n=r.findIndex(([o])=>o===e);if(n===-1)return[...r,t];const i=r.slice();return i[n]=t,i}function le(r,e){const t=C9(r),n=i=>async()=>{n.key=t,await i.wait(ba);const o=e(i);return i.get(ee).create(t,o),n.run=s=>i.get(ee).call(r,s),()=>{i.get(ee).remove(t)}};return n}function mt(r){const e=t=>async()=>{await t.wait(xt);const n=r(t);return t.update(za,i=>[...i,n]),e.inputRule=n,()=>{t.update(za,i=>i.filter(o=>o!==n))}};return e}function z9(r){const e=t=>async()=>{await t.wait(xt);const n=r(t);return t.update(Fa,i=>[...i,n]),e.pasteRule=n,()=>{t.update(Fa,i=>i.filter(o=>o!==n))}};return e}function L9(r,e){const t=n=>async()=>{const i=e(n);return n.update(va,o=>U5(o,r,[r,i])),t.id=r,t.schema=i,()=>{n.update(va,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{const i=n.get(Sr).marks[r];if(!i)throw vw(r);return i},t}function ff(r,e){const t=n=>async()=>{const i=e(n);return n.update(ya,o=>U5(o,r,[r,i])),t.id=r,t.schema=i,()=>{n.update(ya,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{const i=n.get(Sr).nodes[r];if(!i)throw u5(r);return i},t}function Fe(r){let e;const t=n=>async()=>(await n.wait(xt),e=r(n),n.update(vn,i=>[...i,e]),()=>{n.update(vn,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function K5(r){const e=t=>async()=>{await t.wait(wa);const n=t.get(lc),i=r(t),o=n.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function Ha(r,e){const t=n=>async()=>{await n.wait(xt);const i=e(n);return r.type(n)instanceof rc?n.update(Ba,o=>[...o,[r.id,i]]):n.update(Pa,o=>[...o,[r.id,i]]),t.view=i,t.type=r,()=>{r.type(n)instanceof rc?n.update(Ba,o=>o.filter(s=>s[0]!==r.id)):n.update(Pa,o=>o.filter(s=>s[0]!==r.id))}};return t}function ye(r,e){const t=me(r,e),n=i=>(i.inject(t),()=>()=>{i.remove(t)});return n.key=t,n}function $e(r,e){const t=ye(e,r),n=ff(r,o=>o.get(t.key)(o)),i=[t,n];return i.id=n.id,i.node=n,i.type=o=>n.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>$e(r,o(e)),i}function Os(r,e){const t=ye(e,r),n=L9(r,o=>o.get(t.key)(o)),i=[t,n];return i.id=n.id,i.mark=n,i.type=o=>n.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>Os(r,o(e)),i}function Lt(r,e){const t=ye(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:a}])=>[o,{shortcuts:s,priority:a}])),`${r}Keymap`),n=K5(o=>{const s=o.get(t.key),a=Object.entries(e).flatMap(([l,{command:c}])=>{const u=s[l],d=[u.shortcuts].flat(),h=u.priority;return d.map(f=>[f,{key:f,onRun:c,priority:h}])});return Object.fromEntries(a)}),i=[t,n];return i.ctx=t,i.shortcuts=n,i.key=t.key,i.keymap=n.keymap,i}var Mr=(r,e=()=>({}))=>ye(e,`${r}Attr`),jl=(r,e=()=>({}))=>ye(e,`${r}Attr`);function dr(r,e,t){const n=ye(t??{},r),i=s=>async()=>{await s.wait(qi);const a={plugin:e(s),options:s.get(n.key)};return s.update(La,l=>[...l,a]),()=>{s.update(La,l=>l.filter(c=>c!==a))}},o=[n,i];return o.id=r,o.plugin=i,o.options=n,o}function B9(r,e=!1){return t=>{const n=t.get(ge),i=t.get(Do)(r);if(!i)return;if(!e){const{state:l}=n;return n.dispatch(l.tr.replace(0,l.doc.content.size,new Y(i.content,0,0)))}const o=t.get(Sr),s=t.get(j0)({schema:o,doc:i,plugins:t.get(vn)}),a=bi.create(s);n.updateState(a)}}let ih,oh;if(typeof WeakMap<"u"){let r=new WeakMap;ih=e=>r.get(e),oh=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;ih=n=>{for(let i=0;i<r.length;i+=2)if(r[i]==n)return r[i+1]},oh=(n,i)=>(t==10&&(t=0),r[t++]=n,r[t++]=i)}var xe=class{constructor(r,e,t,n){this.width=r,this.height=e,this.map=t,this.problems=n}findCell(r){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=r)continue;const n=e%this.width,i=e/this.width|0;let o=n+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==t;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==t;a++)s++;return{left:n,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${r} found`)}colCount(r){for(let e=0;e<this.map.length;e++)if(this.map[e]==r)return e%this.width;throw new RangeError(`No cell with offset ${r} found`)}nextCell(r,e,t){const{left:n,right:i,top:o,bottom:s}=this.findCell(r);return e=="horiz"?(t<0?n==0:i==this.width)?null:this.map[o*this.width+(t<0?n-1:i)]:(t<0?o==0:s==this.height)?null:this.map[n+this.width*(t<0?o-1:s)]}rectBetween(r,e){const{left:t,right:n,top:i,bottom:o}=this.findCell(r),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,l),right:Math.max(n,a),bottom:Math.max(o,c)}}cellsInRect(r){const e=[],t={};for(let n=r.top;n<r.bottom;n++)for(let i=r.left;i<r.right;i++){const o=n*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==r.left&&i&&this.map[o-1]==s||n==r.top&&n&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(r,e,t){for(let n=0,i=0;;n++){const o=i+t.child(n).nodeSize;if(n==r){let s=e+r*this.width;const a=(r+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(r){return ih(r)||oh(r,P9(r))}};function P9(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=F9(r),t=r.childCount,n=[];let i=0,o=null;const s=[];for(let c=0,u=e*t;c<u;c++)n[c]=0;for(let c=0,u=0;c<t;c++){const d=r.child(c);u++;for(let m=0;;m++){for(;i<n.length&&n[i]!=0;)i++;if(m==d.childCount)break;const y=d.child(m),{colspan:x,rowspan:b,colwidth:S}=y.attrs;for(let A=0;A<b;A++){if(A+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:b-A});break}const D=i+A*e;for(let O=0;O<x;O++){n[D+O]==0?n[D+O]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:x-O});const L=S&&S[O];if(L){const N=(D+O)%e*2,$=s[N];$==null||$!=L&&s[N+1]==1?(s[N]=L,s[N+1]=1):$==L&&s[N+1]++}}}i+=x,u+=y.nodeSize}const h=(c+1)*e;let f=0;for(;i<h;)n[i++]==0&&f++;f&&(o||(o=[])).push({type:"missing",row:c,n:f}),u++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new xe(e,t,n,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(l=!0);return l&&H9(a,s,r),a}function F9(r){let e=-1,t=!1;for(let n=0;n<r.childCount;n++){const i=r.child(n);let o=0;if(t)for(let s=0;s<n;s++){const a=r.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>n&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function H9(r,e,t){r.problems||(r.problems=[]);const n={};for(let i=0;i<r.map.length;i++){const o=r.map[i];if(n[o])continue;n[o]=!0;const s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const u=e[(i+c)%r.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=_9(l)))[c]=u)}a&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function _9(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function B1(r,e){if(typeof r=="string")return{};const t=r.getAttribute("data-colwidth"),n=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,i=Number(r.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(r.getAttribute("rowspan")||1),colwidth:n&&n.length==i?n:null};for(const s in e){const a=e[s].getFromDOM,l=a&&a(r);l!=null&&(o[s]=l)}return o}function P1(r,e){const t={};r.attrs.colspan!=1&&(t.colspan=r.attrs.colspan),r.attrs.rowspan!=1&&(t.rowspan=r.attrs.rowspan),r.attrs.colwidth&&(t["data-colwidth"]=r.attrs.colwidth.join(","));for(const n in e){const i=e[n].setDOMAttr;i&&i(r.attrs[n],t)}return t}function q9(r){if(r!==null){if(!Array.isArray(r))throw new TypeError("colwidth must be null or an array");for(const e of r)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function $9(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:q9}};for(const n in e)t[n]={default:e[n].default,validate:e[n].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:r.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:r.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:n=>B1(n,e)}],toDOM(n){return["td",P1(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>B1(n,e)}],toDOM(n){return["th",P1(n,e),0]}}}}function lr(r){let e=r.cached.tableNodeTypes;if(!e){e=r.cached.tableNodeTypes={};for(const t in r.nodes){const n=r.nodes[t],i=n.spec.tableRole;i&&(e[i]=n)}}return e}const Bn=new Me("selectingCells");function ks(r){for(let e=r.depth-1;e>0;e--)if(r.node(e).type.spec.tableRole=="row")return r.node(0).resolve(r.before(e+1));return null}function hr(r){const e=r.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Pc(r){const e=r.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=ks(e.$head)||j9(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function j9(r){for(let e=r.nodeAfter,t=r.pos;e;e=e.firstChild,t++){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t)}for(let e=r.nodeBefore,t=r.pos;e;e=e.lastChild,t--){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t-e.nodeSize)}}function sh(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function V9(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function pf(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function G5(r,e,t){const n=r.node(-1),i=xe.get(n),o=r.start(-1),s=i.nextCell(r.pos-o,e,t);return s==null?null:r.node(0).resolve(o+s)}function Zi(r,e,t=1){const n={...r,colspan:r.colspan-t};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,t),n.colwidth.some(i=>i>0)||(n.colwidth=null)),n}function W9(r,e,t=1){const n={...r,colspan:r.colspan+t};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let i=0;i<t;i++)n.colwidth.splice(e,0,0)}return n}function U9(r,e,t){const n=lr(e.type.schema).header_cell;for(let i=0;i<r.height;i++)if(e.nodeAt(r.map[t+i*r.width]).type!=n)return!1;return!0}var Ae=class Xr extends ue{constructor(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(u=>u!=t.pos-o);l.unshift(t.pos-o);const c=l.map(u=>{const d=n.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=o+u+1;return new b2(a.resolve(h),a.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(sh(n)&&sh(i)&&pf(n,i)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Xr.rowSelection(n,i):o&&this.isColSelection()?Xr.colSelection(n,i):new Xr(n,i)}return Q.between(n,i)}content(){const e=this.$anchorCell.node(-1),t=xe.get(e),n=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let u=l*t.width+i.left,d=i.left;d<i.right;d++,u++){const h=t.map[u];if(o[h])continue;o[h]=!0;const f=t.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const y=i.left-f.left,x=f.right-i.right;if(y>0||x>0){let b=m.attrs;if(y>0&&(b=Zi(b,0,y)),x>0&&(b=Zi(b,b.colspan-x,x)),f.left<i.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(f.top<i.top||f.bottom>i.bottom){const b={...m.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}s.push(e.child(l).copy(H.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Y(H.from(a),1,1)}replace(e,t=Y.empty){const n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(n);e.replace(c.map(a.pos),c.map(l.pos),s?Y.empty:t)}const o=ue.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new Y(H.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=xe.get(t),i=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new Xr(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=xe.get(e),n=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==t.width}eq(e){return e instanceof Xr&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new Xr(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Xr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new Xr(e.resolve(t),e.resolve(n))}getBookmark(){return new K9(this.$anchorCell.pos,this.$headCell.pos)}};Ae.prototype.visible=!1;ue.jsonID("cell",Ae);var K9=class Y5{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Y5(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&pf(t,n)?new Ae(t,n):ue.near(n,1)}};function G9(r){if(!(r.selection instanceof Ae))return null;const e=[];return r.selection.forEachCell((t,n)=>{e.push(qe.node(n,n+t.nodeSize,{class:"selectedCell"}))}),Se.create(r.doc,e)}function Y9({$from:r,$to:e}){if(r.pos==e.pos||r.pos<e.pos-6)return!1;let t=r.pos,n=e.pos,i=r.depth;for(;i>=0&&!(r.after(i+1)<r.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,n--);return t==n&&/row|table/.test(r.node(i).type.spec.tableRole)}function J9({$from:r,$to:e}){let t,n;for(let i=r.depth;i>0;i--){const o=r.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return t!==n&&e.parentOffset===0}function X9(r,e,t){const n=(e||r).selection,i=(e||r).doc;let o,s;if(n instanceof re&&(s=n.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Ae.create(i,n.from);else if(s=="row"){const a=i.resolve(n.from+1);o=Ae.rowSelection(a,a)}else if(!t){const a=xe.get(n.node),l=n.from+1,c=l+a.map[a.width*a.height-1];o=Ae.create(i,l+1,c)}}else n instanceof Q&&Y9(n)?o=Q.create(i,n.from):n instanceof Q&&J9(n)&&(o=Q.create(i,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}const Z9=new Me("fix-tables");function J5(r,e,t,n){const i=r.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,u=Math.min(i,s+3);c<u;c++)if(r.child(c)==l){a=c+1,t+=l.nodeSize;continue e}n(l,t),a<i&&r.child(a).sameMarkup(l)?J5(r.child(a),l,t+1,n):l.nodesBetween(0,l.content.size,n,t+1),t+=l.nodeSize}}function Q9(r,e){let t;const n=(i,o)=>{i.type.spec.tableRole=="table"&&(t=ex(r,i,o,t))};return e?e.doc!=r.doc&&J5(e.doc,r.doc,0,n):r.doc.descendants(n),t}function ex(r,e,t,n){const i=xe.get(e);if(!i.problems)return n;n||(n=r.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)o[c.row+h]+=c.n;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,Zi(d,d.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=n.mapping.map(t);n.delete(u,u+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=t+1;l<i.height;l++){const u=e.child(l),d=c+u.nodeSize,h=o[l];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const m=[];for(let x=0;x<h;x++){const b=lr(r.schema)[f].createAndFill();b&&m.push(b)}const y=(l==0||s==l-1)&&a==l?c+1:d-1;n.insert(n.mapping.map(y),m)}c=d}return n.setMeta(Z9,{fixTables:!0})}function X5(r){const e=xe.get(r),t=[],n=e.height,i=e.width;for(let o=0;o<n;o++){const s=[];for(let a=0;a<i;a++){const l=o*i+a,c=e.map[l];if(o>0){const u=l-i;if(c===e.map[u]){s.push(null);continue}}if(a>0){const u=l-1;if(c===e.map[u]){s.push(null);continue}}s.push(r.nodeAt(c))}t.push(s)}return t}function Z5(r,e){const t=[],n=xe.get(r),i=n.height,o=n.width;for(let s=0;s<i;s++){const a=r.child(s),l=[];for(let u=0;u<o;u++){const d=e[s][u];if(!d)continue;const h=n.map[s*n.width+u],f=r.nodeAt(h);if(!f)continue;const m=f.type.createChecked(d.attrs,d.content,d.marks);l.push(m)}const c=a.type.createChecked(a.attrs,l,a.marks);t.push(c)}return r.type.createChecked(r.attrs,t,r.marks)}function Q5(r,e,t,n){const i=e[0]>t[0]?-1:1,o=r.splice(e[0],e.length),s=o.length%2===0?1:0;let a;return a=i===-1?t[0]:t[t.length-1]-s,r.splice(a,0,...o),r}function Rs(r){return tx(e=>e.type.spec.tableRole==="table",r)}function tx(r,e){for(let t=e.depth;t>=0;t-=1){const n=e.node(t);if(r(n))return{node:n,pos:t===0?0:e.before(t),start:e.start(t),depth:t}}return null}function So(r,e){const t=Rs(e.$from);if(!t)return;const n=xe.get(t.node);if(!(r<0||r>n.width-1))return n.cellsInRect({left:r,right:r+1,top:0,bottom:n.height}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function Co(r,e){const t=Rs(e.$from);if(!t)return;const n=xe.get(t.node);if(!(r<0||r>n.height-1))return n.cellsInRect({left:0,right:n.width,top:r,bottom:r+1}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function F1(r,e,t=e){let n=e,i=t;for(let u=e;u>=0;u--){const d=So(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.colspan+u-1;f>=n&&(n=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const d=So(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.colspan+u-1;h.node.attrs.colspan>1&&f>i&&(i=f)})}const o=[];for(let u=n;u<=i;u++){const d=So(u,r.selection);d&&d.length>0&&o.push(u)}n=o[0],i=o[o.length-1];const s=So(n,r.selection),a=Co(0,r.selection);if(!s||!a)return;const l=r.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=n;u--){const d=So(u,r.selection);if(d&&d.length>0){for(let h=a.length-1;h>=0;h--)if(a[h].pos===d[0].pos){c=d[0];break}if(c)break}}if(c)return{$anchor:l,$head:r.doc.resolve(c.pos),indexes:o}}function H1(r,e,t=e){let n=e,i=t;for(let u=e;u>=0;u--){const d=Co(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.rowspan+u-1;f>=n&&(n=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const d=Co(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.rowspan+u-1;h.node.attrs.rowspan>1&&f>i&&(i=f)})}const o=[];for(let u=n;u<=i;u++){const d=Co(u,r.selection);d&&d.length>0&&o.push(u)}n=o[0],i=o[o.length-1];const s=Co(n,r.selection),a=So(0,r.selection);if(!s||!a)return;const l=r.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=n;u--){const d=Co(u,r.selection);if(d&&d.length>0){for(let h=a.length-1;h>=0;h--)if(a[h].pos===d[0].pos){c=d[0];break}if(c)break}}if(c)return{$anchor:l,$head:r.doc.resolve(c.pos),indexes:o}}function _1(r){return r[0].map((e,t)=>r.map(n=>n[t]))}function rx(r){var e,t;const{tr:n,originIndex:i,targetIndex:o,select:s,pos:a}=r,l=Rs(n.doc.resolve(a));if(!l)return!1;const c=(e=F1(n,i))===null||e===void 0?void 0:e.indexes,u=(t=F1(n,o))===null||t===void 0?void 0:t.indexes;if(!c||!u||c.includes(o))return!1;const d=nx(l.node,c,u);if(n.replaceWith(l.pos,l.pos+l.node.nodeSize,d),!s)return!0;const h=xe.get(d),f=l.start,m=o,y=h.positionAt(h.height-1,m,d),x=n.doc.resolve(f+y),b=h.positionAt(0,m,d),S=n.doc.resolve(f+b);return n.setSelection(Ae.colSelection(x,S)),!0}function nx(r,e,t,n){let i=_1(X5(r));return i=Q5(i,e,t),i=_1(i),Z5(r,i)}function ix(r){var e,t;const{tr:n,originIndex:i,targetIndex:o,select:s,pos:a}=r,l=Rs(n.doc.resolve(a));if(!l)return!1;const c=(e=H1(n,i))===null||e===void 0?void 0:e.indexes,u=(t=H1(n,o))===null||t===void 0?void 0:t.indexes;if(!c||!u||c.includes(o))return!1;const d=ox(l.node,c,u);if(n.replaceWith(l.pos,l.pos+l.node.nodeSize,d),!s)return!0;const h=xe.get(d),f=l.start,m=o,y=h.positionAt(m,h.width-1,d),x=n.doc.resolve(f+y),b=h.positionAt(m,0,d),S=n.doc.resolve(f+b);return n.setSelection(Ae.rowSelection(x,S)),!0}function ox(r,e,t,n){let i=X5(r);return i=Q5(i,e,t),Z5(r,i)}function ni(r){const e=r.selection,t=Pc(r),n=t.node(-1),i=t.start(-1),o=xe.get(n);return{...e instanceof Ae?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:n}}function e3(r,{map:e,tableStart:t,table:n},i){let o=i>0?-1:0;U9(e,n,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=n.nodeAt(l);r.setNodeMarkup(r.mapping.map(t+l),null,W9(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?lr(n.type.schema).cell:n.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,n);r.insert(r.mapping.map(t+c),l.createAndFill())}}return r}function sx(r,e){if(!hr(r))return!1;if(e){const t=ni(r);e(e3(r.tr,t,t.left))}return!0}function ax(r,e){if(!hr(r))return!1;if(e){const t=ni(r);e(e3(r.tr,t,t.right))}return!0}function lx(r,{map:e,table:t,tableStart:n},i){const o=r.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=t.nodeAt(l),u=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)r.setNodeMarkup(r.mapping.slice(o).map(n+l),null,Zi(u,i-e.colCount(l)));else{const d=r.mapping.slice(o).map(n+l);r.delete(d,d+c.nodeSize)}s+=u.rowspan}}function cx(r,e){if(!hr(r))return!1;if(e){const t=ni(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;lx(n,t,i),i!=t.left;i--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=xe.get(o)}e(n)}return!0}function ux(r,{map:e,table:t,tableStart:n},i){let o=0;for(let c=0;c<i;c++)o+=t.child(c).nodeSize;const s=o+t.child(i).nodeSize,a=r.mapping.maps.length;r.delete(o+n,s+n);const l=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const d=e.map[u];if(!l.has(d)){if(l.add(d),i>0&&d==e.map[u-e.width]){const h=t.nodeAt(d).attrs;r.setNodeMarkup(r.mapping.slice(a).map(d+n),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&d==e.map[u+e.width]){const h=t.nodeAt(d),f=h.attrs,m=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),y=e.positionAt(i+1,c,t);r.insert(r.mapping.slice(a).map(n+y),m),c+=f.colspan-1}}}}function dx(r,e){if(!hr(r))return!1;if(e){const t=ni(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;ux(n,t,i),i!=t.top;i--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=xe.get(t.table)}e(n)}return!0}function hx(r,e){return function(t,n){if(!hr(t))return!1;const i=Pc(t);if(i.nodeAfter.attrs[r]===e)return!1;if(n){const o=t.tr;t.selection instanceof Ae?t.selection.forEachCell((s,a)=>{s.attrs[r]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[r]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[r]:e}),n(o)}return!0}}function fx(r){return function(e,t){if(!hr(e))return!1;if(t){const n=lr(e.schema),i=ni(e),o=e.tr,s=i.map.cellsInRect(r=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:r=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==n.header_cell&&o.setNodeMarkup(i.tableStart+s[l],n.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],n.header_cell,a[l].attrs);t(o)}return!0}}function q1(r,e,t){const n=e.map.cellsInRect({left:0,top:0,right:r=="row"?e.map.width:1,bottom:r=="column"?e.map.height:1});for(let i=0;i<n.length;i++){const o=e.table.nodeAt(n[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function mf(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fx(r):function(t,n){if(!hr(t))return!1;if(n){const i=lr(t.schema),o=ni(t),s=t.tr,a=q1("row",o,i),l=q1("column",o,i),c=(r==="column"?a:r==="row"&&l)?1:0,u=r=="column"?{left:0,top:c,right:1,bottom:o.map.height}:r=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,d=r=="column"?l?i.cell:i.header_cell:r=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(h=>{const f=h+o.tableStart,m=s.doc.nodeAt(f);m&&s.setNodeMarkup(f,d,m.attrs)}),n(s)}return!0}}mf("row",{useDeprecatedLogic:!0});mf("column",{useDeprecatedLogic:!0});mf("cell",{useDeprecatedLogic:!0});function px(r,e){if(e<0){const t=r.nodeBefore;if(t)return r.pos-t.nodeSize;for(let n=r.index(-1)-1,i=r.before();n>=0;n--){const o=r.node(-1).child(n),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(r.index()<r.parent.childCount-1)return r.pos+r.nodeAfter.nodeSize;const t=r.node(-1);for(let n=r.indexAfter(-1),i=r.after();n<t.childCount;n++){const o=t.child(n);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function t3(r){return function(e,t){if(!hr(e))return!1;const n=px(Pc(e),r);if(n==null)return!1;if(t){const i=e.doc.resolve(n);t(e.tr.setSelection(Q.between(i,V9(i))).scrollIntoView())}return!0}}function mx(r,e){const t=r.selection.$anchor;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="table")return e&&e(r.tr.delete(t.before(n),t.after(n)).scrollIntoView()),!0;return!1}function x0(r,e){const t=r.selection;if(!(t instanceof Ae))return!1;if(e){const n=r.tr,i=lr(r.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||n.replace(n.mapping.map(s+1),n.mapping.map(s+o.nodeSize-1),new Y(i,0,0))}),n.docChanged&&e(n)}return!0}function gx(r){return(e,t)=>{const{from:n,to:i,select:o=!0,pos:s=e.selection.from}=r,a=e.tr;return ix({tr:a,originIndex:n,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function yx(r){return(e,t)=>{const{from:n,to:i,select:o=!0,pos:s=e.selection.from}=r,a=e.tr;return rx({tr:a,originIndex:n,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function vx(r){if(r.size===0)return null;let{content:e,openStart:t,openEnd:n}=r;for(;e.childCount==1&&(t>0&&n>0||e.child(0).type.spec.tableRole=="table");)t--,n--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const u=l?0:Math.max(0,t-1),d=l<e.childCount-1?0:Math.max(0,n-1);(u||d)&&(c=ah(lr(s).row,new Y(c,u,d)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||n?ah(lr(s).row,new Y(e,t,n)).content:e);else return null;return bx(s,a)}function bx(r,e){const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)t[c]=(t[c]||0)+l}}let n=0;for(let i=0;i<t.length;i++)n=Math.max(n,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(H.empty),t[i]<n){const o=lr(r).cell.createAndFill(),s=[];for(let a=t[i];a<n;a++)s.push(o);e[i]=e[i].append(H.from(s))}return{height:e.length,width:n,rows:e}}function ah(r,e){const t=r.createAndFill();return new v2(t).replace(0,t.content.size,e).doc}function wx({width:r,height:e,rows:t},n,i){if(r!=n){const o=[],s=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let u=o[a]||0,d=0;u<n;d++){let h=l.child(d%l.childCount);u+h.attrs.colspan>n&&(h=h.type.createChecked(Zi(h.attrs,h.attrs.colspan,u+h.attrs.colspan-n),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)o[a+f]=(o[a+f]||0)+h.attrs.colspan}s.push(H.from(c))}t=s,r=n}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}o.push(H.from(l))}t=o,e=i}return{width:r,height:e,rows:t}}function xx(r,e,t,n,i,o,s){const a=r.doc.type.schema,l=lr(a);let c,u;if(i>e.width)for(let d=0,h=0;d<e.height;d++){const f=t.child(d);h+=f.nodeSize;const m=[];let y;f.lastChild==null||f.lastChild.type==l.cell?y=c||(c=l.cell.createAndFill()):y=u||(u=l.header_cell.createAndFill());for(let x=e.width;x<i;x++)m.push(y);r.insert(r.mapping.slice(s).map(h-1+n),m)}if(o>e.height){const d=[];for(let m=0,y=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const x=m>=e.width?!1:t.nodeAt(e.map[y+m]).type==l.header_cell;d.push(x?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,H.from(d)),f=[];for(let m=e.height;m<o;m++)f.push(h);r.insert(r.mapping.slice(s).map(n+t.nodeSize-2),f)}return!!(c||u)}function $1(r,e,t,n,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){l=!0;const h=t.nodeAt(d),{top:f,left:m}=e.findCell(d);r.setNodeMarkup(r.mapping.slice(a).map(d+n),null,{...h.attrs,rowspan:s-f}),r.insert(r.mapping.slice(a).map(e.positionAt(s,m,t)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function j1(r,e,t,n,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){l=!0;const h=t.nodeAt(d),f=e.colCount(d),m=r.mapping.slice(a).map(d+n);r.setNodeMarkup(m,null,Zi(h.attrs,s-f,h.attrs.colspan-(s-f))),r.insert(m+h.nodeSize,h.type.createAndFill(Zi(h.attrs,0,s-f))),c+=h.attrs.rowspan-1}}return l}function V1(r,e,t,n,i){let o=t?r.doc.nodeAt(t-1):r.doc;if(!o)throw new Error("No table found");let s=xe.get(o);const{top:a,left:l}=n,c=l+i.width,u=a+i.height,d=r.tr;let h=0;function f(){if(o=t?d.doc.nodeAt(t-1):d.doc,!o)throw new Error("No table found");s=xe.get(o),h=d.mapping.maps.length}xx(d,s,o,t,c,u,h)&&f(),$1(d,s,o,t,l,c,a,h)&&f(),$1(d,s,o,t,l,c,u,h)&&f(),j1(d,s,o,t,a,u,l,h)&&f(),j1(d,s,o,t,a,u,c,h)&&f();for(let m=a;m<u;m++){const y=s.positionAt(m,l,o),x=s.positionAt(m,c,o);d.replace(d.mapping.slice(h).map(y+t),d.mapping.slice(h).map(x+t),new Y(i.rows[m-a],0,0))}f(),d.setSelection(new Ae(d.doc.resolve(t+s.positionAt(a,l,o)),d.doc.resolve(t+s.positionAt(u-1,c-1,o)))),e(d)}const kx=hf({ArrowLeft:k0("horiz",-1),ArrowRight:k0("horiz",1),ArrowUp:k0("vert",-1),ArrowDown:k0("vert",1),"Shift-ArrowLeft":S0("horiz",-1),"Shift-ArrowRight":S0("horiz",1),"Shift-ArrowUp":S0("vert",-1),"Shift-ArrowDown":S0("vert",1),Backspace:x0,"Mod-Backspace":x0,Delete:x0,"Mod-Delete":x0});function G0(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function k0(r,e){return(t,n,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Ae)return G0(t,n,ue.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;const s=r3(i,r,e);if(s==null)return!1;if(r=="horiz")return G0(t,n,ue.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=G5(a,r,e);let c;return l?c=ue.near(l,1):e<0?c=ue.near(t.doc.resolve(a.before(-1)),-1):c=ue.near(t.doc.resolve(a.after(-1)),1),G0(t,n,c)}}}function S0(r,e){return(t,n,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Ae)s=o;else{const l=r3(i,r,e);if(l==null)return!1;s=new Ae(t.doc.resolve(l))}const a=G5(s.$headCell,r,e);return a?G0(t,n,new Ae(s.$anchorCell,a)):!1}}function Sx(r,e){const t=r.state.doc,n=ks(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new Ae(n))),!0):!1}function Cx(r,e,t){if(!hr(r.state))return!1;let n=vx(t);const i=r.state.selection;if(i instanceof Ae){n||(n={width:1,height:1,rows:[H.from(ah(lr(r.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=xe.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return n=wx(n,a.right-a.left,a.bottom-a.top),V1(r.state,r.dispatch,s,a,n),!0}else if(n){const o=Pc(r.state),s=o.start(-1);return V1(r.state,r.dispatch,s,xe.get(o.node(-1)).findCell(o.pos-s),n),!0}else return!1}function Mx(r,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const n=W1(r,e.target);let i;if(e.shiftKey&&r.state.selection instanceof Ae)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(i=ks(r.state.selection.$anchor))!=null&&((t=Qu(r,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!n)return;function o(l,c){let u=Qu(r,c);const d=Bn.getState(r.state)==null;if(!u||!pf(l,u))if(d)u=l;else return;const h=new Ae(l,u);if(d||!r.state.selection.eq(h)){const f=r.state.tr.setSelection(h);d&&f.setMeta(Bn,l.pos),r.dispatch(f)}}function s(){r.root.removeEventListener("mouseup",s),r.root.removeEventListener("dragstart",s),r.root.removeEventListener("mousemove",a),Bn.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(Bn,-1))}function a(l){const c=l,u=Bn.getState(r.state);let d;if(u!=null)d=r.state.doc.resolve(u);else if(W1(r,c.target)!=n&&(d=Qu(r,e),!d))return s();d&&o(d,c)}r.root.addEventListener("mouseup",s),r.root.addEventListener("dragstart",s),r.root.addEventListener("mousemove",a)}function r3(r,e,t){if(!(r.state.selection instanceof Q))return null;const{$head:n}=r.state.selection;for(let i=n.depth-1;i>=0;i--){const o=n.node(i);if((t<0?n.index(i):n.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=n.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return r.endOfTextblock(a)?s:null}}return null}function W1(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Qu(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:n,pos:i}=t;return n>=0&&ks(r.state.doc.resolve(n))||ks(r.state.doc.resolve(i))}var Tx=class{constructor(r,e){this.node=r,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),lh(r,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(r){return r.type!=this.node.type?!1:(this.node=r,lh(r,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(r){return r.type=="attributes"&&(r.target==this.table||this.colgroup.contains(r.target))}};function lh(r,e,t,n,i,o){let s=0,a=!0,l=e.firstChild;const c=r.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:m}=c.child(d).attrs;for(let y=0;y<f;y++,h++){const x=i==h?o:m&&m[y],b=x?x+"px":"";if(s+=x||n,x||(a=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const S=document.createElement("col");S.style.width=b,e.appendChild(S)}}}for(;l;){var u;const d=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=d}a?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}const jt=new Me("tableColumnResizing");function Ax({handleWidth:r=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:n=Tx,lastColumnResizable:i=!0}={}){const o=new Ce({key:jt,state:{init(s,a){var l;const c=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=lr(a.schema).table.name;return n&&c&&(c[u]=(d,h)=>new n(d,t,h)),new Nx(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=jt.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{Ex(s,a,r,i)},mouseleave:s=>{Dx(s)},mousedown:(s,a)=>{Ox(s,a,e,t)}},decorations:s=>{const a=jt.getState(s);if(a&&a.activeHandle>-1)return Bx(s,a.activeHandle)},nodeViews:{}}});return o}var Nx=class Y0{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,n=e.getMeta(jt);if(n&&n.setHandle!=null)return new Y0(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Y0(t.activeHandle,n.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return sh(e.doc.resolve(i))||(i=-1),new Y0(i,t.dragging)}return t}};function Ex(r,e,t,n){if(!r.editable)return;const i=jt.getState(r.state);if(i&&!i.dragging){const o=Ix(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=U1(r,e,"left",t):l-e.clientX<=t&&(s=U1(r,e,"right",t))}if(s!=i.activeHandle){if(!n&&s!==-1){const a=r.state.doc.resolve(s),l=a.node(-1),c=xe.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}n3(r,s)}}}function Dx(r){if(!r.editable)return;const e=jt.getState(r.state);e&&e.activeHandle>-1&&!e.dragging&&n3(r,-1)}function Ox(r,e,t,n){var i;if(!r.editable)return!1;const o=(i=r.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=jt.getState(r.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=r.state.doc.nodeAt(s.activeHandle),l=Rx(r,s.activeHandle,a.attrs);r.dispatch(r.state.tr.setMeta(jt,{setDragging:{startX:e.clientX,startWidth:l}}));function c(d){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const h=jt.getState(r.state);h!=null&&h.dragging&&(zx(r,h.activeHandle,K1(h.dragging,d,t)),r.dispatch(r.state.tr.setMeta(jt,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=jt.getState(r.state);if(h&&h.dragging){const f=K1(h.dragging,d,t);G1(r,h.activeHandle,f,n)}}return G1(r,s.activeHandle,l,n),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function Rx(r,e,{colspan:t,colwidth:n}){const i=n&&n[n.length-1];if(i)return i;const o=r.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=t;if(n)for(let l=0;l<t;l++)n[l]&&(s-=n[l],a--);return s/a}function Ix(r){for(;r&&r.nodeName!="TD"&&r.nodeName!="TH";)r=r.classList&&r.classList.contains("ProseMirror")?null:r.parentNode;return r}function U1(r,e,t,n){const i=t=="right"?-n:n,o=r.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=ks(r.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=xe.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function K1(r,e,t){const n=e.clientX-r.startX;return Math.max(t,r.startWidth+n)}function n3(r,e){r.dispatch(r.state.tr.setMeta(jt,{setHandle:e}))}function zx(r,e,t){const n=r.state.doc.resolve(e),i=n.node(-1),o=xe.get(i),s=n.start(-1),a=o.colCount(n.pos-s)+n.nodeAfter.attrs.colspan-1,l=r.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+a;if(c&&o.map[u]==o.map[u-o.width])continue;const d=o.map[u],h=i.nodeAt(d).attrs,f=h.colspan==1?0:a-o.colCount(d);if(h.colwidth&&h.colwidth[f]==t)continue;const m=h.colwidth?h.colwidth.slice():Lx(h.colspan);m[f]=t,l.setNodeMarkup(s+d,null,{...h,colwidth:m})}l.docChanged&&r.dispatch(l)}function G1(r,e,t,n){const i=r.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=xe.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=r.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&lh(o,l.firstChild,l,n,a,t)}function Lx(r){return Array(r).fill(0)}function Bx(r,e){const t=[],n=r.doc.resolve(e),i=n.node(-1);if(!i)return Se.empty;const o=xe.get(i),s=n.start(-1),a=o.colCount(n.pos-s)+n.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const u=a+c*o.width;if((a==o.width-1||o.map[u]!=o.map[u+1])&&(c==0||o.map[u]!=o.map[u-o.width])){var l;const d=o.map[u],h=s+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((l=jt.getState(r))===null||l===void 0)&&l.dragging&&t.push(qe.node(s+d,s+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),t.push(qe.widget(h,f))}}return Se.create(r.doc,t)}function Px({allowTableNodeSelection:r=!1}={}){return new Ce({key:Bn,state:{init(){return null},apply(e,t){const n=e.getMeta(Bn);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:G9,handleDOMEvents:{mousedown:Mx},createSelectionBetween(e){return Bn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Sx,handleKeyDown:kx,handlePaste:Cx},appendTransaction(e,t,n){return X9(n,Q9(n,t),r)}})}function Fx(r,e){return function(t,n){let{$from:i,$to:o,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let a=i.node(-1);if(a.type!=r)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(n){let d=H.empty,h=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-h;b>=i.depth-3;b--)d=H.from(i.node(b).copy(d));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;d=d.append(H.from(r.createAndFill()));let m=i.before(i.depth-(h-1)),y=t.tr.replace(m,i.after(-f),new Y(d,4-h,0)),x=-1;y.doc.nodesBetween(m,y.doc.content.size,(b,S)=>{if(x>-1)return!1;b.isTextblock&&b.content.size==0&&(x=S+1)}),x>-1&&y.setSelection(ue.near(y.doc.resolve(x))),n(y.scrollIntoView())}return!0}let l=o.pos==i.end()?a.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),u=l?[null,{type:l}]:void 0;return fa(c.doc,i.pos,2,u)?(n&&n(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Hx(r){return function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,s=>s.childCount>0&&s.firstChild.type==r);return o?t?n.node(o.depth-1).type==r?_x(e,t,r,o):qx(e,t,o):!0:!1}}function _x(r,e,t,n){let i=r.tr,o=n.end,s=n.$to.end(n.depth);o<s&&(i.step(new dt(o-1,s,o,s,new Y(H.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new J4(i.doc.resolve(n.$from.pos),i.doc.resolve(s),n.depth));const a=Ac(n);if(a==null)return!1;i.lift(n,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Bl(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function qx(r,e,t){let n=r.tr,i=t.parent;for(let f=t.end,m=t.endIndex-1,y=t.startIndex;m>y;m--)f-=i.child(m).nodeSize,n.delete(f-1,f+1);let o=n.doc.resolve(t.start),s=o.nodeAfter;if(n.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?H.empty:H.from(i))))return!1;let d=o.pos,h=d+s.nodeSize;return n.step(new dt(d-(a?1:0),h+(l?1:0),d+1,h-1,new Y((a?H.empty:H.from(i.copy(H.empty))).append(l?H.empty:H.from(i.copy(H.empty))),a?0:1,l?0:1),a?0:1)),e(n.scrollIntoView()),!0}function $x(r){return function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=r)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,u=H.from(c?r.create():null),d=new Y(H.from(r.create(null,H.from(a.type.create(null,u)))),c?3:1,0),h=o.start,f=o.end;t(e.tr.step(new dt(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}function jx(r){const e=new Map;if(!r||!r.type)throw new Error("mdast-util-definitions expected node");return Qi(r,"definition",function(n){const i=Y1(n.identifier);i&&!e.get(i)&&e.set(i,n)}),t;function t(n){const i=Y1(n);return e.get(i)}}function Y1(r){return String(r||"").toUpperCase()}function Vx(){return function(r){const e=jx(r);Qi(r,function(t,n,i){if(t.type==="definition"&&i!==void 0&&typeof n=="number")return i.children.splice(n,1),[Em,n];if(t.type==="imageReference"||t.type==="linkReference"){const o=e(t.identifier);if(o&&i&&typeof n=="number")return i.children[n]=t.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:t.alt}:{type:"link",url:o.url,title:o.title,children:t.children},[Em,n]}})}}function i3(r,e){var n;if(!(e.childCount>=1&&((n=e.lastChild)==null?void 0:n.type.name)==="hardbreak")){r.next(e.content);return}const t=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&t.push(i)}),r.next(H.fromArray(t))}function F(r,e){return Object.assign(r,{meta:{package:"@milkdown/preset-commonmark",...e}}),r}var gf=jl("emphasis");F(gf,{displayName:"Attr<emphasis>",group:"Emphasis"});var to=Os("emphasis",r=>({attrs:{marker:{default:r.get(ga).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",r.get(gf.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));F(to.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});F(to.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Fc=le("ToggleEmphasis",r=>()=>zc(to.type(r)));F(Fc,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var o3=mt(r=>$l(/(?:^|[^*])\*([^*]+)\*$/,to.type(r),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));F(o3,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var s3=mt(r=>$l(/\b_(?![_\s])(.*?[^_\s])_$/,to.type(r),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));F(s3,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var yf=Lt("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:r=>{const e=r.get(ee);return()=>e.call(Fc.key)}}});F(yf.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});F(yf.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var vf=jl("strong");F(vf,{displayName:"Attr<strong>",group:"Strong"});var Is=Os("strong",r=>({attrs:{marker:{default:r.get(ga).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",r.get(vf.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));F(Is.mark,{displayName:"MarkSchema<strong>",group:"Strong"});F(Is.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Hc=le("ToggleStrong",r=>()=>zc(Is.type(r)));F(Hc,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var a3=mt(r=>$l(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),Is.type(r),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));F(a3,{displayName:"InputRule<strong>",group:"Strong"});var bf=Lt("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:r=>{const e=r.get(ee);return()=>e.call(Hc.key)}}});F(bf.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});F(bf.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var wf=jl("inlineCode");F(wf,{displayName:"Attr<inlineCode>",group:"InlineCode"});var hn=Os("inlineCode",r=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",r.get(wf.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));F(hn.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});F(hn.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var _c=le("ToggleInlineCode",r=>()=>(e,t)=>{const{selection:n,tr:i}=e;if(n.empty)return!1;const{from:o,to:s}=n;return e.doc.rangeHasMark(o,s,hn.type(r))?(t==null||t(i.removeMark(o,s,hn.type(r))),!0):(Object.keys(e.schema.marks).filter(a=>a!==hn.type.name).map(a=>e.schema.marks[a]).forEach(a=>{i.removeMark(o,s,a)}),t==null||t(i.addMark(o,s,hn.type(r).create())),!0)});F(_c,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var l3=mt(r=>$l(/(?:`)([^`]+)(?:`)$/,hn.type(r)));F(l3,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var xf=Lt("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:r=>{const e=r.get(ee);return()=>e.call(_c.key)}}});F(xf.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});F(xf.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Wx=new Set(["http:","https:","mailto:","tel:","ftp:"]);function Ux(r){return r<=32||r>=127&&r<=160||r>=8203&&r<=8205||r===8232||r===8233||r===65279}function Kx(r){let e="";for(const t of r)Ux(t.codePointAt(0)??0)||(e+=t);return e}function Gx(r){var i;if(typeof r!="string")return"";const e=r.trim();if(!e)return"";const t=Kx(e),n=(i=/^([a-z][a-z0-9+.-]*):/i.exec(t))==null?void 0:i[1];return!n||Wx.has(`${n.toLowerCase()}:`)?e:""}var kf=jl("link");F(kf,{displayName:"Attr<link>",group:"Link"});var Cr=Os("link",r=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...r.get(kf.key)(e),...e.attrs,href:Gx(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,n)=>{const i=t.url,o=t.title;e.openMark(n,{href:i,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));F(Cr.mark,{displayName:"MarkSchema<link>",group:"Link"});var c3=le("ToggleLink",r=>(e={})=>zc(Cr.type(r),e));F(c3,{displayName:"Command<toggleLinkCommand>",group:"Link"});var u3=le("UpdateLink",r=>(e={})=>(t,n)=>{if(!n)return!1;let i,o=-1;const{selection:s}=t,{from:a,to:l}=s;if(t.doc.nodesBetween(a,a===l?l+1:l,(m,y)=>{if(Cr.type(r).isInSet(m.marks))return i=m,o=y,!1}),!i)return!1;const c=i.marks.find(({type:m})=>m===Cr.type(r));if(!c)return!1;const u=o,d=o+i.nodeSize,{tr:h}=t,f=Cr.type(r).create({...c.attrs,...e});return f?(n(h.removeMark(u,d,c).addMark(u,d,f).setSelection(new Q(h.selection.$anchor)).scrollIntoView()),!0):!1});F(u3,{displayName:"Command<updateLinkCommand>",group:"Link"});var d3=ff("doc",()=>({content:"block+",parseMarkdown:{match:({type:r})=>r==="root",runner:(r,e,t)=>{r.injectRoot(e,t)}},toMarkdown:{match:r=>r.type.name==="doc",runner:(r,e)=>{r.openNode("root"),r.next(e.content)}}}));F(d3,{displayName:"NodeSchema<doc>",group:"Doc"});function Yx(r){return Wy(r,e=>{var t;return e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((t=e.value)==null?void 0:t.trim())},(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1)},!0)}var Ss=dr("remark-preserve-empty-line",()=>()=>Yx);F(Ss.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});F(Ss.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Sf=Mr("paragraph");F(Sf,{displayName:"Attr<paragraph>",group:"Paragraph"});var cr=$e("paragraph",r=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",r.get(Sf.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{var i;const n=(i=r.get(ge).state)==null?void 0:i.doc.lastChild;e.openNode("paragraph"),(!t.content||t.content.size===0)&&t!==n&&Jx(r)?e.addNode("html",void 0,"<br />"):i3(e,t),e.closeNode()}}}));function Jx(r){let e=!1;try{r.get(Ss.id),e=!0}catch{e=!1}return e}F(cr.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});F(cr.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Cf=le("TurnIntoText",r=>()=>Ia(cr.type(r)));F(Cf,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Mf=Lt("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:r=>{const e=r.get(ee);return()=>e.call(Cf.key)}}});F(Mf.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});F(Mf.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var Xx=Array(6).fill(0).map((r,e)=>e+1);function Zx(r){return r.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var qc=ye(Zx,"headingIdGenerator");F(qc,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Tf=Mr("heading");F(Tf,{displayName:"Attr<heading>",group:"Heading"});var ii=$e("heading",r=>{const e=r.get(qc.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Xx.map(t=>({tag:`h${t}`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw Vr(n);return{level:t,id:n.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...r.get(Tf.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,n,i)=>{const o=n.depth;t.openNode(i,{level:o}),t.next(n.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,n)=>{t.openNode("heading",void 0,{depth:n.attrs.level}),i3(t,n),t.closeNode()}}}});F(ii.node,{displayName:"NodeSchema<heading>",group:"Heading"});F(ii.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var h3=mt(r=>df(/^(?<hashes>#+)\s$/,ii.type(r),e=>{var o,s;const t=((s=(o=e.groups)==null?void 0:o.hashes)==null?void 0:s.length)||0,{$from:n}=r.get(ge).state.selection,i=n.node();if(i.type.name==="heading"){let a=Number(i.attrs.level)+Number(t);return a>6&&(a=6),{level:a}}return{level:t}}));F(h3,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var In=le("WrapInHeading",r=>e=>(e??(e=1),e<1?Ia(cr.type(r)):Ia(ii.type(r),{level:e})));F(In,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Af=le("DowngradeHeading",r=>()=>(e,t,n)=>{const{$from:i}=e.selection,o=i.node();if(o.type!==ii.type(r)||!e.selection.empty||i.parentOffset!==0)return!1;const s=o.attrs.level-1;return s?(t==null||t(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Ia(cr.type(r))(e,t,n)});F(Af,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Nf=Lt("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:r=>{const e=r.get(ee);return()=>e.call(In.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:r=>{const e=r.get(ee);return()=>e.call(In.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:r=>{const e=r.get(ee);return()=>e.call(In.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:r=>{const e=r.get(ee);return()=>e.call(In.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:r=>{const e=r.get(ee);return()=>e.call(In.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:r=>{const e=r.get(ee);return()=>e.call(In.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:r=>{const e=r.get(ee);return()=>e.call(Af.key)}}});F(Nf.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});F(Nf.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Ef=Mr("blockquote");F(Ef,{displayName:"Attr<blockquote>",group:"Blockquote"});var zs=$e("blockquote",r=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",r.get(Ef.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));F(zs.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});F(zs.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var f3=mt(r=>uf(/^\s*>\s$/,zs.type(r)));F(f3,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Df=le("WrapInBlockquote",r=>()=>cf(zs.type(r)));F(Df,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Of=Lt("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:r=>{const e=r.get(ee);return()=>e.call(Df.key)}}});F(Of.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});F(Of.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Rf=Mr("codeBlock",()=>({pre:{},code:{}}));F(Rf,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var jr=$e("code_block",r=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{language:e.dataset.language}}}],toDOM:e=>{const t=r.get(Rf.key)(e),n=e.attrs.language,i=n&&n.length>0?{"data-language":n}:void 0;return["pre",{...t.pre,...i},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,n)=>{const i=t.lang??"",o=t.value;e.openNode(n,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{var n;e.addNode("code",void 0,((n=t.content.firstChild)==null?void 0:n.text)||"",{lang:t.attrs.language})}}}));F(jr.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});F(jr.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var p3=mt(r=>df(/^```(?<language>[a-z]*)?[\s\n]$/,jr.type(r),e=>{var t;return{language:((t=e.groups)==null?void 0:t.language)??""}}));F(p3,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var If=le("CreateCodeBlock",r=>(e="")=>Ia(jr.type(r),{language:e}));F(If,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var Qx=le("UpdateCodeBlockLanguage",()=>({pos:r,language:e}={pos:-1,language:""})=>(t,n)=>r>=0?(n==null||n(t.tr.setNodeAttribute(r,"language",e)),!0):!1);F(Qx,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var zf=Lt("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:r=>{const e=r.get(ee);return()=>e.call(If.key)}}});F(zf.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});F(zf.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Lf=Mr("image");F(Lf,{displayName:"Attr<image>",group:"Image"});var ro=$e("image",r=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...r.get(Lf.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,n)=>{const i=t.url,o=t.alt,s=t.title;e.addNode(n,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));F(ro.node,{displayName:"NodeSchema<image>",group:"Image"});F(ro.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var m3=le("InsertImage",r=>(e={})=>(t,n)=>{if(!n)return!0;const{src:i="",alt:o="",title:s=""}=e,a=ro.type(r).create({src:i,alt:o,title:s});return a&&n(t.tr.replaceSelectionWith(a).scrollIntoView()),!0});F(m3,{displayName:"Command<insertImageCommand>",group:"Image"});var g3=le("UpdateImage",r=>(e={})=>(t,n)=>{const i=h9(t.selection,ro.type(r));if(!i)return!1;const{node:o,pos:s}=i,a={...o.attrs},{src:l,alt:c,title:u}=e;return l!==void 0&&(a.src=l),c!==void 0&&(a.alt=c),u!==void 0&&(a.title=u),n==null||n(t.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});F(g3,{displayName:"Command<updateImageCommand>",group:"Image"});var ek=mt(r=>new zt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,n,i)=>{const[o,s,a="",l]=t;return o?e.tr.replaceWith(n,i,ro.type(r).create({src:a,alt:s,title:l})):null}));F(ek,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var cc=Mr("hardbreak",r=>({"data-type":"hardbreak","data-is-inline":r.attrs.isInline}));F(cc,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var $i=$e("hardbreak",r=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",r.get(cc.key)(e)," "]:["br",r.get(cc.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,n)=>{var i;e.addNode(n,{isInline:!!((i=t.data)!=null&&i.isInline)})}},leafText:()=>`
28
+ `))),0,0),r.someProp("transformPasted",h=>{a=h(a,r,!0)}),a;let d=r.someProp("clipboardTextParser",h=>h(e,i,n,r));if(d)a=d;else{let h=i.marks(),{schema:f}=r.state,m=eo.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=s.appendChild(document.createElement("p"));y&&x.appendChild(m.serializeNode(f.text(y,h)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),s=J8(t),Fl&&X8(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(r.someProp("clipboardParser")||r.someProp("domParser")||Yi.fromSchema(r.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!K8.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Z8(y1(a,+u[1],+u[2]),u[4]);else if(a=Y.maxOpen(G8(a.content,i),!0),a.openStart||a.openEnd){let d=0,h=0;for(let f=a.content.firstChild;d<a.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=a.content.lastChild;h<a.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);a=y1(a,d,h)}return r.someProp("transformPasted",d=>{a=d(a,r,l)}),a}const K8=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function G8(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(r.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&j2(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=$2(s[s.length-1],o.length));let u=q2(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return H.from(s)}return r}function q2(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,H.from(r));return r}function j2(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let o=j2(r,e,t,n.lastChild,i+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(H.from(q2(t,r,i+1))))}}function $2(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,$2(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(H.empty,!0);return r.copy(t.append(n))}function Yd(r,e,t,n,i,o){let s=e<0?r.firstChild:r.lastChild,a=s.content;return r.childCount>1&&(o=0),i<n-1&&(a=Yd(a,e,t,n,i+1,o)),i>=t&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(H.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,s.copy(a))}function y1(r,e,t){return e<r.openStart&&(r=new Y(Yd(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new Y(Yd(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const V2={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function W2(){return document.implementation.createHTMLDocument("title")}let Js=null;function Y8(r){let e=window.trustedTypes;if(!e)return r;if(!Js){if(Js=e.defaultPolicy)try{return Js.createHTML(r)}catch{}Js=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Js.createHTML(r)}function J8(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=W2(),n=t.body,i=/<([a-z][^>\s]+)/i.exec(r),o;if((o=i&&V2[i[1].toLowerCase()])&&(r=o.map(s=>"<"+s+">").join("")+r+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Y8(r),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;for(let s=0;s<t.styleSheets.length;s++){let a=t.styleSheets[s];for(let l=0;l<a.rules.length;l++){let c=a.rules[l];if(c instanceof CSSStyleRule){let u=n.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return n}function X8(r){let e=r.querySelectorAll(at?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Z8(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:o,openEnd:s}=r;for(let a=n.length-2;a>=0;a-=2){let l=t.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;try{l.checkAttrs(n[a+1])}catch{break}i=H.from(l.create(n[a+1],i)),o++,s++}return new Y(i,o,s)}const kt={},St={},Q8={touchstart:!0,touchmove:!0};class eb{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function tb(r){for(let e in kt){let t=kt[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{nb(r,n)&&!ef(r,n)&&(r.editable||!(n.type in St))&&t(r,n)},Q8[e]?{passive:!0}:void 0)}ft&&r.dom.addEventListener("input",()=>null),Jd(r)}function dn(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function rb(r){r.input.mouseDown&&r.input.mouseDown.done(),r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Jd(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ef(r,n))})}function ef(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function nb(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ib(r,e){!ef(r,e)&&kt[e.type]&&(r.editable||!(e.type in St))&&kt[e.type](r,e)}St.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Y2(r)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(un&&at&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),ws&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,yi(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||U8(r,t)?t.preventDefault():dn(r,"key")};St.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};St.keypress=(r,e)=>{let t=e;if(Y2(r)||!t.charCode||t.ctrlKey&&!t.altKey||nr&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof Q)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),o=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i,o))&&r.dispatch(o()),t.preventDefault()}};function _l(r){return{left:r.clientX,top:r.clientY}}function ob(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function tf(r,e,t,n,i){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(r.someProp(e,a=>s>o.depth?a(r,t,o.nodeAfter,o.before(s),i,!0):a(r,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function ql(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function sb(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&re.isSelectable(n)?(ql(r,new re(t)),!0):!1}function ab(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof re&&(n=t.node);let o=r.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(re.isSelectable(a)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(ql(r,re.create(r.state.doc,i)),!0):!1}function lb(r,e,t,n,i){return tf(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(i?ab(r,t):sb(r,t))}function cb(r,e,t,n){return tf(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function ub(r,e,t,n){return tf(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||db(r,t,n)}function db(r,e,t){if(t.button!=0)return!1;let n=U2(r,e,!0),i=r.state.doc;return n?(ql(r,n),n instanceof Q&&i.eq(r.state.doc)&&(r.input.mouseDown=new fb(r,n)),!0):!1}function U2(r,e,t){let n=r.state.doc;if(e==-1)return n.inlineContent?Q.create(n,0,n.content.size):null;let i=n.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)return Q.create(n,a+1,a+1+s.content.size);if(t&&re.isSelectable(s))return re.create(n,a)}return null}function rf(r){return oc(r)}const K2=nr?"metaKey":"ctrlKey";kt.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=rf(r),i=Date.now(),o="singleClick";i-r.input.lastClick.time<500&&ob(t,r.input.lastClick)&&!t[K2]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button},r.input.mouseDown&&r.input.mouseDown.done();let s=r.posAtCoords(_l(t));s&&(o=="singleClick"?r.input.mouseDown=new hb(r,s,t,!!n):(o=="doubleClick"?cb:ub)(r,s.pos,s.inside,t)?t.preventDefault():dn(r,"pointer"))};class G2{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class hb extends G2{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[K2],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}const a=i?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof re&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&sr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),dn(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||gn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(_l(e))),this.updateAllowDefault(e),this.allowDefault||!t?dn(this.view,"pointer"):lb(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ft&&this.mightDrag&&!this.mightDrag.node.isAtom||at&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ql(this.view,ue.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):dn(this.view,"pointer")}move(e){this.updateAllowDefault(e),dn(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class fb extends G2{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),dn(this.view,"pointer");let t=this.view.posAtCoords(_l(e)),n=t&&U2(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,o=this.startSelection,[s,a]=n.from<o.from?[o.to,n.from]:[o.from,n.to];ql(this.view,Q.create(i,s,a))}}kt.touchstart=r=>{r.input.lastTouch=Date.now(),rf(r),dn(r,"pointer")};kt.touchmove=r=>{r.input.lastTouch=Date.now(),dn(r,"pointer")};kt.contextmenu=r=>rf(r);function Y2(r,e){return r.composing?!0:ft&&Math.abs(Date.now()-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const pb=un?5e3:-1;St.compositionstart=St.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||at&&C2&&mb(r)))r.markCursor=r.state.storedMarks||t.marks(),oc(r,!0),r.markCursor=null;else if(oc(r,!e.selection.empty),sr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,o=n.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=r.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}r.input.composing=!0}J2(r,pb)};function mb(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}St.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now(),r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,J2(r,20))};function J2(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>oc(r),e))}function X2(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function gb(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=a8(e.focusNode,e.focusOffset),n=l8(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function oc(r,e=!1){if(!(un&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),X2(r),e||r.docView&&r.docView.dirty){let t=Xh(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function yb(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const Da=It&&Un<15||ws&&h8<604;kt.copy=St.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let o=Da?null:t.clipboardData,s=n.content(),{dom:a,text:l}=Qh(r,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):yb(r,a),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vb(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function bb(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Oa(r,n.value,null,i,e):Oa(r,n.textContent,n.innerHTML,i,e)},50)}function Oa(r,e,t,n,i){let o=_2(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",l=>l(r,i,o||Y.empty)))return!0;if(!o)return!1;let s=vb(o),a=s?r.state.tr.replaceSelectionWith(s,n):r.state.tr.replaceSelection(o);return r.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Z2(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}St.paste=(r,e)=>{let t=e;if(r.composing&&!un)return;let n=Da?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Oa(r,Z2(n),n.getData("text/html"),i,t)?t.preventDefault():bb(r,t)};class Q2{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const wb=nr?"altKey":"ctrlKey";function e5(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[wb]}kt.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,o=i.empty?null:r.posAtCoords(_l(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof re?i.to-1:i.to))){if(n&&n.mightDrag)s=re.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(s=re.create(r.state.doc,d.posBefore))}}let a=(s||r.state.selection).content(),{dom:l,text:c,slice:u}=Qh(r,a);(!t.dataTransfer.files.length||!at||S2>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Da?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Da||t.dataTransfer.setData("text/plain",c),r.dragging=new Q2(u,e5(r,t),s)};kt.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};St.dragover=St.dragenter=(r,e)=>e.preventDefault();St.drop=(r,e)=>{try{xb(r,e,r.dragging)}finally{r.dragging=null}};function xb(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(_l(e));if(!n)return;let i=r.state.doc.resolve(n.pos),o=t&&t.slice;o?r.someProp("transformPasted",f=>{o=f(o,r,!1)}):o=_2(r,Z2(e.dataTransfer),Da?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&e5(r,e));if(r.someProp("handleDrop",f=>f(r,e,o||Y.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Yv(r.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=r.state.tr;if(s){let{node:f}=t;f?f.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(d))return;let h=l.doc.resolve(c);if(u&&re.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new re(h));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,x,b)=>f=b),l.setSelection(Zh(r,h,l.doc.resolve(f)))}r.focus(),r.dispatch(l.setMeta("uiEvent","drop"))}kt.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&gn(r)},20))};kt.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};kt.beforeinput=(r,e)=>{if(un&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,yi(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in St)kt[r]=St[r];function Ra(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class sc{constructor(e,t){this.toDOM=e,this.spec=t||Fi,this.side=this.spec.side||0}map(e,t,n,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new qe(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof sc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ra(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Yn{constructor(e,t){this.attrs=e,this.spec=t||Fi}map(e,t,n,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new qe(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Yn&&Ra(this.attrs,e.attrs)&&Ra(this.spec,e.spec)}static is(e){return e.type instanceof Yn}destroy(){}}class nf{constructor(e,t){this.attrs=e,this.spec=t||Fi}map(e,t,n,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new qe(o.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(n)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof nf&&Ra(this.attrs,e.attrs)&&Ra(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new qe(e,e,new sc(t,n))}static inline(e,t,n,i){return new qe(e,t,new Yn(n,i))}static node(e,t,n,i){return new qe(e,t,new nf(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yn}get widget(){return this.type instanceof sc}}const ko=[],Fi={};class Se{constructor(e,t){this.local=e.length?e:ko,this.children=t.length?t:ko}static create(e,t){return t.length?ac(t,e,0,Fi):ut}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&n.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,t-a,n,i+a,o)}}map(e,t,n){return this==ut||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Fi)}mapInner(e,t,n,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,i);l&&l.type.valid(t,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?kb(this.children,s||[],e,t,n,i,o):s?new Se(s.sort(Hi),ko):ut}add(e,t){return t.length?this==ut?Se.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,o=0;e.forEach((a,l)=>{let c=l+n,u;if(u=r5(t,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,u,c+1):i.splice(o,0,l,l+a.nodeSize,ac(u,a,c+1,Fi)),o+=3}});let s=t5(o?n5(t):t,-n);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Se(s.length?this.local.concat(s).sort(Hi):this.local,i||this.children)}remove(e){return e.length==0||this==ut?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let o=0;o<n.length;o+=3){let s,a=n[o]+t,l=n[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,a+1);c!=ut?n[o+2]=c:(n.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new Se(i,n):ut}forChild(e,t){if(this==ut)return this;if(t.isLeaf)return Se.empty;let n,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(n=this.children[a+2]);break}let o=e+1,s=o+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof Yn){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let a=new Se(i.sort(Hi),ko);return n?new Ln([a,n]):a}return n||ut}eq(e){if(this==e)return!0;if(!(e instanceof Se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return of(this.localsInner(e))}localsInner(e){if(this==ut)return ko;if(e.inlineContent||!this.local.some(Yn.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Yn||t.push(this.local[n]);return t}forEachSet(e){e(this)}}Se.empty=new Se([],[]);Se.removeOverlap=of;const ut=Se.empty;class Ln{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,Fi));return Ln.from(n)}forChild(e,t){if(t.isLeaf)return Se.empty;let n=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=ut&&(o instanceof Ln?n=n.concat(o.members):n.push(o))}return Ln.from(n)}eq(e){if(!(e instanceof Ln)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?of(n?t:t.sort(Hi)):ko}static from(e){switch(e.length){case 0:return ut;case 1:return e[0];default:return new Ln(e.every(t=>t instanceof Se)?e:e.reduce((t,n)=>t.concat(n instanceof Se?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function kb(r,e,t,n,i,o,s){let a=r.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((h,f,m,y)=>{let x=y-m-(f-h);for(let b=0;b<a.length;b+=3){let S=a[b+1];if(S<0||h>S+u-d)continue;let A=a[b]+u-d;f>=A?a[b+1]=h<=A?-2:-1:h>=u&&x&&(a[b]+=x,a[b+1]+=x)}d+=x}),u=t.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=t.map(r[c]+o),d=u-i;if(d<0||d>=n.content.size){l=!0;continue}let h=t.map(r[c+1]+o,-1),f=h-i,{index:m,offset:y}=n.content.findIndex(d),x=n.maybeChild(m);if(x&&y==d&&y+x.nodeSize==f){let b=a[c+2].mapInner(t,x,u+1,r[c]+o+1,s);b!=ut?(a[c]=d,a[c+1]=f,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Sb(a,r,e,t,i,o,s),u=ac(c,n,0,s);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<a.length&&a[h]<f;)h+=3;a.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Se(e.sort(Hi),a)}function t5(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new qe(i.from+e,i.to+e,i.type))}return t}function Sb(r,e,t,n,i,o,s){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(n,i,c);d?t.push(d):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<r.length;l+=3)r[l+1]==-1&&a(r[l+2],e[l]+o+1);return t}function r5(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let o=0,s;o<r.length;o++)(s=r[o])&&s.from>t&&s.to<n&&((i||(i=[])).push(s),r[o]=null);return i}function n5(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function ac(r,e,t,n){let i=[],o=!1;e.forEach((a,l)=>{let c=r5(r,a,l+t);if(c){o=!0;let u=ac(c,a,t+l+1,n);u!=ut&&i.push(l,l+a.nodeSize,u)}});let s=t5(o?n5(r):r,-t).sort(Hi);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(n.onRemove&&n.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new Se(s,i):ut}function Hi(r,e){return r.from-e.from||r.to-e.to}function of(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[i]=o.copy(o.from,n.to),v1(e,i+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),v1(e,i,n.copy(o.from,n.to)));break}}}return e}function v1(r,e,t){for(;e<r.length&&Hi(t,r[e])>0;)e++;r.splice(e,0,t)}function Fu(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=ut&&e.push(n)}),r.cursorWrapper&&e.push(Se.create(r.state.doc,[r.cursorWrapper.deco])),Ln.from(e)}const Cb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Mb=It&&Un<=11;class Tb{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ab{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Tb,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);It&&Un<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ft&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Mb&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Cb)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(d1(this.view)){if(this.suppressingSelectionUpdates)return gn(this.view);if(It&&Un<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=bs(o))t.add(o);for(let o=e.anchorNode;o;o=bs(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&d1(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],l);d&&(o=o<0?d.from:Math.min(d.from,o),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||at&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(sr&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||Db(e,d)!=f)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dc(n)&&(c=Xh(e))&&c.eq(ue.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gn(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Nb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ob(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gn(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(It&&Un<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?st(i)+1:0,a=n.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?st(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let b1=new WeakMap,w1=!1;function Nb(r){if(!b1.has(r)&&(b1.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=sr,w1)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),w1=!0}}function x1(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=r.domAtPos(r.state.selection.anchor);return Xi(s.node,s.offset,i,o)&&([t,n,i,o]=[i,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}}function Eb(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return x1(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?x1(r,t):null}function Db(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Ob(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),n==o&&r.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Rb(r,e,t,n){let{node:i,fromOffset:o,toOffset:s,from:a,to:l}=r.docView.parseRange(e,t),c=r.domSelectionRange(),u,d=c.anchorNode;if(d&&r.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],Dc(c)||u.push({node:c.focusNode,offset:c.focusOffset})),at&&r.input.lastKeyCode===8)for(let b=s;b>o;b--){let S=i.childNodes[b-1],A=S.pmViewDesc;if(S.nodeName=="BR"&&!A){s=b;break}if(!A||A.size)break}let h=r.state.doc,f=r.someProp("domParser")||Yi.fromSchema(r.state.schema),m=h.resolve(a),y=null,x=f.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Ib(n),context:m});if(u&&u[0].pos!=null){let b=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=b),y={anchor:b+a,head:S+a}}return{doc:x,sel:y,from:a,to:l}}const Ib=r=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(r);if(e.nodeName=="BR"&&e.parentNode){if(ft&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||ft&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},zb=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Lb(r,e,t,n,i){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let N=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,j=Xh(r,N);if(j&&!r.state.selection.eq(j)){if(at&&un&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",ne=>ne(r,yi(13,"Enter"))))return;let K=r.state.tr.setSelection(j);N=="pointer"?K.setMeta("pointer",!0):N=="key"&&K.scrollIntoView(),o&&K.setMeta("composition",o),r.dispatch(K)}return}let s=r.state.doc.resolve(e),a=s.sharedDepth(t);e=s.before(a+1),t=r.state.doc.resolve(t).after(a+1);let l=r.state.selection,c=Rb(r,e,t,i),u=r.state.doc,d=u.slice(c.from,c.to),h,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(h=r.state.selection.to,f="end"):(h=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let m=Fb(d.content,c.doc.content,c.from,h,f);if(m&&r.input.domChangeCount++,(ws&&r.input.lastIOSEnter>Date.now()-225||un)&&i.some(N=>N.nodeType==1&&!zb.test(N.nodeName))&&(!m||m.endA>=m.endB)&&r.someProp("handleKeyDown",N=>N(r,yi(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!m)if(n&&l instanceof Q&&!l.empty&&l.$head.sameParent(l.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=k1(r,r.state.doc,c.sel);if(N&&!N.eq(r.state.selection)){let j=r.state.tr.setSelection(N);o&&j.setMeta("composition",o),r.dispatch(j)}}return}r.state.selection.from<r.state.selection.to&&m.start==m.endB&&r.state.selection instanceof Q&&(m.start>r.state.selection.from&&m.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?m.start=r.state.selection.from:m.endA<r.state.selection.to&&m.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(m.endB+=r.state.selection.to-m.endA,m.endA=r.state.selection.to)),It&&Un<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let y=c.doc.resolveNoCache(m.start-c.from),x=c.doc.resolveNoCache(m.endB-c.from),b=u.resolve(m.start),S=y.sameParent(x)&&y.parent.inlineContent&&b.end()>=m.endA;if((ws&&r.input.lastIOSEnter>Date.now()-225&&(!S||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&y.pos<c.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(c.doc.textBetween(y.pos,x.pos,"","")))&&r.someProp("handleKeyDown",N=>N(r,yi(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>m.start&&Pb(u,m.start,m.endA,y,x)&&r.someProp("handleKeyDown",N=>N(r,yi(8,"Backspace")))){un&&at&&r.domObserver.suppressSelectionUpdates();return}at&&m.endB==m.start&&(r.input.lastChromeDelete=Date.now()),un&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,x=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(N){return N(r,yi(13,"Enter"))})},20));let A=m.start,D=m.endA,O=N=>{let j=N||r.state.tr.replace(A,D,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let K=k1(r,j.doc,c.sel);K&&!(at&&r.composing&&K.empty&&(m.start!=m.endB||r.input.lastChromeDelete<Date.now()-100)&&(K.head==A||K.head==j.mapping.map(D)-1)||It&&K.empty&&K.head==A)&&j.setSelection(K)}return o&&j.setMeta("composition",o),j.scrollIntoView()},L;if(S)if(y.pos==x.pos){It&&Un<=11&&y.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>gn(r),20));let N=O(r.state.tr.delete(A,D)),j=u.resolve(m.start).marksAcross(u.resolve(m.endA));j&&N.ensureMarks(j),r.dispatch(N)}else if(m.endA==m.endB&&(L=Bb(y.parent.content.cut(y.parentOffset,x.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let N=O(r.state.tr);L.type=="add"?N.addMark(A,D,L.mark):N.removeMark(A,D,L.mark),r.dispatch(N)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let N=y.parent.textBetween(y.parentOffset,x.parentOffset),j=()=>O(r.state.tr.insertText(N,A,D));r.someProp("handleTextInput",K=>K(r,A,D,N,j))||r.dispatch(j())}else r.dispatch(O());else r.dispatch(O())}function k1(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Zh(r,e.resolve(t.anchor),e.resolve(t.head))}function Bb(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,o=n,s,a,l;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=u=>u.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(H.from(c).eq(r))return{mark:a,type:s}}function Pb(r,e,t,n,i){if(t-e<=i.pos-n.pos||Hu(n,!0,!1)<i.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let a=o.nodeAfter;return a!=null&&t==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=r.resolve(Hu(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Hu(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function Hu(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Fb(r,e,t,n,i){let o=r.findDiffStart(e,t),s=t+r.size,a=t+e.size;if(o==null)return null;let{a:l,b:c}=r.findDiffEnd(e,s,a);if(i=="end"){let u=Math.max(0,o-Math.min(l,c));n-=l+u-o}if(l<o&&s<a){let u=n<=o&&n>=l?o-n:0;o-=u,c=o+(c-l),l=o}else if(c<o){let u=n<=o&&n>=c?o-n:0;o-=u,l=o+(l-c),c=o}return{start:o,endA:l,endB:c}}class i5{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new eb,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(A1),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=M1(this),C1(this),this.nodeViews=T1(this),this.docView=o1(this.state.doc,S1(this),Fu(this),this.dom,this),this.domObserver=new Ab(this,(n,i,o,s)=>Lb(this,n,i,o,s)),this.domObserver.start(),tb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Jd(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(A1),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(X2(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=T1(this);_b(f,this.nodeViews)&&(this.nodeViews=f,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Jd(this),this.editable=M1(this),C1(this);let l=Fu(this),c=S1(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(i.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&m8(this);if(s){this.domObserver.stop();let f=d&&(It||at)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Hb(i.selection,e.selection);if(d){let y=at?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gb(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=o1(e.doc,c,l,this.dom,this)),y&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}let m=this.input.mouseDown;f||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&H8(this)&&m.delaySelUpdate())?gn(this,f):(P2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&g8(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof re){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&e1(this,t.getBoundingClientRect(),e)}else e1(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new Q2(e.slice,e.move,i<0?void 0:re.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=t?t(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(It){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&y8(this.dom),gn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return k8(this,e)}coordsAtPos(e,t=1){return E2(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return A8(this,t||this.state,e)}pasteHTML(e,t){return Oa(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Oa(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Qh(this,e)}destroy(){this.docView&&(rb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,o8())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ib(this,e)}domSelectionRange(){let e=this.domSelection();return e?ft&&this.root.nodeType===11&&u8(this.dom.ownerDocument)==this.dom&&Eb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}i5.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function S1(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[qe.node(0,r.state.doc.content.size,e)]}function C1(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:qe.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function M1(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Hb(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function T1(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function _b(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function A1(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const qb=B.createContext({contentRef:()=>{},view:null,mark:null}),jb=B.createContext(r=>{throw new Error("No ProsemirrorAdapterProvider detected, maybe you need to wrap the component with the Editor with ProsemirrorAdapterProvider?")});var $b=class extends nv{constructor(...r){super(...r),this.context={contentRef:this.contentRef,view:this.view,mark:this.mark},this.updateContext=()=>{Object.assign(this.context,{mark:this.mark})}}},Vb=class extends $b{constructor(...r){super(...r),this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(qb.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function Wb(r,e,t){return function(i){return function(s,a,l){const c=new t({mark:s,view:a,inline:l,options:{...i,destroy(){var u;(u=i.destroy)==null||u.call(i),e(c)}}});return r(c,!1),c}}}function Ub(r,e){return B.useMemo(()=>Wb(r,e,Vb),[r,e])}const o5=B.createContext({contentRef:()=>{},view:null,getPos:()=>0,setAttrs:()=>{},node:null,selected:!1,decorations:[],innerDecorations:null}),Es=()=>B.useContext(o5),s5=B.createContext(r=>{throw new Error("No ProsemirrorAdapterProvider detected, maybe you need to wrap the component with the Editor with ProsemirrorAdapterProvider?")}),Kb=()=>B.useContext(s5);var Gb=class extends iv{constructor(...r){super(...r),this.context={contentRef:this.contentRef,view:this.view,getPos:this.getPos,setAttrs:this.setAttrs,node:this.node,selected:this.selected,decorations:this.decorations,innerDecorations:this.innerDecorations},this.updateContext=()=>{Object.assign(this.context,{node:this.node,selected:this.selected,decorations:this.decorations,innerDecorations:this.innerDecorations})}}},Yb=class extends Gb{constructor(...r){super(...r),this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(o5.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function Jb(r,e,t){return function(i){return function(s,a,l,c,u){const d=new t({node:s,view:a,getPos:l,decorations:c,innerDecorations:u,options:{...i,onUpdate(){var h;(h=i.onUpdate)==null||h.call(i),r(d)},selectNode(){var h;(h=i.selectNode)==null||h.call(i),r(d)},deselectNode(){var h;(h=i.deselectNode)==null||h.call(i),r(d)},destroy(){var h;(h=i.destroy)==null||h.call(i),e(d)}}});return r(d,!1),d}}}function Xb(r,e){return B.useMemo(()=>Jb(r,e,Yb),[r,e])}const a5=B.createContext({view:null}),Zb=()=>B.useContext(a5),l5=B.createContext(r=>{throw new Error("out of scope")}),Qb=()=>B.useContext(l5);var ew=class extends ov{constructor(...r){super(...r),this.context={view:this.view,prevState:this.prevState},this.updateContext=()=>{Object.assign(this.context,{view:this.view,prevState:this.prevState})},this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(a5.Provider,{value:this.context},B.createElement(e,null)),this.root,this.key)}}};function tw(r,e){return B.useCallback(t=>n=>{const i=new ew({view:n,options:{...t,update:(o,s)=>{var a;(a=t.update)==null||a.call(t,o,s),r(i)},destroy:()=>{var o;(o=t.destroy)==null||o.call(t),e(i)}}});return r(i,!1),i},[e,r])}function rw(r,e){const[t,n]=r,i=e.key,o=B.createElement(B.Fragment,{key:i},e.render()),s=t.indexOf(i);if(s===-1)return[[...t,i],[...n,o]];{const a=[...n];return a[s]=o,[t,a]}}function nw(r,e){const[t,n]=r,i=t.indexOf(e.key);if(i===-1)return r;const o=[...t],s=[...n];return o.splice(i,1),s.splice(i,1),[o,s]}function iw(){const[r,e]=B.useState([[],[]]),t=B.useRef(!1);B.useLayoutEffect(()=>(t.current=!0,()=>{t.current=!1}),[]);const n=B.useCallback(i=>{t.current?Ll.flushSync(i):i()},[]);return{render:()=>r[1],renderReactRenderer:B.useCallback((i,o=!0)=>{n(()=>(o&&i.updateContext(),e(s=>rw(s,i))))},[n]),removeReactRenderer:B.useCallback(i=>{n(()=>e(o=>nw(o,i)))},[n])}}const ow=B.createContext({view:null,getPos:()=>{}}),sw=B.createContext(r=>{throw new Error("out of scope")});var aw=class extends sv{constructor(...r){super(...r),this.context={view:this.view,getPos:this.getPos,spec:this.spec},this.updateContext=()=>{Object.assign(this.context,{view:this.view,getPos:this.getPos,spec:this.spec})},this.render=()=>{const e=this.component;return Ll.createPortal(B.createElement(ow.Provider,{value:this.context},B.createElement(e,null)),this.dom,this.key)}}};function lw(r,e){return B.useCallback(t=>(n,i={})=>{const o=new aw({pos:n,options:t}),s={...i,destroy:a=>{var l;(l=i.destroy)==null||l.call(i,a),e(o)}};return o.spec=s,qe.widget(n,(a,l)=>(o.bind(a,l),r(o),o.dom),s)},[e,r])}const cw=({children:r})=>{const{renderReactRenderer:e,removeReactRenderer:t,render:n}=iw(),i=Xb(e,t),o=Ub(e,t),s=tw(e,t),a=lw(e,t);return B.createElement(s5.Provider,{value:i},B.createElement(jb.Provider,{value:o},B.createElement(l5.Provider,{value:s},B.createElement(sw.Provider,{value:a},B.createElement(B.Fragment,{key:1},r),B.createElement(B.Fragment,{key:2},n())))))};var Ut=(function(r){return r.docTypeError="docTypeError",r.contextNotFound="contextNotFound",r.timerNotFound="timerNotFound",r.ctxCallOutOfScope="ctxCallOutOfScope",r.createNodeInParserFail="createNodeInParserFail",r.stackOverFlow="stackOverFlow",r.parserMatchError="parserMatchError",r.serializerMatchError="serializerMatchError",r.getAtomFromSchemaFail="getAtomFromSchemaFail",r.expectDomTypeError="expectDomTypeError",r.callCommandBeforeEditorView="callCommandBeforeEditorView",r.missingRootElement="missingRootElement",r.missingNodeInSchema="missingNodeInSchema",r.missingMarkInSchema="missingMarkInSchema",r.ctxNotBind="ctxNotBind",r.missingYjsDoc="missingYjsDoc",r.aiProviderError="aiProviderError",r.aiBuildContextError="aiBuildContextError",r})({}),Kt=class extends Error{constructor(r,e,t){super(e,t),this.name="MilkdownError",this.code=r,(t==null?void 0:t.cause)!==void 0&&(this.cause=t.cause)}},uw=(r,e)=>typeof e=="function"?"[Function]":e,Rc=r=>JSON.stringify(r,uw);function dw(r){return new Kt(Ut.docTypeError,`Doc type error, unsupported type: ${Rc(r)}`)}function hw(r){return new Kt(Ut.contextNotFound,`Context "${r}" not found, do you forget to inject it?`)}function fw(r){return new Kt(Ut.timerNotFound,`Timer "${r}" not found, do you forget to record it?`)}function Ic(){return new Kt(Ut.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function pw(r,e,t){const n=`Cannot create node for ${"name"in r?r.name:r}`,i=s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},o=[["[Description]",n],["[Attributes]",e],["[Content]",(t??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[a,l])=>{const c=`${a}: ${i(l)}.`;return s.concat(c)},[]);return new Kt(Ut.createNodeInParserFail,o.join(`
29
+ `))}function c5(){return new Kt(Ut.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function mw(r){return new Kt(Ut.parserMatchError,`Cannot match target parser for node: ${Rc(r)}.`)}function gw(r){return new Kt(Ut.serializerMatchError,`Cannot match target serializer for node: ${Rc(r)}.`)}function yw(r,e){return new Kt(Ut.getAtomFromSchemaFail,`Cannot get ${r}: ${e} from schema.`)}function Vr(r){return new Kt(Ut.expectDomTypeError,`Expect to be a dom, but get: ${Rc(r)}.`)}function _u(){return new Kt(Ut.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function u5(r){return new Kt(Ut.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${r}" in schema.`)}function vw(r){return new Kt(Ut.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`)}var d5=class{constructor(){this.sliceMap=new Map,this.get=r=>{const e=typeof r=="string"?[...this.sliceMap.values()].find(t=>t.type.name===r):this.sliceMap.get(r.id);if(!e){const t=typeof r=="string"?r:r.name;throw hw(t)}return e},this.remove=r=>{const e=typeof r=="string"?[...this.sliceMap.values()].find(t=>t.type.name===r):this.sliceMap.get(r.id);e&&this.sliceMap.delete(e.type.id)},this.has=r=>typeof r=="string"?[...this.sliceMap.values()].some(e=>e.type.name===r):this.sliceMap.has(r.id)}},gr,tn,zo,C4,bw=(C4=class{constructor(r,e,t){P(this,gr);P(this,tn);P(this,zo);I(this,gr,[]),I(this,zo,()=>{C(this,gr).forEach(n=>n(C(this,tn)))}),this.set=n=>{I(this,tn,n),C(this,zo).call(this)},this.get=()=>C(this,tn),this.update=n=>{I(this,tn,n(C(this,tn))),C(this,zo).call(this)},this.type=t,I(this,tn,e),r.set(t.id,this)}on(r){return C(this,gr).push(r),()=>{I(this,gr,C(this,gr).filter(e=>e!==r))}}once(r){const e=this.on(t=>{r(t),e()});return e}off(r){I(this,gr,C(this,gr).filter(e=>e!==r))}offAll(){I(this,gr,[])}},gr=new WeakMap,tn=new WeakMap,zo=new WeakMap,C4),ww=class{constructor(r,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=r,this._typeInfo=()=>{throw Ic()}}create(r,e=this._defaultValue){return new bw(r,e,this)}},me=(r,e)=>new ww(r,e),Ga,Ya,Ja,Si,Lo,Pn,Bo,Po,Fo,M4,xw=(M4=class{constructor(r,e,t){P(this,Ga);P(this,Ya);P(this,Ja);P(this,Si);P(this,Lo);P(this,Pn);P(this,Bo);P(this,Po);P(this,Fo);I(this,Si,new Set),I(this,Lo,new Set),I(this,Pn,new Map),I(this,Bo,new Map),this.read=()=>({metadata:C(this,Ga),injectedSlices:[...C(this,Si)].map(n=>({name:typeof n=="string"?n:n.name,value:C(this,Po).call(this,n)})),consumedSlices:[...C(this,Lo)].map(n=>({name:typeof n=="string"?n:n.name,value:C(this,Po).call(this,n)})),recordedTimers:[...C(this,Pn)].map(([n,{duration:i}])=>({name:n.name,duration:i,status:C(this,Fo).call(this,n)})),waitTimers:[...C(this,Bo)].map(([n,{duration:i}])=>({name:n.name,duration:i,status:C(this,Fo).call(this,n)}))}),this.onRecord=n=>{C(this,Pn).set(n,{start:Date.now(),duration:0})},this.onClear=n=>{C(this,Pn).delete(n)},this.onDone=n=>{const i=C(this,Pn).get(n);i&&(i.duration=Date.now()-i.start)},this.onWait=(n,i)=>{const o=Date.now();i.finally(()=>{C(this,Bo).set(n,{duration:Date.now()-o})}).catch(console.error)},this.onInject=n=>{C(this,Si).add(n)},this.onRemove=n=>{C(this,Si).delete(n)},this.onUse=n=>{C(this,Lo).add(n)},I(this,Po,n=>C(this,Ya).get(n).get()),I(this,Fo,n=>C(this,Ja).get(n).status),I(this,Ya,r),I(this,Ja,e),I(this,Ga,t)}},Ga=new WeakMap,Ya=new WeakMap,Ja=new WeakMap,Si=new WeakMap,Lo=new WeakMap,Pn=new WeakMap,Bo=new WeakMap,Po=new WeakMap,Fo=new WeakMap,M4),rn,nn,Xa,tr,Ho,kw=(Ho=class{constructor(e,t,n){P(this,rn);P(this,nn);P(this,Xa);P(this,tr);this.produce=i=>i&&Object.keys(i).length?new Ho(C(this,rn),C(this,nn),{...i}):this,this.inject=(i,o)=>{var a;const s=i.create(C(this,rn).sliceMap);return o!=null&&s.set(o),(a=C(this,tr))==null||a.onInject(i),this},this.remove=i=>{var o;return C(this,rn).remove(i),(o=C(this,tr))==null||o.onRemove(i),this},this.record=i=>{var o;return i.create(C(this,nn).store),(o=C(this,tr))==null||o.onRecord(i),this},this.clearTimer=i=>{var o;return C(this,nn).remove(i),(o=C(this,tr))==null||o.onClear(i),this},this.isInjected=i=>C(this,rn).has(i),this.isRecorded=i=>C(this,nn).has(i),this.use=i=>{var o;return(o=C(this,tr))==null||o.onUse(i),C(this,rn).get(i)},this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>C(this,nn).get(i),this.done=i=>{var o;this.timer(i).done(),(o=C(this,tr))==null||o.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=C(this,tr))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},I(this,rn,e),I(this,nn,t),I(this,Xa,n),n&&I(this,tr,new xw(e,t,n))}get meta(){return C(this,Xa)}get inspector(){return C(this,tr)}},rn=new WeakMap,nn=new WeakMap,Xa=new WeakMap,tr=new WeakMap,Ho),Sw=class{constructor(){this.store=new Map,this.get=r=>{const e=this.store.get(r.id);if(!e)throw fw(r.name);return e},this.remove=r=>{this.store.delete(r.id)},this.has=r=>this.store.has(r.id)}},_o,Fn,qo,on,jo,Za,T4,Cw=(T4=class{constructor(r,e){P(this,_o);P(this,Fn);P(this,qo);P(this,on);P(this,jo);P(this,Za);I(this,_o,null),I(this,Fn,null),I(this,on,"pending"),this.start=()=>(C(this,_o)??I(this,_o,new Promise((t,n)=>{I(this,Fn,i=>{i instanceof CustomEvent&&i.detail.id===C(this,qo)&&(I(this,on,"resolved"),C(this,jo).call(this),i.stopImmediatePropagation(),t())}),C(this,Za).call(this,()=>{C(this,on)==="pending"&&I(this,on,"rejected"),C(this,jo).call(this),n(new Error(`Timing ${this.type.name} timeout.`))}),I(this,on,"pending"),addEventListener(this.type.name,C(this,Fn))})),C(this,_o)),this.done=()=>{const t=new CustomEvent(this.type.name,{detail:{id:C(this,qo)}});dispatchEvent(t)},I(this,jo,()=>{C(this,Fn)&&removeEventListener(this.type.name,C(this,Fn))}),I(this,Za,t=>{setTimeout(()=>{t()},this.type.timeout)}),I(this,qo,Symbol(e.name)),this.type=e,r.set(e.id,this)}get status(){return C(this,on)}},_o=new WeakMap,Fn=new WeakMap,qo=new WeakMap,on=new WeakMap,jo=new WeakMap,Za=new WeakMap,T4),Mw=class{constructor(r,e=3e3){this.create=t=>new Cw(t,this),this.id=Symbol(`Timer-${r}`),this.name=r,this.timeout=e}},Wr=(r,e=3e3)=>new Mw(r,e);function Xd(r){const e=this;e.compiler=t;function t(n){return _7(n,{...e.data("settings"),...r,extensions:e.data("toMarkdownExtensions")||[]})}}const sf=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function h5(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const f5=(r,e,t)=>{let n=h5(r,t);if(!n)return!1;let i=af(n);if(!i){let s=n.blockRange(),a=s&&Ac(s);return a==null?!1:(e&&e(r.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(y5(r,i,e,-1))return!0;if(n.parent.content.size==0&&(xs(o,"end")||re.isSelectable(o)))for(let s=n.depth;;s--){let a=Nc(r.doc,n.before(s),n.after(s),Y.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=r.tr.step(a);l.setSelection(xs(o,"end")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):re.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Tw=(r,e,t)=>{let n=h5(r,t);if(!n)return!1;let i=af(n);return i?Aw(r,i,e):!1};function Aw(r,e,t){let n=e.nodeBefore,i=n,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Nc(r.doc,o,l,Y.empty);if(!c||c.from!=o||c instanceof Ke&&c.slice.size>=l-o)return!1;if(t){let u=r.tr.step(c);u.setSelection(Q.create(u.doc,o)),t(u.scrollIntoView())}return!0}function xs(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const p5=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=af(n)}let s=o&&o.nodeBefore;return!s||!re.isSelectable(s)?!1:(e&&e(r.tr.setSelection(re.create(r.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function af(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Nw(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Ew=(r,e,t)=>{let n=Nw(r,t);if(!n)return!1;let i=m5(n);if(!i)return!1;let o=i.nodeAfter;if(y5(r,i,e,1))return!0;if(n.parent.content.size==0&&(xs(o,"start")||re.isSelectable(o))){let s=Nc(r.doc,n.before(),n.after(),Y.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=r.tr.step(s);a.setSelection(xs(o,"start")?ue.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):re.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Dw=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=m5(n)}let s=o&&o.nodeAfter;return!s||!re.isSelectable(s)?!1:(e&&e(r.tr.setSelection(re.create(r.doc,o.pos)).scrollIntoView()),!0)};function m5(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Ow=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
30
+ `).scrollIntoView()),!0)};function lf(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const g5=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=lf(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=t.after(),l=r.tr.replaceWith(a,a,s.createAndFill());l.setSelection(ue.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Rw=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof Rt||n.parent.inlineContent||i.parent.inlineContent)return!1;let o=lf(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,a=r.tr.insert(s,o.createAndFill());a.setSelection(Q.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},Iw=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(fa(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Ac(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function zw(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof re&&e.selection.node.isBlock)return!n.parentOffset||!fa(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let f=n.depth;;f--)if(n.node(f).isBlock){l=n.end(f)==n.pos+(n.depth-f),c=n.start(f)==n.pos-(n.depth-f),a=lf(n.node(f-1).contentMatchAt(n.indexAfter(f-1))),o.unshift(l&&a?{type:a}:null),s=f;break}else{if(f==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof Q||e.selection instanceof Rt)&&u.deleteSelection();let d=u.mapping.map(n.pos),h=fa(u.doc,d,o.length,o);if(h||(o[0]=a?{type:a}:null,h=fa(u.doc,d,o.length,o)),!h)return!1;if(u.split(d,o.length,o),!l&&c&&n.node(s).type!=a){let f=u.mapping.map(n.before(s)),m=u.doc.resolve(f);a&&n.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(n.before(s)),a)}return t&&t(u.scrollIntoView()),!0}}const Lw=zw(),Bw=(r,e)=>(e&&e(r.tr.setSelection(new Rt(r.doc))),!0);function Pw(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,o=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Bl(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function y5(r,e,t,n){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&Pw(r,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(t){let f=e.pos+o.nodeSize,m=H.empty;for(let b=s.length-1;b>=0;b--)m=H.from(s[b].create(null,m));m=H.from(i.copy(m));let y=r.tr.step(new dt(e.pos-1,f,e.pos,f,new Y(m,1,0),s.length,!0)),x=y.doc.resolve(f+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Bl(y.doc,x.pos)&&y.join(x.pos),t(y.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&l?null:ue.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&Ac(d);if(h!=null&&h>=e.depth)return t&&t(r.tr.lift(d,h).scrollIntoView()),!0;if(c&&xs(o,"start",!0)&&xs(i,"end")){let f=i,m=[];for(;m.push(f),!f.isTextblock;)f=f.lastChild;let y=o,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,y.content)){if(t){let b=H.empty;for(let A=m.length-1;A>=0;A--)b=H.from(m[A].copy(b));let S=r.tr.step(new dt(e.pos-m.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new Y(b,m.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function v5(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(Q.create(e.doc,r<0?i.start(o):i.end(o)))),!0):!1}}const Fw=v5(-1),Hw=v5(1);function cf(r,e=null){return function(t,n){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&Gh(s,r,e);return a?(n&&n(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Ia(r,e=null){return function(t,n){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=t.selection.ranges[o];t.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(r,e)))if(l.type==r)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,r)}})}if(!i)return!1;if(n){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[s];o.setBlockType(a,l,r,e)}n(o.scrollIntoView())}return!0}}function _w(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],a=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,s.pos,(l,c)=>{if(a)return!1;a=l.inlineContent&&l.type.allowsMarkType(t)}),a)return!0}return!1}function zc(r,e=null,t){return function(n,i){let{empty:o,$cursor:s,ranges:a}=n.selection;if(o&&!s||!_w(n.doc,a,r))return!1;if(i)if(s)r.isInSet(n.storedMarks||s.marks())?i(n.tr.removeStoredMark(r)):i(n.tr.addStoredMark(r.create(e)));else{let l,c=n.tr;l=!a.some(u=>n.doc.rangeHasMark(u.$from.pos,u.$to.pos,r));for(let u=0;u<a.length;u++){let{$from:d,$to:h}=a[u];if(!l)c.removeMark(d.pos,h.pos,r);else{let f=d.pos,m=h.pos,y=d.nodeAfter,x=h.nodeBefore,b=y&&y.isText?/^\s*/.exec(y.text)[0].length:0,S=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;f+b<m&&(f+=b,m-=S),c.addMark(f,m,r.create(e))}}i(c.scrollIntoView())}return!0}}function Ds(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}let qu=Ds(sf,f5,p5),N1=Ds(sf,Ew,Dw);const Qr={Enter:Ds(Ow,Rw,Iw,Lw),"Mod-Enter":g5,Backspace:qu,"Mod-Backspace":qu,"Shift-Backspace":qu,Delete:N1,"Mod-Delete":N1,"Mod-a":Bw},b5={"Ctrl-h":Qr.Backspace,"Alt-Backspace":Qr["Mod-Backspace"],"Ctrl-d":Qr.Delete,"Ctrl-Alt-Backspace":Qr["Mod-Delete"],"Alt-Delete":Qr["Mod-Delete"],"Alt-d":Qr["Mod-Delete"],"Ctrl-a":Fw,"Ctrl-e":Hw};for(let r in Qr)b5[r]=Qr[r];const qw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,jw=qw?b5:Qr;class zt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?$w(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function $w(r){return function(e,t,n,i){let o=r;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),n+=s;let a=n-i;a>0&&(o=t[0].slice(s-a,s)+o,n=i)}return e.tr.insertText(o,n,i)}}const Vw=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let i=t[n],o;if(i.spec.isInputRules&&(o=i.getState(r))){if(e){let s=r.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l--)s.step(a.steps[l].invert(a.docs[l]));if(o.text){let l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,r.schema.text(o.text,l))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new zt(/--$/,"—",{inCodeMark:!1});new zt(/\.\.\.$/,"…",{inCodeMark:!1});new zt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new zt(/"$/,"”",{inCodeMark:!1});new zt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new zt(/'$/,"’",{inCodeMark:!1});function uf(r,e,t=null,n){return new zt(r,(i,o,s,a)=>{let l=t instanceof Function?t(o):t,c=i.tr.delete(s,a),u=c.doc.resolve(s),d=u.blockRange(),h=d&&Gh(d,e,l);if(!h)return null;c.wrap(d,h);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Bl(c.doc,s-1)&&(!n||n(o,f))&&c.join(s-1),c})}function df(r,e,t=null){return new zt(r,(n,i,o,s)=>{let a=n.doc.resolve(o),l=t instanceof Function?t(i):t;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),e)?n.tr.delete(o,s).setBlockType(o,o,e,l):null})}const Jn=typeof navigator<"u"?navigator:null,E1=typeof document<"u"?document:null,ri=Jn&&Jn.userAgent||"",Zd=/Edge\/(\d+)/.exec(ri),w5=/MSIE \d/.exec(ri),Qd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ri),Lc=!!(w5||Qd||Zd),Ww=w5?document.documentMode:Qd?+Qd[1]:Zd?+Zd[1]:0,x5=!Lc&&/gecko\/(\d+)/i.test(ri),Uw=x5&&+(/Firefox\/(\d+)/.exec(ri)||[0,0])[1],eh=!Lc&&/Chrome\/(\d+)/.exec(ri),k5=!!eh,Kw=eh?+eh[1]:0,S5=!Lc&&!!Jn&&/Apple Computer/.test(Jn.vendor),C5=S5&&(/Mobile\/\w+/.test(ri)||!!Jn&&Jn.maxTouchPoints>2),Gw=C5||(Jn?/Mac/.test(Jn.platform):!1),M5=/Android \d/.test(ri),T5=!!E1&&"webkitFontSmoothing"in E1.documentElement.style,Yw=T5?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var w0=Object.freeze({__proto__:null,android:M5,chrome:k5,chrome_version:Kw,gecko:x5,gecko_version:Uw,ie:Lc,ie_version:Ww,ios:C5,mac:Gw,safari:S5,webkit:T5,webkit_version:Yw});function ju(r,e,t,n,i,o){if(r.composing)return!1;const s=r.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+n;for(let c of i){const u=c,d=u.match.exec(l),h=d&&d[0]&&u.handler(s,d,e-(d[0].length-n.length),t);if(h)return u.undoable!==!1&&h.setMeta(o,{transform:h,from:e,to:t,text:n}),r.dispatch(h),!0}return!1}const Jw=new Me("MILKDOWN_CUSTOM_INPUTRULES");function Xw({rules:r}){const e=new Ce({key:Jw,isInputRules:!0,state:{init(){return null},apply(t,n){const i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,i,o){return ju(t,n,i,o,r,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:n}=t.state.selection;n&&ju(t,n.pos,n.pos,"",r,e)}),!1),keydown:(t,n)=>!(M5&&k5&&n.key==="Enter")||t.composing?!1:t.someProp("handleKeyDown",i=>i(t,n))?(n.preventDefault(),!0):!1},handleKeyDown(t,n){if(n.key!=="Enter")return!1;const{$cursor:i}=t.state.selection;return i?ju(t,i.pos,i.pos,`
31
+ `,r,e):!1}}});return e}function A5(r){return r.some(e=>e.type.spec.code)}function D1(r,e,t){if(e>=t)return!1;let n=!1;return r.doc.nodesBetween(e,t,i=>(i.isInline&&A5(i.marks)&&(n=!0),!n)),n}function Zw(r,e){var t;return A5((t=r.storedMarks)!=null?t:r.doc.resolve(e).marks())}function jl(r,e,t={}){return new zt(r,(n,i,o,s)=>{var a,l,c,u;const{tr:d}=n,h=i.length;let f=i[h-1],m=i[0],y=[],x;const b={group:f,fullMatch:m,start:o,end:s},S=(a=t.updateCaptured)==null?void 0:a.call(t,b);if(Object.assign(b,S),{group:f,fullMatch:m,start:o,end:s}=b,m===null||(f==null?void 0:f.trim())==="")return null;if(f){const A=m.search(/\S/),D=o+m.indexOf(f),O=D+f.length,L=D1(n,o+A,D),N=O<s&&D1(n,O,s);if(L||N||Zw(n,s))return null;y=(l=d.storedMarks)!=null?l:[],O<s&&d.delete(O,s),D>o&&d.delete(o+A,D),x=o+A+f.length;const j=(c=t.getAttr)==null?void 0:c.call(t,i);d.addMark(o,x,e.create(j)),d.setStoredMarks(y),(u=t.beforeDispatch)==null||u.call(t,{match:i,start:o,end:s,tr:d})}return d})}function Qw(r,e,t={}){return new zt(r,(n,i,o,s)=>{var a,l,c;const{tr:u}=n;let d=i[1],h=i[0];const f={group:d,fullMatch:h,start:o,end:s},m=(a=t.updateCaptured)==null?void 0:a.call(t,f);if(Object.assign(f,m),{group:d,fullMatch:h,start:o,end:s}=f,h===null||!d||d.trim()==="")return null;const y=(l=t.getAttr)==null?void 0:l.call(t,i),x=e.createAndFill(y);return x&&(u.replaceRangeWith(e.isBlock?u.doc.resolve(o).before():o,s,x),(c=t.beforeDispatch)==null||c.call(t,{match:[h,d],start:o,end:s,tr:u})),u})}var e9=Object.defineProperty,t9=Object.defineProperties,r9=Object.getOwnPropertyDescriptors,O1=Object.getOwnPropertySymbols,n9=Object.prototype.hasOwnProperty,i9=Object.prototype.propertyIsEnumerable,R1=(r,e,t)=>e in r?e9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o9=(r,e)=>{for(var t in e||(e={}))n9.call(e,t)&&R1(r,t,e[t]);if(O1)for(var t of O1(e))i9.call(e,t)&&R1(r,t,e[t]);return r},s9=(r,e)=>t9(r,r9(e));function I1(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function Bc(r,e,t){const i=r.state.doc.content.size,o=I1(e,0,i),s=I1(t,0,i),a=r.coordsAtPos(o),l=r.coordsAtPos(s,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),h=Math.max(a.right,l.right),f=h-d,m=u-c,b={top:c,bottom:u,left:d,right:h,width:f,height:m,x:d,y:c};return s9(o9({},b),{toJSON:()=>b})}function N5(r){return Object.assign(Object.create(r),r).setTime(Date.now())}function a9(r,e){return Array.isArray(r)&&r.includes(e.type)||e.type===r}function l9(r){if(r.content.childCount===1){const e=r.content.firstChild;if((e==null?void 0:e.type.name)==="text"&&e.marks.length===0)return e;if((e==null?void 0:e.type.name)==="paragraph"&&e.childCount===1){const t=e.firstChild;if((t==null?void 0:t.type.name)==="text"&&t.marks.length===0)return t}}return!1}function Fr(r){return e=>{for(let t=e.depth;t>0;t-=1){const n=e.node(t);if(r(n)){const i=e.before(t),o=e.after(t);return{from:i,to:o,node:n}}}}}function c9(r,e){return Fr(t=>t.type===e)(r)}function u9(r,e){const t=e.nodes[r];if(!t)throw yw("node",r);return t}function E5(r){return e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(r(n))return{pos:e.before(t),start:e.start(t),depth:t,node:n}}}}function d9(r){return e=>E5(r)(e.$from)}function h9(r,e){if(!(r instanceof re))return;const{node:t,$from:n}=r;if(a9(e,t))return{node:t,pos:n.pos,start:n.start(n.depth),depth:n.depth}}const D5=(r,e)=>{const{selection:t,doc:n}=r;if(t instanceof re)return{hasNode:t.node.type===e,pos:t.from,target:t.node};const{from:i,to:o}=t;let s=!1,a=-1,l=null;return n.nodesBetween(i,o,(c,u)=>l?!1:c.type===e?(s=!0,a=u,l=c,!1):!0),{hasNode:s,pos:a,target:l}},f9=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),p9=typeof navigator<"u"&&/Win/.test(navigator.platform);function m9(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))f9?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function g9(r){let e=Object.create(null);for(let t in r)e[m9(t)]=r[t];return e}function $u(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function y9(r){return new Ce({props:{handleKeyDown:hf(r)}})}function hf(r){let e=g9(r);return function(t,n){let i=Qy(n),o,s=e[$u(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let a=e[$u(i,n,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(p9&&n.ctrlKey&&n.altKey)&&(o=e7[n.keyCode])&&o!=i){let a=e[$u(o,n)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var O5=class{},R5=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=r=>{var e;(e=this.top())==null||e.push(r)},this.open=r=>{this.elements.push(r)},this.close=()=>{const r=this.elements.pop();if(!r)throw c5();return r}}},v9=class I5 extends O5{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new I5(e,t,n)}},yr,$o,Qa,el,tl,Vo,Wo,Vi,b9=(Vi=class extends R5{constructor(t){super();P(this,yr);P(this,$o);P(this,Qa);P(this,el);P(this,tl);P(this,Vo);P(this,Wo);I(this,yr,fe.none),I(this,$o,n=>n.isText),I(this,Qa,(n,i)=>{if(C(this,$o).call(this,n)&&C(this,$o).call(this,i)&&fe.sameSet(n.marks,i.marks))return this.schema.text(n.text+i.text,n.marks)}),I(this,el,n=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(n));if(!i)throw mw(n);return i}),I(this,tl,n=>{const i=C(this,el).call(this,n);i.spec.parseMarkdown.runner(this,n,i)}),this.injectRoot=(n,i,o)=>(this.openNode(i,o),this.next(n.children),this),this.openNode=(n,i)=>(this.open(v9.create(n,[],i)),this),I(this,Vo,()=>{I(this,yr,fe.none);const n=this.close();return C(this,Wo).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>{try{C(this,Vo).call(this)}catch(n){console.error(n)}return this},I(this,Wo,(n,i,o)=>{const s=n.createAndFill(i,o,C(this,yr));if(!s)throw pw(n,i,o);return this.push(s),s}),this.addNode=(n,i,o)=>{try{C(this,Wo).call(this,n,i,o)}catch(s){console.error(s)}return this},this.openMark=(n,i)=>{const o=n.create(i);return I(this,yr,o.addToSet(C(this,yr))),this},this.closeMark=n=>(I(this,yr,n.removeFromSet(C(this,yr))),this),this.addText=n=>{try{const i=this.top();if(!i)throw c5();const o=i.pop(),s=this.schema.text(n,C(this,yr));if(!o)return i.push(s),this;const a=C(this,Qa).call(this,o,s);return a?(i.push(a),this):(i.push(o,s),this)}catch(i){return console.error(i),this}},this.build=()=>{let n;do n=C(this,Vo).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(i=>C(this,tl).call(this,i)),this),this.toDoc=()=>this.build(),this.run=(n,i)=>{const o=n.runSync(n.parse(i),i);return this.next(o),this},this.schema=t}},yr=new WeakMap,$o=new WeakMap,Qa=new WeakMap,el=new WeakMap,tl=new WeakMap,Vo=new WeakMap,Wo=new WeakMap,Vi.create=(t,n)=>{const i=new Vi(t);return o=>(i.run(n,o),i.toDoc())},Vi),Wi,z1=(Wi=class extends O5{constructor(e,t,n,i={}){super(),this.type=e,this.children=t,this.value=n,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>{var o;return(o=this.children)==null?void 0:o.pop()}}},Wi.create=(e,t,n,i={})=>new Wi(e,t,n,i),Wi),w9=r=>Object.prototype.hasOwnProperty.call(r,"size"),vt,Uo,rl,nl,il,ol,Ko,Go,sl,al,Ci,Hn,ll,Yo,Ui,x9=(Ui=class extends R5{constructor(t){super();P(this,vt);P(this,Uo);P(this,rl);P(this,nl);P(this,il);P(this,ol);P(this,Ko);P(this,Go);P(this,sl);P(this,al);P(this,Ci);P(this,Hn);P(this,ll);P(this,Yo);I(this,vt,[]),I(this,Uo,n=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(n));if(!i)throw gw(n.type);return i}),I(this,rl,n=>C(this,Uo).call(this,n).spec.toMarkdown.runner(this,n)),I(this,nl,(n,i)=>C(this,Uo).call(this,n).spec.toMarkdown.runner(this,n,i)),I(this,il,n=>{const i=a=>a.type.spec.priority??50,o=[...n].sort((a,l)=>i(a)-i(l)),s=[];return C(this,vt).forEach(({mark:a})=>{const l=o.findIndex(c=>c.eq(a));l>=0&&s.push(...o.splice(l,1))}),s.concat(o)}),I(this,ol,n=>{const i=n==null?void 0:n.marks;let o=0;for(;o<C(this,vt).length;){const{mark:s,spanning:a}=C(this,vt)[o];if(a&&(i!=null&&i.some(l=>l.eq(s))))o++;else break}for(let s=C(this,vt).length-1;s>=o;s--)C(this,Yo).call(this,C(this,vt)[s].mark)}),I(this,Ko,(n,i)=>{C(this,il).call(this,n.marks).every(o=>!C(this,nl).call(this,o,n))&&C(this,rl).call(this,n),C(this,ol).call(this,i)}),I(this,Go,n=>{const{children:i}=n;return i&&(n.children=i.reduce((o,s,a)=>{if(a===0)return[s];const l=o.at(-1);if(l&&l.isMark&&s.isMark){const{children:c,...u}=s,{children:d,...h}=l;if(s.type===l.type&&c&&d&&JSON.stringify(u)===JSON.stringify(h)){const f={...h,children:[...d,...c]};return o.slice(0,-1).concat(C(this,Go).call(this,f))}}return o.concat(s)},[])),n}),I(this,sl,n=>{const i={...n.props,type:n.type};return n.children&&(i.children=n.children),n.value&&(i.value=n.value),i}),this.openNode=(n,i,o)=>(this.open(z1.create(n,void 0,i,o)),this),I(this,al,(n,i)=>{let o="",s="";const a=n.children;if(a){const c=a[0],u=a.at(-1);if(u&&u.type==="text"&&u.value.endsWith(" ")){const d=u.value,h=d.trimEnd();s=d.slice(h.length),u.value=h}if(c&&c.type==="text"&&c.value.startsWith(" ")){const d=c.value,h=d.trimStart();o=d.slice(0,d.length-h.length),c.value=h}}o.length&&C(this,Hn).call(this,"text",void 0,o);const l=i();return s.length&&C(this,Hn).call(this,"text",void 0,s),l}),I(this,Ci,(n=!1)=>{const i=this.close(),o=()=>C(this,Hn).call(this,i.type,i.children,i.value,i.props);return n?C(this,al).call(this,i,o):o()}),this.closeNode=()=>(C(this,Ci).call(this),this),I(this,Hn,(n,i,o,s)=>{const a=z1.create(n,i,o,s),l=C(this,Go).call(this,C(this,sl).call(this,a));return this.push(l),l}),this.addNode=(n,i,o,s)=>(C(this,Hn).call(this,n,i,o,s),this),I(this,ll,(n,i,o,s)=>C(this,vt).some(a=>a.mark.eq(n))?this:(C(this,vt).push({mark:n,spanning:o==null}),this.openNode(i,o,{...s,isMark:!0}))),I(this,Yo,n=>{let i=-1;for(let o=C(this,vt).length-1;o>=0;o--)if(C(this,vt)[o].mark.eq(n)){i=o;break}i<0||(C(this,vt).splice(i,1),C(this,Ci).call(this,!0))}),this.withMark=(n,i,o,s)=>(C(this,ll).call(this,n,i,o,s),this),this.closeMark=n=>(C(this,Yo).call(this,n),this),this.build=()=>{let n=null;do n=C(this,Ci).call(this);while(this.size());return n},this.next=n=>w9(n)?(n.forEach((i,o,s)=>{C(this,Ko).call(this,i,n.maybeChild(s+1)??void 0)}),this):(C(this,Ko).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(I(this,vt,[]),this.next(n),this),this.schema=t}},vt=new WeakMap,Uo=new WeakMap,rl=new WeakMap,nl=new WeakMap,il=new WeakMap,ol=new WeakMap,Ko=new WeakMap,Go=new WeakMap,sl=new WeakMap,al=new WeakMap,Ci=new WeakMap,Hn=new WeakMap,ll=new WeakMap,Yo=new WeakMap,Ui.create=(t,n)=>{const i=new Ui(t);return o=>(i.run(o),i.toString(n))},Ui);function wn(r,e){return r.meta={package:"@milkdown/core",group:"System",...e},r}var z5={text:(r,e,t,n)=>{const i=r.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...n,encode:[]})},strong:(r,e,t,n)=>{const i=r.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(n);let a=s.move(i+i);return a+=s.move(t.containerPhrasing(r,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(r,e,t,n)=>{const i=r.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(n);let a=s.move(i);return a+=s.move(t.containerPhrasing(r,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},ge=me({},"editorView"),oa=me({},"editorState"),Vu=me([],"initTimer"),th=me({},"editor"),za=me([],"inputRules"),vn=me([],"prosePlugins"),La=me([],"remarkPlugins"),Ba=me([],"nodeView"),Pa=me([],"markView"),_i=me(Dd().use(Od).use(Xd),"remark"),ga=me({handlers:z5,encode:[]},"remarkStringifyOptions"),_0=Wr("ConfigReady");function k9(r){const e=t=>(t.record(_0),async()=>(await r(t),t.done(_0),()=>{t.clearTimer(_0)}));return wn(e,{displayName:"Config"}),e}var qi=Wr("InitReady");function S9(r){const e=t=>(t.inject(th,r).inject(vn,[]).inject(La,[]).inject(za,[]).inject(Ba,[]).inject(Pa,[]).inject(ga,{handlers:z5,encode:[]}).inject(_i,Dd().use(Od).use(Xd)).inject(Vu,[_0]).record(qi),async()=>{await t.waitTimers(Vu);const n=t.get(ga);return t.set(_i,Dd().use(Od).use(Xd,n)),t.done(qi),()=>{t.remove(th).remove(vn).remove(La).remove(za).remove(Ba).remove(Pa).remove(ga).remove(_i).remove(Vu).clearTimer(qi)}});return wn(e,{displayName:"Init"}),e}var xt=Wr("SchemaReady"),Wu=me([],"schemaTimer"),Sr=me({},"schema"),ya=me([],"nodes"),va=me([],"marks");function L1(r){var e;return{...r,parseDOM:(e=r.parseDOM)==null?void 0:e.map(t=>({priority:r.priority,...t}))}}var L5=r=>(r.inject(Sr,{}).inject(ya,[]).inject(va,[]).inject(Wu,[qi]).record(xt),async()=>{await r.waitTimers(Wu);const e=r.get(_i),t=r.get(La).reduce((s,a)=>s.use(a.plugin,a.options),e);r.set(_i,t);const n=Object.fromEntries(r.get(ya).map(([s,a])=>[s,L1(a)])),i=Object.fromEntries(r.get(va).map(([s,a])=>[s,L1(a)])),o=new Cv({nodes:n,marks:i});return r.set(Sr,o),r.done(xt),()=>{r.remove(Sr).remove(ya).remove(va).remove(Wu).clearTimer(xt)}});wn(L5,{displayName:"Schema"});var Mi,rr,A4,B5=(A4=class{constructor(){P(this,Mi);P(this,rr);I(this,Mi,new d5),I(this,rr,null),this.setCtx=r=>{I(this,rr,r)},this.chain=()=>{if(C(this,rr)==null)throw _u();const r=C(this,rr),e=[],t=this.get.bind(this),n={run:()=>{const o=Ds(...e),s=r.get(ge);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),n),pipe:i.bind(this)};function i(o,s){const a=t(o);return e.push(a(s)),n}return n}}get ctx(){return C(this,rr)}create(r,e){const t=r.create(C(this,Mi).sliceMap);return t.set(e),t}get(r){return C(this,Mi).get(r).get()}remove(r){return C(this,Mi).remove(r)}call(r,e){if(C(this,rr)==null)throw _u();const t=this.get(r)(e),n=C(this,rr).get(ge);return t(n.state,n.dispatch,n)}inline(r){if(C(this,rr)==null)throw _u();const e=C(this,rr).get(ge);return r(e.state,e.dispatch,e)}},Mi=new WeakMap,rr=new WeakMap,A4);function C9(r="cmdKey"){return me((()=>()=>!1),r)}var ee=me(new B5,"commands"),Uu=me([xt],"commandsTimer"),ba=Wr("CommandsReady"),P5=r=>{const e=new B5;return e.setCtx(r),r.inject(ee,e).inject(Uu,[xt]).record(ba),async()=>(await r.waitTimers(Uu),r.done(ba),()=>{r.remove(ee).remove(Uu).clearTimer(ba)})};wn(P5,{displayName:"Commands"});function M9(r){return r.Backspace=Ds(Vw,sf,Tw,p5),r}var Ti,At,N4,F5=(N4=class{constructor(){P(this,Ti);P(this,At);I(this,Ti,null),I(this,At,[]),this.setCtx=r=>{I(this,Ti,r)},this.add=r=>(C(this,At).push(r),()=>{I(this,At,C(this,At).filter(e=>e!==r))}),this.addObjectKeymap=r=>{const e=[];return Object.entries(r).forEach(([t,n])=>{if(typeof n=="function"){const i={key:t,onRun:()=>n};C(this,At).push(i),e.push(()=>{I(this,At,C(this,At).filter(o=>o!==i))})}else C(this,At).push(n),e.push(()=>{I(this,At,C(this,At).filter(i=>i!==n))})}),()=>{e.forEach(t=>t())}},this.addBaseKeymap=()=>{const r=M9(jw);return this.addObjectKeymap(r)},this.build=()=>{const r={};return C(this,At).forEach(e=>{r[e.key]=[...r[e.key]||[],e]}),Object.fromEntries(Object.entries(r).map(([e,t])=>{const n=t.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,a)=>{const l=C(this,Ti);if(l==null)throw Ic();const c=n.map(u=>u.onRun(l));return Ds(...c)(o,s,a)}]}))}}get ctx(){return C(this,Ti)}},Ti=new WeakMap,At=new WeakMap,N4),lc=me(new F5,"keymap"),Ku=me([xt],"keymapTimer"),wa=Wr("KeymapReady"),T9=r=>{const e=new F5;return e.setCtx(r),r.inject(lc,e).inject(Ku,[xt]).record(wa),async()=>(await r.waitTimers(Ku),r.done(wa),()=>{r.remove(lc).remove(Ku).clearTimer(wa)})},q0=Wr("ParserReady"),H5=(()=>{throw Ic()}),Do=me(H5,"parser"),Gu=me([],"parserTimer"),_5=r=>(r.inject(Do,H5).inject(Gu,[xt]).record(q0),async()=>{await r.waitTimers(Gu);const e=r.get(_i),t=r.get(Sr);return r.set(Do,b9.create(t,e)),r.done(q0),()=>{r.remove(Do).remove(Gu).clearTimer(q0)}});wn(_5,{displayName:"Parser"});var xa=Wr("SerializerReady"),Yu=me([],"serializerTimer"),q5=(()=>{throw Ic()}),ka=me(q5,"serializer"),j5=r=>(r.inject(ka,q5).inject(Yu,[xt]).record(xa),async()=>{await r.waitTimers(Yu);const e=r.get(_i),t=r.get(Sr);return r.set(ka,x9.create(t,e)),r.done(xa),()=>{r.remove(ka).remove(Yu).clearTimer(xa)}});wn(j5,{displayName:"Serializer"});var j0=me("","defaultValue"),$0=me(r=>r,"stateOptions"),Ju=me([],"editorStateTimer"),V0=Wr("EditorStateReady");function A9(r,e,t){if(typeof r=="string")return e(r);if(r.type==="html")return Yi.fromSchema(t).parse(r.dom);if(r.type==="json")return mn.fromJSON(t,r.value);throw dw(r)}var N9=new Me("MILKDOWN_STATE_TRACKER"),$5=r=>(r.inject(j0,"").inject(oa,{}).inject($0,e=>e).inject(Ju,[q0,xa,ba,wa]).record(V0),async()=>{await r.waitTimers(Ju);const e=r.get(Sr),t=r.get(Do),n=r.get(za),i=r.get($0),o=r.get(vn),s=A9(r.get(j0),t,e),a=r.get(lc),l=a.addBaseKeymap(),c=[...o,new Ce({key:N9,state:{init:()=>{},apply:(h,f,m,y)=>{r.set(oa,y)}}}),Xw({rules:n}),y9(a.build())];r.set(vn,c);const u=i({schema:e,doc:s,plugins:c}),d=bi.create(u);return r.set(oa,d),r.done(V0),()=>{l(),r.remove(j0).remove(oa).remove($0).remove(Ju).clearTimer(V0)}});wn($5,{displayName:"EditorState"});var Fa=me([],"pasteRule"),Xu=me([xt],"pasteRuleTimer"),W0=Wr("PasteRuleReady"),V5=r=>(r.inject(Fa,[]).inject(Xu,[xt]).record(W0),async()=>(await r.waitTimers(Xu),r.done(W0),()=>{r.remove(Fa).remove(Xu).clearTimer(W0)}));wn(V5,{displayName:"PasteRule"});var U0=Wr("EditorViewReady"),Zu=me([],"editorViewTimer"),Sa=me({},"editorViewOptions"),K0=me(null,"root"),rh=me(null,"rootDOM"),nh=me({},"rootAttrs");function E9(r,e){const t=document.createElement("div");t.className="milkdown",r.appendChild(t),e.set(rh,t);const n=e.get(nh);return Object.entries(n).forEach(([i,o])=>t.setAttribute(i,o)),t}function D9(r){r.classList.add("editor"),r.setAttribute("role","textbox")}var O9=new Me("MILKDOWN_VIEW_CLEAR"),W5=r=>(r.inject(K0,document.body).inject(ge,{}).inject(Sa,{}).inject(rh,null).inject(nh,{}).inject(Zu,[V0,W0]).record(U0),async()=>{await r.wait(qi);const e=r.get(K0)||document.body,t=typeof e=="string"?document.querySelector(e):e;r.update(vn,l=>[new Ce({key:O9,view:c=>{const u=t?E9(t,r):void 0;return(()=>{if(u&&t){const h=c.dom;t.replaceChild(u,h),u.appendChild(h)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(c.dom,u)),u==null||u.remove()}}}}),...l]),await r.waitTimers(Zu);const n=r.get(oa),i=r.get(Sa),o=Object.fromEntries(r.get(Ba)),s=Object.fromEntries(r.get(Pa)),a=new i5(t,{state:n,nodeViews:o,markViews:s,transformPasted:(l,c,u)=>(r.get(Fa).sort((d,h)=>(h.priority??50)-(d.priority??50)).map(d=>d.run).forEach(d=>{l=d(l,c,u)}),l),...i});return D9(a.dom),r.set(ge,a),r.done(U0),()=>{a==null||a.destroy(),r.remove(K0).remove(ge).remove(Sa).remove(rh).remove(nh).remove(Zu).clearTimer(U0)}});wn(W5,{displayName:"EditorView"});var R9=(function(r){return r.Idle="Idle",r.OnCreate="OnCreate",r.Created="Created",r.OnDestroy="OnDestroy",r.Destroyed="Destroyed",r})({}),Ai,qt,sn,Jo,cl,ul,Nt,an,Ni,dl,Ei,Xo,hl,_n,Zo,Qo,I9=(Qo=class{constructor(){P(this,Ai);P(this,qt);P(this,sn);P(this,Jo);P(this,cl);P(this,ul);P(this,Nt);P(this,an);P(this,Ni);P(this,dl);P(this,Ei);P(this,Xo);P(this,hl);P(this,_n);P(this,Zo);I(this,Ai,!1),I(this,qt,"Idle"),I(this,sn,[]),I(this,Jo,()=>{}),I(this,cl,new d5),I(this,ul,new Sw),I(this,Nt,new Map),I(this,an,new Map),I(this,Ni,new kw(C(this,cl),C(this,ul))),I(this,dl,()=>{const e=k9(async n=>{await Promise.all(C(this,sn).map(i=>Promise.resolve(i(n))))}),t=[L5,_5,j5,P5,T9,V5,$5,W5,S9(this),e];C(this,Ei).call(this,t,C(this,an))}),I(this,Ei,(e,t)=>{e.forEach(n=>{const i=C(this,Ni).produce(C(this,Ai)?n.meta:void 0),o=n(i);t.set(n,{ctx:i,handler:o,cleanup:void 0})})}),I(this,Xo,(e,t=!1)=>Promise.all([e].flat().map(async n=>{var o;const i=(o=C(this,Nt).get(n))==null?void 0:o.cleanup;return t?C(this,Nt).delete(n):C(this,Nt).set(n,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i}))),I(this,hl,async()=>{await Promise.all([...C(this,an).entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),C(this,an).clear()}),I(this,_n,e=>{I(this,qt,e),C(this,Jo).call(this,e)}),I(this,Zo,e=>[...e.entries()].map(async([t,n])=>{const{ctx:i,handler:o}=n;if(!o)return;const s=await o();e.set(t,{ctx:i,handler:o,cleanup:s})})),this.enableInspector=(e=!0)=>(I(this,Ai,e),this),this.onStatusChange=e=>(I(this,Jo,e),this),this.config=e=>(C(this,sn).push(e),this),this.removeConfig=e=>(I(this,sn,C(this,sn).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(n=>{C(this,Nt).set(n,{ctx:void 0,handler:void 0,cleanup:void 0})}),C(this,qt)==="Created"&&C(this,Ei).call(this,t,C(this,Nt)),this},this.remove=async e=>C(this,qt)==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await C(this,Xo).call(this,[e].flat(),!0),this),this.create=async()=>C(this,qt)==="OnCreate"?this:(C(this,qt)==="Created"&&await this.destroy(),C(this,_n).call(this,"OnCreate"),C(this,dl).call(this),C(this,Ei).call(this,[...C(this,Nt).keys()],C(this,Nt)),await Promise.all([C(this,Zo).call(this,C(this,an)),C(this,Zo).call(this,C(this,Nt))].flat()),C(this,_n).call(this,"Created"),this),this.destroy=async(e=!1)=>C(this,qt)==="Destroyed"||C(this,qt)==="OnDestroy"?this:C(this,qt)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&I(this,sn,[]),C(this,_n).call(this,"OnDestroy"),await C(this,Xo).call(this,[...C(this,Nt).keys()],e),await C(this,hl).call(this),C(this,_n).call(this,"Destroyed"),this),this.action=e=>e(C(this,Ni)),this.inspect=()=>C(this,Ai)?[...C(this,an).values(),...C(this,Nt).values()].map(({ctx:e})=>{var t;return(t=e==null?void 0:e.inspector)==null?void 0:t.read()}).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Qo}get ctx(){return C(this,Ni)}get status(){return C(this,qt)}},Ai=new WeakMap,qt=new WeakMap,sn=new WeakMap,Jo=new WeakMap,cl=new WeakMap,ul=new WeakMap,Nt=new WeakMap,an=new WeakMap,Ni=new WeakMap,dl=new WeakMap,Ei=new WeakMap,Xo=new WeakMap,hl=new WeakMap,_n=new WeakMap,Zo=new WeakMap,Qo);function U5(r,e,t){const n=r.findIndex(([o])=>o===e);if(n===-1)return[...r,t];const i=r.slice();return i[n]=t,i}function le(r,e){const t=C9(r),n=i=>async()=>{n.key=t,await i.wait(ba);const o=e(i);return i.get(ee).create(t,o),n.run=s=>i.get(ee).call(r,s),()=>{i.get(ee).remove(t)}};return n}function mt(r){const e=t=>async()=>{await t.wait(xt);const n=r(t);return t.update(za,i=>[...i,n]),e.inputRule=n,()=>{t.update(za,i=>i.filter(o=>o!==n))}};return e}function z9(r){const e=t=>async()=>{await t.wait(xt);const n=r(t);return t.update(Fa,i=>[...i,n]),e.pasteRule=n,()=>{t.update(Fa,i=>i.filter(o=>o!==n))}};return e}function L9(r,e){const t=n=>async()=>{const i=e(n);return n.update(va,o=>U5(o,r,[r,i])),t.id=r,t.schema=i,()=>{n.update(va,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{const i=n.get(Sr).marks[r];if(!i)throw vw(r);return i},t}function ff(r,e){const t=n=>async()=>{const i=e(n);return n.update(ya,o=>U5(o,r,[r,i])),t.id=r,t.schema=i,()=>{n.update(ya,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{const i=n.get(Sr).nodes[r];if(!i)throw u5(r);return i},t}function Fe(r){let e;const t=n=>async()=>(await n.wait(xt),e=r(n),n.update(vn,i=>[...i,e]),()=>{n.update(vn,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function K5(r){const e=t=>async()=>{await t.wait(wa);const n=t.get(lc),i=r(t),o=n.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function Ha(r,e){const t=n=>async()=>{await n.wait(xt);const i=e(n);return r.type(n)instanceof rc?n.update(Ba,o=>[...o,[r.id,i]]):n.update(Pa,o=>[...o,[r.id,i]]),t.view=i,t.type=r,()=>{r.type(n)instanceof rc?n.update(Ba,o=>o.filter(s=>s[0]!==r.id)):n.update(Pa,o=>o.filter(s=>s[0]!==r.id))}};return t}function ye(r,e){const t=me(r,e),n=i=>(i.inject(t),()=>()=>{i.remove(t)});return n.key=t,n}function je(r,e){const t=ye(e,r),n=ff(r,o=>o.get(t.key)(o)),i=[t,n];return i.id=n.id,i.node=n,i.type=o=>n.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>je(r,o(e)),i}function Os(r,e){const t=ye(e,r),n=L9(r,o=>o.get(t.key)(o)),i=[t,n];return i.id=n.id,i.mark=n,i.type=o=>n.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>Os(r,o(e)),i}function Lt(r,e){const t=ye(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:a}])=>[o,{shortcuts:s,priority:a}])),`${r}Keymap`),n=K5(o=>{const s=o.get(t.key),a=Object.entries(e).flatMap(([l,{command:c}])=>{const u=s[l],d=[u.shortcuts].flat(),h=u.priority;return d.map(f=>[f,{key:f,onRun:c,priority:h}])});return Object.fromEntries(a)}),i=[t,n];return i.ctx=t,i.shortcuts=n,i.key=t.key,i.keymap=n.keymap,i}var Mr=(r,e=()=>({}))=>ye(e,`${r}Attr`),$l=(r,e=()=>({}))=>ye(e,`${r}Attr`);function dr(r,e,t){const n=ye(t??{},r),i=s=>async()=>{await s.wait(qi);const a={plugin:e(s),options:s.get(n.key)};return s.update(La,l=>[...l,a]),()=>{s.update(La,l=>l.filter(c=>c!==a))}},o=[n,i];return o.id=r,o.plugin=i,o.options=n,o}function B9(r,e=!1){return t=>{const n=t.get(ge),i=t.get(Do)(r);if(!i)return;if(!e){const{state:l}=n;return n.dispatch(l.tr.replace(0,l.doc.content.size,new Y(i.content,0,0)))}const o=t.get(Sr),s=t.get($0)({schema:o,doc:i,plugins:t.get(vn)}),a=bi.create(s);n.updateState(a)}}let ih,oh;if(typeof WeakMap<"u"){let r=new WeakMap;ih=e=>r.get(e),oh=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;ih=n=>{for(let i=0;i<r.length;i+=2)if(r[i]==n)return r[i+1]},oh=(n,i)=>(t==10&&(t=0),r[t++]=n,r[t++]=i)}var xe=class{constructor(r,e,t,n){this.width=r,this.height=e,this.map=t,this.problems=n}findCell(r){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=r)continue;const n=e%this.width,i=e/this.width|0;let o=n+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==t;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==t;a++)s++;return{left:n,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${r} found`)}colCount(r){for(let e=0;e<this.map.length;e++)if(this.map[e]==r)return e%this.width;throw new RangeError(`No cell with offset ${r} found`)}nextCell(r,e,t){const{left:n,right:i,top:o,bottom:s}=this.findCell(r);return e=="horiz"?(t<0?n==0:i==this.width)?null:this.map[o*this.width+(t<0?n-1:i)]:(t<0?o==0:s==this.height)?null:this.map[n+this.width*(t<0?o-1:s)]}rectBetween(r,e){const{left:t,right:n,top:i,bottom:o}=this.findCell(r),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,l),right:Math.max(n,a),bottom:Math.max(o,c)}}cellsInRect(r){const e=[],t={};for(let n=r.top;n<r.bottom;n++)for(let i=r.left;i<r.right;i++){const o=n*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==r.left&&i&&this.map[o-1]==s||n==r.top&&n&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(r,e,t){for(let n=0,i=0;;n++){const o=i+t.child(n).nodeSize;if(n==r){let s=e+r*this.width;const a=(r+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(r){return ih(r)||oh(r,P9(r))}};function P9(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=F9(r),t=r.childCount,n=[];let i=0,o=null;const s=[];for(let c=0,u=e*t;c<u;c++)n[c]=0;for(let c=0,u=0;c<t;c++){const d=r.child(c);u++;for(let m=0;;m++){for(;i<n.length&&n[i]!=0;)i++;if(m==d.childCount)break;const y=d.child(m),{colspan:x,rowspan:b,colwidth:S}=y.attrs;for(let A=0;A<b;A++){if(A+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:b-A});break}const D=i+A*e;for(let O=0;O<x;O++){n[D+O]==0?n[D+O]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:x-O});const L=S&&S[O];if(L){const N=(D+O)%e*2,j=s[N];j==null||j!=L&&s[N+1]==1?(s[N]=L,s[N+1]=1):j==L&&s[N+1]++}}}i+=x,u+=y.nodeSize}const h=(c+1)*e;let f=0;for(;i<h;)n[i++]==0&&f++;f&&(o||(o=[])).push({type:"missing",row:c,n:f}),u++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new xe(e,t,n,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(l=!0);return l&&H9(a,s,r),a}function F9(r){let e=-1,t=!1;for(let n=0;n<r.childCount;n++){const i=r.child(n);let o=0;if(t)for(let s=0;s<n;s++){const a=r.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>n&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function H9(r,e,t){r.problems||(r.problems=[]);const n={};for(let i=0;i<r.map.length;i++){const o=r.map[i];if(n[o])continue;n[o]=!0;const s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const u=e[(i+c)%r.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=_9(l)))[c]=u)}a&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function _9(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function B1(r,e){if(typeof r=="string")return{};const t=r.getAttribute("data-colwidth"),n=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,i=Number(r.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(r.getAttribute("rowspan")||1),colwidth:n&&n.length==i?n:null};for(const s in e){const a=e[s].getFromDOM,l=a&&a(r);l!=null&&(o[s]=l)}return o}function P1(r,e){const t={};r.attrs.colspan!=1&&(t.colspan=r.attrs.colspan),r.attrs.rowspan!=1&&(t.rowspan=r.attrs.rowspan),r.attrs.colwidth&&(t["data-colwidth"]=r.attrs.colwidth.join(","));for(const n in e){const i=e[n].setDOMAttr;i&&i(r.attrs[n],t)}return t}function q9(r){if(r!==null){if(!Array.isArray(r))throw new TypeError("colwidth must be null or an array");for(const e of r)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function j9(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:q9}};for(const n in e)t[n]={default:e[n].default,validate:e[n].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:r.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:r.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:n=>B1(n,e)}],toDOM(n){return["td",P1(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>B1(n,e)}],toDOM(n){return["th",P1(n,e),0]}}}}function lr(r){let e=r.cached.tableNodeTypes;if(!e){e=r.cached.tableNodeTypes={};for(const t in r.nodes){const n=r.nodes[t],i=n.spec.tableRole;i&&(e[i]=n)}}return e}const Bn=new Me("selectingCells");function ks(r){for(let e=r.depth-1;e>0;e--)if(r.node(e).type.spec.tableRole=="row")return r.node(0).resolve(r.before(e+1));return null}function hr(r){const e=r.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Pc(r){const e=r.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=ks(e.$head)||$9(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function $9(r){for(let e=r.nodeAfter,t=r.pos;e;e=e.firstChild,t++){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t)}for(let e=r.nodeBefore,t=r.pos;e;e=e.lastChild,t--){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t-e.nodeSize)}}function sh(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function V9(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function pf(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function G5(r,e,t){const n=r.node(-1),i=xe.get(n),o=r.start(-1),s=i.nextCell(r.pos-o,e,t);return s==null?null:r.node(0).resolve(o+s)}function Zi(r,e,t=1){const n={...r,colspan:r.colspan-t};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,t),n.colwidth.some(i=>i>0)||(n.colwidth=null)),n}function W9(r,e,t=1){const n={...r,colspan:r.colspan+t};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let i=0;i<t;i++)n.colwidth.splice(e,0,0)}return n}function U9(r,e,t){const n=lr(e.type.schema).header_cell;for(let i=0;i<r.height;i++)if(e.nodeAt(r.map[t+i*r.width]).type!=n)return!1;return!0}var Ae=class Xr extends ue{constructor(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(u=>u!=t.pos-o);l.unshift(t.pos-o);const c=l.map(u=>{const d=n.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=o+u+1;return new b2(a.resolve(h),a.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(sh(n)&&sh(i)&&pf(n,i)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Xr.rowSelection(n,i):o&&this.isColSelection()?Xr.colSelection(n,i):new Xr(n,i)}return Q.between(n,i)}content(){const e=this.$anchorCell.node(-1),t=xe.get(e),n=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let u=l*t.width+i.left,d=i.left;d<i.right;d++,u++){const h=t.map[u];if(o[h])continue;o[h]=!0;const f=t.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const y=i.left-f.left,x=f.right-i.right;if(y>0||x>0){let b=m.attrs;if(y>0&&(b=Zi(b,0,y)),x>0&&(b=Zi(b,b.colspan-x,x)),f.left<i.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(f.top<i.top||f.bottom>i.bottom){const b={...m.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}s.push(e.child(l).copy(H.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Y(H.from(a),1,1)}replace(e,t=Y.empty){const n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(n);e.replace(c.map(a.pos),c.map(l.pos),s?Y.empty:t)}const o=ue.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new Y(H.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=xe.get(t),i=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new Xr(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=xe.get(e),n=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==t.width}eq(e){return e instanceof Xr&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),i=xe.get(n),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new Xr(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Xr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new Xr(e.resolve(t),e.resolve(n))}getBookmark(){return new K9(this.$anchorCell.pos,this.$headCell.pos)}};Ae.prototype.visible=!1;ue.jsonID("cell",Ae);var K9=class Y5{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Y5(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&pf(t,n)?new Ae(t,n):ue.near(n,1)}};function G9(r){if(!(r.selection instanceof Ae))return null;const e=[];return r.selection.forEachCell((t,n)=>{e.push(qe.node(n,n+t.nodeSize,{class:"selectedCell"}))}),Se.create(r.doc,e)}function Y9({$from:r,$to:e}){if(r.pos==e.pos||r.pos<e.pos-6)return!1;let t=r.pos,n=e.pos,i=r.depth;for(;i>=0&&!(r.after(i+1)<r.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,n--);return t==n&&/row|table/.test(r.node(i).type.spec.tableRole)}function J9({$from:r,$to:e}){let t,n;for(let i=r.depth;i>0;i--){const o=r.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return t!==n&&e.parentOffset===0}function X9(r,e,t){const n=(e||r).selection,i=(e||r).doc;let o,s;if(n instanceof re&&(s=n.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Ae.create(i,n.from);else if(s=="row"){const a=i.resolve(n.from+1);o=Ae.rowSelection(a,a)}else if(!t){const a=xe.get(n.node),l=n.from+1,c=l+a.map[a.width*a.height-1];o=Ae.create(i,l+1,c)}}else n instanceof Q&&Y9(n)?o=Q.create(i,n.from):n instanceof Q&&J9(n)&&(o=Q.create(i,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}const Z9=new Me("fix-tables");function J5(r,e,t,n){const i=r.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,u=Math.min(i,s+3);c<u;c++)if(r.child(c)==l){a=c+1,t+=l.nodeSize;continue e}n(l,t),a<i&&r.child(a).sameMarkup(l)?J5(r.child(a),l,t+1,n):l.nodesBetween(0,l.content.size,n,t+1),t+=l.nodeSize}}function Q9(r,e){let t;const n=(i,o)=>{i.type.spec.tableRole=="table"&&(t=ex(r,i,o,t))};return e?e.doc!=r.doc&&J5(e.doc,r.doc,0,n):r.doc.descendants(n),t}function ex(r,e,t,n){const i=xe.get(e);if(!i.problems)return n;n||(n=r.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)o[c.row+h]+=c.n;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,Zi(d,d.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=n.mapping.map(t);n.delete(u,u+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=t+1;l<i.height;l++){const u=e.child(l),d=c+u.nodeSize,h=o[l];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const m=[];for(let x=0;x<h;x++){const b=lr(r.schema)[f].createAndFill();b&&m.push(b)}const y=(l==0||s==l-1)&&a==l?c+1:d-1;n.insert(n.mapping.map(y),m)}c=d}return n.setMeta(Z9,{fixTables:!0})}function X5(r){const e=xe.get(r),t=[],n=e.height,i=e.width;for(let o=0;o<n;o++){const s=[];for(let a=0;a<i;a++){const l=o*i+a,c=e.map[l];if(o>0){const u=l-i;if(c===e.map[u]){s.push(null);continue}}if(a>0){const u=l-1;if(c===e.map[u]){s.push(null);continue}}s.push(r.nodeAt(c))}t.push(s)}return t}function Z5(r,e){const t=[],n=xe.get(r),i=n.height,o=n.width;for(let s=0;s<i;s++){const a=r.child(s),l=[];for(let u=0;u<o;u++){const d=e[s][u];if(!d)continue;const h=n.map[s*n.width+u],f=r.nodeAt(h);if(!f)continue;const m=f.type.createChecked(d.attrs,d.content,d.marks);l.push(m)}const c=a.type.createChecked(a.attrs,l,a.marks);t.push(c)}return r.type.createChecked(r.attrs,t,r.marks)}function Q5(r,e,t,n){const i=e[0]>t[0]?-1:1,o=r.splice(e[0],e.length),s=o.length%2===0?1:0;let a;return a=i===-1?t[0]:t[t.length-1]-s,r.splice(a,0,...o),r}function Rs(r){return tx(e=>e.type.spec.tableRole==="table",r)}function tx(r,e){for(let t=e.depth;t>=0;t-=1){const n=e.node(t);if(r(n))return{node:n,pos:t===0?0:e.before(t),start:e.start(t),depth:t}}return null}function So(r,e){const t=Rs(e.$from);if(!t)return;const n=xe.get(t.node);if(!(r<0||r>n.width-1))return n.cellsInRect({left:r,right:r+1,top:0,bottom:n.height}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function Co(r,e){const t=Rs(e.$from);if(!t)return;const n=xe.get(t.node);if(!(r<0||r>n.height-1))return n.cellsInRect({left:0,right:n.width,top:r,bottom:r+1}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function F1(r,e,t=e){let n=e,i=t;for(let u=e;u>=0;u--){const d=So(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.colspan+u-1;f>=n&&(n=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const d=So(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.colspan+u-1;h.node.attrs.colspan>1&&f>i&&(i=f)})}const o=[];for(let u=n;u<=i;u++){const d=So(u,r.selection);d&&d.length>0&&o.push(u)}n=o[0],i=o[o.length-1];const s=So(n,r.selection),a=Co(0,r.selection);if(!s||!a)return;const l=r.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=n;u--){const d=So(u,r.selection);if(d&&d.length>0){for(let h=a.length-1;h>=0;h--)if(a[h].pos===d[0].pos){c=d[0];break}if(c)break}}if(c)return{$anchor:l,$head:r.doc.resolve(c.pos),indexes:o}}function H1(r,e,t=e){let n=e,i=t;for(let u=e;u>=0;u--){const d=Co(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.rowspan+u-1;f>=n&&(n=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const d=Co(u,r.selection);d&&d.forEach(h=>{const f=h.node.attrs.rowspan+u-1;h.node.attrs.rowspan>1&&f>i&&(i=f)})}const o=[];for(let u=n;u<=i;u++){const d=Co(u,r.selection);d&&d.length>0&&o.push(u)}n=o[0],i=o[o.length-1];const s=Co(n,r.selection),a=So(0,r.selection);if(!s||!a)return;const l=r.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=n;u--){const d=Co(u,r.selection);if(d&&d.length>0){for(let h=a.length-1;h>=0;h--)if(a[h].pos===d[0].pos){c=d[0];break}if(c)break}}if(c)return{$anchor:l,$head:r.doc.resolve(c.pos),indexes:o}}function _1(r){return r[0].map((e,t)=>r.map(n=>n[t]))}function rx(r){var e,t;const{tr:n,originIndex:i,targetIndex:o,select:s,pos:a}=r,l=Rs(n.doc.resolve(a));if(!l)return!1;const c=(e=F1(n,i))===null||e===void 0?void 0:e.indexes,u=(t=F1(n,o))===null||t===void 0?void 0:t.indexes;if(!c||!u||c.includes(o))return!1;const d=nx(l.node,c,u);if(n.replaceWith(l.pos,l.pos+l.node.nodeSize,d),!s)return!0;const h=xe.get(d),f=l.start,m=o,y=h.positionAt(h.height-1,m,d),x=n.doc.resolve(f+y),b=h.positionAt(0,m,d),S=n.doc.resolve(f+b);return n.setSelection(Ae.colSelection(x,S)),!0}function nx(r,e,t,n){let i=_1(X5(r));return i=Q5(i,e,t),i=_1(i),Z5(r,i)}function ix(r){var e,t;const{tr:n,originIndex:i,targetIndex:o,select:s,pos:a}=r,l=Rs(n.doc.resolve(a));if(!l)return!1;const c=(e=H1(n,i))===null||e===void 0?void 0:e.indexes,u=(t=H1(n,o))===null||t===void 0?void 0:t.indexes;if(!c||!u||c.includes(o))return!1;const d=ox(l.node,c,u);if(n.replaceWith(l.pos,l.pos+l.node.nodeSize,d),!s)return!0;const h=xe.get(d),f=l.start,m=o,y=h.positionAt(m,h.width-1,d),x=n.doc.resolve(f+y),b=h.positionAt(m,0,d),S=n.doc.resolve(f+b);return n.setSelection(Ae.rowSelection(x,S)),!0}function ox(r,e,t,n){let i=X5(r);return i=Q5(i,e,t),Z5(r,i)}function ni(r){const e=r.selection,t=Pc(r),n=t.node(-1),i=t.start(-1),o=xe.get(n);return{...e instanceof Ae?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:n}}function e3(r,{map:e,tableStart:t,table:n},i){let o=i>0?-1:0;U9(e,n,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=n.nodeAt(l);r.setNodeMarkup(r.mapping.map(t+l),null,W9(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?lr(n.type.schema).cell:n.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,n);r.insert(r.mapping.map(t+c),l.createAndFill())}}return r}function sx(r,e){if(!hr(r))return!1;if(e){const t=ni(r);e(e3(r.tr,t,t.left))}return!0}function ax(r,e){if(!hr(r))return!1;if(e){const t=ni(r);e(e3(r.tr,t,t.right))}return!0}function lx(r,{map:e,table:t,tableStart:n},i){const o=r.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=t.nodeAt(l),u=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)r.setNodeMarkup(r.mapping.slice(o).map(n+l),null,Zi(u,i-e.colCount(l)));else{const d=r.mapping.slice(o).map(n+l);r.delete(d,d+c.nodeSize)}s+=u.rowspan}}function cx(r,e){if(!hr(r))return!1;if(e){const t=ni(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;lx(n,t,i),i!=t.left;i--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=xe.get(o)}e(n)}return!0}function ux(r,{map:e,table:t,tableStart:n},i){let o=0;for(let c=0;c<i;c++)o+=t.child(c).nodeSize;const s=o+t.child(i).nodeSize,a=r.mapping.maps.length;r.delete(o+n,s+n);const l=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const d=e.map[u];if(!l.has(d)){if(l.add(d),i>0&&d==e.map[u-e.width]){const h=t.nodeAt(d).attrs;r.setNodeMarkup(r.mapping.slice(a).map(d+n),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&d==e.map[u+e.width]){const h=t.nodeAt(d),f=h.attrs,m=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),y=e.positionAt(i+1,c,t);r.insert(r.mapping.slice(a).map(n+y),m),c+=f.colspan-1}}}}function dx(r,e){if(!hr(r))return!1;if(e){const t=ni(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;ux(n,t,i),i!=t.top;i--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=xe.get(t.table)}e(n)}return!0}function hx(r,e){return function(t,n){if(!hr(t))return!1;const i=Pc(t);if(i.nodeAfter.attrs[r]===e)return!1;if(n){const o=t.tr;t.selection instanceof Ae?t.selection.forEachCell((s,a)=>{s.attrs[r]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[r]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[r]:e}),n(o)}return!0}}function fx(r){return function(e,t){if(!hr(e))return!1;if(t){const n=lr(e.schema),i=ni(e),o=e.tr,s=i.map.cellsInRect(r=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:r=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==n.header_cell&&o.setNodeMarkup(i.tableStart+s[l],n.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],n.header_cell,a[l].attrs);t(o)}return!0}}function q1(r,e,t){const n=e.map.cellsInRect({left:0,top:0,right:r=="row"?e.map.width:1,bottom:r=="column"?e.map.height:1});for(let i=0;i<n.length;i++){const o=e.table.nodeAt(n[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function mf(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fx(r):function(t,n){if(!hr(t))return!1;if(n){const i=lr(t.schema),o=ni(t),s=t.tr,a=q1("row",o,i),l=q1("column",o,i),c=(r==="column"?a:r==="row"&&l)?1:0,u=r=="column"?{left:0,top:c,right:1,bottom:o.map.height}:r=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,d=r=="column"?l?i.cell:i.header_cell:r=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(h=>{const f=h+o.tableStart,m=s.doc.nodeAt(f);m&&s.setNodeMarkup(f,d,m.attrs)}),n(s)}return!0}}mf("row",{useDeprecatedLogic:!0});mf("column",{useDeprecatedLogic:!0});mf("cell",{useDeprecatedLogic:!0});function px(r,e){if(e<0){const t=r.nodeBefore;if(t)return r.pos-t.nodeSize;for(let n=r.index(-1)-1,i=r.before();n>=0;n--){const o=r.node(-1).child(n),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(r.index()<r.parent.childCount-1)return r.pos+r.nodeAfter.nodeSize;const t=r.node(-1);for(let n=r.indexAfter(-1),i=r.after();n<t.childCount;n++){const o=t.child(n);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function t3(r){return function(e,t){if(!hr(e))return!1;const n=px(Pc(e),r);if(n==null)return!1;if(t){const i=e.doc.resolve(n);t(e.tr.setSelection(Q.between(i,V9(i))).scrollIntoView())}return!0}}function mx(r,e){const t=r.selection.$anchor;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="table")return e&&e(r.tr.delete(t.before(n),t.after(n)).scrollIntoView()),!0;return!1}function x0(r,e){const t=r.selection;if(!(t instanceof Ae))return!1;if(e){const n=r.tr,i=lr(r.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||n.replace(n.mapping.map(s+1),n.mapping.map(s+o.nodeSize-1),new Y(i,0,0))}),n.docChanged&&e(n)}return!0}function gx(r){return(e,t)=>{const{from:n,to:i,select:o=!0,pos:s=e.selection.from}=r,a=e.tr;return ix({tr:a,originIndex:n,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function yx(r){return(e,t)=>{const{from:n,to:i,select:o=!0,pos:s=e.selection.from}=r,a=e.tr;return rx({tr:a,originIndex:n,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function vx(r){if(r.size===0)return null;let{content:e,openStart:t,openEnd:n}=r;for(;e.childCount==1&&(t>0&&n>0||e.child(0).type.spec.tableRole=="table");)t--,n--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const u=l?0:Math.max(0,t-1),d=l<e.childCount-1?0:Math.max(0,n-1);(u||d)&&(c=ah(lr(s).row,new Y(c,u,d)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||n?ah(lr(s).row,new Y(e,t,n)).content:e);else return null;return bx(s,a)}function bx(r,e){const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)t[c]=(t[c]||0)+l}}let n=0;for(let i=0;i<t.length;i++)n=Math.max(n,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(H.empty),t[i]<n){const o=lr(r).cell.createAndFill(),s=[];for(let a=t[i];a<n;a++)s.push(o);e[i]=e[i].append(H.from(s))}return{height:e.length,width:n,rows:e}}function ah(r,e){const t=r.createAndFill();return new v2(t).replace(0,t.content.size,e).doc}function wx({width:r,height:e,rows:t},n,i){if(r!=n){const o=[],s=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let u=o[a]||0,d=0;u<n;d++){let h=l.child(d%l.childCount);u+h.attrs.colspan>n&&(h=h.type.createChecked(Zi(h.attrs,h.attrs.colspan,u+h.attrs.colspan-n),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)o[a+f]=(o[a+f]||0)+h.attrs.colspan}s.push(H.from(c))}t=s,r=n}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}o.push(H.from(l))}t=o,e=i}return{width:r,height:e,rows:t}}function xx(r,e,t,n,i,o,s){const a=r.doc.type.schema,l=lr(a);let c,u;if(i>e.width)for(let d=0,h=0;d<e.height;d++){const f=t.child(d);h+=f.nodeSize;const m=[];let y;f.lastChild==null||f.lastChild.type==l.cell?y=c||(c=l.cell.createAndFill()):y=u||(u=l.header_cell.createAndFill());for(let x=e.width;x<i;x++)m.push(y);r.insert(r.mapping.slice(s).map(h-1+n),m)}if(o>e.height){const d=[];for(let m=0,y=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const x=m>=e.width?!1:t.nodeAt(e.map[y+m]).type==l.header_cell;d.push(x?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,H.from(d)),f=[];for(let m=e.height;m<o;m++)f.push(h);r.insert(r.mapping.slice(s).map(n+t.nodeSize-2),f)}return!!(c||u)}function j1(r,e,t,n,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){l=!0;const h=t.nodeAt(d),{top:f,left:m}=e.findCell(d);r.setNodeMarkup(r.mapping.slice(a).map(d+n),null,{...h.attrs,rowspan:s-f}),r.insert(r.mapping.slice(a).map(e.positionAt(s,m,t)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function $1(r,e,t,n,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){l=!0;const h=t.nodeAt(d),f=e.colCount(d),m=r.mapping.slice(a).map(d+n);r.setNodeMarkup(m,null,Zi(h.attrs,s-f,h.attrs.colspan-(s-f))),r.insert(m+h.nodeSize,h.type.createAndFill(Zi(h.attrs,0,s-f))),c+=h.attrs.rowspan-1}}return l}function V1(r,e,t,n,i){let o=t?r.doc.nodeAt(t-1):r.doc;if(!o)throw new Error("No table found");let s=xe.get(o);const{top:a,left:l}=n,c=l+i.width,u=a+i.height,d=r.tr;let h=0;function f(){if(o=t?d.doc.nodeAt(t-1):d.doc,!o)throw new Error("No table found");s=xe.get(o),h=d.mapping.maps.length}xx(d,s,o,t,c,u,h)&&f(),j1(d,s,o,t,l,c,a,h)&&f(),j1(d,s,o,t,l,c,u,h)&&f(),$1(d,s,o,t,a,u,l,h)&&f(),$1(d,s,o,t,a,u,c,h)&&f();for(let m=a;m<u;m++){const y=s.positionAt(m,l,o),x=s.positionAt(m,c,o);d.replace(d.mapping.slice(h).map(y+t),d.mapping.slice(h).map(x+t),new Y(i.rows[m-a],0,0))}f(),d.setSelection(new Ae(d.doc.resolve(t+s.positionAt(a,l,o)),d.doc.resolve(t+s.positionAt(u-1,c-1,o)))),e(d)}const kx=hf({ArrowLeft:k0("horiz",-1),ArrowRight:k0("horiz",1),ArrowUp:k0("vert",-1),ArrowDown:k0("vert",1),"Shift-ArrowLeft":S0("horiz",-1),"Shift-ArrowRight":S0("horiz",1),"Shift-ArrowUp":S0("vert",-1),"Shift-ArrowDown":S0("vert",1),Backspace:x0,"Mod-Backspace":x0,Delete:x0,"Mod-Delete":x0});function G0(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function k0(r,e){return(t,n,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Ae)return G0(t,n,ue.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;const s=r3(i,r,e);if(s==null)return!1;if(r=="horiz")return G0(t,n,ue.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=G5(a,r,e);let c;return l?c=ue.near(l,1):e<0?c=ue.near(t.doc.resolve(a.before(-1)),-1):c=ue.near(t.doc.resolve(a.after(-1)),1),G0(t,n,c)}}}function S0(r,e){return(t,n,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Ae)s=o;else{const l=r3(i,r,e);if(l==null)return!1;s=new Ae(t.doc.resolve(l))}const a=G5(s.$headCell,r,e);return a?G0(t,n,new Ae(s.$anchorCell,a)):!1}}function Sx(r,e){const t=r.state.doc,n=ks(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new Ae(n))),!0):!1}function Cx(r,e,t){if(!hr(r.state))return!1;let n=vx(t);const i=r.state.selection;if(i instanceof Ae){n||(n={width:1,height:1,rows:[H.from(ah(lr(r.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=xe.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return n=wx(n,a.right-a.left,a.bottom-a.top),V1(r.state,r.dispatch,s,a,n),!0}else if(n){const o=Pc(r.state),s=o.start(-1);return V1(r.state,r.dispatch,s,xe.get(o.node(-1)).findCell(o.pos-s),n),!0}else return!1}function Mx(r,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const n=W1(r,e.target);let i;if(e.shiftKey&&r.state.selection instanceof Ae)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(i=ks(r.state.selection.$anchor))!=null&&((t=Qu(r,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!n)return;function o(l,c){let u=Qu(r,c);const d=Bn.getState(r.state)==null;if(!u||!pf(l,u))if(d)u=l;else return;const h=new Ae(l,u);if(d||!r.state.selection.eq(h)){const f=r.state.tr.setSelection(h);d&&f.setMeta(Bn,l.pos),r.dispatch(f)}}function s(){r.root.removeEventListener("mouseup",s),r.root.removeEventListener("dragstart",s),r.root.removeEventListener("mousemove",a),Bn.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(Bn,-1))}function a(l){const c=l,u=Bn.getState(r.state);let d;if(u!=null)d=r.state.doc.resolve(u);else if(W1(r,c.target)!=n&&(d=Qu(r,e),!d))return s();d&&o(d,c)}r.root.addEventListener("mouseup",s),r.root.addEventListener("dragstart",s),r.root.addEventListener("mousemove",a)}function r3(r,e,t){if(!(r.state.selection instanceof Q))return null;const{$head:n}=r.state.selection;for(let i=n.depth-1;i>=0;i--){const o=n.node(i);if((t<0?n.index(i):n.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=n.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return r.endOfTextblock(a)?s:null}}return null}function W1(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Qu(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:n,pos:i}=t;return n>=0&&ks(r.state.doc.resolve(n))||ks(r.state.doc.resolve(i))}var Tx=class{constructor(r,e){this.node=r,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),lh(r,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(r){return r.type!=this.node.type?!1:(this.node=r,lh(r,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(r){return r.type=="attributes"&&(r.target==this.table||this.colgroup.contains(r.target))}};function lh(r,e,t,n,i,o){let s=0,a=!0,l=e.firstChild;const c=r.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:m}=c.child(d).attrs;for(let y=0;y<f;y++,h++){const x=i==h?o:m&&m[y],b=x?x+"px":"";if(s+=x||n,x||(a=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const S=document.createElement("col");S.style.width=b,e.appendChild(S)}}}for(;l;){var u;const d=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=d}a?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}const $t=new Me("tableColumnResizing");function Ax({handleWidth:r=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:n=Tx,lastColumnResizable:i=!0}={}){const o=new Ce({key:$t,state:{init(s,a){var l;const c=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=lr(a.schema).table.name;return n&&c&&(c[u]=(d,h)=>new n(d,t,h)),new Nx(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=$t.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{Ex(s,a,r,i)},mouseleave:s=>{Dx(s)},mousedown:(s,a)=>{Ox(s,a,e,t)}},decorations:s=>{const a=$t.getState(s);if(a&&a.activeHandle>-1)return Bx(s,a.activeHandle)},nodeViews:{}}});return o}var Nx=class Y0{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,n=e.getMeta($t);if(n&&n.setHandle!=null)return new Y0(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Y0(t.activeHandle,n.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return sh(e.doc.resolve(i))||(i=-1),new Y0(i,t.dragging)}return t}};function Ex(r,e,t,n){if(!r.editable)return;const i=$t.getState(r.state);if(i&&!i.dragging){const o=Ix(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=U1(r,e,"left",t):l-e.clientX<=t&&(s=U1(r,e,"right",t))}if(s!=i.activeHandle){if(!n&&s!==-1){const a=r.state.doc.resolve(s),l=a.node(-1),c=xe.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}n3(r,s)}}}function Dx(r){if(!r.editable)return;const e=$t.getState(r.state);e&&e.activeHandle>-1&&!e.dragging&&n3(r,-1)}function Ox(r,e,t,n){var i;if(!r.editable)return!1;const o=(i=r.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=$t.getState(r.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=r.state.doc.nodeAt(s.activeHandle),l=Rx(r,s.activeHandle,a.attrs);r.dispatch(r.state.tr.setMeta($t,{setDragging:{startX:e.clientX,startWidth:l}}));function c(d){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const h=$t.getState(r.state);h!=null&&h.dragging&&(zx(r,h.activeHandle,K1(h.dragging,d,t)),r.dispatch(r.state.tr.setMeta($t,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=$t.getState(r.state);if(h&&h.dragging){const f=K1(h.dragging,d,t);G1(r,h.activeHandle,f,n)}}return G1(r,s.activeHandle,l,n),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function Rx(r,e,{colspan:t,colwidth:n}){const i=n&&n[n.length-1];if(i)return i;const o=r.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=t;if(n)for(let l=0;l<t;l++)n[l]&&(s-=n[l],a--);return s/a}function Ix(r){for(;r&&r.nodeName!="TD"&&r.nodeName!="TH";)r=r.classList&&r.classList.contains("ProseMirror")?null:r.parentNode;return r}function U1(r,e,t,n){const i=t=="right"?-n:n,o=r.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=ks(r.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=xe.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function K1(r,e,t){const n=e.clientX-r.startX;return Math.max(t,r.startWidth+n)}function n3(r,e){r.dispatch(r.state.tr.setMeta($t,{setHandle:e}))}function zx(r,e,t){const n=r.state.doc.resolve(e),i=n.node(-1),o=xe.get(i),s=n.start(-1),a=o.colCount(n.pos-s)+n.nodeAfter.attrs.colspan-1,l=r.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+a;if(c&&o.map[u]==o.map[u-o.width])continue;const d=o.map[u],h=i.nodeAt(d).attrs,f=h.colspan==1?0:a-o.colCount(d);if(h.colwidth&&h.colwidth[f]==t)continue;const m=h.colwidth?h.colwidth.slice():Lx(h.colspan);m[f]=t,l.setNodeMarkup(s+d,null,{...h,colwidth:m})}l.docChanged&&r.dispatch(l)}function G1(r,e,t,n){const i=r.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=xe.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=r.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&lh(o,l.firstChild,l,n,a,t)}function Lx(r){return Array(r).fill(0)}function Bx(r,e){const t=[],n=r.doc.resolve(e),i=n.node(-1);if(!i)return Se.empty;const o=xe.get(i),s=n.start(-1),a=o.colCount(n.pos-s)+n.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const u=a+c*o.width;if((a==o.width-1||o.map[u]!=o.map[u+1])&&(c==0||o.map[u]!=o.map[u-o.width])){var l;const d=o.map[u],h=s+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((l=$t.getState(r))===null||l===void 0)&&l.dragging&&t.push(qe.node(s+d,s+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),t.push(qe.widget(h,f))}}return Se.create(r.doc,t)}function Px({allowTableNodeSelection:r=!1}={}){return new Ce({key:Bn,state:{init(){return null},apply(e,t){const n=e.getMeta(Bn);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:G9,handleDOMEvents:{mousedown:Mx},createSelectionBetween(e){return Bn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Sx,handleKeyDown:kx,handlePaste:Cx},appendTransaction(e,t,n){return X9(n,Q9(n,t),r)}})}function Fx(r,e){return function(t,n){let{$from:i,$to:o,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let a=i.node(-1);if(a.type!=r)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(n){let d=H.empty,h=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-h;b>=i.depth-3;b--)d=H.from(i.node(b).copy(d));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;d=d.append(H.from(r.createAndFill()));let m=i.before(i.depth-(h-1)),y=t.tr.replace(m,i.after(-f),new Y(d,4-h,0)),x=-1;y.doc.nodesBetween(m,y.doc.content.size,(b,S)=>{if(x>-1)return!1;b.isTextblock&&b.content.size==0&&(x=S+1)}),x>-1&&y.setSelection(ue.near(y.doc.resolve(x))),n(y.scrollIntoView())}return!0}let l=o.pos==i.end()?a.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),u=l?[null,{type:l}]:void 0;return fa(c.doc,i.pos,2,u)?(n&&n(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Hx(r){return function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,s=>s.childCount>0&&s.firstChild.type==r);return o?t?n.node(o.depth-1).type==r?_x(e,t,r,o):qx(e,t,o):!0:!1}}function _x(r,e,t,n){let i=r.tr,o=n.end,s=n.$to.end(n.depth);o<s&&(i.step(new dt(o-1,s,o,s,new Y(H.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new J4(i.doc.resolve(n.$from.pos),i.doc.resolve(s),n.depth));const a=Ac(n);if(a==null)return!1;i.lift(n,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Bl(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function qx(r,e,t){let n=r.tr,i=t.parent;for(let f=t.end,m=t.endIndex-1,y=t.startIndex;m>y;m--)f-=i.child(m).nodeSize,n.delete(f-1,f+1);let o=n.doc.resolve(t.start),s=o.nodeAfter;if(n.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?H.empty:H.from(i))))return!1;let d=o.pos,h=d+s.nodeSize;return n.step(new dt(d-(a?1:0),h+(l?1:0),d+1,h-1,new Y((a?H.empty:H.from(i.copy(H.empty))).append(l?H.empty:H.from(i.copy(H.empty))),a?0:1,l?0:1),a?0:1)),e(n.scrollIntoView()),!0}function jx(r){return function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=r)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,u=H.from(c?r.create():null),d=new Y(H.from(r.create(null,H.from(a.type.create(null,u)))),c?3:1,0),h=o.start,f=o.end;t(e.tr.step(new dt(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}function $x(r){const e=new Map;if(!r||!r.type)throw new Error("mdast-util-definitions expected node");return Qi(r,"definition",function(n){const i=Y1(n.identifier);i&&!e.get(i)&&e.set(i,n)}),t;function t(n){const i=Y1(n);return e.get(i)}}function Y1(r){return String(r||"").toUpperCase()}function Vx(){return function(r){const e=$x(r);Qi(r,function(t,n,i){if(t.type==="definition"&&i!==void 0&&typeof n=="number")return i.children.splice(n,1),[Em,n];if(t.type==="imageReference"||t.type==="linkReference"){const o=e(t.identifier);if(o&&i&&typeof n=="number")return i.children[n]=t.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:t.alt}:{type:"link",url:o.url,title:o.title,children:t.children},[Em,n]}})}}function i3(r,e){var n;if(!(e.childCount>=1&&((n=e.lastChild)==null?void 0:n.type.name)==="hardbreak")){r.next(e.content);return}const t=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&t.push(i)}),r.next(H.fromArray(t))}function F(r,e){return Object.assign(r,{meta:{package:"@milkdown/preset-commonmark",...e}}),r}var gf=$l("emphasis");F(gf,{displayName:"Attr<emphasis>",group:"Emphasis"});var to=Os("emphasis",r=>({attrs:{marker:{default:r.get(ga).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",r.get(gf.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));F(to.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});F(to.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Fc=le("ToggleEmphasis",r=>()=>zc(to.type(r)));F(Fc,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var o3=mt(r=>jl(/(?:^|[^*])\*([^*]+)\*$/,to.type(r),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));F(o3,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var s3=mt(r=>jl(/\b_(?![_\s])(.*?[^_\s])_$/,to.type(r),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));F(s3,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var yf=Lt("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:r=>{const e=r.get(ee);return()=>e.call(Fc.key)}}});F(yf.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});F(yf.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var vf=$l("strong");F(vf,{displayName:"Attr<strong>",group:"Strong"});var Is=Os("strong",r=>({attrs:{marker:{default:r.get(ga).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",r.get(vf.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));F(Is.mark,{displayName:"MarkSchema<strong>",group:"Strong"});F(Is.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Hc=le("ToggleStrong",r=>()=>zc(Is.type(r)));F(Hc,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var a3=mt(r=>jl(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),Is.type(r),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));F(a3,{displayName:"InputRule<strong>",group:"Strong"});var bf=Lt("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:r=>{const e=r.get(ee);return()=>e.call(Hc.key)}}});F(bf.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});F(bf.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var wf=$l("inlineCode");F(wf,{displayName:"Attr<inlineCode>",group:"InlineCode"});var hn=Os("inlineCode",r=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",r.get(wf.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));F(hn.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});F(hn.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var _c=le("ToggleInlineCode",r=>()=>(e,t)=>{const{selection:n,tr:i}=e;if(n.empty)return!1;const{from:o,to:s}=n;return e.doc.rangeHasMark(o,s,hn.type(r))?(t==null||t(i.removeMark(o,s,hn.type(r))),!0):(Object.keys(e.schema.marks).filter(a=>a!==hn.type.name).map(a=>e.schema.marks[a]).forEach(a=>{i.removeMark(o,s,a)}),t==null||t(i.addMark(o,s,hn.type(r).create())),!0)});F(_c,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var l3=mt(r=>jl(/(?:`)([^`]+)(?:`)$/,hn.type(r)));F(l3,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var xf=Lt("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:r=>{const e=r.get(ee);return()=>e.call(_c.key)}}});F(xf.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});F(xf.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Wx=new Set(["http:","https:","mailto:","tel:","ftp:"]);function Ux(r){return r<=32||r>=127&&r<=160||r>=8203&&r<=8205||r===8232||r===8233||r===65279}function Kx(r){let e="";for(const t of r)Ux(t.codePointAt(0)??0)||(e+=t);return e}function Gx(r){var i;if(typeof r!="string")return"";const e=r.trim();if(!e)return"";const t=Kx(e),n=(i=/^([a-z][a-z0-9+.-]*):/i.exec(t))==null?void 0:i[1];return!n||Wx.has(`${n.toLowerCase()}:`)?e:""}var kf=$l("link");F(kf,{displayName:"Attr<link>",group:"Link"});var Cr=Os("link",r=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...r.get(kf.key)(e),...e.attrs,href:Gx(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,n)=>{const i=t.url,o=t.title;e.openMark(n,{href:i,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));F(Cr.mark,{displayName:"MarkSchema<link>",group:"Link"});var c3=le("ToggleLink",r=>(e={})=>zc(Cr.type(r),e));F(c3,{displayName:"Command<toggleLinkCommand>",group:"Link"});var u3=le("UpdateLink",r=>(e={})=>(t,n)=>{if(!n)return!1;let i,o=-1;const{selection:s}=t,{from:a,to:l}=s;if(t.doc.nodesBetween(a,a===l?l+1:l,(m,y)=>{if(Cr.type(r).isInSet(m.marks))return i=m,o=y,!1}),!i)return!1;const c=i.marks.find(({type:m})=>m===Cr.type(r));if(!c)return!1;const u=o,d=o+i.nodeSize,{tr:h}=t,f=Cr.type(r).create({...c.attrs,...e});return f?(n(h.removeMark(u,d,c).addMark(u,d,f).setSelection(new Q(h.selection.$anchor)).scrollIntoView()),!0):!1});F(u3,{displayName:"Command<updateLinkCommand>",group:"Link"});var d3=ff("doc",()=>({content:"block+",parseMarkdown:{match:({type:r})=>r==="root",runner:(r,e,t)=>{r.injectRoot(e,t)}},toMarkdown:{match:r=>r.type.name==="doc",runner:(r,e)=>{r.openNode("root"),r.next(e.content)}}}));F(d3,{displayName:"NodeSchema<doc>",group:"Doc"});function Yx(r){return Wy(r,e=>{var t;return e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((t=e.value)==null?void 0:t.trim())},(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1)},!0)}var Ss=dr("remark-preserve-empty-line",()=>()=>Yx);F(Ss.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});F(Ss.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Sf=Mr("paragraph");F(Sf,{displayName:"Attr<paragraph>",group:"Paragraph"});var cr=je("paragraph",r=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",r.get(Sf.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{var i;const n=(i=r.get(ge).state)==null?void 0:i.doc.lastChild;e.openNode("paragraph"),(!t.content||t.content.size===0)&&t!==n&&Jx(r)?e.addNode("html",void 0,"<br />"):i3(e,t),e.closeNode()}}}));function Jx(r){let e=!1;try{r.get(Ss.id),e=!0}catch{e=!1}return e}F(cr.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});F(cr.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Cf=le("TurnIntoText",r=>()=>Ia(cr.type(r)));F(Cf,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Mf=Lt("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:r=>{const e=r.get(ee);return()=>e.call(Cf.key)}}});F(Mf.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});F(Mf.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var Xx=Array(6).fill(0).map((r,e)=>e+1);function Zx(r){return r.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var qc=ye(Zx,"headingIdGenerator");F(qc,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Tf=Mr("heading");F(Tf,{displayName:"Attr<heading>",group:"Heading"});var ii=je("heading",r=>{const e=r.get(qc.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Xx.map(t=>({tag:`h${t}`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw Vr(n);return{level:t,id:n.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...r.get(Tf.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,n,i)=>{const o=n.depth;t.openNode(i,{level:o}),t.next(n.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,n)=>{t.openNode("heading",void 0,{depth:n.attrs.level}),i3(t,n),t.closeNode()}}}});F(ii.node,{displayName:"NodeSchema<heading>",group:"Heading"});F(ii.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var h3=mt(r=>df(/^(?<hashes>#+)\s$/,ii.type(r),e=>{var o,s;const t=((s=(o=e.groups)==null?void 0:o.hashes)==null?void 0:s.length)||0,{$from:n}=r.get(ge).state.selection,i=n.node();if(i.type.name==="heading"){let a=Number(i.attrs.level)+Number(t);return a>6&&(a=6),{level:a}}return{level:t}}));F(h3,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var In=le("WrapInHeading",r=>e=>(e??(e=1),e<1?Ia(cr.type(r)):Ia(ii.type(r),{level:e})));F(In,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Af=le("DowngradeHeading",r=>()=>(e,t,n)=>{const{$from:i}=e.selection,o=i.node();if(o.type!==ii.type(r)||!e.selection.empty||i.parentOffset!==0)return!1;const s=o.attrs.level-1;return s?(t==null||t(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Ia(cr.type(r))(e,t,n)});F(Af,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Nf=Lt("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:r=>{const e=r.get(ee);return()=>e.call(In.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:r=>{const e=r.get(ee);return()=>e.call(In.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:r=>{const e=r.get(ee);return()=>e.call(In.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:r=>{const e=r.get(ee);return()=>e.call(In.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:r=>{const e=r.get(ee);return()=>e.call(In.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:r=>{const e=r.get(ee);return()=>e.call(In.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:r=>{const e=r.get(ee);return()=>e.call(Af.key)}}});F(Nf.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});F(Nf.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Ef=Mr("blockquote");F(Ef,{displayName:"Attr<blockquote>",group:"Blockquote"});var zs=je("blockquote",r=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",r.get(Ef.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));F(zs.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});F(zs.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var f3=mt(r=>uf(/^\s*>\s$/,zs.type(r)));F(f3,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Df=le("WrapInBlockquote",r=>()=>cf(zs.type(r)));F(Df,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Of=Lt("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:r=>{const e=r.get(ee);return()=>e.call(Df.key)}}});F(Of.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});F(Of.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Rf=Mr("codeBlock",()=>({pre:{},code:{}}));F(Rf,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var $r=je("code_block",r=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{language:e.dataset.language}}}],toDOM:e=>{const t=r.get(Rf.key)(e),n=e.attrs.language,i=n&&n.length>0?{"data-language":n}:void 0;return["pre",{...t.pre,...i},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,n)=>{const i=t.lang??"",o=t.value;e.openNode(n,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{var n;e.addNode("code",void 0,((n=t.content.firstChild)==null?void 0:n.text)||"",{lang:t.attrs.language})}}}));F($r.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});F($r.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var p3=mt(r=>df(/^```(?<language>[a-z]*)?[\s\n]$/,$r.type(r),e=>{var t;return{language:((t=e.groups)==null?void 0:t.language)??""}}));F(p3,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var If=le("CreateCodeBlock",r=>(e="")=>Ia($r.type(r),{language:e}));F(If,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var Qx=le("UpdateCodeBlockLanguage",()=>({pos:r,language:e}={pos:-1,language:""})=>(t,n)=>r>=0?(n==null||n(t.tr.setNodeAttribute(r,"language",e)),!0):!1);F(Qx,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var zf=Lt("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:r=>{const e=r.get(ee);return()=>e.call(If.key)}}});F(zf.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});F(zf.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Lf=Mr("image");F(Lf,{displayName:"Attr<image>",group:"Image"});var ro=je("image",r=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...r.get(Lf.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,n)=>{const i=t.url,o=t.alt,s=t.title;e.addNode(n,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));F(ro.node,{displayName:"NodeSchema<image>",group:"Image"});F(ro.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var m3=le("InsertImage",r=>(e={})=>(t,n)=>{if(!n)return!0;const{src:i="",alt:o="",title:s=""}=e,a=ro.type(r).create({src:i,alt:o,title:s});return a&&n(t.tr.replaceSelectionWith(a).scrollIntoView()),!0});F(m3,{displayName:"Command<insertImageCommand>",group:"Image"});var g3=le("UpdateImage",r=>(e={})=>(t,n)=>{const i=h9(t.selection,ro.type(r));if(!i)return!1;const{node:o,pos:s}=i,a={...o.attrs},{src:l,alt:c,title:u}=e;return l!==void 0&&(a.src=l),c!==void 0&&(a.alt=c),u!==void 0&&(a.title=u),n==null||n(t.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});F(g3,{displayName:"Command<updateImageCommand>",group:"Image"});var ek=mt(r=>new zt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,n,i)=>{const[o,s,a="",l]=t;return o?e.tr.replaceWith(n,i,ro.type(r).create({src:a,alt:s,title:l})):null}));F(ek,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var cc=Mr("hardbreak",r=>({"data-type":"hardbreak","data-is-inline":r.attrs.isInline}));F(cc,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var ji=je("hardbreak",r=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",r.get(cc.key)(e)," "]:["br",r.get(cc.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,n)=>{var i;e.addNode(n,{isInline:!!((i=t.data)!=null&&i.isInline)})}},leafText:()=>`
32
32
  `,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,`
33
- `):e.addNode("break")}}}));F($i.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});F($i.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Bf=le("InsertHardbreak",r=>()=>(e,t)=>{var o;const{selection:n,tr:i}=e;if(!(n instanceof Q))return!1;if(n.empty){const s=n.$from.node();if(s.childCount>0&&((o=s.lastChild)==null?void 0:o.type.name)==="hardbreak")return t==null||t(i.replaceRangeWith(n.to-1,n.to,e.schema.node("paragraph")).setSelection(ue.near(i.doc.resolve(n.to))).scrollIntoView()),!0}return t==null||t(i.setMeta("hardbreak",!0).replaceSelectionWith($i.type(r).create()).scrollIntoView()),!0});F(Bf,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Pf=Lt("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:r=>{const e=r.get(ee);return()=>e.call(Bf.key)}}});F(Pf.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});F(Pf.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Ff=Mr("hr");F(Ff,{displayName:"Attr<hr>",group:"Hr"});var Ls=$e("hr",r=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",r.get(Ff.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));F(Ls.node,{displayName:"NodeSchema<hr>",group:"Hr"});F(Ls.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var y3=mt(r=>new zt(/^(?:---|___\s|\*\*\*\s)$/,(e,t,n,i)=>{const{tr:o}=e;return t[0]&&o.replaceWith(n-1,i,Ls.type(r).create()),o}));F(y3,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var v3=le("InsertHr",r=>()=>(e,t)=>{if(!t)return!0;const n=cr.node.type(r).create(),{tr:i,selection:o}=e,{from:s}=o,a=Ls.type(r).create();if(!a)return!0;const l=i.replaceSelectionWith(a).insert(s,n),c=ue.findFrom(l.doc.resolve(s),1,!0);return c&&t(l.setSelection(c).scrollIntoView()),!0});F(v3,{displayName:"Command<insertHrCommand>",group:"Hr"});var Hf=Mr("bulletList");F(Hf,{displayName:"Attr<bulletList>",group:"BulletList"});var no=$e("bullet_list",r=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...r.get(Hf.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,n)=>{const i=t.spread??!1;e.openNode(n,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));F(no.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});F(no.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var b3=mt(r=>uf(/^\s*([-+*])\s$/,no.type(r)));F(b3,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var _f=le("WrapInBulletList",r=>()=>cf(no.type(r)));F(_f,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var qf=Lt("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:r=>{const e=r.get(ee);return()=>e.call(_f.key)}}});F(qf.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});F(qf.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var $f=Mr("orderedList");F($f,{displayName:"Attr<orderedList>",group:"OrderedList"});var oi=$e("ordered_list",r=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...r.get($f.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,n)=>{const i=t.spread??!0;e.openNode(n,{spread:i,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));F(oi.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});F(oi.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var w3=mt(r=>uf(/^\s*(\d+)\.\s$/,oi.type(r),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));F(w3,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var jf=le("WrapInOrderedList",r=>()=>cf(oi.type(r)));F(jf,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Vf=Lt("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:r=>{const e=r.get(ee);return()=>e.call(jf.key)}}});F(Vf.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});F(Vf.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Wf=Mr("listItem");F(Wf,{displayName:"Attr<listItem>",group:"ListItem"});var fr=$e("list_item",r=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...r.get(Wf.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,n)=>{const i=t.label!=null?`${t.label}.`:"•",o=t.label!=null?"ordered":"bullet",s=t.spread??!0;e.openNode(n,{label:i,listType:o,spread:s}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));F(fr.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});F(fr.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Uf=le("SinkListItem",r=>()=>$x(fr.type(r)));F(Uf,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Kf=le("LiftListItem",r=>()=>Hx(fr.type(r)));F(Kf,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Gf=le("SplitListItem",r=>()=>Fx(fr.type(r)));F(Gf,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function tk(r){return(e,t,n)=>{const{selection:i}=e;if(!(i instanceof Q))return!1;const{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==fr.type(r)?!1:f5(e,t,n)}}var Yf=le("LiftFirstListItem",r=>()=>tk(r));F(Yf,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Jf=Lt("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:r=>{const e=r.get(ee);return()=>e.call(Gf.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:r=>{const e=r.get(ee);return()=>e.call(Uf.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:r=>{const e=r.get(ee);return()=>e.call(Kf.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:r=>{const e=r.get(ee);return()=>e.call(Yf.key)}}});F(Jf.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});F(Jf.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var x3=ff("text",()=>({group:"inline",parseMarkdown:{match:({type:r})=>r==="text",runner:(r,e)=>{r.addText(e.value)}},toMarkdown:{match:r=>r.type.name==="text",runner:(r,e)=>{r.addNode("text",void 0,e.text)}}}));F(x3,{displayName:"NodeSchema<text>",group:"Text"});var Xf=Mr("html");F(Xf,{displayName:"Attr<html>",group:"Html"});var Zf=$e("html",r=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const t=document.createElement("span"),n={...r.get(Xf.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",n,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));F(Zf.node,{displayName:"NodeSchema<html>",group:"Html"});F(Zf.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var rk=[d3,Sf,cr,qc,Tf,ii,cc,$i,Ef,zs,Rf,jr,Ff,Ls,Lf,ro,Hf,no,$f,oi,Wf,fr,gf,to,vf,Is,wf,hn,kf,Cr,Xf,Zf,x3].flat(),nk=[f3,b3,w3,p3,y3,h3].flat(),ik=[o3,s3,l3,a3],Mo=le("IsMarkSelected",()=>r=>e=>{if(!r)return!1;const{doc:t,selection:n}=e;return t.rangeHasMark(n.from,n.to,r)}),ok=le("IsNoteSelected",()=>r=>e=>r?D5(e,r).hasNode:!1),Qt=le("ClearTextInCurrentBlock",()=>()=>(r,e)=>{let t=r.tr;const{$from:n,$to:i}=t.selection,{pos:o}=n,{pos:s}=i,a=o-n.node().content.size;return a<0?!1:(t=t.deleteRange(a,s),e==null||e(t),!0)}),J0=le("SetBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const o=e.tr,{from:s,to:a}=o.selection;try{o.setBlockType(s,a,n,i)}catch{return!1}return t==null||t(o),!0}),sa=le("WrapInBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;let o=e.tr;try{const{$from:s,$to:a}=o.selection,l=s.blockRange(a),c=l&&Gh(l,n,i);if(!c)return!1;o=o.wrap(l,c)}catch{return!1}return t==null||t(o),!0}),aa=le("AddBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const o=e.tr;try{const s=n instanceof mn?n:n.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t==null||t(o),!0}),k3=le("SelectTextNearPos",()=>r=>(e,t)=>{const{pos:n}=r??{};if(n==null)return!1;const i=(s,a,l)=>Math.min(Math.max(s,a),l),o=e.tr;try{const s=e.doc.resolve(i(n,0,e.doc.content.size));o.setSelection(Q.near(s))}catch{return!1}return t==null||t(o.scrollIntoView()),!0}),sk=[Cf,Df,In,Af,If,Bf,v3,m3,g3,jf,_f,Uf,Gf,Kf,Yf,Fc,_c,Hc,c3,u3,Mo,ok,Qt,J0,sa,aa,k3],ak=[Of,zf,Pf,Nf,Jf,Vf,qf,Mf,yf,xf,bf].flat(),Qf=dr("remarkAddOrderInList",()=>()=>r=>{Qi(r,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((n,i)=>{n.label=i+t})}})});F(Qf.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});F(Qf.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var ep=dr("remarkLineBreak",()=>()=>r=>{const e=/[\t ]*(?:\r?\n|\r)/g;Qi(r,"text",(t,n,i)=>{if(!t.value||typeof t.value!="string")return;const o=[];let s=0;e.lastIndex=0;let a=e.exec(t.value);for(;a;){const l=a.index;s!==l&&o.push({type:"text",value:t.value.slice(s,l)}),o.push({type:"break",data:{isInline:!0}}),s=l+a[0].length,a=e.exec(t.value)}if(o.length>0&&i&&typeof n=="number")return s<t.value.length&&o.push({type:"text",value:t.value.slice(s)}),i.children.splice(n,1,...o),n+o.length})});F(ep.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});F(ep.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var tp=dr("remarkInlineLink",()=>Vx);F(tp.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});F(tp.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var lk=r=>!!r.children,ck=r=>r.type==="html";function uk(r,e){return t(r,0,null)[0];function t(n,i,o){if(lk(n)){const s=[];for(let a=0,l=n.children.length;a<l;a++){const c=n.children[a];if(c){const u=t(c,a,n);if(u)for(let d=0,h=u.length;d<h;d++){const f=u[d];f&&s.push(f)}}}n.children=s}return e(n,i,o)}}var dk=["root","blockquote","listItem"],rp=dr("remarkHTMLTransformer",()=>()=>r=>{uk(r,(e,t,n)=>ck(e)?(n&&dk.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});F(rp.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});F(rp.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var np=dr("remarkMarker",()=>()=>(r,e)=>{const t=n=>e.value.charAt(n.position.start.offset);Qi(r,n=>["strong","emphasis"].includes(n.type),n=>{n.marker=t(n)})});F(np.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});F(np.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var S3=Fe(()=>{let r=!1;const e=new Me("MILKDOWN_INLINE_NODES_CURSOR"),t=new Ce({key:e,state:{init(){return!1},apply(n){if(!n.selection.empty)return!1;const i=n.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(n,i)=>r?(r=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const o=n.state.selection.from;i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",o))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(r=!0),!1),beforeinput:(n,i)=>{if(t.getState(n.state)&&i instanceof InputEvent&&i.data&&!r){const o=n.state.selection.from;return i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",o)),!0}return!1}},decorations(n){if(t.getState(n)){const i=n.selection.$from.pos,o=document.createElement("span"),s=qe.widget(i,o,{side:-1}),a=document.createElement("span"),l=qe.widget(i,a);return setTimeout(()=>{o.contentEditable="true",a.contentEditable="true"}),Se.create(n.doc,[s,l])}return Se.empty}}});return t});F(S3,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var C3=Fe(r=>new Ce({key:new Me("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,n)=>{if(!e.length)return;const[i]=e;if(!i)return;const[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof Ke))return;const{from:s}=o;return n.tr.setNodeMarkup(s,$i.type(r),void 0,[])}if(o instanceof cn){let s=n.tr;const{from:a,to:l}=o;return n.doc.nodesBetween(a,l,(c,u)=>{c.type===$i.type(r)&&(s=s.setNodeMarkup(u,$i.type(r),void 0,[]))}),s}}}));F(C3,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ip=ye(["table","code_block"],"hardbreakFilterNodes");F(ip,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var M3=Fe(r=>{const e=r.get(ip.key);return new Ce({key:new Me("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,n)=>{const i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){const{from:s}=o,a=n.doc.resolve(s);let l=a.depth,c=!0;for(;l>0;)e.includes(a.node(l).type.name)&&(c=!1),l--;return c}return!0}})});F(M3,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var T3=Fe(r=>{const e=new Me("MILKDOWN_HEADING_ID"),t=n=>{if(n.composing)return;const i=r.get(qc.key),o=n.state.tr.setMeta("addToHistory",!1);let s=!1;const a={};n.state.doc.descendants((l,c)=>{if(l.type===ii.type(r)){if(l.textContent.trim().length===0)return;const u=l.attrs;let d=i(l);a[d]?(a[d]+=1,d+=`-#${a[d]}`):a[d]=1,u.id!==d&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:d}))}}),s&&n.dispatch(o)};return new Ce({key:e,view:n=>(t(n),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});F(T3,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var A3=Fe(r=>{const e=(t,n,i)=>{if(!i.selection||t.some(d=>d.getMeta("addToHistory")===!1||!d.isGeneric))return null;const o=oi.type(r),s=no.type(r),a=fr.type(r),l=(d,h,f=1)=>{let m=!1;const y=`${h+f}.`;return d.label!==y&&(d.label=y,m=!0),m};let c=i.tr,u=!1;return i.doc.descendants((d,h,f,m)=>{if(d.type===s){const y=d.maybeChild(0);(y==null?void 0:y.type)===a&&y.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(h,o,{spread:!0}),d.descendants((x,b,S,A)=>{if(x.type===a){const D={...x.attrs};l(D,A)&&(c=c.setNodeMarkup(b,void 0,D))}return!1}))}else if(d.type===a&&(f==null?void 0:f.type)===o){const y={...d.attrs};let x=!1;y.listType!=="ordered"&&(y.listType="ordered",x=!0),f!=null&&f.maybeChild(0)&&(x=l(y,m,(f==null?void 0:f.attrs.order)??1)),x&&(c=c.setNodeMarkup(h,void 0,y),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new Ce({key:new Me("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});F(A3,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var hk=[C3,ip,M3,S3,Qf,tp,ep,rp,np,Ss,T3,A3].flat(),fk=[rk,nk,ik,sk,ak,hk].flat(),uc=typeof navigator<"u"?navigator:null,op=uc&&uc.userAgent||"",pk=/Edge\/(\d+)/.exec(op),mk=/MSIE \d/.exec(op),gk=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(op),yk=!!(mk||gk||pk),vk=!yk&&!!uc&&/Apple Computer/.test(uc.vendor),N3=new Me("safari-ime-span"),ch=!1,bk={key:N3,props:{decorations:wk,handleDOMEvents:{compositionstart:()=>{ch=!0},compositionend:()=>{ch=!1}}}};function wk(r){const{$from:e,$to:t,to:n}=r.selection;if(ch&&e.sameParent(t)){const i=qe.widget(n,xk,{ignoreSelection:!0,key:"safari-ime-span"});return Se.create(r.doc,[i])}}function xk(r){const e=r.dom.ownerDocument.createElement("span");return e.className="ProseMirror-safari-ime-span",e}var kk=new Ce(vk?bk:{key:N3});function oe(r,e){return Object.assign(r,{meta:{package:"@milkdown/preset-gfm",...e}}),r}var sp=jl("strike_through");oe(sp,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var Bs=Os("strike_through",r=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",r.get(sp.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,t)=>{e.withMark(t,"delete")}}}));oe(Bs.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});oe(Bs.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var $c=le("ToggleStrikeThrough",r=>()=>zc(Bs.type(r)));oe($c,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var E3=mt(r=>$l(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)$"),Bs.type(r)));oe(E3,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var ap=Lt("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:r=>{const e=r.get(ee);return()=>e.call($c.key)}}});oe(ap.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});oe(ap.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});var Vl=$9({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:r=>r.style.textAlign||"left",setDOMAttr:(r,e)=>{e.style=`text-align: ${r||"left"}`}}}}),Hr=$e("table",()=>({...Vl.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="table",runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n,isHeader:s===0}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table",runner:(r,e)=>{var i;const t=(i=e.content.firstChild)==null?void 0:i.content;if(!t)return;const n=[];t.forEach(o=>{n.push(o.attrs.alignment)}),r.openNode("table",void 0,{align:n}),r.next(e.content),r.closeNode()}}}));oe(Hr.node,{displayName:"NodeSchema<table>",group:"Table"});oe(Hr.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var Wl=$e("table_header_row",()=>({...Vl.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:r=>r instanceof HTMLElement&&r.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:r=>!!(r.type==="tableRow"&&r.isHeader),runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n[s],isHeader:e.isHeader}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_header_row",runner:(r,e)=>{e.content.size!==0&&(r.openNode("tableRow",void 0,{isHeader:!0}),r.next(e.content),r.closeNode())}}}));oe(Wl.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});oe(Wl.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var Ps=$e("table_row",()=>({...Vl.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:r=>r.type==="tableRow",runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n[s]}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_row",runner:(r,e)=>{e.content.size!==0&&(r.openNode("tableRow"),r.next(e.content),r.closeNode())}}}));oe(Ps.node,{displayName:"NodeSchema<tableRow>",group:"Table"});oe(Ps.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var Ul=$e("table_cell",()=>({...Vl.table_cell,disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="tableCell"&&!r.isHeader,runner:(r,e,t)=>{const n=e.align;r.openNode(t,{alignment:n}).openNode(r.schema.nodes.paragraph).next(e.children).closeNode().closeNode()}},toMarkdown:{match:r=>r.type.name==="table_cell",runner:(r,e)=>{r.openNode("tableCell").next(e.content).closeNode()}}}));oe(Ul.node,{displayName:"NodeSchema<tableCell>",group:"Table"});oe(Ul.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var Cs=$e("table_header",()=>({...Vl.table_header,disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="tableCell"&&!!r.isHeader,runner:(r,e,t)=>{const n=e.align;r.openNode(t,{alignment:n}),r.openNode(r.schema.nodes.paragraph),r.next(e.children),r.closeNode(),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_header",runner:(r,e)=>{r.openNode("tableCell"),r.next(e.content),r.closeNode()}}}));oe(Cs.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});oe(Cs.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function lp(r,e=3,t=3){const n=Array(t).fill(0).map(()=>Ul.type(r).createAndFill()),i=Array(t).fill(0).map(()=>Cs.type(r).createAndFill()),o=Array(e).fill(0).map((s,a)=>a===0?Wl.type(r).create(null,i):Ps.type(r).create(null,n));return Hr.type(r).create(null,o)}function D3(r){return(e,t)=>n=>{t=t??n.selection.from;const i=n.doc.resolve(t),o=E5(l=>l.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,a=r==="row";if(s){const l=xe.get(s.node);if(e>=0&&e<(a?l.height:l.width)){const c=l.positionAt(a?e:l.height-1,a?l.width-1:e,s.node),u=n.doc.resolve(s.from+c),d=a?Ae.rowSelection:Ae.colSelection,h=l.positionAt(a?e:0,a?0:e,s.node),f=n.doc.resolve(s.from+h);return N5(n.setSelection(d(u,f)))}}return n}}var Sk=D3("row"),Ck=D3("col");function O3(r,e,{map:t,tableStart:n,table:i},o){const s=Array(o).fill(0).reduce((l,c,u)=>l+i.child(u).nodeSize,n),a=Array(t.width).fill(0).map((l,c)=>{const u=i.nodeAt(t.map[c]);return Ul.type(r).createAndFill({alignment:u==null?void 0:u.attrs.alignment})});return e.insert(s,Ps.type(r).create(null,a)),e}function Mk(r){const e=Rs(r.$from);if(!e)return;const t=xe.get(e.node);return t.cellsInRect({left:0,right:t.width,top:0,bottom:t.height}).map(n=>{const i=e.node.nodeAt(n),o=n+e.start;return{pos:o,start:o+1,node:i}})}function Tk(r){const e=Mk(r.selection);if(e&&e[0]){const t=r.doc.resolve(e[0].pos),n=e[e.length-1];if(n){const i=r.doc.resolve(n.pos);return N5(r.setSelection(new Ae(i,t)))}}return r}var cp=le("GoToPrevTableCell",()=>()=>t3(-1));oe(cp,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var up=le("GoToNextTableCell",()=>()=>t3(1));oe(up,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var dp=le("ExitTable",r=>()=>(e,t)=>{if(!hr(e))return!1;const{$head:n}=e.selection,i=c9(n,Hr.type(r));if(!i)return!1;const{to:o}=i,s=e.tr.replaceWith(o,o,cr.type(r).createAndFill());return s.setSelection(ue.near(s.doc.resolve(o),1)).scrollIntoView(),t==null||t(s),!0});oe(dp,{displayName:"Command<breakTableCommand>",group:"Table"});var R3=le("InsertTable",r=>({row:e,col:t}={})=>(n,i)=>{const{selection:o,tr:s}=n,{from:a}=o,l=lp(r,e,t),c=s.replaceSelectionWith(l),u=ue.findFrom(c.doc.resolve(a),1,!0);return u&&c.setSelection(u),i==null||i(c),!0});oe(R3,{displayName:"Command<insertTableCommand>",group:"Table"});var jc=le("MoveRow",()=>({from:r,to:e,pos:t}={})=>gx({from:r??0,to:e??0,pos:t}));oe(jc,{displayName:"Command<moveRowCommand>",group:"Table"});var Vc=le("MoveCol",()=>({from:r,to:e,pos:t}={})=>yx({from:r??0,to:e??0,pos:t}));oe(Vc,{displayName:"Command<moveColCommand>",group:"Table"});var fn=le("SelectRow",()=>(r={index:0})=>(e,t)=>{const{tr:n}=e;return!!(t==null?void 0:t(Sk(r.index,r.pos)(n)))});oe(fn,{displayName:"Command<selectRowCommand>",group:"Table"});var pn=le("SelectCol",()=>(r={index:0})=>(e,t)=>{const{tr:n}=e;return!!(t==null?void 0:t(Ck(r.index,r.pos)(n)))});oe(pn,{displayName:"Command<selectColCommand>",group:"Table"});var I3=le("SelectTable",()=>()=>(r,e)=>{const{tr:t}=r;return!!(e==null?void 0:e(Tk(t)))});oe(I3,{displayName:"Command<selectTableCommand>",group:"Table"});var _a=le("DeleteSelectedCells",()=>()=>(r,e)=>{const{selection:t}=r;if(!(t instanceof Ae))return!1;const n=t.isRowSelection(),i=t.isColSelection();return n&&i?mx(r,e):i?cx(r,e):dx(r,e)});oe(_a,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var hp=le("AddColBefore",()=>()=>sx);oe(hp,{displayName:"Command<addColBeforeCommand>",group:"Table"});var Wc=le("AddColAfter",()=>()=>ax);oe(Wc,{displayName:"Command<addColAfterCommand>",group:"Table"});var fp=le("AddRowBefore",r=>()=>(e,t)=>{if(!hr(e))return!1;if(t){const n=ni(e);t(O3(r,e.tr,n,n.top))}return!0});oe(fp,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var Uc=le("AddRowAfter",r=>()=>(e,t)=>{if(!hr(e))return!1;if(t){const n=ni(e);t(O3(r,e.tr,n,n.bottom))}return!0});oe(Uc,{displayName:"Command<addRowAfterCommand>",group:"Table"});var pp=le("SetAlign",()=>(r="left")=>hx("alignment",r));oe(pp,{displayName:"Command<setAlignCommand>",group:"Table"});var z3=mt(r=>new zt(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,t,n,i)=>{var l,c;const o=e.doc.resolve(n);if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),Hr.type(r)))return null;const s=lp(r,Math.max(Number(((l=t.groups)==null?void 0:l.row)??0),2),Number((c=t.groups)==null?void 0:c.col)),a=e.tr.replaceRangeWith(n,i,s);return a.setSelection(Q.create(a.doc,n+3)).scrollIntoView()}));oe(z3,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var L3=z9(r=>({run:(e,t,n)=>{if(n)return e;function i(c){var x;const u=c.childCount,d=((x=c.lastChild)==null?void 0:x.childCount)??0;if(u===0||d===0)return cr.type(r).create();const h=c.firstChild;if(!(d>0&&h&&h.childCount===0))return c;if(u>=3){const b=c.child(1),S=[];for(let O=0;O<b.childCount;O++){const L=b.child(O);S.push(Cs.type(r).create(L.attrs,L.content,L.marks))}const A=h.type.create(h.attrs,S),D=[];for(let O=2;O<u;O++)D.push(c.child(O));return c.type.create(c.attrs,[A,...D])}const f=Array(d).fill(0).map(()=>Cs.type(r).createAndFill()),m=new Y(H.from(f),0,0),y=h.replace(0,0,m);return c.replace(0,h.nodeSize,new Y(H.from(y),0,0))}function o(c){const u=Ps.type(r),d=[];let h=[],f=!1;function m(){if(h.length===0)return;const y=Wl.type(r).createAndFill(),x=Hr.type(r).create(null,[y,...h]);d.push(i(x)),h=[]}return c.forEach(y=>{y.type===u?(f=!0,h.push(y)):(m(),d.push(y))}),m(),f?H.from(d):c}function s(c){let u=o(c),d=u!==c;const h=[];return u.forEach(f=>{if(f.type===Hr.type(r)){const m=i(f);m!==f&&(d=!0),h.push(m)}else if(f.childCount>0){const m=s(f.content);m!==f.content?(d=!0,h.push(f.copy(m))):h.push(f)}else h.push(f)}),d?H.from(h):c}function a(c){const u=[],d=[];c.forEach(h=>d.push(h));for(let h=0;h<d.length;h++){const f=d[h],m=d[h+1];f.type===cr.type(r)&&f.content.size===0&&m&&m.type===Hr.type(r)||u.push(f)}return u.length<d.length?H.from(u):c}let l=s(e.content);return l=a(l),new Y(H.from(l),e.openStart,e.openEnd)}}));oe(L3,{displayName:"PasteRule<table>",group:"Table"});var mp=Lt("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:r=>{const e=r.get(ee);return()=>e.call(up.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:r=>{const e=r.get(ee);return()=>e.call(cp.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:r=>{const e=r.get(ee);return()=>e.call(dp.key)}}});oe(mp.ctx,{displayName:"KeymapCtx<table>",group:"Table"});oe(mp.shortcuts,{displayName:"Keymap<table>",group:"Table"});var ed="footnote_definition",J1="footnoteDefinition",gp=$e("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${ed}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Vr(r);return{label:r.dataset.label}},contentElement:"dd"}],toDOM:r=>{const e=r.attrs.label;return["dl",{"data-label":e,"data-type":ed},["dt",e],["dd",0]]},parseMarkdown:{match:({type:r})=>r===J1,runner:(r,e,t)=>{r.openNode(t,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:r=>r.type.name===ed,runner:(r,e)=>{r.openNode(J1,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));oe(gp.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});oe(gp.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var td="footnote_reference",yp=$e("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${td}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Vr(r);return{label:r.dataset.label}}}],toDOM:r=>{const e=r.attrs.label;return["sup",{"data-label":e,"data-type":td},e]},parseMarkdown:{match:({type:r})=>r==="footnoteReference",runner:(r,e,t)=>{r.addNode(t,{label:e.label})}},toMarkdown:{match:r=>r.type.name===td,runner:(r,e)=>{r.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));oe(yp.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});oe(yp.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var vp=fr.extendSchema(r=>e=>{const t=r(e);return{...t,attrs:{...t.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:n=>{if(!(n instanceof HTMLElement))throw Vr(n);return{label:n.dataset.label,listType:n.dataset.listType,spread:n.dataset.spread==="true",checked:n.dataset.checked?n.dataset.checked==="true":null}}},...(t==null?void 0:t.parseDOM)||[]],toDOM:n=>t.toDOM&&n.attrs.checked==null?t.toDOM(n):["li",{"data-item-type":"task","data-label":n.attrs.label,"data-list-type":n.attrs.listType,"data-spread":n.attrs.spread,"data-checked":n.attrs.checked},0],parseMarkdown:{match:({type:n})=>n==="listItem",runner:(n,i,o)=>{if(i.checked==null){t.parseMarkdown.runner(n,i,o);return}const s=i.label!=null?`${i.label}.`:"•",a=i.checked!=null?!!i.checked:null,l=i.label!=null?"ordered":"bullet",c=i.spread??!0;n.openNode(o,{label:s,listType:l,spread:c,checked:a}),n.next(i.children),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="list_item",runner:(n,i)=>{if(i.attrs.checked==null){t.toMarkdown.runner(n,i);return}const o=i.attrs.label,s=i.attrs.listType,a=i.attrs.spread,l=i.attrs.checked;n.openNode("listItem",void 0,{label:o,listType:s,spread:a,checked:l}),n.next(i.content),n.closeNode()}}}});oe(vp.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});oe(vp.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var B3=mt(()=>new zt(/^\[(?<checked>\s|x)\]\s$/,(r,e,t,n)=>{var u;const i=r.doc.resolve(t);let o=0,s=i.node(o);for(;s&&s.type.name!=="list_item";)o--,s=i.node(o);if(!s||s.attrs.checked!=null)return null;const a=((u=e.groups)==null?void 0:u.checked)==="x",l=i.before(o),c=r.tr;return c.deleteRange(t,n).setNodeMarkup(l,void 0,{...s.attrs,checked:a}),c}));oe(B3,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var Ak=[ap,mp].flat(),Nk=[z3,B3],Ek=[E3],Dk=[L3],P3=Fe(()=>kk);oe(P3,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var Ok=Fe(()=>Ax({}));oe(Ok,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var F3=Fe(()=>Px({allowTableNodeSelection:!0}));oe(F3,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var bp=dr("remarkGFM",()=>Uy);oe(bp.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});oe(bp.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var Rk=new Me("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function Ik(r,e){let t=0;return e.forEach((n,i,o)=>{n===r&&(t=o)}),t}function zk(r,e){const t=r.content.findDiffStart(e.content);if(t==null)return null;const n=r.content.findDiffEnd(e.content);return n?{from:t,to:Math.max(n.b,t)}:null}var H3=Fe(()=>new Ce({key:Rk,appendTransaction:(r,e,t)=>{if(e.doc===t.doc)return;const n=zk(e.doc,t.doc);if(!n)return;let i;const o=(s,a)=>{if(s.type.name!=="table_cell")return;const l=t.doc.resolve(a),c=l.node(l.depth),u=l.node(l.depth-1).firstChild;if(!u)return;const d=Ik(s,c),h=u.maybeChild(d);if(!h)return;const f=h.attrs.alignment;f!==s.attrs.alignment&&(i||(i=t.tr),i.setNodeMarkup(a,void 0,{...s.attrs,alignment:f}))};return t.doc.nodesBetween(n.from,n.to,(s,a)=>s.type.name!=="table"?!0:(t.doc.nodesBetween(a,a+s.nodeSize,o),!1)),i}}));oe(H3,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var Lk=[H3,P3,bp,F3].flat(),Bk=[vp,Hr,Wl,Ps,Cs,Ul,gp,yp,sp,Bs].flat(),Pk=[up,cp,dp,R3,jc,Vc,fn,pn,I3,_a,fp,Uc,hp,Wc,pp,$c],Fk=[Bk,Nk,Dk,Ek,Ak,Pk,Lk].flat();function uh(r){if(!r)return!1;if(Array.isArray(r))return r.length>1?!1:uh(r[0]);const e=r.content;return e?uh(e):r.type==="text"}function Hk(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-clipboard",...e}}),r}function X1(r,e){const t=l9(e);if(t)return r.dispatch(r.state.tr.replaceSelectionWith(t,!0)),!0;try{return r.dispatch(r.state.tr.replaceSelection(e)),!0}catch{return!1}}var _3=Fe(r=>{const e=r.get(Sr);r.update(Sa,n=>({...n,editable:n.editable??(()=>!0),transformPastedHTML:(i,o)=>{const s=n.transformPastedHTML;return s&&(i=s(i,o)),i.includes("docs-internal-guid")&&(i=i.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,"$1"),i=i.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,"$1")),i}}));const t=new Me("MILKDOWN_CLIPBOARD");return new Ce({key:t,props:{handlePaste:(n,i,o)=>{var m,y,x;const s=r.get(Do),a=(y=(m=n.props).editable)==null?void 0:y.call(m,n.state),{clipboardData:l}=i;if(!a||!l||n.state.selection.$from.node().type.spec.code)return!1;const c=l.getData("text/plain"),u=l.getData("vscode-editor-data");if(u){const b=(x=JSON.parse(u))==null?void 0:x.mode;if(c&&b){const{tr:S}=n.state,A=u9("code_block",e);return S.replaceSelectionWith(A.create({language:b})).setSelection(Q.near(S.doc.resolve(Math.max(0,S.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
33
+ `):e.addNode("break")}}}));F(ji.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});F(ji.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Bf=le("InsertHardbreak",r=>()=>(e,t)=>{var o;const{selection:n,tr:i}=e;if(!(n instanceof Q))return!1;if(n.empty){const s=n.$from.node();if(s.childCount>0&&((o=s.lastChild)==null?void 0:o.type.name)==="hardbreak")return t==null||t(i.replaceRangeWith(n.to-1,n.to,e.schema.node("paragraph")).setSelection(ue.near(i.doc.resolve(n.to))).scrollIntoView()),!0}return t==null||t(i.setMeta("hardbreak",!0).replaceSelectionWith(ji.type(r).create()).scrollIntoView()),!0});F(Bf,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Pf=Lt("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:r=>{const e=r.get(ee);return()=>e.call(Bf.key)}}});F(Pf.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});F(Pf.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Ff=Mr("hr");F(Ff,{displayName:"Attr<hr>",group:"Hr"});var Ls=je("hr",r=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",r.get(Ff.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));F(Ls.node,{displayName:"NodeSchema<hr>",group:"Hr"});F(Ls.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var y3=mt(r=>new zt(/^(?:---|___\s|\*\*\*\s)$/,(e,t,n,i)=>{const{tr:o}=e;return t[0]&&o.replaceWith(n-1,i,Ls.type(r).create()),o}));F(y3,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var v3=le("InsertHr",r=>()=>(e,t)=>{if(!t)return!0;const n=cr.node.type(r).create(),{tr:i,selection:o}=e,{from:s}=o,a=Ls.type(r).create();if(!a)return!0;const l=i.replaceSelectionWith(a).insert(s,n),c=ue.findFrom(l.doc.resolve(s),1,!0);return c&&t(l.setSelection(c).scrollIntoView()),!0});F(v3,{displayName:"Command<insertHrCommand>",group:"Hr"});var Hf=Mr("bulletList");F(Hf,{displayName:"Attr<bulletList>",group:"BulletList"});var no=je("bullet_list",r=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...r.get(Hf.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,n)=>{const i=t.spread??!1;e.openNode(n,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));F(no.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});F(no.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var b3=mt(r=>uf(/^\s*([-+*])\s$/,no.type(r)));F(b3,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var _f=le("WrapInBulletList",r=>()=>cf(no.type(r)));F(_f,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var qf=Lt("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:r=>{const e=r.get(ee);return()=>e.call(_f.key)}}});F(qf.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});F(qf.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var jf=Mr("orderedList");F(jf,{displayName:"Attr<orderedList>",group:"OrderedList"});var oi=je("ordered_list",r=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...r.get(jf.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,n)=>{const i=t.spread??!0;e.openNode(n,{spread:i,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));F(oi.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});F(oi.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var w3=mt(r=>uf(/^\s*(\d+)\.\s$/,oi.type(r),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));F(w3,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var $f=le("WrapInOrderedList",r=>()=>cf(oi.type(r)));F($f,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Vf=Lt("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:r=>{const e=r.get(ee);return()=>e.call($f.key)}}});F(Vf.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});F(Vf.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Wf=Mr("listItem");F(Wf,{displayName:"Attr<listItem>",group:"ListItem"});var fr=je("list_item",r=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Vr(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...r.get(Wf.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,n)=>{const i=t.label!=null?`${t.label}.`:"•",o=t.label!=null?"ordered":"bullet",s=t.spread??!0;e.openNode(n,{label:i,listType:o,spread:s}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));F(fr.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});F(fr.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Uf=le("SinkListItem",r=>()=>jx(fr.type(r)));F(Uf,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Kf=le("LiftListItem",r=>()=>Hx(fr.type(r)));F(Kf,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Gf=le("SplitListItem",r=>()=>Fx(fr.type(r)));F(Gf,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function tk(r){return(e,t,n)=>{const{selection:i}=e;if(!(i instanceof Q))return!1;const{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==fr.type(r)?!1:f5(e,t,n)}}var Yf=le("LiftFirstListItem",r=>()=>tk(r));F(Yf,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Jf=Lt("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:r=>{const e=r.get(ee);return()=>e.call(Gf.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:r=>{const e=r.get(ee);return()=>e.call(Uf.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:r=>{const e=r.get(ee);return()=>e.call(Kf.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:r=>{const e=r.get(ee);return()=>e.call(Yf.key)}}});F(Jf.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});F(Jf.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var x3=ff("text",()=>({group:"inline",parseMarkdown:{match:({type:r})=>r==="text",runner:(r,e)=>{r.addText(e.value)}},toMarkdown:{match:r=>r.type.name==="text",runner:(r,e)=>{r.addNode("text",void 0,e.text)}}}));F(x3,{displayName:"NodeSchema<text>",group:"Text"});var Xf=Mr("html");F(Xf,{displayName:"Attr<html>",group:"Html"});var Zf=je("html",r=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const t=document.createElement("span"),n={...r.get(Xf.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",n,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));F(Zf.node,{displayName:"NodeSchema<html>",group:"Html"});F(Zf.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var rk=[d3,Sf,cr,qc,Tf,ii,cc,ji,Ef,zs,Rf,$r,Ff,Ls,Lf,ro,Hf,no,jf,oi,Wf,fr,gf,to,vf,Is,wf,hn,kf,Cr,Xf,Zf,x3].flat(),nk=[f3,b3,w3,p3,y3,h3].flat(),ik=[o3,s3,l3,a3],Mo=le("IsMarkSelected",()=>r=>e=>{if(!r)return!1;const{doc:t,selection:n}=e;return t.rangeHasMark(n.from,n.to,r)}),ok=le("IsNoteSelected",()=>r=>e=>r?D5(e,r).hasNode:!1),Qt=le("ClearTextInCurrentBlock",()=>()=>(r,e)=>{let t=r.tr;const{$from:n,$to:i}=t.selection,{pos:o}=n,{pos:s}=i,a=o-n.node().content.size;return a<0?!1:(t=t.deleteRange(a,s),e==null||e(t),!0)}),J0=le("SetBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const o=e.tr,{from:s,to:a}=o.selection;try{o.setBlockType(s,a,n,i)}catch{return!1}return t==null||t(o),!0}),sa=le("WrapInBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;let o=e.tr;try{const{$from:s,$to:a}=o.selection,l=s.blockRange(a),c=l&&Gh(l,n,i);if(!c)return!1;o=o.wrap(l,c)}catch{return!1}return t==null||t(o),!0}),aa=le("AddBlockType",()=>r=>(e,t)=>{const{nodeType:n,attrs:i=null}=r??{};if(!n)return!1;const o=e.tr;try{const s=n instanceof mn?n:n.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t==null||t(o),!0}),k3=le("SelectTextNearPos",()=>r=>(e,t)=>{const{pos:n}=r??{};if(n==null)return!1;const i=(s,a,l)=>Math.min(Math.max(s,a),l),o=e.tr;try{const s=e.doc.resolve(i(n,0,e.doc.content.size));o.setSelection(Q.near(s))}catch{return!1}return t==null||t(o.scrollIntoView()),!0}),sk=[Cf,Df,In,Af,If,Bf,v3,m3,g3,$f,_f,Uf,Gf,Kf,Yf,Fc,_c,Hc,c3,u3,Mo,ok,Qt,J0,sa,aa,k3],ak=[Of,zf,Pf,Nf,Jf,Vf,qf,Mf,yf,xf,bf].flat(),Qf=dr("remarkAddOrderInList",()=>()=>r=>{Qi(r,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((n,i)=>{n.label=i+t})}})});F(Qf.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});F(Qf.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var ep=dr("remarkLineBreak",()=>()=>r=>{const e=/[\t ]*(?:\r?\n|\r)/g;Qi(r,"text",(t,n,i)=>{if(!t.value||typeof t.value!="string")return;const o=[];let s=0;e.lastIndex=0;let a=e.exec(t.value);for(;a;){const l=a.index;s!==l&&o.push({type:"text",value:t.value.slice(s,l)}),o.push({type:"break",data:{isInline:!0}}),s=l+a[0].length,a=e.exec(t.value)}if(o.length>0&&i&&typeof n=="number")return s<t.value.length&&o.push({type:"text",value:t.value.slice(s)}),i.children.splice(n,1,...o),n+o.length})});F(ep.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});F(ep.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var tp=dr("remarkInlineLink",()=>Vx);F(tp.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});F(tp.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var lk=r=>!!r.children,ck=r=>r.type==="html";function uk(r,e){return t(r,0,null)[0];function t(n,i,o){if(lk(n)){const s=[];for(let a=0,l=n.children.length;a<l;a++){const c=n.children[a];if(c){const u=t(c,a,n);if(u)for(let d=0,h=u.length;d<h;d++){const f=u[d];f&&s.push(f)}}}n.children=s}return e(n,i,o)}}var dk=["root","blockquote","listItem"],rp=dr("remarkHTMLTransformer",()=>()=>r=>{uk(r,(e,t,n)=>ck(e)?(n&&dk.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});F(rp.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});F(rp.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var np=dr("remarkMarker",()=>()=>(r,e)=>{const t=n=>e.value.charAt(n.position.start.offset);Qi(r,n=>["strong","emphasis"].includes(n.type),n=>{n.marker=t(n)})});F(np.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});F(np.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var S3=Fe(()=>{let r=!1;const e=new Me("MILKDOWN_INLINE_NODES_CURSOR"),t=new Ce({key:e,state:{init(){return!1},apply(n){if(!n.selection.empty)return!1;const i=n.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(n,i)=>r?(r=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const o=n.state.selection.from;i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",o))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(r=!0),!1),beforeinput:(n,i)=>{if(t.getState(n.state)&&i instanceof InputEvent&&i.data&&!r){const o=n.state.selection.from;return i.preventDefault(),n.dispatch(n.state.tr.insertText(i.data||"",o)),!0}return!1}},decorations(n){if(t.getState(n)){const i=n.selection.$from.pos,o=document.createElement("span"),s=qe.widget(i,o,{side:-1}),a=document.createElement("span"),l=qe.widget(i,a);return setTimeout(()=>{o.contentEditable="true",a.contentEditable="true"}),Se.create(n.doc,[s,l])}return Se.empty}}});return t});F(S3,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var C3=Fe(r=>new Ce({key:new Me("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,n)=>{if(!e.length)return;const[i]=e;if(!i)return;const[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof Ke))return;const{from:s}=o;return n.tr.setNodeMarkup(s,ji.type(r),void 0,[])}if(o instanceof cn){let s=n.tr;const{from:a,to:l}=o;return n.doc.nodesBetween(a,l,(c,u)=>{c.type===ji.type(r)&&(s=s.setNodeMarkup(u,ji.type(r),void 0,[]))}),s}}}));F(C3,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ip=ye(["table","code_block"],"hardbreakFilterNodes");F(ip,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var M3=Fe(r=>{const e=r.get(ip.key);return new Ce({key:new Me("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,n)=>{const i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){const{from:s}=o,a=n.doc.resolve(s);let l=a.depth,c=!0;for(;l>0;)e.includes(a.node(l).type.name)&&(c=!1),l--;return c}return!0}})});F(M3,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var T3=Fe(r=>{const e=new Me("MILKDOWN_HEADING_ID"),t=n=>{if(n.composing)return;const i=r.get(qc.key),o=n.state.tr.setMeta("addToHistory",!1);let s=!1;const a={};n.state.doc.descendants((l,c)=>{if(l.type===ii.type(r)){if(l.textContent.trim().length===0)return;const u=l.attrs;let d=i(l);a[d]?(a[d]+=1,d+=`-#${a[d]}`):a[d]=1,u.id!==d&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:d}))}}),s&&n.dispatch(o)};return new Ce({key:e,view:n=>(t(n),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});F(T3,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var A3=Fe(r=>{const e=(t,n,i)=>{if(!i.selection||t.some(d=>d.getMeta("addToHistory")===!1||!d.isGeneric))return null;const o=oi.type(r),s=no.type(r),a=fr.type(r),l=(d,h,f=1)=>{let m=!1;const y=`${h+f}.`;return d.label!==y&&(d.label=y,m=!0),m};let c=i.tr,u=!1;return i.doc.descendants((d,h,f,m)=>{if(d.type===s){const y=d.maybeChild(0);(y==null?void 0:y.type)===a&&y.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(h,o,{spread:!0}),d.descendants((x,b,S,A)=>{if(x.type===a){const D={...x.attrs};l(D,A)&&(c=c.setNodeMarkup(b,void 0,D))}return!1}))}else if(d.type===a&&(f==null?void 0:f.type)===o){const y={...d.attrs};let x=!1;y.listType!=="ordered"&&(y.listType="ordered",x=!0),f!=null&&f.maybeChild(0)&&(x=l(y,m,(f==null?void 0:f.attrs.order)??1)),x&&(c=c.setNodeMarkup(h,void 0,y),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new Ce({key:new Me("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});F(A3,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var hk=[C3,ip,M3,S3,Qf,tp,ep,rp,np,Ss,T3,A3].flat(),fk=[rk,nk,ik,sk,ak,hk].flat(),uc=typeof navigator<"u"?navigator:null,op=uc&&uc.userAgent||"",pk=/Edge\/(\d+)/.exec(op),mk=/MSIE \d/.exec(op),gk=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(op),yk=!!(mk||gk||pk),vk=!yk&&!!uc&&/Apple Computer/.test(uc.vendor),N3=new Me("safari-ime-span"),ch=!1,bk={key:N3,props:{decorations:wk,handleDOMEvents:{compositionstart:()=>{ch=!0},compositionend:()=>{ch=!1}}}};function wk(r){const{$from:e,$to:t,to:n}=r.selection;if(ch&&e.sameParent(t)){const i=qe.widget(n,xk,{ignoreSelection:!0,key:"safari-ime-span"});return Se.create(r.doc,[i])}}function xk(r){const e=r.dom.ownerDocument.createElement("span");return e.className="ProseMirror-safari-ime-span",e}var kk=new Ce(vk?bk:{key:N3});function oe(r,e){return Object.assign(r,{meta:{package:"@milkdown/preset-gfm",...e}}),r}var sp=$l("strike_through");oe(sp,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var Bs=Os("strike_through",r=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",r.get(sp.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,t)=>{e.withMark(t,"delete")}}}));oe(Bs.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});oe(Bs.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var jc=le("ToggleStrikeThrough",r=>()=>zc(Bs.type(r)));oe(jc,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var E3=mt(r=>jl(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)$"),Bs.type(r)));oe(E3,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var ap=Lt("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:r=>{const e=r.get(ee);return()=>e.call(jc.key)}}});oe(ap.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});oe(ap.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});var Vl=j9({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:r=>r.style.textAlign||"left",setDOMAttr:(r,e)=>{e.style=`text-align: ${r||"left"}`}}}}),Hr=je("table",()=>({...Vl.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="table",runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n,isHeader:s===0}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table",runner:(r,e)=>{var i;const t=(i=e.content.firstChild)==null?void 0:i.content;if(!t)return;const n=[];t.forEach(o=>{n.push(o.attrs.alignment)}),r.openNode("table",void 0,{align:n}),r.next(e.content),r.closeNode()}}}));oe(Hr.node,{displayName:"NodeSchema<table>",group:"Table"});oe(Hr.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var Wl=je("table_header_row",()=>({...Vl.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:r=>r instanceof HTMLElement&&r.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:r=>!!(r.type==="tableRow"&&r.isHeader),runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n[s],isHeader:e.isHeader}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_header_row",runner:(r,e)=>{e.content.size!==0&&(r.openNode("tableRow",void 0,{isHeader:!0}),r.next(e.content),r.closeNode())}}}));oe(Wl.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});oe(Wl.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var Ps=je("table_row",()=>({...Vl.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:r=>r.type==="tableRow",runner:(r,e,t)=>{const n=e.align,i=e.children.map((o,s)=>({...o,align:n[s]}));r.openNode(t),r.next(i),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_row",runner:(r,e)=>{e.content.size!==0&&(r.openNode("tableRow"),r.next(e.content),r.closeNode())}}}));oe(Ps.node,{displayName:"NodeSchema<tableRow>",group:"Table"});oe(Ps.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var Ul=je("table_cell",()=>({...Vl.table_cell,disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="tableCell"&&!r.isHeader,runner:(r,e,t)=>{const n=e.align;r.openNode(t,{alignment:n}).openNode(r.schema.nodes.paragraph).next(e.children).closeNode().closeNode()}},toMarkdown:{match:r=>r.type.name==="table_cell",runner:(r,e)=>{r.openNode("tableCell").next(e.content).closeNode()}}}));oe(Ul.node,{displayName:"NodeSchema<tableCell>",group:"Table"});oe(Ul.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var Cs=je("table_header",()=>({...Vl.table_header,disableDropCursor:!0,parseMarkdown:{match:r=>r.type==="tableCell"&&!!r.isHeader,runner:(r,e,t)=>{const n=e.align;r.openNode(t,{alignment:n}),r.openNode(r.schema.nodes.paragraph),r.next(e.children),r.closeNode(),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="table_header",runner:(r,e)=>{r.openNode("tableCell"),r.next(e.content),r.closeNode()}}}));oe(Cs.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});oe(Cs.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function lp(r,e=3,t=3){const n=Array(t).fill(0).map(()=>Ul.type(r).createAndFill()),i=Array(t).fill(0).map(()=>Cs.type(r).createAndFill()),o=Array(e).fill(0).map((s,a)=>a===0?Wl.type(r).create(null,i):Ps.type(r).create(null,n));return Hr.type(r).create(null,o)}function D3(r){return(e,t)=>n=>{t=t??n.selection.from;const i=n.doc.resolve(t),o=E5(l=>l.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,a=r==="row";if(s){const l=xe.get(s.node);if(e>=0&&e<(a?l.height:l.width)){const c=l.positionAt(a?e:l.height-1,a?l.width-1:e,s.node),u=n.doc.resolve(s.from+c),d=a?Ae.rowSelection:Ae.colSelection,h=l.positionAt(a?e:0,a?0:e,s.node),f=n.doc.resolve(s.from+h);return N5(n.setSelection(d(u,f)))}}return n}}var Sk=D3("row"),Ck=D3("col");function O3(r,e,{map:t,tableStart:n,table:i},o){const s=Array(o).fill(0).reduce((l,c,u)=>l+i.child(u).nodeSize,n),a=Array(t.width).fill(0).map((l,c)=>{const u=i.nodeAt(t.map[c]);return Ul.type(r).createAndFill({alignment:u==null?void 0:u.attrs.alignment})});return e.insert(s,Ps.type(r).create(null,a)),e}function Mk(r){const e=Rs(r.$from);if(!e)return;const t=xe.get(e.node);return t.cellsInRect({left:0,right:t.width,top:0,bottom:t.height}).map(n=>{const i=e.node.nodeAt(n),o=n+e.start;return{pos:o,start:o+1,node:i}})}function Tk(r){const e=Mk(r.selection);if(e&&e[0]){const t=r.doc.resolve(e[0].pos),n=e[e.length-1];if(n){const i=r.doc.resolve(n.pos);return N5(r.setSelection(new Ae(i,t)))}}return r}var cp=le("GoToPrevTableCell",()=>()=>t3(-1));oe(cp,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var up=le("GoToNextTableCell",()=>()=>t3(1));oe(up,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var dp=le("ExitTable",r=>()=>(e,t)=>{if(!hr(e))return!1;const{$head:n}=e.selection,i=c9(n,Hr.type(r));if(!i)return!1;const{to:o}=i,s=e.tr.replaceWith(o,o,cr.type(r).createAndFill());return s.setSelection(ue.near(s.doc.resolve(o),1)).scrollIntoView(),t==null||t(s),!0});oe(dp,{displayName:"Command<breakTableCommand>",group:"Table"});var R3=le("InsertTable",r=>({row:e,col:t}={})=>(n,i)=>{const{selection:o,tr:s}=n,{from:a}=o,l=lp(r,e,t),c=s.replaceSelectionWith(l),u=ue.findFrom(c.doc.resolve(a),1,!0);return u&&c.setSelection(u),i==null||i(c),!0});oe(R3,{displayName:"Command<insertTableCommand>",group:"Table"});var $c=le("MoveRow",()=>({from:r,to:e,pos:t}={})=>gx({from:r??0,to:e??0,pos:t}));oe($c,{displayName:"Command<moveRowCommand>",group:"Table"});var Vc=le("MoveCol",()=>({from:r,to:e,pos:t}={})=>yx({from:r??0,to:e??0,pos:t}));oe(Vc,{displayName:"Command<moveColCommand>",group:"Table"});var fn=le("SelectRow",()=>(r={index:0})=>(e,t)=>{const{tr:n}=e;return!!(t==null?void 0:t(Sk(r.index,r.pos)(n)))});oe(fn,{displayName:"Command<selectRowCommand>",group:"Table"});var pn=le("SelectCol",()=>(r={index:0})=>(e,t)=>{const{tr:n}=e;return!!(t==null?void 0:t(Ck(r.index,r.pos)(n)))});oe(pn,{displayName:"Command<selectColCommand>",group:"Table"});var I3=le("SelectTable",()=>()=>(r,e)=>{const{tr:t}=r;return!!(e==null?void 0:e(Tk(t)))});oe(I3,{displayName:"Command<selectTableCommand>",group:"Table"});var _a=le("DeleteSelectedCells",()=>()=>(r,e)=>{const{selection:t}=r;if(!(t instanceof Ae))return!1;const n=t.isRowSelection(),i=t.isColSelection();return n&&i?mx(r,e):i?cx(r,e):dx(r,e)});oe(_a,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var hp=le("AddColBefore",()=>()=>sx);oe(hp,{displayName:"Command<addColBeforeCommand>",group:"Table"});var Wc=le("AddColAfter",()=>()=>ax);oe(Wc,{displayName:"Command<addColAfterCommand>",group:"Table"});var fp=le("AddRowBefore",r=>()=>(e,t)=>{if(!hr(e))return!1;if(t){const n=ni(e);t(O3(r,e.tr,n,n.top))}return!0});oe(fp,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var Uc=le("AddRowAfter",r=>()=>(e,t)=>{if(!hr(e))return!1;if(t){const n=ni(e);t(O3(r,e.tr,n,n.bottom))}return!0});oe(Uc,{displayName:"Command<addRowAfterCommand>",group:"Table"});var pp=le("SetAlign",()=>(r="left")=>hx("alignment",r));oe(pp,{displayName:"Command<setAlignCommand>",group:"Table"});var z3=mt(r=>new zt(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,t,n,i)=>{var l,c;const o=e.doc.resolve(n);if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),Hr.type(r)))return null;const s=lp(r,Math.max(Number(((l=t.groups)==null?void 0:l.row)??0),2),Number((c=t.groups)==null?void 0:c.col)),a=e.tr.replaceRangeWith(n,i,s);return a.setSelection(Q.create(a.doc,n+3)).scrollIntoView()}));oe(z3,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var L3=z9(r=>({run:(e,t,n)=>{if(n)return e;function i(c){var x;const u=c.childCount,d=((x=c.lastChild)==null?void 0:x.childCount)??0;if(u===0||d===0)return cr.type(r).create();const h=c.firstChild;if(!(d>0&&h&&h.childCount===0))return c;if(u>=3){const b=c.child(1),S=[];for(let O=0;O<b.childCount;O++){const L=b.child(O);S.push(Cs.type(r).create(L.attrs,L.content,L.marks))}const A=h.type.create(h.attrs,S),D=[];for(let O=2;O<u;O++)D.push(c.child(O));return c.type.create(c.attrs,[A,...D])}const f=Array(d).fill(0).map(()=>Cs.type(r).createAndFill()),m=new Y(H.from(f),0,0),y=h.replace(0,0,m);return c.replace(0,h.nodeSize,new Y(H.from(y),0,0))}function o(c){const u=Ps.type(r),d=[];let h=[],f=!1;function m(){if(h.length===0)return;const y=Wl.type(r).createAndFill(),x=Hr.type(r).create(null,[y,...h]);d.push(i(x)),h=[]}return c.forEach(y=>{y.type===u?(f=!0,h.push(y)):(m(),d.push(y))}),m(),f?H.from(d):c}function s(c){let u=o(c),d=u!==c;const h=[];return u.forEach(f=>{if(f.type===Hr.type(r)){const m=i(f);m!==f&&(d=!0),h.push(m)}else if(f.childCount>0){const m=s(f.content);m!==f.content?(d=!0,h.push(f.copy(m))):h.push(f)}else h.push(f)}),d?H.from(h):c}function a(c){const u=[],d=[];c.forEach(h=>d.push(h));for(let h=0;h<d.length;h++){const f=d[h],m=d[h+1];f.type===cr.type(r)&&f.content.size===0&&m&&m.type===Hr.type(r)||u.push(f)}return u.length<d.length?H.from(u):c}let l=s(e.content);return l=a(l),new Y(H.from(l),e.openStart,e.openEnd)}}));oe(L3,{displayName:"PasteRule<table>",group:"Table"});var mp=Lt("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:r=>{const e=r.get(ee);return()=>e.call(up.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:r=>{const e=r.get(ee);return()=>e.call(cp.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:r=>{const e=r.get(ee);return()=>e.call(dp.key)}}});oe(mp.ctx,{displayName:"KeymapCtx<table>",group:"Table"});oe(mp.shortcuts,{displayName:"Keymap<table>",group:"Table"});var ed="footnote_definition",J1="footnoteDefinition",gp=je("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${ed}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Vr(r);return{label:r.dataset.label}},contentElement:"dd"}],toDOM:r=>{const e=r.attrs.label;return["dl",{"data-label":e,"data-type":ed},["dt",e],["dd",0]]},parseMarkdown:{match:({type:r})=>r===J1,runner:(r,e,t)=>{r.openNode(t,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:r=>r.type.name===ed,runner:(r,e)=>{r.openNode(J1,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));oe(gp.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});oe(gp.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var td="footnote_reference",yp=je("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${td}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Vr(r);return{label:r.dataset.label}}}],toDOM:r=>{const e=r.attrs.label;return["sup",{"data-label":e,"data-type":td},e]},parseMarkdown:{match:({type:r})=>r==="footnoteReference",runner:(r,e,t)=>{r.addNode(t,{label:e.label})}},toMarkdown:{match:r=>r.type.name===td,runner:(r,e)=>{r.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));oe(yp.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});oe(yp.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var vp=fr.extendSchema(r=>e=>{const t=r(e);return{...t,attrs:{...t.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:n=>{if(!(n instanceof HTMLElement))throw Vr(n);return{label:n.dataset.label,listType:n.dataset.listType,spread:n.dataset.spread==="true",checked:n.dataset.checked?n.dataset.checked==="true":null}}},...(t==null?void 0:t.parseDOM)||[]],toDOM:n=>t.toDOM&&n.attrs.checked==null?t.toDOM(n):["li",{"data-item-type":"task","data-label":n.attrs.label,"data-list-type":n.attrs.listType,"data-spread":n.attrs.spread,"data-checked":n.attrs.checked},0],parseMarkdown:{match:({type:n})=>n==="listItem",runner:(n,i,o)=>{if(i.checked==null){t.parseMarkdown.runner(n,i,o);return}const s=i.label!=null?`${i.label}.`:"•",a=i.checked!=null?!!i.checked:null,l=i.label!=null?"ordered":"bullet",c=i.spread??!0;n.openNode(o,{label:s,listType:l,spread:c,checked:a}),n.next(i.children),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="list_item",runner:(n,i)=>{if(i.attrs.checked==null){t.toMarkdown.runner(n,i);return}const o=i.attrs.label,s=i.attrs.listType,a=i.attrs.spread,l=i.attrs.checked;n.openNode("listItem",void 0,{label:o,listType:s,spread:a,checked:l}),n.next(i.content),n.closeNode()}}}});oe(vp.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});oe(vp.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var B3=mt(()=>new zt(/^\[(?<checked>\s|x)\]\s$/,(r,e,t,n)=>{var u;const i=r.doc.resolve(t);let o=0,s=i.node(o);for(;s&&s.type.name!=="list_item";)o--,s=i.node(o);if(!s||s.attrs.checked!=null)return null;const a=((u=e.groups)==null?void 0:u.checked)==="x",l=i.before(o),c=r.tr;return c.deleteRange(t,n).setNodeMarkup(l,void 0,{...s.attrs,checked:a}),c}));oe(B3,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var Ak=[ap,mp].flat(),Nk=[z3,B3],Ek=[E3],Dk=[L3],P3=Fe(()=>kk);oe(P3,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var Ok=Fe(()=>Ax({}));oe(Ok,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var F3=Fe(()=>Px({allowTableNodeSelection:!0}));oe(F3,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var bp=dr("remarkGFM",()=>Uy);oe(bp.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});oe(bp.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var Rk=new Me("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function Ik(r,e){let t=0;return e.forEach((n,i,o)=>{n===r&&(t=o)}),t}function zk(r,e){const t=r.content.findDiffStart(e.content);if(t==null)return null;const n=r.content.findDiffEnd(e.content);return n?{from:t,to:Math.max(n.b,t)}:null}var H3=Fe(()=>new Ce({key:Rk,appendTransaction:(r,e,t)=>{if(e.doc===t.doc)return;const n=zk(e.doc,t.doc);if(!n)return;let i;const o=(s,a)=>{if(s.type.name!=="table_cell")return;const l=t.doc.resolve(a),c=l.node(l.depth),u=l.node(l.depth-1).firstChild;if(!u)return;const d=Ik(s,c),h=u.maybeChild(d);if(!h)return;const f=h.attrs.alignment;f!==s.attrs.alignment&&(i||(i=t.tr),i.setNodeMarkup(a,void 0,{...s.attrs,alignment:f}))};return t.doc.nodesBetween(n.from,n.to,(s,a)=>s.type.name!=="table"?!0:(t.doc.nodesBetween(a,a+s.nodeSize,o),!1)),i}}));oe(H3,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var Lk=[H3,P3,bp,F3].flat(),Bk=[vp,Hr,Wl,Ps,Cs,Ul,gp,yp,sp,Bs].flat(),Pk=[up,cp,dp,R3,$c,Vc,fn,pn,I3,_a,fp,Uc,hp,Wc,pp,jc],Fk=[Bk,Nk,Dk,Ek,Ak,Pk,Lk].flat();function uh(r){if(!r)return!1;if(Array.isArray(r))return r.length>1?!1:uh(r[0]);const e=r.content;return e?uh(e):r.type==="text"}function Hk(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-clipboard",...e}}),r}function X1(r,e){const t=l9(e);if(t)return r.dispatch(r.state.tr.replaceSelectionWith(t,!0)),!0;try{return r.dispatch(r.state.tr.replaceSelection(e)),!0}catch{return!1}}var _3=Fe(r=>{const e=r.get(Sr);r.update(Sa,n=>({...n,editable:n.editable??(()=>!0),transformPastedHTML:(i,o)=>{const s=n.transformPastedHTML;return s&&(i=s(i,o)),i.includes("docs-internal-guid")&&(i=i.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,"$1"),i=i.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,"$1")),i}}));const t=new Me("MILKDOWN_CLIPBOARD");return new Ce({key:t,props:{handlePaste:(n,i,o)=>{var m,y,x;const s=r.get(Do),a=(y=(m=n.props).editable)==null?void 0:y.call(m,n.state),{clipboardData:l}=i;if(!a||!l||n.state.selection.$from.node().type.spec.code)return!1;const c=l.getData("text/plain"),u=l.getData("vscode-editor-data");if(u){const b=(x=JSON.parse(u))==null?void 0:x.mode;if(c&&b){const{tr:S}=n.state,A=u9("code_block",e);return S.replaceSelectionWith(A.create({language:b})).setSelection(Q.near(S.doc.resolve(Math.max(0,S.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
34
34
  `)),n.dispatch(S),!0}}const d=l.getData("text/html");if(d.length===0&&c.length===0)return!1;if(d.length>0&&o)return X1(n,o);const h=Yi.fromSchema(e);let f;if(d.length===0){const b=s(c);if(!b||typeof b=="string")return!1;f=eo.fromSchema(e).serializeFragment(b.content)}else{const b=document.createElement("template");b.innerHTML=d,f=b.content.cloneNode(!0),b.remove()}return X1(n,h.parseSlice(f))},clipboardTextSerializer:n=>{const i=r.get(ka);if(uh(n.content.toJSON()))return n.content.textBetween(0,n.content.size,`
35
35
 
36
- `);const o=e.topNodeType.createAndFill(void 0,n.content);return o?i(o):""}}})});Hk(_3,{displayName:"Prose<clipboard>"});var dc=200,nt=function(){};nt.prototype.append=function(e){return e.length?(e=nt.from(e),!this.length&&e||e.length<dc&&this.leafAppend(e)||this.length<dc&&e.leafPrepend(this)||this.appendInner(e)):this};nt.prototype.prepend=function(e){return e.length?nt.from(e).append(this):this};nt.prototype.appendInner=function(e){return new _k(this,e)};nt.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nt.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};nt.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};nt.from=function(e){return e instanceof nt?e:e&&e.length?new q3(e):nt.empty};var q3=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=dc)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=dc)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(nt);nt.empty=new q3([]);var _k=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(n,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(n,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(n,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(n,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(nt);const qk=500;class xr{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){i||(i=this.remapping(n,h+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new Rr(d.map));let f=d.step.map(i.slice(o)),m;f&&s.maybeStep(f).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new Rr(m,void 0,void 0,c.length+u.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(o)):d.selection,l=new xr(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,t,n,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Rr(e.mapping.maps[u],d,t),f;(f=l&&l.merge(h))&&(h=f,u?o.pop():a=a.slice(0,a.length-1)),o.push(h),t&&(s++,t=void 0),i||(l=h)}let c=s-n.depth;return c>jk&&(a=$k(a,c),s-=c),new xr(a.append(o),s)}remapping(e,t){let n=new Na;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new xr(this.items.append(e.map(t=>new Rr(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=t;this.items.forEach(h=>{let f=o.getMirror(--l);if(f==null)return;s=Math.min(s,f);let m=o.maps[f];if(h.step){let y=e.steps[f].invert(e.docs[f]),x=h.selection&&h.selection.map(o.slice(l+1,f));x&&a++,n.push(new Rr(m,y,x))}else n.push(new Rr(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new Rr(o.maps[h]));let u=this.items.slice(0,i).append(c).append(n),d=new xr(u,a);return d.emptyItemCount()>qk&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(t.slice(n)),c=l&&l.getMap();if(n--,c&&t.appendMap(c,n),l){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let d=new Rr(c.invert(),l,u),h,f=i.length-1;(h=i.length&&i[f].merge(d))?i[f]=h:i.push(d)}}else s.map&&n--},this.items.length,0),new xr(nt.from(i.reverse()),o)}}xr.empty=new xr(nt.empty,0);function $k(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Rr{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Rr(t.getMap().invert(),t,this.selection)}}}class zn{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const jk=20;function Vk(r,e,t,n){let i=t.getMeta(ji),o;if(i)return i.historyState;t.getMeta(Kk)&&(r=new zn(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(ji))return s.getMeta(ji).redo?new zn(r.done.addTransform(t,void 0,n,X0(e)),r.undone,Z1(t.mapping.maps),r.prevTime,r.prevComposition):new zn(r.done,r.undone.addTransform(t,void 0,n,X0(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=r.prevTime==0||!s&&r.prevComposition!=a&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Wk(t,r.prevRanges)),c=s?rd(r.prevRanges,t.mapping):Z1(t.mapping.maps);return new zn(r.done.addTransform(t,l?e.selection.getBookmark():void 0,n,X0(e)),xr.empty,c,t.time,a??r.prevComposition)}else return(o=t.getMeta("rebased"))?new zn(r.done.rebased(t,o),r.undone.rebased(t,o),rd(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new zn(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),rd(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Wk(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Z1(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function rd(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function Uk(r,e,t){let n=X0(e),i=ji.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),l=new zn(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(ji,{redo:t,historyState:l})}let nd=!1,Q1=null;function X0(r){let e=r.plugins;if(Q1!=e){nd=!1,Q1=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){nd=!0;break}}return nd}const ji=new Me("history"),Kk=new Me("closeHistory");function Gk(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Ce({key:ji,state:{init(){return new zn(xr.empty,xr.empty,null,0,-1)},apply(e,t,n){return Vk(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?wp:n=="historyRedo"?hc:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function $3(r,e){return(t,n)=>{let i=ji.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=Uk(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const wp=$3(!1,!0),hc=$3(!0,!0);function Fs(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-history",...e}}),r}var xp=le("Undo",()=>()=>wp);Fs(xp,{displayName:"Command<undo>"});var kp=le("Redo",()=>()=>hc);Fs(kp,{displayName:"Command<redo>"});var Sp=ye({},"historyProviderConfig");Fs(Sp,{displayName:"Ctx<historyProviderConfig>"});var j3=Fe(r=>Gk(r.get(Sp.key)));Fs(j3,{displayName:"Ctx<historyProviderPlugin>"});var Cp=Lt("historyKeymap",{Undo:{shortcuts:"Mod-z",command:r=>{const e=r.get(ee);return()=>e.call(xp.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:r=>{const e=r.get(ee);return()=>e.call(kp.key)}}});Fs(Cp.ctx,{displayName:"KeymapCtx<history>"});Fs(Cp.shortcuts,{displayName:"Keymap<history>"});var Yk=[Sp,j3,Cp,xp,kp].flat();function Jk(r,e){const{doc:t,selection:n}=r;if(!t||!n||!(n instanceof Q||n instanceof Rt))return r;const{to:i}=n,o=e.type==="space"?Array(e.size).fill(" ").join(""):" ";return r.insertText(o,i)}var Mp=ye({type:"space",size:2},"indentConfig");Mp.meta={package:"@milkdown/plugin-indent",displayName:"Ctx<indentConfig>"};var V3=K5(r=>({Tab:(e,t)=>{const n=r.get(Mp.key),{tr:i}=e,o=Jk(i,n);return o.docChanged?(t==null||t(o),!0):!1}}));V3.meta={package:"@milkdown/plugin-indent",displayName:"Shortcut<indent>"};var Xk=[Mp,V3],Zk=typeof global=="object"&&global&&global.Object===Object&&global,Qk=typeof self=="object"&&self&&self.Object===Object&&self,W3=Zk||Qk||Function("return this")(),fc=W3.Symbol,U3=Object.prototype,eS=U3.hasOwnProperty,tS=U3.toString,Xs=fc?fc.toStringTag:void 0;function rS(r){var e=eS.call(r,Xs),t=r[Xs];try{r[Xs]=void 0;var n=!0}catch{}var i=tS.call(r);return n&&(e?r[Xs]=t:delete r[Xs]),i}var nS=Object.prototype,iS=nS.toString;function oS(r){return iS.call(r)}var sS="[object Null]",aS="[object Undefined]",eg=fc?fc.toStringTag:void 0;function lS(r){return r==null?r===void 0?aS:sS:eg&&eg in Object(r)?rS(r):oS(r)}function cS(r){return r!=null&&typeof r=="object"}var uS="[object Symbol]";function dS(r){return typeof r=="symbol"||cS(r)&&lS(r)==uS}var hS=/\s/;function fS(r){for(var e=r.length;e--&&hS.test(r.charAt(e)););return e}var pS=/^\s+/;function mS(r){return r&&r.slice(0,fS(r)+1).replace(pS,"")}function pc(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var tg=NaN,gS=/^[-+]0x[0-9a-f]+$/i,yS=/^0b[01]+$/i,vS=/^0o[0-7]+$/i,bS=parseInt;function rg(r){if(typeof r=="number")return r;if(dS(r))return tg;if(pc(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=pc(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=mS(r);var t=yS.test(r);return t||vS.test(r)?bS(r.slice(2),t?2:8):gS.test(r)?tg:+r}var id=function(){return W3.Date.now()},wS="Expected a function",xS=Math.max,kS=Math.min;function Tp(r,e,t){var n,i,o,s,a,l,c=0,u=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(wS);e=rg(e)||0,pc(t)&&(u=!!t.leading,d="maxWait"in t,o=d?xS(rg(t.maxWait)||0,e):o,h="trailing"in t?!!t.trailing:h);function f(L){var N=n,$=i;return n=i=void 0,c=L,s=r.apply($,N),s}function m(L){return c=L,a=setTimeout(b,e),u?f(L):s}function y(L){var N=L-l,$=L-c,K=e-N;return d?kS(K,o-$):K}function x(L){var N=L-l,$=L-c;return l===void 0||N>=e||N<0||d&&$>=o}function b(){var L=id();if(x(L))return S(L);a=setTimeout(b,y(L))}function S(L){return a=void 0,h&&n?f(L):(n=i=void 0,s)}function A(){a!==void 0&&clearTimeout(a),c=0,n=l=i=a=void 0}function D(){return a===void 0?s:S(id())}function O(){var L=id(),N=x(L);if(n=arguments,i=this,l=L,N){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(b,e),f(l)}return a===void 0&&(a=setTimeout(b,e)),s}return O.cancel=A,O.flush=D,O}var SS="Expected a function";function K3(r,e,t){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(SS);return pc(t)&&(n="leading"in t?!!t.leading:n,i="trailing"in t?!!t.trailing:i),Tp(r,e,{leading:n,maxWait:e,trailing:i})}var G3=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=r=>(this.beforeMountedListeners.push(r),this),this.mounted=r=>(this.mountedListeners.push(r),this),this.updated=r=>(this.updatedListeners.push(r),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(r){return this.markdownUpdatedListeners.push(r),this}blur(r){return this.blurListeners.push(r),this}focus(r){return this.focusListeners.push(r),this}destroy(r){return this.destroyListeners.push(r),this}selectionUpdated(r){return this.selectionUpdatedListeners.push(r),this}},dh=me(new G3,"listener"),CS=new Me("MILKDOWN_LISTENER"),Y3=r=>(r.inject(dh,new G3),async()=>{await r.wait(qi);const{listeners:e}=r.get(dh);e.beforeMount.forEach(c=>c(r)),await r.wait(xa);const t=r.get(ka);let n=null,i=null,o=null,s=null;const a=Tp(()=>{if(!s)return;const{doc:c}=s;if(e.updated.length>0&&n&&!n.eq(c)&&e.updated.forEach(u=>{u(r,c,n)}),e.markdownUpdated.length>0&&n&&!n.eq(c)){const u=t(c);e.markdownUpdated.forEach(d=>{d(r,u,i)}),i=u}n=c,s=null},200),l=new Ce({key:CS,view:()=>({destroy:()=>{a.cancel(),e.destroy.forEach(c=>c(r))}}),props:{handleDOMEvents:{focus:()=>(e.focus.forEach(c=>c(r)),!1),blur:()=>(e.blur.forEach(c=>c(r)),!1)}},state:{init:(c,u)=>{n=u.doc,i=t(u.doc)},apply:c=>{const u=c.selection;(!o&&u||o&&!u.eq(o))&&(e.selectionUpdated.forEach(d=>{d(r,u,o)}),o=u),!(!(c.docChanged||c.storedMarksSet)||c.getMeta("addToHistory")===!1)&&(s=c,a())}}});r.update(vn,c=>c.concat(l)),await r.wait(U0),e.mounted.forEach(c=>c(r))});Y3.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var Ap=ye({shouldAppend:r=>!(!r||["heading","paragraph"].includes(r.type.name)),getNode:r=>r.schema.nodes.paragraph.create()},"trailingConfig");Ap.meta={package:"@milkdown/plugin-trailing",displayName:"Ctx<trailingConfig>"};var J3=Fe(r=>{const e=new Me("MILKDOWN_TRAILING"),{shouldAppend:t,getNode:n}=r.get(Ap.key),i=new Ce({key:e,state:{init:(o,s)=>{const a=s.tr.doc.lastChild;return t(a,s)},apply:(o,s,a,l)=>{if(!o.docChanged)return s;const c=o.doc.lastChild;return t(c,l)}},appendTransaction:(o,s,a)=>{const{doc:l,tr:c}=a,u=n==null?void 0:n(a),d=i.getState(a),h=l.content.size;if(!(!d||!u))return c.insert(h,u)}});return i});J3.meta={package:"@milkdown/plugin-trailing",displayName:"Prose<trailing>"};var MS=[Ap,J3];function TS(r){return new Promise(e=>{const t=new FileReader;t.addEventListener("load",()=>{e({alt:r.name,src:t.result})},!1),t.readAsDataURL(r)})}var AS=async(r,e)=>{const t=[];for(let i=0;i<r.length;i++){const o=r.item(i);o&&o.type.includes("image")&&t.push(o)}const{image:n}=e.nodes;if(!n)throw u5("image");return(await Promise.all(t.map(i=>TS(i)))).map(({alt:i,src:o})=>n.createAndFill({src:o,alt:i}))},Oo=ye({uploader:AS,enableHtmlFileUploader:!1,uploadWidgetFactory:(r,e)=>{const t=document.createElement("span");return t.textContent="Upload in progress...",qe.widget(r,t,e)}},"uploadConfig");Oo.meta={package:"@milkdown/plugin-upload",displayName:"Ctx<uploadConfig>"};var X3=Fe(r=>{const e=new Me("MILKDOWN_UPLOAD"),t=(i,o)=>{var l;const s=e.getState(i);if(!s)return-1;const a=s.find(void 0,void 0,c=>c.id===o);return a.length?((l=a[0])==null?void 0:l.from)??-1:-1},n=(i,o,s)=>{var m;if(!s||s.length<=0)return!1;const a=Symbol("upload symbol"),l=r.get(Sr),{uploader:c,getInsertPos:u}=r.get(Oo.key),{tr:d}=i.state,h=o instanceof DragEvent?((m=i.posAtCoords({left:o.clientX,top:o.clientY}))==null?void 0:m.pos)??d.selection.from:d.selection.from,f=typeof u=="function"?u(o,r,h):h;return i.dispatch(d.setMeta(e,{add:{id:a,pos:f}})),c(s,l,r,f).then(y=>{const x=t(i.state,a);x<0||i.dispatch(i.state.tr.replaceWith(x,x,y).setMeta(e,{remove:{id:a}}))}).catch(y=>{console.error(y)}),!0};return new Ce({key:e,state:{init(){return Se.empty},apply(i,o){const s=o.map(i.mapping,i.doc),a=i.getMeta(this);if(!a)return s;if(a.add){const{uploadWidgetFactory:l}=r.get(Oo.key),c=l(a.add.pos,{id:a.add.id});return s.add(i.doc,[c])}if(a.remove){const l=s.find(void 0,void 0,c=>c.id===a.remove.id);return s.remove(l)}return s}},props:{decorations(i){return this.getState(i)},handlePaste:(i,o)=>{var a,l;const{enableHtmlFileUploader:s}=r.get(Oo.key);return!(o instanceof ClipboardEvent)||!s&&((a=o.clipboardData)!=null&&a.getData("text/html"))?!1:n(i,o,(l=o.clipboardData)==null?void 0:l.files)},handleDrop:(i,o)=>{var s;return o instanceof DragEvent?n(i,o,(s=o.dataTransfer)==null?void 0:s.files):!1}}})});X3.meta={package:"@milkdown/plugin-upload",displayName:"Prose<upload>"};var NS=[Oo,X3];function Kl(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-block",...e}}),r}var ES=r=>!Fr(e=>e.type.name==="table")(r),Kc=ye({filterNodes:ES},"blockConfig");Kl(Kc,{displayName:"Ctx<blockConfig>"});function DS(r,e,t){var n;if(!r.dom.parentElement)return null;try{const i=(n=r.posAtCoords({left:e.x,top:e.y}))==null?void 0:n.inside;if(i==null||i<0)return null;let o=r.state.doc.resolve(i),s=r.state.doc.nodeAt(i),a=r.nodeDOM(i);const l=c=>{const u=o.depth>=1&&o.index(o.depth)===0;if(!(c||u))return;const d=o.before(o.depth);s=r.state.doc.nodeAt(d),a=r.nodeDOM(d),o=r.state.doc.resolve(d),t(o,s)||l(!0)};return l(!t(o,s)),!a||!s?null:{node:s,$pos:o,el:a}}catch{return null}}var ng=w0.ie&&w0.ie_version<15||w0.ios&&w0.webkit_version<604,ig=20,es,fl,qn,vr,ts,br,Lr,Z3,To,Di,Oi,pl,rs,ns,is,ss,ml,$n,E4,OS=(E4=class{constructor(){P(this,Lr);P(this,es);P(this,fl);P(this,qn);P(this,vr);P(this,ts);P(this,br);P(this,Di);P(this,Oi);P(this,pl);P(this,rs);P(this,ns);P(this,is);P(this,ss);P(this,ml);P(this,$n);I(this,fl,()=>{if(!C(this,vr))return null;const r=C(this,vr),e=C(this,Lr,To);if(I(this,qn,null),e&&re.isSelectable(r.node)){const t=re.create(e.state.doc,r.$pos.pos);return e.dispatch(e.state.tr.setSelection(t)),e.focus(),I(this,qn,t),t}return null}),I(this,qn,null),I(this,vr,null),I(this,ts,void 0),I(this,br,!1),I(this,Oi,()=>{var r;(r=C(this,Di))==null||r.call(this,{type:"hide"}),I(this,vr,null)}),I(this,pl,r=>{var e;I(this,vr,r),(e=C(this,Di))==null||e.call(this,{type:"show",active:r})}),this.bind=(r,e)=>{I(this,es,r),I(this,Di,e)},this.addEvent=r=>{r.addEventListener("mousedown",C(this,rs)),r.addEventListener("mouseup",C(this,ns)),r.addEventListener("dragstart",C(this,is)),r.addEventListener("dragend",C(this,ss))},this.removeEvent=r=>{r.removeEventListener("mousedown",C(this,rs)),r.removeEventListener("mouseup",C(this,ns)),r.removeEventListener("dragstart",C(this,is)),r.removeEventListener("dragend",C(this,ss))},this.unBind=()=>{I(this,Di,void 0)},I(this,rs,()=>{var r;I(this,ts,(r=C(this,vr))==null?void 0:r.el.getBoundingClientRect()),C(this,fl).call(this)}),I(this,ns,()=>{if(!C(this,br)){requestAnimationFrame(()=>{var r;C(this,ts)&&((r=C(this,Lr,To))==null||r.focus())});return}I(this,br,!1),I(this,qn,null)}),I(this,is,r=>{var n;I(this,br,!0);const e=C(this,Lr,To);if(!e)return;e.dom.dataset.dragging="true";const t=C(this,qn);if(r.dataTransfer&&t){const i=t.content();r.dataTransfer.effectAllowed="copyMove";const{dom:o,text:s}=e.serializeForClipboard(i);r.dataTransfer.clearData(),r.dataTransfer.setData(ng?"Text":"text/html",o.innerHTML),ng||r.dataTransfer.setData("text/plain",s);const a=(n=C(this,vr))==null?void 0:n.el;a&&r.dataTransfer.setDragImage(a,0,0),e.dragging={slice:i,move:!0,node:t}}}),I(this,ss,()=>{const r=C(this,Lr,To);if(!r)return;C(this,$n).call(this,r);const e=r.dragging;window.setTimeout(()=>{r.dragging===e&&(r.dragging=null)},50)}),this.keydownCallback=r=>(C(this,Oi).call(this),I(this,br,!1),r.dom.dataset.dragging="false",!1),I(this,ml,K3((r,e)=>{if(!r.editable)return;const t=r.dom.getBoundingClientRect(),n=t.left+t.width/2;if(!(r.root.elementFromPoint(n,e.clientY)instanceof Element)){C(this,Oi).call(this);return}const i=C(this,Lr,Z3);if(!i)return;const o=DS(r,{x:n,y:e.clientY},i);if(!o){C(this,Oi).call(this);return}C(this,pl).call(this,o)},200)),this.mousemoveCallback=(r,e)=>(r.composing||!r.editable||C(this,ml).call(this,r,e),!1),this.dragoverCallback=(r,e)=>{var t;if(C(this,br)){const n=(t=C(this,Lr,To))==null?void 0:t.dom.parentElement;if(!n)return!1;const i=n.scrollHeight>n.clientHeight,o=n.getBoundingClientRect();if(i){if(n.scrollTop>0&&Math.abs(e.y-o.y)<ig)return n.scrollTop=n.scrollTop>10?n.scrollTop-10:0,!1;const s=Math.round(r.dom.getBoundingClientRect().height);if(Math.round(n.scrollTop+o.height)<s&&Math.abs(e.y-(o.height+o.y))<ig)return n.scrollTop=n.scrollTop+10,!1}}return!1},this.dragenterCallback=r=>{r.dragging&&(I(this,br,!0),r.dom.dataset.dragging="true")},this.dragleaveCallback=(r,e)=>{const t=e.clientX,n=e.clientY;(t<0||n<0||t>window.innerWidth||n>window.innerHeight)&&(I(this,vr,null),C(this,$n).call(this,r))},this.dropCallback=r=>(C(this,$n).call(this,r),!1),this.dragendCallback=r=>{C(this,$n).call(this,r)},I(this,$n,r=>{I(this,br,!1),r.dom.dataset.dragging="false"})}},es=new WeakMap,fl=new WeakMap,qn=new WeakMap,vr=new WeakMap,ts=new WeakMap,br=new WeakMap,Lr=new WeakSet,Z3=function(){var r;try{return(r=C(this,es))==null?void 0:r.get(Kc.key).filterNodes}catch{return}},To=function(){var r;return(r=C(this,es))==null?void 0:r.get(ge)},Di=new WeakMap,Oi=new WeakMap,pl=new WeakMap,rs=new WeakMap,ns=new WeakMap,is=new WeakMap,ss=new WeakMap,ml=new WeakMap,$n=new WeakMap,E4),Np=ye(()=>new OS,"blockService"),Gc=ye({},"blockServiceInstance");Kl(Np,{displayName:"Ctx<blockService>"});Kl(Gc,{displayName:"Ctx<blockServiceInstance>"});var Yc=ye({},"blockSpec");Kl(Yc,{displayName:"Ctx<blockSpec>"});var Ep=Fe(r=>{const e=new Me("MILKDOWN_BLOCK"),t=r.get(Np.key)();r.set(Gc.key,t);const n=r.get(Yc.key);return new Ce({key:e,...n,props:{...n.props,handleDOMEvents:{drop:i=>t.dropCallback(i),pointermove:(i,o)=>t.mousemoveCallback(i,o),keydown:i=>t.keydownCallback(i),dragover:(i,o)=>t.dragoverCallback(i,o),dragleave:(i,o)=>t.dragleaveCallback(i,o),dragenter:i=>t.dragenterCallback(i),dragend:i=>t.dragendCallback(i)}}})});Kl(Ep,{displayName:"Prose<block>"});var Et,ln,Ri,Ii,gl,as,yl,vl,ls,cs,us,Sc,Q3,D4,RS=(D4=class{constructor(r){P(this,Sc);P(this,Et);P(this,ln);P(this,Ri);P(this,Ii);P(this,gl);P(this,as);P(this,yl);P(this,vl);P(this,ls);P(this,cs);P(this,us);I(this,Ii,null),I(this,as,!1),this.update=()=>{requestAnimationFrame(()=>{if(!C(this,as))try{ui(this,Sc,Q3).call(this),I(this,as,!0)}catch{}})},this.destroy=()=>{var e,t;(e=C(this,Ri))==null||e.unBind(),(t=C(this,Ri))==null||t.removeEvent(C(this,Et)),C(this,Et).remove()},this.show=e=>{const t=e.el,n=C(this,ln).get(ge).dom,i={ctx:C(this,ln),active:e,editorDom:n,blockDom:C(this,Et)},o={contextElement:t,getBoundingClientRect:()=>C(this,cs)?C(this,cs).call(this,i):t.getBoundingClientRect()},s=[Vh()];if(C(this,ls)){const a=C(this,ls).call(this,i),l=Ki(a);s.push(l)}qr(o,C(this,Et),{placement:C(this,us)?C(this,us).call(this,i):"left",middleware:[...s,...C(this,yl)],...C(this,vl)}).then(({x:a,y:l})=>{Object.assign(C(this,Et).style,{left:`${a}px`,top:`${l}px`}),C(this,Et).dataset.show="true"}).catch(console.error)},this.hide=()=>{C(this,Et).dataset.show="false"},I(this,ln,r.ctx),I(this,Et,r.content),I(this,ls,r.getOffset),I(this,cs,r.getPosition),I(this,us,r.getPlacement),I(this,yl,r.middleware??[]),I(this,vl,r.floatingUIOptions??{}),I(this,gl,r.root),this.hide()}get active(){return C(this,Ii)}},Et=new WeakMap,ln=new WeakMap,Ri=new WeakMap,Ii=new WeakMap,gl=new WeakMap,as=new WeakMap,yl=new WeakMap,vl=new WeakMap,ls=new WeakMap,cs=new WeakMap,us=new WeakMap,Sc=new WeakSet,Q3=function(){const r=C(this,ln).get(ge);(C(this,gl)??r.dom.parentElement??document.body).appendChild(C(this,Et));const e=C(this,ln).get(Gc.key);e.bind(C(this,ln),t=>{t.type==="hide"?(this.hide(),I(this,Ii,null)):t.type==="show"&&(this.show(t.active),I(this,Ii,t.active))}),I(this,Ri,e),C(this,Ri).addEvent(C(this,Et)),C(this,Et).draggable=!0},D4),Jc=[Yc,Kc,Np,Gc,Ep];Jc.key=Yc.key;Jc.pluginKey=Ep.key;function IS(r){const e=ye({},`${r}_SLASH_SPEC`),t=Fe(i=>{const o=i.get(e.key);return new Ce({key:new Me(`${r}_SLASH`),...o})}),n=[e,t];return n.key=e.key,n.pluginKey=t.key,e.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${r}`},t.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${r}`},n}var ds,bl,wl,xl,kl,zi,Sl,hs,Cl,Ml,Tl,O4,zS=(O4=class{constructor(r){P(this,ds);P(this,bl);P(this,wl);P(this,xl);P(this,kl);P(this,zi);P(this,Sl);P(this,hs);P(this,Cl);P(this,Ml);P(this,Tl);I(this,ds,!1),this.onShow=()=>{},this.onHide=()=>{},I(this,Ml,(e,t)=>{const{state:n,composing:i}=e,{selection:o,doc:s}=n,{ranges:a}=o,l=Math.min(...a.map(d=>d.$from.pos)),c=Math.max(...a.map(d=>d.$to.pos)),u=t&&t.doc.eq(s)&&t.selection.eq(o);if(C(this,ds)||((C(this,xl)??e.dom.parentElement??document.body).appendChild(this.element),I(this,ds,!0)),!(i||u)){if(!C(this,Sl).call(this,e,t)){this.hide();return}qr({getBoundingClientRect:()=>Bc(e,l,c)},this.element,{placement:"bottom-start",middleware:[Vh(),Ki(C(this,Cl)),...C(this,bl)],...C(this,wl)}).then(({x:d,y:h})=>{Object.assign(this.element.style,{left:`${d}px`,top:`${h}px`})}).catch(console.error),this.show()}}),I(this,Tl,e=>{const t=this.getContent(e);if(!t)return!1;const n=t.at(-1);return n?Array.isArray(C(this,zi))?C(this,zi).includes(n):C(this,zi)===n:!1}),this.update=(e,t)=>{C(this,hs).call(this,e,t)},this.getContent=(e,t=n=>n.type.name==="paragraph")=>{const{selection:n}=e.state,{empty:i,$from:o}=n,s=e.state.selection instanceof Q;if(typeof document>"u")return;const a=this.element.contains(document.activeElement),l=!e.hasFocus()&&!a,c=!e.editable,u=!d9(t)(e.state.selection);if(!(l||c||!i||!s||u))return o.parent.textBetween(Math.max(0,o.parentOffset-500),o.parentOffset,void 0,"")},this.destroy=()=>{C(this,hs).cancel()},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=r.content,I(this,kl,r.debounce??200),I(this,Sl,r.shouldShow??C(this,Tl)),I(this,zi,r.trigger??"/"),I(this,Cl,r.offset),I(this,bl,r.middleware??[]),I(this,wl,r.floatingUIOptions??{}),I(this,xl,r.root),I(this,hs,Tp(C(this,Ml),C(this,kl)))}},ds=new WeakMap,bl=new WeakMap,wl=new WeakMap,xl=new WeakMap,kl=new WeakMap,zi=new WeakMap,Sl=new WeakMap,hs=new WeakMap,Cl=new WeakMap,Ml=new WeakMap,Tl=new WeakMap,O4);/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */function og(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function LS(r){if(Array.isArray(r))return r}function BS(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,o,s,a=[],l=!0,c=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(l=(n=o.call(t)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function PS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
37
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function FS(r,e){return LS(r)||BS(r,e)||HS(r,e)||PS()}function HS(r,e){if(r){if(typeof r=="string")return og(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?og(r,e):void 0}}const e6=Object.entries,sg=Object.setPrototypeOf,_S=Object.isFrozen,qS=Object.getPrototypeOf,$S=Object.getOwnPropertyDescriptor;let et=Object.freeze,it=Object.seal,Ao=Object.create,t6=typeof Reflect<"u"&&Reflect,hh=t6.apply,fh=t6.construct;et||(et=function(e){return e});it||(it=function(e){return e});hh||(hh=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)});fh||(fh=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const gi=Xe(Array.prototype.forEach),jS=Xe(Array.prototype.lastIndexOf),ag=Xe(Array.prototype.pop),Zs=Xe(Array.prototype.push),VS=Xe(Array.prototype.splice),Ro=Array.isArray,la=Xe(String.prototype.toLowerCase),od=Xe(String.prototype.toString),lg=Xe(String.prototype.match),Qs=Xe(String.prototype.replace),cg=Xe(String.prototype.indexOf),WS=Xe(String.prototype.trim),US=Xe(Number.prototype.toString),KS=Xe(Boolean.prototype.toString),ug=typeof BigInt>"u"?null:Xe(BigInt.prototype.toString),dg=typeof Symbol>"u"?null:Xe(Symbol.prototype.toString),Dt=Xe(Object.prototype.hasOwnProperty),ea=Xe(Object.prototype.toString),ct=Xe(RegExp.prototype.test),hi=GS(TypeError);function Xe(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return hh(r,e,n)}}function GS(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return fh(r,t)}}function ve(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:la;if(sg&&sg(r,null),!Ro(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(_S(e)||(e[n]=o),i=o)}r[i]=!0}return r}function YS(r){for(let e=0;e<r.length;e++)Dt(r,e)||(r[e]=null);return r}function _t(r){const e=Ao(null);for(const n of e6(r)){var t=FS(n,2);const i=t[0],o=t[1];Dt(r,i)&&(Ro(o)?e[i]=YS(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=_t(o):e[i]=o)}return e}function JS(r){switch(typeof r){case"string":return r;case"number":return US(r);case"boolean":return KS(r);case"bigint":return ug?ug(r):"0";case"symbol":return dg?dg(r):"Symbol()";case"undefined":return ea(r);case"function":case"object":{if(r===null)return ea(r);const e=r,t=er(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:ea(n)}return ea(r)}default:return ea(r)}}function er(r,e){for(;r!==null;){const n=$S(r,e);if(n){if(n.get)return Xe(n.get);if(typeof n.value=="function")return Xe(n.value)}r=qS(r)}function t(){return null}return t}function XS(r){try{return ct(r,""),!0}catch{return!1}}const hg=et(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),sd=et(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ad=et(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ZS=et(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ld=et(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),QS=et(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),fg=et(["#text"]),pg=et(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),cd=et(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mg=et(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),C0=et(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eC=it(/{{[\w\W]*|^[\w\W]*}}/g),tC=it(/<%[\w\W]*|^[\w\W]*%>/g),rC=it(/\${[\w\W]*/g),nC=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),iC=it(/^aria-[\-\w]+$/),gg=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oC=it(/^(?:\w+script|data):/i),sC=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aC=it(/^html$/i),lC=it(/^[a-z][.\w]*(-[.\w]+)+$/i),yg=it(/<[/\w!]/g),vg=it(/<[/\w]/g),cC=it(/<\/no(script|embed|frames)/i),uC=it(/\/>/i),Ht={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},r6=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],dC=et(ve({},r6)),hC=(function(){const r={};return gi(r6,e=>{r[e]=it(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),et(r)})(),fC=function(){return typeof window>"u"?null:window},pC=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},bg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Nn=function(e,t,n,i){return Dt(e,t)&&Ro(e[t])?ve(i.base?_t(i.base):{},e[t],i.transform):n},ud=function(e,t,n){const i=Dt(e,t)?e[t]:void 0;return i&&typeof i=="object"?_t(i):n()};function n6(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fC();const e=U=>n6(U);if(e.version="3.4.15",e.removed=[],!r||!r.document||r.document.nodeType!==Ht.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,a=r.Element,l=r.NodeFilter,c=r.NamedNodeMap;c===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const u=r.DOMParser,d=r.trustedTypes,h=a.prototype,f=er(h,"cloneNode"),m=er(h,"remove"),y=er(h,"removeAttributeNode"),x=er(h,"nextSibling"),b=er(h,"childNodes"),S=er(h,"parentNode"),A=er(h,"shadowRoot"),D=er(h,"attributes"),O=s&&s.prototype?er(s.prototype,"nodeType"):null,L=s&&s.prototype?er(s.prototype,"nodeName"):null,N=s&&s.prototype?er(s.prototype,"ownerDocument"):null,$=function(k){return O?O(k):k.nodeType},K=function(k){return L?L(k):k.nodeName};if(typeof o=="function"){const U=t.createElement("template");U.content&&U.content.ownerDocument&&(t=U.content.ownerDocument)}let ne,pe="",se,lt=!1,Re=0;const Ue=function(){if(Re>0)throw hi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},je=function(k){Ue(),Re++;try{return ne.createHTML(k)}finally{Re--}},Bt=function(k){Ue(),Re++;try{return ne.createScriptURL(k)}finally{Re--}},pr=function(){return lt||(se=pC(d,i),lt=!0),se},Cn=t,Jt=Cn.implementation,mr=Cn.createNodeIterator,ai=Cn.createDocumentFragment,Pt=Cn.getElementsByTagName,oo=n.importNode;let Te=bg();e.isSupported=typeof e6=="function"&&typeof S=="function"&&Jt&&Jt.createHTMLDocument!==void 0;const mu=eC,Mn=tC,Jl=rC,Tn=nC,Xl=iC,Zl=oC,js=sC,so=lC;let li=gg,Ee=null;const Vs=ve({},[...hg,...sd,...ad,...ld,...fg]);let De=null;const ao=ve({},[...pg,...cd,...mg,...C0]);let Ft=Object.seal(Ao(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ar=null,Ql=null;const Nr=Object.seal(Ao(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let lo=!0,co=!0,Ws=!1,e0=!0,Er=!1,Xt=!0,Zt=!1,gu=!1,t0=null,r0=null,yu=!1,uo=!1,n0=!1,i0=!1,nm=!0,im=!1;const om="user-content-";let vu=!0,bu=!1,ho={},fo=null;const sm=ve({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let am=null;const lm=ve({},["audio","video","img","source","image","track"]);let cm=null;const um=ve({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),o0="http://www.w3.org/1998/Math/MathML",s0="http://www.w3.org/2000/svg",Dr="http://www.w3.org/1999/xhtml";let po=Dr,wu=!1,xu=null;const ky=ve({},[o0,s0,Dr],od),dm=et(["mi","mo","mn","ms","mtext"]);let ku=ve({},dm);const hm=et(["annotation-xml"]);let Su=ve({},hm);const Sy=ve({},["title","style","font","a","script"]);let Us=null;const Cy=["application/xhtml+xml","text/html"],My="text/html";let Ve=null,mo=null;const Ty=t.createElement("form"),fm=function(k){return k instanceof RegExp||k instanceof Function},Cu=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(mo&&mo===k)return;(!k||typeof k!="object")&&(k={}),k=_t(k),Us=Cy.indexOf(k.PARSER_MEDIA_TYPE)===-1?My:k.PARSER_MEDIA_TYPE,Ve=Us==="application/xhtml+xml"?od:la,Ee=Nn(k,"ALLOWED_TAGS",Vs,{transform:Ve}),De=Nn(k,"ALLOWED_ATTR",ao,{transform:Ve}),xu=Nn(k,"ALLOWED_NAMESPACES",ky,{transform:od}),cm=Nn(k,"ADD_URI_SAFE_ATTR",um,{transform:Ve,base:um}),am=Nn(k,"ADD_DATA_URI_TAGS",lm,{transform:Ve,base:lm}),fo=Nn(k,"FORBID_CONTENTS",sm,{transform:Ve}),Ar=Nn(k,"FORBID_TAGS",_t({}),{transform:Ve}),Ql=Nn(k,"FORBID_ATTR",_t({}),{transform:Ve}),ho=Dt(k,"USE_PROFILES")?k.USE_PROFILES&&typeof k.USE_PROFILES=="object"?_t(k.USE_PROFILES):k.USE_PROFILES:!1,lo=k.ALLOW_ARIA_ATTR!==!1,co=k.ALLOW_DATA_ATTR!==!1,Ws=k.ALLOW_UNKNOWN_PROTOCOLS||!1,e0=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Er=k.SAFE_FOR_TEMPLATES||!1,Xt=k.SAFE_FOR_XML!==!1,Zt=k.WHOLE_DOCUMENT||!1,uo=k.RETURN_DOM||!1,n0=k.RETURN_DOM_FRAGMENT||!1,i0=k.RETURN_TRUSTED_TYPE||!1,yu=k.FORCE_BODY||!1,nm=k.SANITIZE_DOM!==!1,im=k.SANITIZE_NAMED_PROPS||!1,vu=k.KEEP_CONTENT!==!1,bu=k.IN_PLACE||!1,li=XS(k.ALLOWED_URI_REGEXP)?k.ALLOWED_URI_REGEXP:gg,po=typeof k.NAMESPACE=="string"?k.NAMESPACE:Dr,ku=ud(k,"MATHML_TEXT_INTEGRATION_POINTS",()=>ve({},dm)),Su=ud(k,"HTML_INTEGRATION_POINTS",()=>ve({},hm));const R=ud(k,"CUSTOM_ELEMENT_HANDLING",()=>Ao(null));if(Ft=Ao(null),Dt(R,"tagNameCheck")&&fm(R.tagNameCheck)&&(Ft.tagNameCheck=R.tagNameCheck),Dt(R,"attributeNameCheck")&&fm(R.attributeNameCheck)&&(Ft.attributeNameCheck=R.attributeNameCheck),Dt(R,"allowCustomizedBuiltInElements")&&typeof R.allowCustomizedBuiltInElements=="boolean"&&(Ft.allowCustomizedBuiltInElements=R.allowCustomizedBuiltInElements),it(Ft),Er&&(co=!1),n0&&(uo=!0),ho&&(Ee=ve({},fg),De=Ao(null),ho.html===!0&&(ve(Ee,hg),ve(De,pg)),ho.svg===!0&&(ve(Ee,sd),ve(De,cd),ve(De,C0)),ho.svgFilters===!0&&(ve(Ee,ad),ve(De,cd),ve(De,C0)),ho.mathMl===!0&&(ve(Ee,ld),ve(De,mg),ve(De,C0))),Nr.tagCheck=null,Nr.attributeCheck=null,Dt(k,"ADD_TAGS")&&(typeof k.ADD_TAGS=="function"?Nr.tagCheck=k.ADD_TAGS:Ro(k.ADD_TAGS)&&(Ee===Vs&&(Ee=_t(Ee)),ve(Ee,k.ADD_TAGS,Ve))),Dt(k,"ADD_ATTR")&&(typeof k.ADD_ATTR=="function"?Nr.attributeCheck=k.ADD_ATTR:Ro(k.ADD_ATTR)&&(De===ao&&(De=_t(De)),ve(De,k.ADD_ATTR,Ve))),Dt(k,"ADD_FORBID_CONTENTS")&&Ro(k.ADD_FORBID_CONTENTS)&&(fo===sm&&(fo=_t(fo)),ve(fo,k.ADD_FORBID_CONTENTS,Ve)),vu&&(Ee["#text"]=!0),Zt&&ve(Ee,["html","head","body"]),Ee.table&&(ve(Ee,["tbody"]),delete Ar.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const _=ne;ne=k.TRUSTED_TYPES_POLICY;try{pe=je("")}catch(J){throw ne=_,J}}else k.TRUSTED_TYPES_POLICY===null?(ne=void 0,pe=""):(ne===void 0&&(ne=pr()),ne&&typeof pe=="string"&&(pe=je("")));et&&et(k),mo=k},pm=ve({},[...sd,...ad,...ZS]),mm=ve({},[...ld,...QS]),Ay=function(k,R,_){return R.namespaceURI===Dr?k==="svg":R.namespaceURI===o0?k==="svg"&&(_==="annotation-xml"||ku[_]):!!pm[k]},Ny=function(k,R,_){return R.namespaceURI===Dr?k==="math":R.namespaceURI===s0?k==="math"&&Su[_]:!!mm[k]},Ey=function(k,R,_){return R.namespaceURI===s0&&!Su[_]||R.namespaceURI===o0&&!ku[_]?!1:!mm[k]&&(Sy[k]||!pm[k])},Dy=function(k){let R=S(k);(!R||!R.tagName)&&(R={namespaceURI:po,tagName:"template"});const _=la(k.tagName),J=la(R.tagName);return xu[k.namespaceURI]?k.namespaceURI===s0?Ay(_,R,J):k.namespaceURI===o0?Ny(_,R,J):k.namespaceURI===Dr?Ey(_,R,J):!!(Us==="application/xhtml+xml"&&xu[k.namespaceURI]):!1},An=function(k){Zs(e.removed,{element:k});try{S(k).removeChild(k)}catch{if(m(k),!S(k))throw hi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},gm=function(k,R,_){try{y(k,R)}catch{try{k.removeAttribute(_)}catch{}}},a0=function(k){l0(k);const R=b(k);if(R){const J=[];gi(R,te=>{Zs(J,te)}),gi(J,te=>{try{m(te)}catch{}})}const _=D(k);if(_)for(let J=_.length-1;J>=0;--J){const te=_[J],ce=te&&te.name;typeof ce=="string"&&gm(k,te,ce)}},ci=function(k,R,_){if(!_)try{_=R.getAttributeNode(k)}catch{_=null}Zs(e.removed,{attribute:_||null,from:R});try{_?y(R,_):R.removeAttribute(k)}catch{try{R.removeAttribute(k)}catch{}}if(k==="is")if(uo||n0)try{An(R)}catch{}else try{R.setAttribute(k,"")}catch{}},Oy=function(k){const R=D(k);if(R)for(let _=R.length-1;_>=0;--_){const J=R[_],te=J&&J.name;typeof te!="string"||De[Ve(te)]||gm(k,J,te)}},l0=function(k){const R=[k];for(;R.length>0;){const _=R.pop();$(_)===Ht.element&&Oy(_);const te=b(_);if(te)for(let ce=te.length-1;ce>=0;--ce)R.push(te[ce])}},ym=function(k,R){return Xt?k==="patchsrc"?!0:k==="for"&&R!=="label"&&R!=="output":!1},Ry=function(k){if(!Xt)return;const R=[k];for(;R.length>0;){const _=R.pop(),J=$(_);if(J===Ht.processingInstruction||J===Ht.comment&&ct(vg,_.data)){try{m(_)}catch{}continue}if(J===Ht.element){const ce=_,Oe=Ve(K(_));try{ce.hasAttribute&&ce.hasAttribute("patchsrc")&&ce.removeAttribute("patchsrc"),ce.hasAttribute&&ce.hasAttribute("for")&&ym("for",Oe)&&ce.removeAttribute("for")}catch{}}const te=b(_);if(te)for(let ce=te.length-1;ce>=0;--ce)R.push(te[ce])}},vm=function(k){let R=null,_=null;if(yu)k="<remove></remove>"+k;else{const ce=lg(k,/^[\r\n\t ]+/);_=ce&&ce[0]}Us==="application/xhtml+xml"&&po===Dr&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const J=ne?je(k):k;if(po===Dr)try{R=new u().parseFromString(J,Us)}catch{}if(!R||!R.documentElement){R=Jt.createDocument(po,"template",null);try{R.documentElement.innerHTML=wu?pe:J}catch{}}const te=R.body||R.documentElement;return k&&_&&te.insertBefore(t.createTextNode(_),te.childNodes[0]||null),po===Dr?Pt.call(R,Zt?"html":"body")[0]:Zt?R.documentElement:te},bm=function(k){const R=N?N(k):k.ownerDocument;return mr.call(R||k,k,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},c0=function(k){return k=Qs(k,mu," "),k=Qs(k,Mn," "),k=Qs(k,Jl," "),k},Mu=function(k){var R;k.normalize();const _=N?N(k):k.ownerDocument,J=mr.call(_||k,k,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let te=J.nextNode();for(;te;)te.data=c0(te.data),te=J.nextNode();const ce=(R=k.querySelectorAll)===null||R===void 0?void 0:R.call(k,"template");ce&&gi(ce,Oe=>{go(Oe.content)&&Mu(Oe.content)})},u0=function(k){const R=L?L(k):null;return typeof R!="string"||Ve(R)!=="form"?!1:typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||k.attributes!==D(k)||typeof k.removeAttribute!="function"||typeof k.removeAttributeNode!="function"||typeof k.getAttributeNode!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function"||k.nodeType!==O(k)||k.childNodes!==b(k)},go=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return O(k)===Ht.documentFragment}catch{return!1}},Ks=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return typeof O(k)=="number"}catch{return!1}};function Or(U,k,R){U.length!==0&&gi(U,_=>{_.call(e,k,R,mo)})}const Iy=function(k,R){return!!(Xt&&k.hasChildNodes()&&!Ks(k.firstElementChild)&&ct(yg,k.textContent)&&ct(yg,k.innerHTML)||Xt&&k.namespaceURI===Dr&&dC[R]&&(Ks(k.firstElementChild)||typeof k.textContent=="string"&&ct(hC[R],k.textContent))||k.nodeType===Ht.processingInstruction||Xt&&k.nodeType===Ht.comment&&ct(vg,k.data))},d0=function(k,R){if(k instanceof RegExp)return ct(k,R);if(k instanceof Function){for(var _=arguments.length,J=new Array(_>2?_-2:0),te=2;te<_;te++)J[te-2]=arguments[te];return!!k(R,...J)}return!1},zy=function(k,R,_){if(!Ar[R]&&Cm(R)&&d0(Ft.tagNameCheck,R))return!1;if(vu&&!fo[R]){const J=S(k),te=b(k);if(te&&J){const ce=te.length;for(let Oe=ce-1;Oe>=0;--Oe){const Le=k===_?f(te[Oe],!0):te[Oe];J.insertBefore(Le,x(k))}}}return An(k),!0},wm=function(k,R,_,J){return k.length===0?R:R===_||R===J?_t(R):R},xm=function(k,R){return k===R||S(k)!==null?!1:(bu&&l0(k),!0)},km=function(k,R){if(Or(Te.beforeSanitizeElements,k,null),xm(k,R))return!0;if(u0(k))return An(k),!0;const _=Ve(K(k));if(Ee=wm(Te.uponSanitizeElement,Ee,Vs,t0),Or(Te.uponSanitizeElement,k,{tagName:_,allowedTags:Ee}),xm(k,R))return!0;if(Iy(k,_))return An(k),!0;if(Ar[_]||!(Nr.tagCheck instanceof Function&&Nr.tagCheck(_))&&!Ee[_]){const te=zy(k,_,R);return te===!1&&Or(Te.afterSanitizeElements,k,null),te}if($(k)===Ht.element&&!Dy(k)||(_==="noscript"||_==="noembed"||_==="noframes")&&ct(cC,k.innerHTML))return An(k),!0;if(Er&&k.nodeType===Ht.text){const te=c0(k.textContent);k.textContent!==te&&(Zs(e.removed,{element:k.cloneNode()}),k.textContent=te)}return Or(Te.afterSanitizeElements,k,null),!1},Sm=function(k,R,_){if(Ql[R]||ym(R,k)||nm&&(R==="id"||R==="name")&&(_ in t||_ in Ty))return!1;const J=De[R]||Nr.attributeCheck instanceof Function&&Nr.attributeCheck(R,k);return co&&ct(Tn,R)||lo&&ct(Xl,R)?!0:J?cm[R]||ct(li,Qs(_,js,""))||(R==="src"||R==="xlink:href"||R==="href")&&k!=="script"&&cg(_,"data:")===0&&am[k]||Ws&&!ct(Zl,Qs(_,js,""))?!0:!_:Cm(k)&&d0(Ft.tagNameCheck,k)&&d0(Ft.attributeNameCheck,R,k)||R==="is"&&Ft.allowCustomizedBuiltInElements&&d0(Ft.tagNameCheck,_)},Ly=ve({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Cm=function(k){return!Ly[la(k)]&&ct(so,k)},By=function(k,R,_,J){if(ne&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!_)switch(d.getAttributeType(k,R)){case"TrustedHTML":return je(J);case"TrustedScriptURL":return Bt(J)}return J},Py=function(k,R,_,J){try{return _?k.setAttributeNS(_,R,J):k.setAttribute(R,J),u0(k)?(An(k),!1):!0}catch{return ci(R,k),!1}},Mm=function(k){Or(Te.beforeSanitizeAttributes,k,null);const R=k.attributes;if(!R||u0(k))return;De=wm(Te.uponSanitizeAttribute,De,ao,r0);const _={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:De,forceKeepAttr:void 0};let J=R.length;const te=Ve(k.nodeName);for(;J--;){const ce=R[J],Oe=ce.name,Le=ce.namespaceURI,Mt=ce.value,Tt=Ve(Oe),Au=Mt;let gt=Oe==="value"?Au:WS(Au),Tm=!1;if(_.attrName=Tt,_.attrValue=gt,_.keepAttr=!0,_.forceKeepAttr=void 0,Or(Te.uponSanitizeAttribute,k,_),gt=_.attrValue,im&&(Tt==="id"||Tt==="name")&&cg(gt,om)!==0&&(ci(Oe,k,ce),gt=om+gt,Tm=!0),Xt&&ct(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,gt)){ci(Oe,k,ce);continue}if(Tt==="attributename"&&lg(gt,"href")){ci(Oe,k,ce);continue}if(!_.forceKeepAttr){if(!_.keepAttr){ci(Oe,k,ce);continue}if(!e0&&ct(uC,gt)){ci(Oe,k,ce);continue}if(Er&&(gt=c0(gt)),!Sm(te,Tt,gt)){ci(Oe,k,ce);continue}gt=By(te,Tt,Le,gt),gt!==Au&&Py(k,Oe,Le,gt)&&Tm&&ag(e.removed)}}Or(Te.afterSanitizeAttributes,k,null)},h0=function(k){let R=null;const _=bm(k);for(Or(Te.beforeSanitizeShadowDOM,k,null);R=_.nextNode();)if(Or(Te.uponSanitizeShadowNode,R,null),km(R,k),Mm(R),go(R.content)&&h0(R.content),$(R)===Ht.element){const J=A(R);go(J)&&(Tu(J),h0(J))}Or(Te.afterSanitizeShadowDOM,k,null)},Tu=function(k){const R=[{node:k,shadow:null}];for(;R.length>0;){const _=R.pop();if(_.shadow){h0(_.shadow);continue}const J=_.node,ce=$(J)===Ht.element,Oe=b(J);if(Oe)for(let Le=Oe.length-1;Le>=0;--Le)R.push({node:Oe[Le],shadow:null});if(ce){const Le=L?L(J):null;if(typeof Le=="string"&&Ve(Le)==="template"){const Mt=J.content;go(Mt)&&R.push({node:Mt,shadow:null})}}if(ce){const Le=A(J);go(Le)&&R.push({node:null,shadow:Le},{node:Le,shadow:null})}}};return e.sanitize=function(U){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},R=null,_=null,J=null,te=null;if(wu=!U,wu&&(U="<!-->"),typeof U!="string"&&!Ks(U)&&(U=JS(U),typeof U!="string"))throw hi("dirty is not a string, aborting");if(!e.isSupported)return U;gu?(Ee=t0,De=r0):Cu(k),(Te.uponSanitizeElement.length>0||Te.uponSanitizeAttribute.length>0)&&(Ee=_t(Ee)),Te.uponSanitizeAttribute.length>0&&(De=_t(De)),e.removed=[];const ce=bu&&typeof U!="string"&&Ks(U);if(ce){Ry(U);const Mt=K(U);if(typeof Mt=="string"){const Tt=Ve(Mt);if(!Ee[Tt]||Ar[Tt])throw a0(U),hi("root node is forbidden and cannot be sanitized in-place")}if(u0(U))throw a0(U),hi("root node is clobbered and cannot be sanitized in-place");try{Tu(U)}catch(Tt){throw a0(U),Tt}}else if(Ks(U))R=vm("<!---->"),_=R.ownerDocument.importNode(U,!0),_.nodeType===Ht.element&&_.nodeName==="BODY"||_.nodeName==="HTML"?R=_:R.appendChild(_),Tu(R);else{if(!uo&&!Er&&!Zt&&U.indexOf("<")===-1)return ne&&i0?je(U):U;if(R=vm(U),!R)return uo?null:i0?pe:""}R&&yu&&An(R.firstChild);const Oe=ce?U:R;try{const Mt=bm(Oe);for(;J=Mt.nextNode();)km(J,Oe),Mm(J),go(J.content)&&h0(J.content)}catch(Mt){throw ce&&(a0(U),gi(e.removed,Tt=>{Tt.element&&l0(Tt.element)})),Mt}if(ce)return gi(e.removed,Mt=>{Mt.element&&l0(Mt.element)}),Er&&Mu(U),U;if(uo){if(Er&&Mu(R),n0)for(te=ai.call(R.ownerDocument);R.firstChild;)te.appendChild(R.firstChild);else te=R;return(De.shadowroot||De.shadowrootmode)&&(te=oo.call(n,te,!0)),te}let Le=Zt?R.outerHTML:R.innerHTML;return Zt&&Ee["!doctype"]&&R.ownerDocument&&R.ownerDocument.doctype&&R.ownerDocument.doctype.name&&ct(aC,R.ownerDocument.doctype.name)&&(Le="<!DOCTYPE "+R.ownerDocument.doctype.name+`>
38
- `+Le),Er&&(Le=c0(Le)),ne&&i0?je(Le):Le},e.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cu(U),gu=!0,t0=Ee,r0=De},e.clearConfig=function(){mo=null,gu=!1,t0=null,r0=null,ne=se,pe=""},e.isValidAttribute=function(U,k,R){mo||Cu({});const _=Ve(U),J=Ve(k);return Sm(_,J,R)},e.addHook=function(U,k){typeof k=="function"&&Dt(Te,U)&&Zs(Te[U],k)},e.removeHook=function(U,k){if(Dt(Te,U)){if(k!==void 0){const R=jS(Te[U],k);return R===-1?void 0:VS(Te[U],R,1)[0]}return ag(Te[U])}},e.removeHooks=function(U){Dt(Te,U)&&(Te[U]=[])},e.removeAllHooks=function(){Te=bg()},e}var i6=n6();/**
36
+ `);const o=e.topNodeType.createAndFill(void 0,n.content);return o?i(o):""}}})});Hk(_3,{displayName:"Prose<clipboard>"});var dc=200,nt=function(){};nt.prototype.append=function(e){return e.length?(e=nt.from(e),!this.length&&e||e.length<dc&&this.leafAppend(e)||this.length<dc&&e.leafPrepend(this)||this.appendInner(e)):this};nt.prototype.prepend=function(e){return e.length?nt.from(e).append(this):this};nt.prototype.appendInner=function(e){return new _k(this,e)};nt.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nt.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};nt.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};nt.from=function(e){return e instanceof nt?e:e&&e.length?new q3(e):nt.empty};var q3=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=dc)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=dc)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(nt);nt.empty=new q3([]);var _k=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(n,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(n,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(n,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(n,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(nt);const qk=500;class xr{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){i||(i=this.remapping(n,h+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new Rr(d.map));let f=d.step.map(i.slice(o)),m;f&&s.maybeStep(f).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new Rr(m,void 0,void 0,c.length+u.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(o)):d.selection,l=new xr(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,t,n,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Rr(e.mapping.maps[u],d,t),f;(f=l&&l.merge(h))&&(h=f,u?o.pop():a=a.slice(0,a.length-1)),o.push(h),t&&(s++,t=void 0),i||(l=h)}let c=s-n.depth;return c>$k&&(a=jk(a,c),s-=c),new xr(a.append(o),s)}remapping(e,t){let n=new Na;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new xr(this.items.append(e.map(t=>new Rr(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=t;this.items.forEach(h=>{let f=o.getMirror(--l);if(f==null)return;s=Math.min(s,f);let m=o.maps[f];if(h.step){let y=e.steps[f].invert(e.docs[f]),x=h.selection&&h.selection.map(o.slice(l+1,f));x&&a++,n.push(new Rr(m,y,x))}else n.push(new Rr(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new Rr(o.maps[h]));let u=this.items.slice(0,i).append(c).append(n),d=new xr(u,a);return d.emptyItemCount()>qk&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(t.slice(n)),c=l&&l.getMap();if(n--,c&&t.appendMap(c,n),l){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let d=new Rr(c.invert(),l,u),h,f=i.length-1;(h=i.length&&i[f].merge(d))?i[f]=h:i.push(d)}}else s.map&&n--},this.items.length,0),new xr(nt.from(i.reverse()),o)}}xr.empty=new xr(nt.empty,0);function jk(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Rr{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Rr(t.getMap().invert(),t,this.selection)}}}class zn{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const $k=20;function Vk(r,e,t,n){let i=t.getMeta($i),o;if(i)return i.historyState;t.getMeta(Kk)&&(r=new zn(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta($i))return s.getMeta($i).redo?new zn(r.done.addTransform(t,void 0,n,X0(e)),r.undone,Z1(t.mapping.maps),r.prevTime,r.prevComposition):new zn(r.done,r.undone.addTransform(t,void 0,n,X0(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=r.prevTime==0||!s&&r.prevComposition!=a&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Wk(t,r.prevRanges)),c=s?rd(r.prevRanges,t.mapping):Z1(t.mapping.maps);return new zn(r.done.addTransform(t,l?e.selection.getBookmark():void 0,n,X0(e)),xr.empty,c,t.time,a??r.prevComposition)}else return(o=t.getMeta("rebased"))?new zn(r.done.rebased(t,o),r.undone.rebased(t,o),rd(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new zn(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),rd(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Wk(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Z1(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function rd(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function Uk(r,e,t){let n=X0(e),i=$i.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),l=new zn(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta($i,{redo:t,historyState:l})}let nd=!1,Q1=null;function X0(r){let e=r.plugins;if(Q1!=e){nd=!1,Q1=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){nd=!0;break}}return nd}const $i=new Me("history"),Kk=new Me("closeHistory");function Gk(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Ce({key:$i,state:{init(){return new zn(xr.empty,xr.empty,null,0,-1)},apply(e,t,n){return Vk(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?wp:n=="historyRedo"?hc:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function j3(r,e){return(t,n)=>{let i=$i.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=Uk(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const wp=j3(!1,!0),hc=j3(!0,!0);function Fs(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-history",...e}}),r}var xp=le("Undo",()=>()=>wp);Fs(xp,{displayName:"Command<undo>"});var kp=le("Redo",()=>()=>hc);Fs(kp,{displayName:"Command<redo>"});var Sp=ye({},"historyProviderConfig");Fs(Sp,{displayName:"Ctx<historyProviderConfig>"});var $3=Fe(r=>Gk(r.get(Sp.key)));Fs($3,{displayName:"Ctx<historyProviderPlugin>"});var Cp=Lt("historyKeymap",{Undo:{shortcuts:"Mod-z",command:r=>{const e=r.get(ee);return()=>e.call(xp.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:r=>{const e=r.get(ee);return()=>e.call(kp.key)}}});Fs(Cp.ctx,{displayName:"KeymapCtx<history>"});Fs(Cp.shortcuts,{displayName:"Keymap<history>"});var Yk=[Sp,$3,Cp,xp,kp].flat();function Jk(r,e){const{doc:t,selection:n}=r;if(!t||!n||!(n instanceof Q||n instanceof Rt))return r;const{to:i}=n,o=e.type==="space"?Array(e.size).fill(" ").join(""):" ";return r.insertText(o,i)}var Mp=ye({type:"space",size:2},"indentConfig");Mp.meta={package:"@milkdown/plugin-indent",displayName:"Ctx<indentConfig>"};var V3=K5(r=>({Tab:(e,t)=>{const n=r.get(Mp.key),{tr:i}=e,o=Jk(i,n);return o.docChanged?(t==null||t(o),!0):!1}}));V3.meta={package:"@milkdown/plugin-indent",displayName:"Shortcut<indent>"};var Xk=[Mp,V3],Zk=typeof global=="object"&&global&&global.Object===Object&&global,Qk=typeof self=="object"&&self&&self.Object===Object&&self,W3=Zk||Qk||Function("return this")(),fc=W3.Symbol,U3=Object.prototype,eS=U3.hasOwnProperty,tS=U3.toString,Xs=fc?fc.toStringTag:void 0;function rS(r){var e=eS.call(r,Xs),t=r[Xs];try{r[Xs]=void 0;var n=!0}catch{}var i=tS.call(r);return n&&(e?r[Xs]=t:delete r[Xs]),i}var nS=Object.prototype,iS=nS.toString;function oS(r){return iS.call(r)}var sS="[object Null]",aS="[object Undefined]",eg=fc?fc.toStringTag:void 0;function lS(r){return r==null?r===void 0?aS:sS:eg&&eg in Object(r)?rS(r):oS(r)}function cS(r){return r!=null&&typeof r=="object"}var uS="[object Symbol]";function dS(r){return typeof r=="symbol"||cS(r)&&lS(r)==uS}var hS=/\s/;function fS(r){for(var e=r.length;e--&&hS.test(r.charAt(e)););return e}var pS=/^\s+/;function mS(r){return r&&r.slice(0,fS(r)+1).replace(pS,"")}function pc(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var tg=NaN,gS=/^[-+]0x[0-9a-f]+$/i,yS=/^0b[01]+$/i,vS=/^0o[0-7]+$/i,bS=parseInt;function rg(r){if(typeof r=="number")return r;if(dS(r))return tg;if(pc(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=pc(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=mS(r);var t=yS.test(r);return t||vS.test(r)?bS(r.slice(2),t?2:8):gS.test(r)?tg:+r}var id=function(){return W3.Date.now()},wS="Expected a function",xS=Math.max,kS=Math.min;function Tp(r,e,t){var n,i,o,s,a,l,c=0,u=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(wS);e=rg(e)||0,pc(t)&&(u=!!t.leading,d="maxWait"in t,o=d?xS(rg(t.maxWait)||0,e):o,h="trailing"in t?!!t.trailing:h);function f(L){var N=n,j=i;return n=i=void 0,c=L,s=r.apply(j,N),s}function m(L){return c=L,a=setTimeout(b,e),u?f(L):s}function y(L){var N=L-l,j=L-c,K=e-N;return d?kS(K,o-j):K}function x(L){var N=L-l,j=L-c;return l===void 0||N>=e||N<0||d&&j>=o}function b(){var L=id();if(x(L))return S(L);a=setTimeout(b,y(L))}function S(L){return a=void 0,h&&n?f(L):(n=i=void 0,s)}function A(){a!==void 0&&clearTimeout(a),c=0,n=l=i=a=void 0}function D(){return a===void 0?s:S(id())}function O(){var L=id(),N=x(L);if(n=arguments,i=this,l=L,N){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(b,e),f(l)}return a===void 0&&(a=setTimeout(b,e)),s}return O.cancel=A,O.flush=D,O}var SS="Expected a function";function K3(r,e,t){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(SS);return pc(t)&&(n="leading"in t?!!t.leading:n,i="trailing"in t?!!t.trailing:i),Tp(r,e,{leading:n,maxWait:e,trailing:i})}var G3=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=r=>(this.beforeMountedListeners.push(r),this),this.mounted=r=>(this.mountedListeners.push(r),this),this.updated=r=>(this.updatedListeners.push(r),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(r){return this.markdownUpdatedListeners.push(r),this}blur(r){return this.blurListeners.push(r),this}focus(r){return this.focusListeners.push(r),this}destroy(r){return this.destroyListeners.push(r),this}selectionUpdated(r){return this.selectionUpdatedListeners.push(r),this}},dh=me(new G3,"listener"),CS=new Me("MILKDOWN_LISTENER"),Y3=r=>(r.inject(dh,new G3),async()=>{await r.wait(qi);const{listeners:e}=r.get(dh);e.beforeMount.forEach(c=>c(r)),await r.wait(xa);const t=r.get(ka);let n=null,i=null,o=null,s=null;const a=Tp(()=>{if(!s)return;const{doc:c}=s;if(e.updated.length>0&&n&&!n.eq(c)&&e.updated.forEach(u=>{u(r,c,n)}),e.markdownUpdated.length>0&&n&&!n.eq(c)){const u=t(c);e.markdownUpdated.forEach(d=>{d(r,u,i)}),i=u}n=c,s=null},200),l=new Ce({key:CS,view:()=>({destroy:()=>{a.cancel(),e.destroy.forEach(c=>c(r))}}),props:{handleDOMEvents:{focus:()=>(e.focus.forEach(c=>c(r)),!1),blur:()=>(e.blur.forEach(c=>c(r)),!1)}},state:{init:(c,u)=>{n=u.doc,i=t(u.doc)},apply:c=>{const u=c.selection;(!o&&u||o&&!u.eq(o))&&(e.selectionUpdated.forEach(d=>{d(r,u,o)}),o=u),!(!(c.docChanged||c.storedMarksSet)||c.getMeta("addToHistory")===!1)&&(s=c,a())}}});r.update(vn,c=>c.concat(l)),await r.wait(U0),e.mounted.forEach(c=>c(r))});Y3.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var Ap=ye({shouldAppend:r=>!(!r||["heading","paragraph"].includes(r.type.name)),getNode:r=>r.schema.nodes.paragraph.create()},"trailingConfig");Ap.meta={package:"@milkdown/plugin-trailing",displayName:"Ctx<trailingConfig>"};var J3=Fe(r=>{const e=new Me("MILKDOWN_TRAILING"),{shouldAppend:t,getNode:n}=r.get(Ap.key),i=new Ce({key:e,state:{init:(o,s)=>{const a=s.tr.doc.lastChild;return t(a,s)},apply:(o,s,a,l)=>{if(!o.docChanged)return s;const c=o.doc.lastChild;return t(c,l)}},appendTransaction:(o,s,a)=>{const{doc:l,tr:c}=a,u=n==null?void 0:n(a),d=i.getState(a),h=l.content.size;if(!(!d||!u))return c.insert(h,u)}});return i});J3.meta={package:"@milkdown/plugin-trailing",displayName:"Prose<trailing>"};var MS=[Ap,J3];function TS(r){return new Promise(e=>{const t=new FileReader;t.addEventListener("load",()=>{e({alt:r.name,src:t.result})},!1),t.readAsDataURL(r)})}var AS=async(r,e)=>{const t=[];for(let i=0;i<r.length;i++){const o=r.item(i);o&&o.type.includes("image")&&t.push(o)}const{image:n}=e.nodes;if(!n)throw u5("image");return(await Promise.all(t.map(i=>TS(i)))).map(({alt:i,src:o})=>n.createAndFill({src:o,alt:i}))},Oo=ye({uploader:AS,enableHtmlFileUploader:!1,uploadWidgetFactory:(r,e)=>{const t=document.createElement("span");return t.textContent="Upload in progress...",qe.widget(r,t,e)}},"uploadConfig");Oo.meta={package:"@milkdown/plugin-upload",displayName:"Ctx<uploadConfig>"};var X3=Fe(r=>{const e=new Me("MILKDOWN_UPLOAD"),t=(i,o)=>{var l;const s=e.getState(i);if(!s)return-1;const a=s.find(void 0,void 0,c=>c.id===o);return a.length?((l=a[0])==null?void 0:l.from)??-1:-1},n=(i,o,s)=>{var m;if(!s||s.length<=0)return!1;const a=Symbol("upload symbol"),l=r.get(Sr),{uploader:c,getInsertPos:u}=r.get(Oo.key),{tr:d}=i.state,h=o instanceof DragEvent?((m=i.posAtCoords({left:o.clientX,top:o.clientY}))==null?void 0:m.pos)??d.selection.from:d.selection.from,f=typeof u=="function"?u(o,r,h):h;return i.dispatch(d.setMeta(e,{add:{id:a,pos:f}})),c(s,l,r,f).then(y=>{const x=t(i.state,a);x<0||i.dispatch(i.state.tr.replaceWith(x,x,y).setMeta(e,{remove:{id:a}}))}).catch(y=>{console.error(y)}),!0};return new Ce({key:e,state:{init(){return Se.empty},apply(i,o){const s=o.map(i.mapping,i.doc),a=i.getMeta(this);if(!a)return s;if(a.add){const{uploadWidgetFactory:l}=r.get(Oo.key),c=l(a.add.pos,{id:a.add.id});return s.add(i.doc,[c])}if(a.remove){const l=s.find(void 0,void 0,c=>c.id===a.remove.id);return s.remove(l)}return s}},props:{decorations(i){return this.getState(i)},handlePaste:(i,o)=>{var a,l;const{enableHtmlFileUploader:s}=r.get(Oo.key);return!(o instanceof ClipboardEvent)||!s&&((a=o.clipboardData)!=null&&a.getData("text/html"))?!1:n(i,o,(l=o.clipboardData)==null?void 0:l.files)},handleDrop:(i,o)=>{var s;return o instanceof DragEvent?n(i,o,(s=o.dataTransfer)==null?void 0:s.files):!1}}})});X3.meta={package:"@milkdown/plugin-upload",displayName:"Prose<upload>"};var NS=[Oo,X3];function Kl(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-block",...e}}),r}var ES=r=>!Fr(e=>e.type.name==="table")(r),Kc=ye({filterNodes:ES},"blockConfig");Kl(Kc,{displayName:"Ctx<blockConfig>"});function DS(r,e,t){var n;if(!r.dom.parentElement)return null;try{const i=(n=r.posAtCoords({left:e.x,top:e.y}))==null?void 0:n.inside;if(i==null||i<0)return null;let o=r.state.doc.resolve(i),s=r.state.doc.nodeAt(i),a=r.nodeDOM(i);const l=c=>{const u=o.depth>=1&&o.index(o.depth)===0;if(!(c||u))return;const d=o.before(o.depth);s=r.state.doc.nodeAt(d),a=r.nodeDOM(d),o=r.state.doc.resolve(d),t(o,s)||l(!0)};return l(!t(o,s)),!a||!s?null:{node:s,$pos:o,el:a}}catch{return null}}var ng=w0.ie&&w0.ie_version<15||w0.ios&&w0.webkit_version<604,ig=20,es,fl,qn,vr,ts,br,Lr,Z3,To,Di,Oi,pl,rs,ns,is,ss,ml,jn,E4,OS=(E4=class{constructor(){P(this,Lr);P(this,es);P(this,fl);P(this,qn);P(this,vr);P(this,ts);P(this,br);P(this,Di);P(this,Oi);P(this,pl);P(this,rs);P(this,ns);P(this,is);P(this,ss);P(this,ml);P(this,jn);I(this,fl,()=>{if(!C(this,vr))return null;const r=C(this,vr),e=C(this,Lr,To);if(I(this,qn,null),e&&re.isSelectable(r.node)){const t=re.create(e.state.doc,r.$pos.pos);return e.dispatch(e.state.tr.setSelection(t)),e.focus(),I(this,qn,t),t}return null}),I(this,qn,null),I(this,vr,null),I(this,ts,void 0),I(this,br,!1),I(this,Oi,()=>{var r;(r=C(this,Di))==null||r.call(this,{type:"hide"}),I(this,vr,null)}),I(this,pl,r=>{var e;I(this,vr,r),(e=C(this,Di))==null||e.call(this,{type:"show",active:r})}),this.bind=(r,e)=>{I(this,es,r),I(this,Di,e)},this.addEvent=r=>{r.addEventListener("mousedown",C(this,rs)),r.addEventListener("mouseup",C(this,ns)),r.addEventListener("dragstart",C(this,is)),r.addEventListener("dragend",C(this,ss))},this.removeEvent=r=>{r.removeEventListener("mousedown",C(this,rs)),r.removeEventListener("mouseup",C(this,ns)),r.removeEventListener("dragstart",C(this,is)),r.removeEventListener("dragend",C(this,ss))},this.unBind=()=>{I(this,Di,void 0)},I(this,rs,()=>{var r;I(this,ts,(r=C(this,vr))==null?void 0:r.el.getBoundingClientRect()),C(this,fl).call(this)}),I(this,ns,()=>{if(!C(this,br)){requestAnimationFrame(()=>{var r;C(this,ts)&&((r=C(this,Lr,To))==null||r.focus())});return}I(this,br,!1),I(this,qn,null)}),I(this,is,r=>{var n;I(this,br,!0);const e=C(this,Lr,To);if(!e)return;e.dom.dataset.dragging="true";const t=C(this,qn);if(r.dataTransfer&&t){const i=t.content();r.dataTransfer.effectAllowed="copyMove";const{dom:o,text:s}=e.serializeForClipboard(i);r.dataTransfer.clearData(),r.dataTransfer.setData(ng?"Text":"text/html",o.innerHTML),ng||r.dataTransfer.setData("text/plain",s);const a=(n=C(this,vr))==null?void 0:n.el;a&&r.dataTransfer.setDragImage(a,0,0),e.dragging={slice:i,move:!0,node:t}}}),I(this,ss,()=>{const r=C(this,Lr,To);if(!r)return;C(this,jn).call(this,r);const e=r.dragging;window.setTimeout(()=>{r.dragging===e&&(r.dragging=null)},50)}),this.keydownCallback=r=>(C(this,Oi).call(this),I(this,br,!1),r.dom.dataset.dragging="false",!1),I(this,ml,K3((r,e)=>{if(!r.editable)return;const t=r.dom.getBoundingClientRect(),n=t.left+t.width/2;if(!(r.root.elementFromPoint(n,e.clientY)instanceof Element)){C(this,Oi).call(this);return}const i=C(this,Lr,Z3);if(!i)return;const o=DS(r,{x:n,y:e.clientY},i);if(!o){C(this,Oi).call(this);return}C(this,pl).call(this,o)},200)),this.mousemoveCallback=(r,e)=>(r.composing||!r.editable||C(this,ml).call(this,r,e),!1),this.dragoverCallback=(r,e)=>{var t;if(C(this,br)){const n=(t=C(this,Lr,To))==null?void 0:t.dom.parentElement;if(!n)return!1;const i=n.scrollHeight>n.clientHeight,o=n.getBoundingClientRect();if(i){if(n.scrollTop>0&&Math.abs(e.y-o.y)<ig)return n.scrollTop=n.scrollTop>10?n.scrollTop-10:0,!1;const s=Math.round(r.dom.getBoundingClientRect().height);if(Math.round(n.scrollTop+o.height)<s&&Math.abs(e.y-(o.height+o.y))<ig)return n.scrollTop=n.scrollTop+10,!1}}return!1},this.dragenterCallback=r=>{r.dragging&&(I(this,br,!0),r.dom.dataset.dragging="true")},this.dragleaveCallback=(r,e)=>{const t=e.clientX,n=e.clientY;(t<0||n<0||t>window.innerWidth||n>window.innerHeight)&&(I(this,vr,null),C(this,jn).call(this,r))},this.dropCallback=r=>(C(this,jn).call(this,r),!1),this.dragendCallback=r=>{C(this,jn).call(this,r)},I(this,jn,r=>{I(this,br,!1),r.dom.dataset.dragging="false"})}},es=new WeakMap,fl=new WeakMap,qn=new WeakMap,vr=new WeakMap,ts=new WeakMap,br=new WeakMap,Lr=new WeakSet,Z3=function(){var r;try{return(r=C(this,es))==null?void 0:r.get(Kc.key).filterNodes}catch{return}},To=function(){var r;return(r=C(this,es))==null?void 0:r.get(ge)},Di=new WeakMap,Oi=new WeakMap,pl=new WeakMap,rs=new WeakMap,ns=new WeakMap,is=new WeakMap,ss=new WeakMap,ml=new WeakMap,jn=new WeakMap,E4),Np=ye(()=>new OS,"blockService"),Gc=ye({},"blockServiceInstance");Kl(Np,{displayName:"Ctx<blockService>"});Kl(Gc,{displayName:"Ctx<blockServiceInstance>"});var Yc=ye({},"blockSpec");Kl(Yc,{displayName:"Ctx<blockSpec>"});var Ep=Fe(r=>{const e=new Me("MILKDOWN_BLOCK"),t=r.get(Np.key)();r.set(Gc.key,t);const n=r.get(Yc.key);return new Ce({key:e,...n,props:{...n.props,handleDOMEvents:{drop:i=>t.dropCallback(i),pointermove:(i,o)=>t.mousemoveCallback(i,o),keydown:i=>t.keydownCallback(i),dragover:(i,o)=>t.dragoverCallback(i,o),dragleave:(i,o)=>t.dragleaveCallback(i,o),dragenter:i=>t.dragenterCallback(i),dragend:i=>t.dragendCallback(i)}}})});Kl(Ep,{displayName:"Prose<block>"});var Et,ln,Ri,Ii,gl,as,yl,vl,ls,cs,us,Sc,Q3,D4,RS=(D4=class{constructor(r){P(this,Sc);P(this,Et);P(this,ln);P(this,Ri);P(this,Ii);P(this,gl);P(this,as);P(this,yl);P(this,vl);P(this,ls);P(this,cs);P(this,us);I(this,Ii,null),I(this,as,!1),this.update=()=>{requestAnimationFrame(()=>{if(!C(this,as))try{ui(this,Sc,Q3).call(this),I(this,as,!0)}catch{}})},this.destroy=()=>{var e,t;(e=C(this,Ri))==null||e.unBind(),(t=C(this,Ri))==null||t.removeEvent(C(this,Et)),C(this,Et).remove()},this.show=e=>{const t=e.el,n=C(this,ln).get(ge).dom,i={ctx:C(this,ln),active:e,editorDom:n,blockDom:C(this,Et)},o={contextElement:t,getBoundingClientRect:()=>C(this,cs)?C(this,cs).call(this,i):t.getBoundingClientRect()},s=[Vh()];if(C(this,ls)){const a=C(this,ls).call(this,i),l=Ki(a);s.push(l)}qr(o,C(this,Et),{placement:C(this,us)?C(this,us).call(this,i):"left",middleware:[...s,...C(this,yl)],...C(this,vl)}).then(({x:a,y:l})=>{Object.assign(C(this,Et).style,{left:`${a}px`,top:`${l}px`}),C(this,Et).dataset.show="true"}).catch(console.error)},this.hide=()=>{C(this,Et).dataset.show="false"},I(this,ln,r.ctx),I(this,Et,r.content),I(this,ls,r.getOffset),I(this,cs,r.getPosition),I(this,us,r.getPlacement),I(this,yl,r.middleware??[]),I(this,vl,r.floatingUIOptions??{}),I(this,gl,r.root),this.hide()}get active(){return C(this,Ii)}},Et=new WeakMap,ln=new WeakMap,Ri=new WeakMap,Ii=new WeakMap,gl=new WeakMap,as=new WeakMap,yl=new WeakMap,vl=new WeakMap,ls=new WeakMap,cs=new WeakMap,us=new WeakMap,Sc=new WeakSet,Q3=function(){const r=C(this,ln).get(ge);(C(this,gl)??r.dom.parentElement??document.body).appendChild(C(this,Et));const e=C(this,ln).get(Gc.key);e.bind(C(this,ln),t=>{t.type==="hide"?(this.hide(),I(this,Ii,null)):t.type==="show"&&(this.show(t.active),I(this,Ii,t.active))}),I(this,Ri,e),C(this,Ri).addEvent(C(this,Et)),C(this,Et).draggable=!0},D4),Jc=[Yc,Kc,Np,Gc,Ep];Jc.key=Yc.key;Jc.pluginKey=Ep.key;function IS(r){const e=ye({},`${r}_SLASH_SPEC`),t=Fe(i=>{const o=i.get(e.key);return new Ce({key:new Me(`${r}_SLASH`),...o})}),n=[e,t];return n.key=e.key,n.pluginKey=t.key,e.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${r}`},t.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${r}`},n}var ds,bl,wl,xl,kl,zi,Sl,hs,Cl,Ml,Tl,O4,zS=(O4=class{constructor(r){P(this,ds);P(this,bl);P(this,wl);P(this,xl);P(this,kl);P(this,zi);P(this,Sl);P(this,hs);P(this,Cl);P(this,Ml);P(this,Tl);I(this,ds,!1),this.onShow=()=>{},this.onHide=()=>{},I(this,Ml,(e,t)=>{const{state:n,composing:i}=e,{selection:o,doc:s}=n,{ranges:a}=o,l=Math.min(...a.map(d=>d.$from.pos)),c=Math.max(...a.map(d=>d.$to.pos)),u=t&&t.doc.eq(s)&&t.selection.eq(o);if(C(this,ds)||((C(this,xl)??e.dom.parentElement??document.body).appendChild(this.element),I(this,ds,!0)),!(i||u)){if(!C(this,Sl).call(this,e,t)){this.hide();return}qr({getBoundingClientRect:()=>Bc(e,l,c)},this.element,{placement:"bottom-start",middleware:[Vh(),Ki(C(this,Cl)),...C(this,bl)],...C(this,wl)}).then(({x:d,y:h})=>{Object.assign(this.element.style,{left:`${d}px`,top:`${h}px`})}).catch(console.error),this.show()}}),I(this,Tl,e=>{const t=this.getContent(e);if(!t)return!1;const n=t.at(-1);return n?Array.isArray(C(this,zi))?C(this,zi).includes(n):C(this,zi)===n:!1}),this.update=(e,t)=>{C(this,hs).call(this,e,t)},this.getContent=(e,t=n=>n.type.name==="paragraph")=>{const{selection:n}=e.state,{empty:i,$from:o}=n,s=e.state.selection instanceof Q;if(typeof document>"u")return;const a=this.element.contains(document.activeElement),l=!e.hasFocus()&&!a,c=!e.editable,u=!d9(t)(e.state.selection);if(!(l||c||!i||!s||u))return o.parent.textBetween(Math.max(0,o.parentOffset-500),o.parentOffset,void 0,"")},this.destroy=()=>{C(this,hs).cancel()},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=r.content,I(this,kl,r.debounce??200),I(this,Sl,r.shouldShow??C(this,Tl)),I(this,zi,r.trigger??"/"),I(this,Cl,r.offset),I(this,bl,r.middleware??[]),I(this,wl,r.floatingUIOptions??{}),I(this,xl,r.root),I(this,hs,Tp(C(this,Ml),C(this,kl)))}},ds=new WeakMap,bl=new WeakMap,wl=new WeakMap,xl=new WeakMap,kl=new WeakMap,zi=new WeakMap,Sl=new WeakMap,hs=new WeakMap,Cl=new WeakMap,Ml=new WeakMap,Tl=new WeakMap,O4);/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */function og(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function LS(r){if(Array.isArray(r))return r}function BS(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,o,s,a=[],l=!0,c=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(l=(n=o.call(t)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function PS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
37
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function FS(r,e){return LS(r)||BS(r,e)||HS(r,e)||PS()}function HS(r,e){if(r){if(typeof r=="string")return og(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?og(r,e):void 0}}const e6=Object.entries,sg=Object.setPrototypeOf,_S=Object.isFrozen,qS=Object.getPrototypeOf,jS=Object.getOwnPropertyDescriptor;let et=Object.freeze,it=Object.seal,Ao=Object.create,t6=typeof Reflect<"u"&&Reflect,hh=t6.apply,fh=t6.construct;et||(et=function(e){return e});it||(it=function(e){return e});hh||(hh=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)});fh||(fh=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const gi=Xe(Array.prototype.forEach),$S=Xe(Array.prototype.lastIndexOf),ag=Xe(Array.prototype.pop),Zs=Xe(Array.prototype.push),VS=Xe(Array.prototype.splice),Ro=Array.isArray,la=Xe(String.prototype.toLowerCase),od=Xe(String.prototype.toString),lg=Xe(String.prototype.match),Qs=Xe(String.prototype.replace),cg=Xe(String.prototype.indexOf),WS=Xe(String.prototype.trim),US=Xe(Number.prototype.toString),KS=Xe(Boolean.prototype.toString),ug=typeof BigInt>"u"?null:Xe(BigInt.prototype.toString),dg=typeof Symbol>"u"?null:Xe(Symbol.prototype.toString),Dt=Xe(Object.prototype.hasOwnProperty),ea=Xe(Object.prototype.toString),ct=Xe(RegExp.prototype.test),hi=GS(TypeError);function Xe(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return hh(r,e,n)}}function GS(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return fh(r,t)}}function ve(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:la;if(sg&&sg(r,null),!Ro(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(_S(e)||(e[n]=o),i=o)}r[i]=!0}return r}function YS(r){for(let e=0;e<r.length;e++)Dt(r,e)||(r[e]=null);return r}function _t(r){const e=Ao(null);for(const n of e6(r)){var t=FS(n,2);const i=t[0],o=t[1];Dt(r,i)&&(Ro(o)?e[i]=YS(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=_t(o):e[i]=o)}return e}function JS(r){switch(typeof r){case"string":return r;case"number":return US(r);case"boolean":return KS(r);case"bigint":return ug?ug(r):"0";case"symbol":return dg?dg(r):"Symbol()";case"undefined":return ea(r);case"function":case"object":{if(r===null)return ea(r);const e=r,t=er(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:ea(n)}return ea(r)}default:return ea(r)}}function er(r,e){for(;r!==null;){const n=jS(r,e);if(n){if(n.get)return Xe(n.get);if(typeof n.value=="function")return Xe(n.value)}r=qS(r)}function t(){return null}return t}function XS(r){try{return ct(r,""),!0}catch{return!1}}const hg=et(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),sd=et(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ad=et(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ZS=et(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ld=et(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),QS=et(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),fg=et(["#text"]),pg=et(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),cd=et(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mg=et(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),C0=et(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eC=it(/{{[\w\W]*|^[\w\W]*}}/g),tC=it(/<%[\w\W]*|^[\w\W]*%>/g),rC=it(/\${[\w\W]*/g),nC=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),iC=it(/^aria-[\-\w]+$/),gg=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oC=it(/^(?:\w+script|data):/i),sC=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aC=it(/^html$/i),lC=it(/^[a-z][.\w]*(-[.\w]+)+$/i),yg=it(/<[/\w!]/g),vg=it(/<[/\w]/g),cC=it(/<\/no(script|embed|frames)/i),uC=it(/\/>/i),Ht={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},r6=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],dC=et(ve({},r6)),hC=(function(){const r={};return gi(r6,e=>{r[e]=it(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),et(r)})(),fC=function(){return typeof window>"u"?null:window},pC=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},bg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Nn=function(e,t,n,i){return Dt(e,t)&&Ro(e[t])?ve(i.base?_t(i.base):{},e[t],i.transform):n},ud=function(e,t,n){const i=Dt(e,t)?e[t]:void 0;return i&&typeof i=="object"?_t(i):n()};function n6(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fC();const e=U=>n6(U);if(e.version="3.4.15",e.removed=[],!r||!r.document||r.document.nodeType!==Ht.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,a=r.Element,l=r.NodeFilter,c=r.NamedNodeMap;c===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const u=r.DOMParser,d=r.trustedTypes,h=a.prototype,f=er(h,"cloneNode"),m=er(h,"remove"),y=er(h,"removeAttributeNode"),x=er(h,"nextSibling"),b=er(h,"childNodes"),S=er(h,"parentNode"),A=er(h,"shadowRoot"),D=er(h,"attributes"),O=s&&s.prototype?er(s.prototype,"nodeType"):null,L=s&&s.prototype?er(s.prototype,"nodeName"):null,N=s&&s.prototype?er(s.prototype,"ownerDocument"):null,j=function(k){return O?O(k):k.nodeType},K=function(k){return L?L(k):k.nodeName};if(typeof o=="function"){const U=t.createElement("template");U.content&&U.content.ownerDocument&&(t=U.content.ownerDocument)}let ne,pe="",se,lt=!1,Re=0;const Ue=function(){if(Re>0)throw hi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},$e=function(k){Ue(),Re++;try{return ne.createHTML(k)}finally{Re--}},Bt=function(k){Ue(),Re++;try{return ne.createScriptURL(k)}finally{Re--}},pr=function(){return lt||(se=pC(d,i),lt=!0),se},Cn=t,Jt=Cn.implementation,mr=Cn.createNodeIterator,ai=Cn.createDocumentFragment,Pt=Cn.getElementsByTagName,oo=n.importNode;let Te=bg();e.isSupported=typeof e6=="function"&&typeof S=="function"&&Jt&&Jt.createHTMLDocument!==void 0;const mu=eC,Mn=tC,Jl=rC,Tn=nC,Xl=iC,Zl=oC,$s=sC,so=lC;let li=gg,Ee=null;const Vs=ve({},[...hg,...sd,...ad,...ld,...fg]);let De=null;const ao=ve({},[...pg,...cd,...mg,...C0]);let Ft=Object.seal(Ao(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ar=null,Ql=null;const Nr=Object.seal(Ao(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let lo=!0,co=!0,Ws=!1,e0=!0,Er=!1,Xt=!0,Zt=!1,gu=!1,t0=null,r0=null,yu=!1,uo=!1,n0=!1,i0=!1,nm=!0,im=!1;const om="user-content-";let vu=!0,bu=!1,ho={},fo=null;const sm=ve({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let am=null;const lm=ve({},["audio","video","img","source","image","track"]);let cm=null;const um=ve({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),o0="http://www.w3.org/1998/Math/MathML",s0="http://www.w3.org/2000/svg",Dr="http://www.w3.org/1999/xhtml";let po=Dr,wu=!1,xu=null;const ky=ve({},[o0,s0,Dr],od),dm=et(["mi","mo","mn","ms","mtext"]);let ku=ve({},dm);const hm=et(["annotation-xml"]);let Su=ve({},hm);const Sy=ve({},["title","style","font","a","script"]);let Us=null;const Cy=["application/xhtml+xml","text/html"],My="text/html";let Ve=null,mo=null;const Ty=t.createElement("form"),fm=function(k){return k instanceof RegExp||k instanceof Function},Cu=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(mo&&mo===k)return;(!k||typeof k!="object")&&(k={}),k=_t(k),Us=Cy.indexOf(k.PARSER_MEDIA_TYPE)===-1?My:k.PARSER_MEDIA_TYPE,Ve=Us==="application/xhtml+xml"?od:la,Ee=Nn(k,"ALLOWED_TAGS",Vs,{transform:Ve}),De=Nn(k,"ALLOWED_ATTR",ao,{transform:Ve}),xu=Nn(k,"ALLOWED_NAMESPACES",ky,{transform:od}),cm=Nn(k,"ADD_URI_SAFE_ATTR",um,{transform:Ve,base:um}),am=Nn(k,"ADD_DATA_URI_TAGS",lm,{transform:Ve,base:lm}),fo=Nn(k,"FORBID_CONTENTS",sm,{transform:Ve}),Ar=Nn(k,"FORBID_TAGS",_t({}),{transform:Ve}),Ql=Nn(k,"FORBID_ATTR",_t({}),{transform:Ve}),ho=Dt(k,"USE_PROFILES")?k.USE_PROFILES&&typeof k.USE_PROFILES=="object"?_t(k.USE_PROFILES):k.USE_PROFILES:!1,lo=k.ALLOW_ARIA_ATTR!==!1,co=k.ALLOW_DATA_ATTR!==!1,Ws=k.ALLOW_UNKNOWN_PROTOCOLS||!1,e0=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Er=k.SAFE_FOR_TEMPLATES||!1,Xt=k.SAFE_FOR_XML!==!1,Zt=k.WHOLE_DOCUMENT||!1,uo=k.RETURN_DOM||!1,n0=k.RETURN_DOM_FRAGMENT||!1,i0=k.RETURN_TRUSTED_TYPE||!1,yu=k.FORCE_BODY||!1,nm=k.SANITIZE_DOM!==!1,im=k.SANITIZE_NAMED_PROPS||!1,vu=k.KEEP_CONTENT!==!1,bu=k.IN_PLACE||!1,li=XS(k.ALLOWED_URI_REGEXP)?k.ALLOWED_URI_REGEXP:gg,po=typeof k.NAMESPACE=="string"?k.NAMESPACE:Dr,ku=ud(k,"MATHML_TEXT_INTEGRATION_POINTS",()=>ve({},dm)),Su=ud(k,"HTML_INTEGRATION_POINTS",()=>ve({},hm));const R=ud(k,"CUSTOM_ELEMENT_HANDLING",()=>Ao(null));if(Ft=Ao(null),Dt(R,"tagNameCheck")&&fm(R.tagNameCheck)&&(Ft.tagNameCheck=R.tagNameCheck),Dt(R,"attributeNameCheck")&&fm(R.attributeNameCheck)&&(Ft.attributeNameCheck=R.attributeNameCheck),Dt(R,"allowCustomizedBuiltInElements")&&typeof R.allowCustomizedBuiltInElements=="boolean"&&(Ft.allowCustomizedBuiltInElements=R.allowCustomizedBuiltInElements),it(Ft),Er&&(co=!1),n0&&(uo=!0),ho&&(Ee=ve({},fg),De=Ao(null),ho.html===!0&&(ve(Ee,hg),ve(De,pg)),ho.svg===!0&&(ve(Ee,sd),ve(De,cd),ve(De,C0)),ho.svgFilters===!0&&(ve(Ee,ad),ve(De,cd),ve(De,C0)),ho.mathMl===!0&&(ve(Ee,ld),ve(De,mg),ve(De,C0))),Nr.tagCheck=null,Nr.attributeCheck=null,Dt(k,"ADD_TAGS")&&(typeof k.ADD_TAGS=="function"?Nr.tagCheck=k.ADD_TAGS:Ro(k.ADD_TAGS)&&(Ee===Vs&&(Ee=_t(Ee)),ve(Ee,k.ADD_TAGS,Ve))),Dt(k,"ADD_ATTR")&&(typeof k.ADD_ATTR=="function"?Nr.attributeCheck=k.ADD_ATTR:Ro(k.ADD_ATTR)&&(De===ao&&(De=_t(De)),ve(De,k.ADD_ATTR,Ve))),Dt(k,"ADD_FORBID_CONTENTS")&&Ro(k.ADD_FORBID_CONTENTS)&&(fo===sm&&(fo=_t(fo)),ve(fo,k.ADD_FORBID_CONTENTS,Ve)),vu&&(Ee["#text"]=!0),Zt&&ve(Ee,["html","head","body"]),Ee.table&&(ve(Ee,["tbody"]),delete Ar.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const _=ne;ne=k.TRUSTED_TYPES_POLICY;try{pe=$e("")}catch(J){throw ne=_,J}}else k.TRUSTED_TYPES_POLICY===null?(ne=void 0,pe=""):(ne===void 0&&(ne=pr()),ne&&typeof pe=="string"&&(pe=$e("")));et&&et(k),mo=k},pm=ve({},[...sd,...ad,...ZS]),mm=ve({},[...ld,...QS]),Ay=function(k,R,_){return R.namespaceURI===Dr?k==="svg":R.namespaceURI===o0?k==="svg"&&(_==="annotation-xml"||ku[_]):!!pm[k]},Ny=function(k,R,_){return R.namespaceURI===Dr?k==="math":R.namespaceURI===s0?k==="math"&&Su[_]:!!mm[k]},Ey=function(k,R,_){return R.namespaceURI===s0&&!Su[_]||R.namespaceURI===o0&&!ku[_]?!1:!mm[k]&&(Sy[k]||!pm[k])},Dy=function(k){let R=S(k);(!R||!R.tagName)&&(R={namespaceURI:po,tagName:"template"});const _=la(k.tagName),J=la(R.tagName);return xu[k.namespaceURI]?k.namespaceURI===s0?Ay(_,R,J):k.namespaceURI===o0?Ny(_,R,J):k.namespaceURI===Dr?Ey(_,R,J):!!(Us==="application/xhtml+xml"&&xu[k.namespaceURI]):!1},An=function(k){Zs(e.removed,{element:k});try{S(k).removeChild(k)}catch{if(m(k),!S(k))throw hi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},gm=function(k,R,_){try{y(k,R)}catch{try{k.removeAttribute(_)}catch{}}},a0=function(k){l0(k);const R=b(k);if(R){const J=[];gi(R,te=>{Zs(J,te)}),gi(J,te=>{try{m(te)}catch{}})}const _=D(k);if(_)for(let J=_.length-1;J>=0;--J){const te=_[J],ce=te&&te.name;typeof ce=="string"&&gm(k,te,ce)}},ci=function(k,R,_){if(!_)try{_=R.getAttributeNode(k)}catch{_=null}Zs(e.removed,{attribute:_||null,from:R});try{_?y(R,_):R.removeAttribute(k)}catch{try{R.removeAttribute(k)}catch{}}if(k==="is")if(uo||n0)try{An(R)}catch{}else try{R.setAttribute(k,"")}catch{}},Oy=function(k){const R=D(k);if(R)for(let _=R.length-1;_>=0;--_){const J=R[_],te=J&&J.name;typeof te!="string"||De[Ve(te)]||gm(k,J,te)}},l0=function(k){const R=[k];for(;R.length>0;){const _=R.pop();j(_)===Ht.element&&Oy(_);const te=b(_);if(te)for(let ce=te.length-1;ce>=0;--ce)R.push(te[ce])}},ym=function(k,R){return Xt?k==="patchsrc"?!0:k==="for"&&R!=="label"&&R!=="output":!1},Ry=function(k){if(!Xt)return;const R=[k];for(;R.length>0;){const _=R.pop(),J=j(_);if(J===Ht.processingInstruction||J===Ht.comment&&ct(vg,_.data)){try{m(_)}catch{}continue}if(J===Ht.element){const ce=_,Oe=Ve(K(_));try{ce.hasAttribute&&ce.hasAttribute("patchsrc")&&ce.removeAttribute("patchsrc"),ce.hasAttribute&&ce.hasAttribute("for")&&ym("for",Oe)&&ce.removeAttribute("for")}catch{}}const te=b(_);if(te)for(let ce=te.length-1;ce>=0;--ce)R.push(te[ce])}},vm=function(k){let R=null,_=null;if(yu)k="<remove></remove>"+k;else{const ce=lg(k,/^[\r\n\t ]+/);_=ce&&ce[0]}Us==="application/xhtml+xml"&&po===Dr&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const J=ne?$e(k):k;if(po===Dr)try{R=new u().parseFromString(J,Us)}catch{}if(!R||!R.documentElement){R=Jt.createDocument(po,"template",null);try{R.documentElement.innerHTML=wu?pe:J}catch{}}const te=R.body||R.documentElement;return k&&_&&te.insertBefore(t.createTextNode(_),te.childNodes[0]||null),po===Dr?Pt.call(R,Zt?"html":"body")[0]:Zt?R.documentElement:te},bm=function(k){const R=N?N(k):k.ownerDocument;return mr.call(R||k,k,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},c0=function(k){return k=Qs(k,mu," "),k=Qs(k,Mn," "),k=Qs(k,Jl," "),k},Mu=function(k){var R;k.normalize();const _=N?N(k):k.ownerDocument,J=mr.call(_||k,k,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let te=J.nextNode();for(;te;)te.data=c0(te.data),te=J.nextNode();const ce=(R=k.querySelectorAll)===null||R===void 0?void 0:R.call(k,"template");ce&&gi(ce,Oe=>{go(Oe.content)&&Mu(Oe.content)})},u0=function(k){const R=L?L(k):null;return typeof R!="string"||Ve(R)!=="form"?!1:typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||k.attributes!==D(k)||typeof k.removeAttribute!="function"||typeof k.removeAttributeNode!="function"||typeof k.getAttributeNode!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function"||k.nodeType!==O(k)||k.childNodes!==b(k)},go=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return O(k)===Ht.documentFragment}catch{return!1}},Ks=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return typeof O(k)=="number"}catch{return!1}};function Or(U,k,R){U.length!==0&&gi(U,_=>{_.call(e,k,R,mo)})}const Iy=function(k,R){return!!(Xt&&k.hasChildNodes()&&!Ks(k.firstElementChild)&&ct(yg,k.textContent)&&ct(yg,k.innerHTML)||Xt&&k.namespaceURI===Dr&&dC[R]&&(Ks(k.firstElementChild)||typeof k.textContent=="string"&&ct(hC[R],k.textContent))||k.nodeType===Ht.processingInstruction||Xt&&k.nodeType===Ht.comment&&ct(vg,k.data))},d0=function(k,R){if(k instanceof RegExp)return ct(k,R);if(k instanceof Function){for(var _=arguments.length,J=new Array(_>2?_-2:0),te=2;te<_;te++)J[te-2]=arguments[te];return!!k(R,...J)}return!1},zy=function(k,R,_){if(!Ar[R]&&Cm(R)&&d0(Ft.tagNameCheck,R))return!1;if(vu&&!fo[R]){const J=S(k),te=b(k);if(te&&J){const ce=te.length;for(let Oe=ce-1;Oe>=0;--Oe){const Le=k===_?f(te[Oe],!0):te[Oe];J.insertBefore(Le,x(k))}}}return An(k),!0},wm=function(k,R,_,J){return k.length===0?R:R===_||R===J?_t(R):R},xm=function(k,R){return k===R||S(k)!==null?!1:(bu&&l0(k),!0)},km=function(k,R){if(Or(Te.beforeSanitizeElements,k,null),xm(k,R))return!0;if(u0(k))return An(k),!0;const _=Ve(K(k));if(Ee=wm(Te.uponSanitizeElement,Ee,Vs,t0),Or(Te.uponSanitizeElement,k,{tagName:_,allowedTags:Ee}),xm(k,R))return!0;if(Iy(k,_))return An(k),!0;if(Ar[_]||!(Nr.tagCheck instanceof Function&&Nr.tagCheck(_))&&!Ee[_]){const te=zy(k,_,R);return te===!1&&Or(Te.afterSanitizeElements,k,null),te}if(j(k)===Ht.element&&!Dy(k)||(_==="noscript"||_==="noembed"||_==="noframes")&&ct(cC,k.innerHTML))return An(k),!0;if(Er&&k.nodeType===Ht.text){const te=c0(k.textContent);k.textContent!==te&&(Zs(e.removed,{element:k.cloneNode()}),k.textContent=te)}return Or(Te.afterSanitizeElements,k,null),!1},Sm=function(k,R,_){if(Ql[R]||ym(R,k)||nm&&(R==="id"||R==="name")&&(_ in t||_ in Ty))return!1;const J=De[R]||Nr.attributeCheck instanceof Function&&Nr.attributeCheck(R,k);return co&&ct(Tn,R)||lo&&ct(Xl,R)?!0:J?cm[R]||ct(li,Qs(_,$s,""))||(R==="src"||R==="xlink:href"||R==="href")&&k!=="script"&&cg(_,"data:")===0&&am[k]||Ws&&!ct(Zl,Qs(_,$s,""))?!0:!_:Cm(k)&&d0(Ft.tagNameCheck,k)&&d0(Ft.attributeNameCheck,R,k)||R==="is"&&Ft.allowCustomizedBuiltInElements&&d0(Ft.tagNameCheck,_)},Ly=ve({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Cm=function(k){return!Ly[la(k)]&&ct(so,k)},By=function(k,R,_,J){if(ne&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!_)switch(d.getAttributeType(k,R)){case"TrustedHTML":return $e(J);case"TrustedScriptURL":return Bt(J)}return J},Py=function(k,R,_,J){try{return _?k.setAttributeNS(_,R,J):k.setAttribute(R,J),u0(k)?(An(k),!1):!0}catch{return ci(R,k),!1}},Mm=function(k){Or(Te.beforeSanitizeAttributes,k,null);const R=k.attributes;if(!R||u0(k))return;De=wm(Te.uponSanitizeAttribute,De,ao,r0);const _={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:De,forceKeepAttr:void 0};let J=R.length;const te=Ve(k.nodeName);for(;J--;){const ce=R[J],Oe=ce.name,Le=ce.namespaceURI,Mt=ce.value,Tt=Ve(Oe),Au=Mt;let gt=Oe==="value"?Au:WS(Au),Tm=!1;if(_.attrName=Tt,_.attrValue=gt,_.keepAttr=!0,_.forceKeepAttr=void 0,Or(Te.uponSanitizeAttribute,k,_),gt=_.attrValue,im&&(Tt==="id"||Tt==="name")&&cg(gt,om)!==0&&(ci(Oe,k,ce),gt=om+gt,Tm=!0),Xt&&ct(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,gt)){ci(Oe,k,ce);continue}if(Tt==="attributename"&&lg(gt,"href")){ci(Oe,k,ce);continue}if(!_.forceKeepAttr){if(!_.keepAttr){ci(Oe,k,ce);continue}if(!e0&&ct(uC,gt)){ci(Oe,k,ce);continue}if(Er&&(gt=c0(gt)),!Sm(te,Tt,gt)){ci(Oe,k,ce);continue}gt=By(te,Tt,Le,gt),gt!==Au&&Py(k,Oe,Le,gt)&&Tm&&ag(e.removed)}}Or(Te.afterSanitizeAttributes,k,null)},h0=function(k){let R=null;const _=bm(k);for(Or(Te.beforeSanitizeShadowDOM,k,null);R=_.nextNode();)if(Or(Te.uponSanitizeShadowNode,R,null),km(R,k),Mm(R),go(R.content)&&h0(R.content),j(R)===Ht.element){const J=A(R);go(J)&&(Tu(J),h0(J))}Or(Te.afterSanitizeShadowDOM,k,null)},Tu=function(k){const R=[{node:k,shadow:null}];for(;R.length>0;){const _=R.pop();if(_.shadow){h0(_.shadow);continue}const J=_.node,ce=j(J)===Ht.element,Oe=b(J);if(Oe)for(let Le=Oe.length-1;Le>=0;--Le)R.push({node:Oe[Le],shadow:null});if(ce){const Le=L?L(J):null;if(typeof Le=="string"&&Ve(Le)==="template"){const Mt=J.content;go(Mt)&&R.push({node:Mt,shadow:null})}}if(ce){const Le=A(J);go(Le)&&R.push({node:null,shadow:Le},{node:Le,shadow:null})}}};return e.sanitize=function(U){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},R=null,_=null,J=null,te=null;if(wu=!U,wu&&(U="<!-->"),typeof U!="string"&&!Ks(U)&&(U=JS(U),typeof U!="string"))throw hi("dirty is not a string, aborting");if(!e.isSupported)return U;gu?(Ee=t0,De=r0):Cu(k),(Te.uponSanitizeElement.length>0||Te.uponSanitizeAttribute.length>0)&&(Ee=_t(Ee)),Te.uponSanitizeAttribute.length>0&&(De=_t(De)),e.removed=[];const ce=bu&&typeof U!="string"&&Ks(U);if(ce){Ry(U);const Mt=K(U);if(typeof Mt=="string"){const Tt=Ve(Mt);if(!Ee[Tt]||Ar[Tt])throw a0(U),hi("root node is forbidden and cannot be sanitized in-place")}if(u0(U))throw a0(U),hi("root node is clobbered and cannot be sanitized in-place");try{Tu(U)}catch(Tt){throw a0(U),Tt}}else if(Ks(U))R=vm("<!---->"),_=R.ownerDocument.importNode(U,!0),_.nodeType===Ht.element&&_.nodeName==="BODY"||_.nodeName==="HTML"?R=_:R.appendChild(_),Tu(R);else{if(!uo&&!Er&&!Zt&&U.indexOf("<")===-1)return ne&&i0?$e(U):U;if(R=vm(U),!R)return uo?null:i0?pe:""}R&&yu&&An(R.firstChild);const Oe=ce?U:R;try{const Mt=bm(Oe);for(;J=Mt.nextNode();)km(J,Oe),Mm(J),go(J.content)&&h0(J.content)}catch(Mt){throw ce&&(a0(U),gi(e.removed,Tt=>{Tt.element&&l0(Tt.element)})),Mt}if(ce)return gi(e.removed,Mt=>{Mt.element&&l0(Mt.element)}),Er&&Mu(U),U;if(uo){if(Er&&Mu(R),n0)for(te=ai.call(R.ownerDocument);R.firstChild;)te.appendChild(R.firstChild);else te=R;return(De.shadowroot||De.shadowrootmode)&&(te=oo.call(n,te,!0)),te}let Le=Zt?R.outerHTML:R.innerHTML;return Zt&&Ee["!doctype"]&&R.ownerDocument&&R.ownerDocument.doctype&&R.ownerDocument.doctype.name&&ct(aC,R.ownerDocument.doctype.name)&&(Le="<!DOCTYPE "+R.ownerDocument.doctype.name+`>
38
+ `+Le),Er&&(Le=c0(Le)),ne&&i0?$e(Le):Le},e.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cu(U),gu=!0,t0=Ee,r0=De},e.clearConfig=function(){mo=null,gu=!1,t0=null,r0=null,ne=se,pe=""},e.isValidAttribute=function(U,k,R){mo||Cu({});const _=Ve(U),J=Ve(k);return Sm(_,J,R)},e.addHook=function(U,k){typeof k=="function"&&Dt(Te,U)&&Zs(Te[U],k)},e.removeHook=function(U,k){if(Dt(Te,U)){if(k!==void 0){const R=$S(Te[U],k);return R===-1?void 0:VS(Te[U],R,1)[0]}return ag(Te[U])}},e.removeHooks=function(U){Dt(Te,U)&&(Te[U]=[])},e.removeAllHooks=function(){Te=bg()},e}var i6=n6();/**
39
39
  * @license lucide-static v1.21.0 - ISC
40
40
  *
41
41
  * This source code is licensed under the ISC license.
@@ -769,7 +769,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
769
769
  *
770
770
  * This source code is licensed under the ISC license.
771
771
  * See the LICENSE file in the root directory of this source tree.
772
- */const $C=`
772
+ */const jC=`
773
773
  <svg
774
774
  class="lucide lucide-text-align-end"
775
775
  xmlns="http://www.w3.org/2000/svg"
@@ -791,7 +791,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
791
791
  *
792
792
  * This source code is licensed under the ISC license.
793
793
  * See the LICENSE file in the root directory of this source tree.
794
- */const jC=`
794
+ */const $C=`
795
795
  <svg
796
796
  class="lucide lucide-text-align-start"
797
797
  xmlns="http://www.w3.org/2000/svg"
@@ -875,9 +875,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
875
875
  <path d="M18 6 6 18" />
876
876
  <path d="m6 6 12 12" />
877
877
  </svg>
878
- `,UC=[t7(),r7(),n7(),i7(),o7(),z4(),s7(),P0.allowMultipleSelections.of(!0),a7(),L4(l7,{fallback:!0}),c7(),u7(),d7(),h7(),f7(),p7(),m7(),Wh.of([...g7,...B4,...y7,...v7,...b7,...w7,...x7])];function KC(r){const e=[[-1,r.state.doc]],t=[];for(;e.length>0;){const[n,i]=e.pop();if(n>=0){const o=r.nodeDOM(n);if(o&&ev(o)){const{top:s,bottom:a,left:l,right:c}=o.getBoundingClientRect();t.push([n,[l,s,c,s]],[n+i.nodeSize,[l,a,c,a]])}}if(i.isBlock&&!i.isTextblock){let o=n+1;for(const s of i.children)e.push([o,s]),o+=s.nodeSize}}return t}function GC(r,e){let t=[],n,i;const o=()=>{const u=r.dom.getBoundingClientRect(),d=r.state.doc;return t&&n&&i&&u.width===i.width&&u.height===i.height&&u.x===i.x&&u.y===i.y&&n.eq(d)||(i=u,n=d,t=KC(r)),t},s=(u,d)=>{if(!r.editable||r.isDestroyed)return;const h=(y,x)=>{const[b,S]=y,[A,D]=x;return xg(u,S)-xg(u,D)||b-A};let f=o();f.sort(h),f=f.slice(0,8);const m=f.find(y=>(e==null?void 0:e({view:r,pos:y[0],event:d}))!==!1);if(!(m&&JC(r,m[0])))return m};let a,l;return(u,d)=>(a&&YC(a,u)||(a=u,l=s(u,d)),l)}function YC(r,e){return r[0]===e[0]&&r[1]===e[1]}function wg(r,e){return Math.abs(r[0]-e[0])+Math.abs(r[1]-e[1])}function xg(r,e){return Math.min(wg(r,[e[0],e[1]]),wg(r,[e[2],e[3]]))}function JC(r,e){const t=r.dragging;if(!t)return;const{move:n}=t;if(!n)return;const i=r.state.selection;if(!(i instanceof re))return;const{from:o,to:s}=i;return o<=e&&e<=s}function XC(r){let e;return new Ce({key:new Me("prosemirror-drop-indicator"),view:t=>(e=GC(t,r.onDrag),QC(t,e,r)),props:{handleDrop(t,n,i,o){if(!e)return!1;const s=e([n.clientX,n.clientY],n);if(!s)return!1;n.preventDefault();const a=s[0],l=t.state.tr;if(o){const{node:f}=t.dragging||{};f?f.replace(l):l.deleteSelection()}const c=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i),l.doc.eq(d))return!0;const h=l.doc.resolve(c);if(u&&re.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new re(h));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,x,b)=>f=b),l.setSelection(ZC(t,h,l.doc.resolve(f)))}return t.focus(),t.dispatch(l.setMeta("uiEvent","drop")),!0}}})}function ZC(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||Q.between(e,t,n)}function QC(r,e,t){const n=r.dom;let i,o,s,a=!1;const l=()=>{i&&clearTimeout(i),a=!1,i=setTimeout(()=>{var d;a||(d=t.onHide)==null||d.call(t)},30)},c=d=>{var y;a=!0;const{clientX:h,clientY:f}=d;if(o===h&&s===f)return;o=h,s=f;const m=e([h,f],d);if(m){const[x,[b,S,A,D]]=m,O={p1:{x:b,y:S},p2:{x:A,y:D}};(y=t.onShow)==null||y.call(t,{view:r,pos:x,line:O})}else{l();return}};return n.addEventListener("dragover",c),n.addEventListener("dragend",l),n.addEventListener("drop",l),n.addEventListener("dragleave",l),{destroy:()=>{n.removeEventListener("dragover",c),n.removeEventListener("dragend",l),n.removeEventListener("drop",l),n.removeEventListener("dragleave",l)}}}class _e extends ue{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return _e.valid(n)?new _e(n):ue.near(n)}content(){return Y.empty}eq(e){return e instanceof _e&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new _e(e.resolve(t.pos))}getBookmark(){return new Op(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!eM(e)||!tM(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&_e.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(t>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let l=e.doc.resolve(i);if(_e.valid(l))return l}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!re.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!1;continue e}break}o=s,i+=t;let a=e.doc.resolve(i);if(_e.valid(a))return a}return null}}}_e.prototype.visible=!1;_e.findFrom=_e.findGapCursorFrom;ue.jsonID("gapcursor",_e);class Op{constructor(e){this.pos=e}map(e){return new Op(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return _e.valid(t)?new _e(t):ue.near(t)}}function l6(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function eM(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||l6(i.type))return!0;if(i.inlineContent)return!1}}return!0}function tM(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||l6(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rM(){return new Ce({props:{decorations:sM,createSelectionBetween(r,e,t){return e.pos==t.pos&&_e.valid(t)?new _e(t):null},handleClick:iM,handleKeyDown:nM,handleDOMEvents:{beforeinput:oM}}})}const nM=hf({ArrowLeft:M0("horiz",-1),ArrowRight:M0("horiz",1),ArrowUp:M0("vert",-1),ArrowDown:M0("vert",1)});function M0(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Q){if(!o.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=n.doc.resolve(e>0?a.after():a.before())}let c=_e.findGapCursorFrom(a,e,l);return c?(i&&i(n.tr.setSelection(new _e(c))),!0):!1}}function iM(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!_e.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&re.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new _e(n))),!0)}function oM(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof _e))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=H.empty;for(let s=n.length-1;s>=0;s--)i=H.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new Y(i,0,0));return o.setSelection(Q.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function sM(r){if(!(r.selection instanceof _e))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Se.create(r.doc,[qe.widget(r.selection.head,e,{key:"gapcursor"})])}function Gl(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-cursor",...e}}),r}var qa=ye(null,"dropIndicatorState");Gl(qa,{displayName:"Ctx<dropIndicatorState>"});var Zc=ye({width:2,color:!1,class:"milkdown-drop-indicator"},"dropIndicatorConfig");Gl(Zc,{displayName:"Ctx<dropIndicatorConfig>"});var aM=new Me("MILKDOWN_DROP_INDICATOR_DOM"),c6=Fe(r=>new Ce({key:aM,view:e=>{var s;const t=r.get(Zc.key),n=document.createElement("div");Object.assign(n.style,{position:"fixed",pointerEvents:"none",display:"none",backgroundColor:t.color,top:"0",left:"0"}),n.classList.add(t.class),n.classList.add("milkdown-drop-indicator"),(s=e.dom.parentNode)==null||s.appendChild(n);const i=r.use(qa.key),o=a=>{lM(n,a,t)};return i.on(o),{destroy:()=>{i.off(o),n.remove()}}}}));Gl(c6,{displayName:"Prose<dropIndicatorDOM>"});function lM(r,e,t){if(!e){Object.assign(r.style,{display:"none"});return}const{line:n}=e,{width:i}=t,{p1:{x:o,y:s},p2:{x:a,y:l}}=n,c=s===l;let u,d,h=s,f=o;c?(u=a-o,d=i,h-=i/2):(u=i,d=l-s,f-=i/2),h=Math.round(h),f=Math.round(f),Object.assign(r.style,{display:"block",width:`${u}px`,height:`${d}px`,transform:`translate(${f}px, ${h}px)`})}var u6=Fe(r=>XC({onShow:n=>{r.set(qa.key,n)},onHide:()=>{r.set(qa.key,null)},onDrag:()=>!0}));Gl(u6,{displayName:"Prose<dropIndicator>"});var d6=Fe(()=>rM());Gl(d6,{displayName:"Prose<gapCursor>"});var cM=[d6,Zc,qa,c6,u6].flat();function uM(r){var e;const t=(e=void 0)!=null?e:!1;let n=typeof document>"u"?null:document.createElement("div");return new Ce({key:dM,view:i=>{t!==!0&&mM(i.state.schema,t||[]);const o=i.dom.ownerDocument;n=n||document.createElement("div");const s=n,a=()=>{fM(i,s)};let l;return window.ResizeObserver&&(l=new window.ResizeObserver(()=>a()),l.observe(i.dom)),o.addEventListener("selectionchange",a),{update:()=>{a()},destroy:()=>{o.removeEventListener("selectionchange",a),l&&l.unobserve(i.dom)}}},props:{handleKeyDown:(i,o)=>{var s;const{selection:a}=i.state;if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey||o.isComposing||!["ArrowLeft","ArrowRight"].includes(o.key)||!gh(a)||!a.empty)return!1;const l=a.$head,[c,u]=h6(l),d=i.state.storedMarks||l.marks();if(c&&u&&!fe.sameSet(c,u)){if(o.key==="ArrowLeft"&&!fe.sameSet(c,d))return i.dispatch(i.state.tr.setStoredMarks(c)),!0;if(o.key==="ArrowRight"&&!fe.sameSet(u,d))return i.dispatch(i.state.tr.setStoredMarks(u)),!0}return o.key==="ArrowLeft"&&l.textOffset===1?(i.dispatch(i.state.tr.setSelection(Q.create(i.state.doc,l.pos-1)).setStoredMarks(l.marks())),!0):o.key==="ArrowRight"&&l.textOffset+1===((s=l.parent.maybeChild(l.index()))==null?void 0:s.nodeSize)?(i.dispatch(i.state.tr.setSelection(Q.create(i.state.doc,l.pos+1)).setStoredMarks(l.marks())),!0):!1},decorations:i=>{if(!(!n||!gh(i.selection)||!i.selection.empty))return Se.create(i.doc,[qe.widget(0,n,{key:"prosemirror-virtual-cursor"})])},attributes:{class:"virtual-cursor-enabled"}}})}var dM=new Me("prosemirror-virtual-cursor");function hM(r,e){var t;const n=window.getSelection();if(!n||!n.rangeCount)return null;const i=(t=n==null?void 0:n.getRangeAt(0))==null?void 0:t.cloneRange();if(!i)return null;i.collapse(e);const o=i.getClientRects(),s=o!=null&&o.length?o[o.length-1]:null;return s!=null&&s.height?s:r.coordsAtPos(r.state.selection.head)}function h6(r){const e=r.index(),t=r.parent.maybeChild(e);let n=r.textOffset?t:null;return!n&&e>0&&(n=r.parent.maybeChild(e-1)),[n==null?void 0:n.marks,t==null?void 0:t.marks]}function gh(r){return r&&typeof r=="object"&&"$cursor"in r}function fM(r,e){if(!r||!r.dom||r.isDestroyed||!e)return;const{state:t,dom:n}=r,{selection:i}=t;if(!gh(i))return;const o=hM(r,i.$head===i.$from);if(!o)return e;const s=n.getBoundingClientRect();let a="prosemirror-virtual-cursor";const l=t.selection.$head,[c,u]=h6(l),d=t.storedMarks||l.marks();i.$cursor&&c&&u&&d&&!fe.sameSet(c,u)&&(fe.sameSet(c,d)?a+=" prosemirror-virtual-cursor-left":fe.sameSet(u,d)&&(a+=" prosemirror-virtual-cursor-right")),e.className=a,pM(e,"prosemirror-virtual-cursor-animation"),e.style.height=`${o.bottom-o.top}px`,e.style.left=`${o.left-s.left}px`,e.style.top=`${o.top-s.top}px`}function pM(r,e){r.classList.remove(e),r.offsetWidth,r.classList.add(e)}function mM(r,e){for(const[t,n]of Object.entries(r.marks))n.spec.inclusive===!1&&!e.includes(t)&&console.warn(`[prosemirror-virtual-cursor] Virtual cursor does not work well with marks that have inclusive set to false. Please consider removing the inclusive option from the "${t}" mark or adding it to the "skipWarning" option.`)}var dd={exports:{}},kg;function gM(){return kg||(kg=1,(function(r){(function(){var e;e=r.exports=i,e.format=i,e.vsprintf=n,typeof console<"u"&&typeof console.log=="function"&&(e.printf=t);function t(){console.log(i.apply(null,arguments))}function n(o,s){return i.apply(null,[o].concat(s))}function i(o){for(var s=1,a=[].slice.call(arguments),l=0,c=o.length,u="",d,h=!1,f,m,y=!1,x,b=function(){return a[s++]},S=function(){for(var A="";/\d/.test(o[l]);)A+=o[l++],d=o[l];return A.length>0?parseInt(A):null};l<c;++l)if(d=o[l],h)switch(h=!1,d=="."?(y=!1,d=o[++l]):d=="0"&&o[l+1]=="."?(y=!0,l+=2,d=o[l]):y=!0,x=S(),d){case"b":u+=parseInt(b(),10).toString(2);break;case"c":f=b(),typeof f=="string"||f instanceof String?u+=f:u+=String.fromCharCode(parseInt(f,10));break;case"d":u+=parseInt(b(),10);break;case"f":m=String(parseFloat(b()).toFixed(x||6)),u+=y?m:m.replace(/^0/,"");break;case"j":u+=JSON.stringify(b());break;case"o":u+="0"+parseInt(b(),10).toString(8);break;case"s":u+=b();break;case"x":u+="0x"+parseInt(b(),10).toString(16);break;case"X":u+="0x"+parseInt(b(),10).toString(16).toUpperCase();break;default:u+=d;break}else d==="%"?h=!0:u+=d;return u}})()})(dd)),dd.exports}var yM=gM();const vM=Ky(yM),T0=Object.assign(fi(Error),{eval:fi(EvalError),range:fi(RangeError),reference:fi(ReferenceError),syntax:fi(SyntaxError),type:fi(TypeError),uri:fi(URIError)});function fi(r){return e.displayName=r.displayName||r.name,e;function e(t,...n){const i=t&&vM(t,...n);return new r(i)}}const A0={}.hasOwnProperty,Sg={yaml:"-",toml:"+"};function Rp(r){const e=[];let t=-1;const n=Array.isArray(r)?r:r?[r]:["yaml"];for(;++t<n.length;)e[t]=bM(n[t]);return e}function bM(r){let e=r;if(typeof e=="string"){if(!A0.call(Sg,e))throw T0("Missing matter definition for `%s`",e);e={type:e,marker:Sg[e]}}else if(typeof e!="object")throw T0("Expected matter to be an object, not `%j`",e);if(!A0.call(e,"type"))throw T0("Missing `type` in matter `%j`",e);if(!A0.call(e,"fence")&&!A0.call(e,"marker"))throw T0("Missing `marker` or `fence` in matter `%j`",e);return e}function wM(r){const e=Rp(r),t={};let n=-1;for(;++n<e.length;){const i=e[n],o=yh(i,"open").charCodeAt(0),s=xM(i),a=t[o];Array.isArray(a)?a.push(s):t[o]=[s]}return{flow:t}}function xM(r){const e=r.anywhere,t=r.type,n=t+"Fence",i=n+"Sequence",o=t+"Value",s={tokenize:u,partial:!0};let a,l=0;return{tokenize:c,concrete:!0};function c(d,h,f){const m=this;return y;function y(N){const $=m.now();return $.column===1&&($.line===1||e)&&(a=yh(r,"open"),l=0,N===a.charCodeAt(l))?(d.enter(t),d.enter(n),d.enter(i),x(N)):f(N)}function x(N){return l===a.length?(d.exit(i),f0(N)?(d.enter("whitespace"),b(N)):S(N)):N===a.charCodeAt(l++)?(d.consume(N),x):f(N)}function b(N){return f0(N)?(d.consume(N),b):(d.exit("whitespace"),S(N))}function S(N){return wr(N)?(d.exit(n),d.enter("lineEnding"),d.consume(N),d.exit("lineEnding"),a=yh(r,"close"),l=0,d.attempt(s,L,A)):f(N)}function A(N){return N===null||wr(N)?O(N):(d.enter(o),D(N))}function D(N){return N===null||wr(N)?(d.exit(o),O(N)):(d.consume(N),D)}function O(N){return N===null?f(N):(d.enter("lineEnding"),d.consume(N),d.exit("lineEnding"),d.attempt(s,L,A))}function L(N){return d.exit(t),h(N)}}function u(d,h,f){let m=0;return y;function y(A){return A===a.charCodeAt(m)?(d.enter(n),d.enter(i),x(A)):f(A)}function x(A){return m===a.length?(d.exit(i),f0(A)?(d.enter("whitespace"),b(A)):S(A)):A===a.charCodeAt(m++)?(d.consume(A),x):f(A)}function b(A){return f0(A)?(d.consume(A),b):(d.exit("whitespace"),S(A))}function S(A){return A===null||wr(A)?(d.exit(n),h(A)):f(A)}}}function yh(r,e){return r.marker?Cg(r.marker,e).repeat(3):Cg(r.fence,e)}function Cg(r,e){return typeof r=="string"?r:r[e]}function kM(r){const e=Rp(r),t={},n={};let i=-1;for(;++i<e.length;){const o=e[i];t[o.type]=SM(o),n[o.type]=CM,n[o.type+"Value"]=MM}return{enter:t,exit:n}}function SM(r){return e;function e(t){this.enter({type:r.type,value:""},t),this.buffer()}}function CM(r){const e=this.resume(),t=this.stack[this.stack.length-1];this.exit(r),t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,"")}function MM(r){this.config.enter.data.call(this,r),this.config.exit.data.call(this,r)}function TM(r){const e=[],t={},n=Rp(r);let i=-1;for(;++i<n.length;){const o=n[i];t[o.type]=AM(o);const s=vh(o,"open");e.push({atBreak:!0,character:s.charAt(0),after:Gy(s.charAt(1))})}return{unsafe:e,handlers:t}}function AM(r){const e=vh(r,"open"),t=vh(r,"close");return n;function n(i){return e+(i.value?`
878
+ `,UC=[t7(),r7(),n7(),i7(),o7(),z4(),s7(),P0.allowMultipleSelections.of(!0),a7(),L4(l7,{fallback:!0}),c7(),u7(),d7(),h7(),f7(),p7(),m7(),Wh.of([...g7,...B4,...y7,...v7,...b7,...w7,...x7])];function KC(r){const e=[[-1,r.state.doc]],t=[];for(;e.length>0;){const[n,i]=e.pop();if(n>=0){const o=r.nodeDOM(n);if(o&&ev(o)){const{top:s,bottom:a,left:l,right:c}=o.getBoundingClientRect();t.push([n,[l,s,c,s]],[n+i.nodeSize,[l,a,c,a]])}}if(i.isBlock&&!i.isTextblock){let o=n+1;for(const s of i.children)e.push([o,s]),o+=s.nodeSize}}return t}function GC(r,e){let t=[],n,i;const o=()=>{const u=r.dom.getBoundingClientRect(),d=r.state.doc;return t&&n&&i&&u.width===i.width&&u.height===i.height&&u.x===i.x&&u.y===i.y&&n.eq(d)||(i=u,n=d,t=KC(r)),t},s=(u,d)=>{if(!r.editable||r.isDestroyed)return;const h=(y,x)=>{const[b,S]=y,[A,D]=x;return xg(u,S)-xg(u,D)||b-A};let f=o();f.sort(h),f=f.slice(0,8);const m=f.find(y=>(e==null?void 0:e({view:r,pos:y[0],event:d}))!==!1);if(!(m&&JC(r,m[0])))return m};let a,l;return(u,d)=>(a&&YC(a,u)||(a=u,l=s(u,d)),l)}function YC(r,e){return r[0]===e[0]&&r[1]===e[1]}function wg(r,e){return Math.abs(r[0]-e[0])+Math.abs(r[1]-e[1])}function xg(r,e){return Math.min(wg(r,[e[0],e[1]]),wg(r,[e[2],e[3]]))}function JC(r,e){const t=r.dragging;if(!t)return;const{move:n}=t;if(!n)return;const i=r.state.selection;if(!(i instanceof re))return;const{from:o,to:s}=i;return o<=e&&e<=s}function XC(r){let e;return new Ce({key:new Me("prosemirror-drop-indicator"),view:t=>(e=GC(t,r.onDrag),QC(t,e,r)),props:{handleDrop(t,n,i,o){if(!e)return!1;const s=e([n.clientX,n.clientY],n);if(!s)return!1;n.preventDefault();const a=s[0],l=t.state.tr;if(o){const{node:f}=t.dragging||{};f?f.replace(l):l.deleteSelection()}const c=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i),l.doc.eq(d))return!0;const h=l.doc.resolve(c);if(u&&re.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new re(h));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,x,b)=>f=b),l.setSelection(ZC(t,h,l.doc.resolve(f)))}return t.focus(),t.dispatch(l.setMeta("uiEvent","drop")),!0}}})}function ZC(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||Q.between(e,t,n)}function QC(r,e,t){const n=r.dom;let i,o,s,a=!1;const l=()=>{i&&clearTimeout(i),a=!1,i=setTimeout(()=>{var d;a||(d=t.onHide)==null||d.call(t)},30)},c=d=>{var y;a=!0;const{clientX:h,clientY:f}=d;if(o===h&&s===f)return;o=h,s=f;const m=e([h,f],d);if(m){const[x,[b,S,A,D]]=m,O={p1:{x:b,y:S},p2:{x:A,y:D}};(y=t.onShow)==null||y.call(t,{view:r,pos:x,line:O})}else{l();return}};return n.addEventListener("dragover",c),n.addEventListener("dragend",l),n.addEventListener("drop",l),n.addEventListener("dragleave",l),{destroy:()=>{n.removeEventListener("dragover",c),n.removeEventListener("dragend",l),n.removeEventListener("drop",l),n.removeEventListener("dragleave",l)}}}class _e extends ue{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return _e.valid(n)?new _e(n):ue.near(n)}content(){return Y.empty}eq(e){return e instanceof _e&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new _e(e.resolve(t.pos))}getBookmark(){return new Op(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!eM(e)||!tM(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&_e.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(t>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let l=e.doc.resolve(i);if(_e.valid(l))return l}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!re.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!1;continue e}break}o=s,i+=t;let a=e.doc.resolve(i);if(_e.valid(a))return a}return null}}}_e.prototype.visible=!1;_e.findFrom=_e.findGapCursorFrom;ue.jsonID("gapcursor",_e);class Op{constructor(e){this.pos=e}map(e){return new Op(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return _e.valid(t)?new _e(t):ue.near(t)}}function l6(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function eM(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||l6(i.type))return!0;if(i.inlineContent)return!1}}return!0}function tM(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||l6(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rM(){return new Ce({props:{decorations:sM,createSelectionBetween(r,e,t){return e.pos==t.pos&&_e.valid(t)?new _e(t):null},handleClick:iM,handleKeyDown:nM,handleDOMEvents:{beforeinput:oM}}})}const nM=hf({ArrowLeft:M0("horiz",-1),ArrowRight:M0("horiz",1),ArrowUp:M0("vert",-1),ArrowDown:M0("vert",1)});function M0(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Q){if(!o.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=n.doc.resolve(e>0?a.after():a.before())}let c=_e.findGapCursorFrom(a,e,l);return c?(i&&i(n.tr.setSelection(new _e(c))),!0):!1}}function iM(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!_e.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&re.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new _e(n))),!0)}function oM(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof _e))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=H.empty;for(let s=n.length-1;s>=0;s--)i=H.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new Y(i,0,0));return o.setSelection(Q.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function sM(r){if(!(r.selection instanceof _e))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Se.create(r.doc,[qe.widget(r.selection.head,e,{key:"gapcursor"})])}function Gl(r,e){return Object.assign(r,{meta:{package:"@milkdown/plugin-cursor",...e}}),r}var qa=ye(null,"dropIndicatorState");Gl(qa,{displayName:"Ctx<dropIndicatorState>"});var Zc=ye({width:2,color:!1,class:"milkdown-drop-indicator"},"dropIndicatorConfig");Gl(Zc,{displayName:"Ctx<dropIndicatorConfig>"});var aM=new Me("MILKDOWN_DROP_INDICATOR_DOM"),c6=Fe(r=>new Ce({key:aM,view:e=>{var s;const t=r.get(Zc.key),n=document.createElement("div");Object.assign(n.style,{position:"fixed",pointerEvents:"none",display:"none",backgroundColor:t.color,top:"0",left:"0"}),n.classList.add(t.class),n.classList.add("milkdown-drop-indicator"),(s=e.dom.parentNode)==null||s.appendChild(n);const i=r.use(qa.key),o=a=>{lM(n,a,t)};return i.on(o),{destroy:()=>{i.off(o),n.remove()}}}}));Gl(c6,{displayName:"Prose<dropIndicatorDOM>"});function lM(r,e,t){if(!e){Object.assign(r.style,{display:"none"});return}const{line:n}=e,{width:i}=t,{p1:{x:o,y:s},p2:{x:a,y:l}}=n,c=s===l;let u,d,h=s,f=o;c?(u=a-o,d=i,h-=i/2):(u=i,d=l-s,f-=i/2),h=Math.round(h),f=Math.round(f),Object.assign(r.style,{display:"block",width:`${u}px`,height:`${d}px`,transform:`translate(${f}px, ${h}px)`})}var u6=Fe(r=>XC({onShow:n=>{r.set(qa.key,n)},onHide:()=>{r.set(qa.key,null)},onDrag:()=>!0}));Gl(u6,{displayName:"Prose<dropIndicator>"});var d6=Fe(()=>rM());Gl(d6,{displayName:"Prose<gapCursor>"});var cM=[d6,Zc,qa,c6,u6].flat();function uM(r){var e;const t=(e=void 0)!=null?e:!1;let n=typeof document>"u"?null:document.createElement("div");return new Ce({key:dM,view:i=>{t!==!0&&mM(i.state.schema,t||[]);const o=i.dom.ownerDocument;n=n||document.createElement("div");const s=n,a=()=>{fM(i,s)};let l;return window.ResizeObserver&&(l=new window.ResizeObserver(()=>a()),l.observe(i.dom)),o.addEventListener("selectionchange",a),{update:()=>{a()},destroy:()=>{o.removeEventListener("selectionchange",a),l&&l.unobserve(i.dom)}}},props:{handleKeyDown:(i,o)=>{var s;const{selection:a}=i.state;if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey||o.isComposing||!["ArrowLeft","ArrowRight"].includes(o.key)||!gh(a)||!a.empty)return!1;const l=a.$head,[c,u]=h6(l),d=i.state.storedMarks||l.marks();if(c&&u&&!fe.sameSet(c,u)){if(o.key==="ArrowLeft"&&!fe.sameSet(c,d))return i.dispatch(i.state.tr.setStoredMarks(c)),!0;if(o.key==="ArrowRight"&&!fe.sameSet(u,d))return i.dispatch(i.state.tr.setStoredMarks(u)),!0}return o.key==="ArrowLeft"&&l.textOffset===1?(i.dispatch(i.state.tr.setSelection(Q.create(i.state.doc,l.pos-1)).setStoredMarks(l.marks())),!0):o.key==="ArrowRight"&&l.textOffset+1===((s=l.parent.maybeChild(l.index()))==null?void 0:s.nodeSize)?(i.dispatch(i.state.tr.setSelection(Q.create(i.state.doc,l.pos+1)).setStoredMarks(l.marks())),!0):!1},decorations:i=>{if(!(!n||!gh(i.selection)||!i.selection.empty))return Se.create(i.doc,[qe.widget(0,n,{key:"prosemirror-virtual-cursor"})])},attributes:{class:"virtual-cursor-enabled"}}})}var dM=new Me("prosemirror-virtual-cursor");function hM(r,e){var t;const n=window.getSelection();if(!n||!n.rangeCount)return null;const i=(t=n==null?void 0:n.getRangeAt(0))==null?void 0:t.cloneRange();if(!i)return null;i.collapse(e);const o=i.getClientRects(),s=o!=null&&o.length?o[o.length-1]:null;return s!=null&&s.height?s:r.coordsAtPos(r.state.selection.head)}function h6(r){const e=r.index(),t=r.parent.maybeChild(e);let n=r.textOffset?t:null;return!n&&e>0&&(n=r.parent.maybeChild(e-1)),[n==null?void 0:n.marks,t==null?void 0:t.marks]}function gh(r){return r&&typeof r=="object"&&"$cursor"in r}function fM(r,e){if(!r||!r.dom||r.isDestroyed||!e)return;const{state:t,dom:n}=r,{selection:i}=t;if(!gh(i))return;const o=hM(r,i.$head===i.$from);if(!o)return e;const s=n.getBoundingClientRect();let a="prosemirror-virtual-cursor";const l=t.selection.$head,[c,u]=h6(l),d=t.storedMarks||l.marks();i.$cursor&&c&&u&&d&&!fe.sameSet(c,u)&&(fe.sameSet(c,d)?a+=" prosemirror-virtual-cursor-left":fe.sameSet(u,d)&&(a+=" prosemirror-virtual-cursor-right")),e.className=a,pM(e,"prosemirror-virtual-cursor-animation"),e.style.height=`${o.bottom-o.top}px`,e.style.left=`${o.left-s.left}px`,e.style.top=`${o.top-s.top}px`}function pM(r,e){r.classList.remove(e),r.offsetWidth,r.classList.add(e)}function mM(r,e){for(const[t,n]of Object.entries(r.marks))n.spec.inclusive===!1&&!e.includes(t)&&console.warn(`[prosemirror-virtual-cursor] Virtual cursor does not work well with marks that have inclusive set to false. Please consider removing the inclusive option from the "${t}" mark or adding it to the "skipWarning" option.`)}var dd={exports:{}},kg;function gM(){return kg||(kg=1,(function(r){(function(){var e;e=r.exports=i,e.format=i,e.vsprintf=n,typeof console<"u"&&typeof console.log=="function"&&(e.printf=t);function t(){console.log(i.apply(null,arguments))}function n(o,s){return i.apply(null,[o].concat(s))}function i(o){for(var s=1,a=[].slice.call(arguments),l=0,c=o.length,u="",d,h=!1,f,m,y=!1,x,b=function(){return a[s++]},S=function(){for(var A="";/\d/.test(o[l]);)A+=o[l++],d=o[l];return A.length>0?parseInt(A):null};l<c;++l)if(d=o[l],h)switch(h=!1,d=="."?(y=!1,d=o[++l]):d=="0"&&o[l+1]=="."?(y=!0,l+=2,d=o[l]):y=!0,x=S(),d){case"b":u+=parseInt(b(),10).toString(2);break;case"c":f=b(),typeof f=="string"||f instanceof String?u+=f:u+=String.fromCharCode(parseInt(f,10));break;case"d":u+=parseInt(b(),10);break;case"f":m=String(parseFloat(b()).toFixed(x||6)),u+=y?m:m.replace(/^0/,"");break;case"j":u+=JSON.stringify(b());break;case"o":u+="0"+parseInt(b(),10).toString(8);break;case"s":u+=b();break;case"x":u+="0x"+parseInt(b(),10).toString(16);break;case"X":u+="0x"+parseInt(b(),10).toString(16).toUpperCase();break;default:u+=d;break}else d==="%"?h=!0:u+=d;return u}})()})(dd)),dd.exports}var yM=gM();const vM=Ky(yM),T0=Object.assign(fi(Error),{eval:fi(EvalError),range:fi(RangeError),reference:fi(ReferenceError),syntax:fi(SyntaxError),type:fi(TypeError),uri:fi(URIError)});function fi(r){return e.displayName=r.displayName||r.name,e;function e(t,...n){const i=t&&vM(t,...n);return new r(i)}}const A0={}.hasOwnProperty,Sg={yaml:"-",toml:"+"};function Rp(r){const e=[];let t=-1;const n=Array.isArray(r)?r:r?[r]:["yaml"];for(;++t<n.length;)e[t]=bM(n[t]);return e}function bM(r){let e=r;if(typeof e=="string"){if(!A0.call(Sg,e))throw T0("Missing matter definition for `%s`",e);e={type:e,marker:Sg[e]}}else if(typeof e!="object")throw T0("Expected matter to be an object, not `%j`",e);if(!A0.call(e,"type"))throw T0("Missing `type` in matter `%j`",e);if(!A0.call(e,"fence")&&!A0.call(e,"marker"))throw T0("Missing `marker` or `fence` in matter `%j`",e);return e}function wM(r){const e=Rp(r),t={};let n=-1;for(;++n<e.length;){const i=e[n],o=yh(i,"open").charCodeAt(0),s=xM(i),a=t[o];Array.isArray(a)?a.push(s):t[o]=[s]}return{flow:t}}function xM(r){const e=r.anywhere,t=r.type,n=t+"Fence",i=n+"Sequence",o=t+"Value",s={tokenize:u,partial:!0};let a,l=0;return{tokenize:c,concrete:!0};function c(d,h,f){const m=this;return y;function y(N){const j=m.now();return j.column===1&&(j.line===1||e)&&(a=yh(r,"open"),l=0,N===a.charCodeAt(l))?(d.enter(t),d.enter(n),d.enter(i),x(N)):f(N)}function x(N){return l===a.length?(d.exit(i),f0(N)?(d.enter("whitespace"),b(N)):S(N)):N===a.charCodeAt(l++)?(d.consume(N),x):f(N)}function b(N){return f0(N)?(d.consume(N),b):(d.exit("whitespace"),S(N))}function S(N){return wr(N)?(d.exit(n),d.enter("lineEnding"),d.consume(N),d.exit("lineEnding"),a=yh(r,"close"),l=0,d.attempt(s,L,A)):f(N)}function A(N){return N===null||wr(N)?O(N):(d.enter(o),D(N))}function D(N){return N===null||wr(N)?(d.exit(o),O(N)):(d.consume(N),D)}function O(N){return N===null?f(N):(d.enter("lineEnding"),d.consume(N),d.exit("lineEnding"),d.attempt(s,L,A))}function L(N){return d.exit(t),h(N)}}function u(d,h,f){let m=0;return y;function y(A){return A===a.charCodeAt(m)?(d.enter(n),d.enter(i),x(A)):f(A)}function x(A){return m===a.length?(d.exit(i),f0(A)?(d.enter("whitespace"),b(A)):S(A)):A===a.charCodeAt(m++)?(d.consume(A),x):f(A)}function b(A){return f0(A)?(d.consume(A),b):(d.exit("whitespace"),S(A))}function S(A){return A===null||wr(A)?(d.exit(n),h(A)):f(A)}}}function yh(r,e){return r.marker?Cg(r.marker,e).repeat(3):Cg(r.fence,e)}function Cg(r,e){return typeof r=="string"?r:r[e]}function kM(r){const e=Rp(r),t={},n={};let i=-1;for(;++i<e.length;){const o=e[i];t[o.type]=SM(o),n[o.type]=CM,n[o.type+"Value"]=MM}return{enter:t,exit:n}}function SM(r){return e;function e(t){this.enter({type:r.type,value:""},t),this.buffer()}}function CM(r){const e=this.resume(),t=this.stack[this.stack.length-1];this.exit(r),t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,"")}function MM(r){this.config.enter.data.call(this,r),this.config.exit.data.call(this,r)}function TM(r){const e=[],t={},n=Rp(r);let i=-1;for(;++i<n.length;){const o=n[i];t[o.type]=AM(o);const s=vh(o,"open");e.push({atBreak:!0,character:s.charAt(0),after:Gy(s.charAt(1))})}return{unsafe:e,handlers:t}}function AM(r){const e=vh(r,"open"),t=vh(r,"close");return n;function n(i){return e+(i.value?`
879
879
  `+i.value:"")+`
880
- `+t}}function vh(r,e){return r.marker?Mg(r.marker,e).repeat(3):Mg(r.fence,e)}function Mg(r,e){return typeof r=="string"?r:r[e]}const NM="yaml";function EM(r){const e=this,t=r||NM,n=e.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(wM(t)),o.push(kM(t)),s.push(TM(t))}var Al,Nl,El,fs,ps,ms,Ir,Dl,Ol,gs,jn,ys,Rl,Il,R4,Qc=(R4=class{constructor(r){P(this,Al);P(this,Nl);P(this,El);P(this,fs);P(this,ps);P(this,ms);P(this,Ir);P(this,Dl);P(this,Ol);P(this,gs);P(this,jn);P(this,ys);P(this,Rl);P(this,Il);I(this,ms,!1),this.onShow=()=>{},this.onHide=()=>{},I(this,jn,e=>{qr(e,this.element,{placement:C(this,fs).placement??"top",middleware:[Vh(),Ki(C(this,Dl)),Yy(C(this,Ol)),...C(this,El)],...C(this,fs)}).then(({x:t,y:n})=>{Object.assign(this.element.style,{left:`${t}px`,top:`${n}px`})}).catch(console.error)}),I(this,ys,e=>C(this,ps)!==e.dom.parentElement),I(this,Rl,(e,t)=>{var h;const{state:n,composing:i}=e,{selection:o,doc:s}=n,{ranges:a}=o,l=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=t&&t.doc.eq(s)&&t.selection.eq(o);if(C(this,ms)||((C(this,ps)??e.dom.parentElement??document.body).appendChild(this.element),I(this,ms,!0)),i||u)return;if((h=C(this,Ir))==null||h.call(this),I(this,Ir,void 0),!C(this,Nl).call(this,e,t)){this.hide();return}const d={getBoundingClientRect:()=>Bc(e,l,c),contextElement:e.dom};C(this,ys).call(this,e)?I(this,Ir,Dm(d,this.element,()=>C(this,jn).call(this,d))):C(this,jn).call(this,d),this.show()}),this.update=(e,t)=>{C(this,gs).call(this,e,t)},I(this,Il,e=>{const{doc:t,selection:n}=e.state,{empty:i,from:o,to:s}=n,a=!t.textBetween(o,s).length&&e.state.selection instanceof Q,l=this.element.contains(document.activeElement),c=!e.hasFocus()&&!l,u=!e.editable;return!(c||i||a||u)}),this.destroy=()=>{var e;(e=C(this,Ir))==null||e.call(this),C(this,gs).cancel()},this.show=(e,t)=>{var n;if(this.element.dataset.show="true",e){(n=C(this,Ir))==null||n.call(this),I(this,Ir,void 0);const i={...e,contextElement:t==null?void 0:t.dom};t&&C(this,ys).call(this,t)?I(this,Ir,Dm(i,this.element,()=>C(this,jn).call(this,i))):C(this,jn).call(this,i)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=r.content,I(this,Al,r.debounce??200),I(this,Nl,r.shouldShow??C(this,Il)),I(this,Dl,r.offset),I(this,Ol,r.shift),I(this,El,r.middleware??[]),I(this,fs,r.floatingUIOptions??{}),I(this,ps,r.root),this.element.dataset.show="false",I(this,gs,K3(C(this,Rl),C(this,Al)))}},Al=new WeakMap,Nl=new WeakMap,El=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakMap,Ir=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,gs=new WeakMap,jn=new WeakMap,ys=new WeakMap,Rl=new WeakMap,Il=new WeakMap,R4);function eu(r){const e=ye({},`${r}_TOOLTIP_SPEC`),t=Fe(i=>{const o=i.get(e.key);return new Ce({key:new Me(`${r}_TOOLTIP`),...o})}),n=[e,t];return n.key=e.key,n.pluginKey=t.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${r}`},t.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${r}`},n}class V extends Error{constructor(e,t){var n="KaTeX parse error: "+e,i,o,s=t&&t.loc;if(s&&s.start<=s.end){var a=s.lexer.input;i=s.start,o=s.end,i===a.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=a.slice(i,o).replace(/[^]/g,"$&̲"),c;i>15?c="…"+a.slice(i-15,i):c=a.slice(0,i);var u;o+15<a.length?u=a.slice(o,o+15)+"…":u=a.slice(o),n+=c+l+u}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,V.prototype),this.position=i,i!=null&&o!=null&&(this.length=o-i),this.rawMessage=e}}var DM=/([A-Z])/g,OM=r=>r.replace(DM,"-$1").toLowerCase(),RM={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},IM=/[&><"']/g,ht=r=>String(r).replace(IM,e=>RM[e]),Z0=r=>r.type==="ordgroup"||r.type==="color"?r.body.length===1?Z0(r.body[0]):r:r.type==="font"?Z0(r.body):r,zM=new Set(["mathord","textord","atom"]),xn=r=>zM.has(Z0(r).type),LM=r=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(r);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},bh={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:r=>"#"+r},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(r,e)=>(e.push(r),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:r=>Math.max(0,r),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:r=>Math.max(0,r),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:r=>Math.max(0,r),cli:"-e, --max-expand <n>",cliProcessor:r=>r==="Infinity"?1/0:parseInt(r)},globalGroup:{type:"boolean",cli:!1}};function BM(r){if(typeof r!="string")return r.enum[0];switch(r){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function PM(r){if(r.default!==void 0)return r.default;var e=Array.isArray(r.type)?r.type[0]:r.type;return BM(e)}function FM(r,e,t,n){var i=t[e];r[e]=i!==void 0?n.processor?n.processor(i):i:PM(n)}class Ip{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var t of Object.keys(bh)){var n=bh[t];n&&FM(this,t,e,n)}}reportNonstrict(e,t,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,t,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new V("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+t+" ["+e+"]"))}}useStrictBehavior(e,t,n){var i=this.strict;if(typeof i=="function")try{i=i(e,t,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+t+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var t=LM(e.url);if(t==null)return!1;e.protocol=t}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class En{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return zr[HM[this.id]]}sub(){return zr[_M[this.id]]}fracNum(){return zr[qM[this.id]]}fracDen(){return zr[$M[this.id]]}cramp(){return zr[jM[this.id]]}text(){return zr[VM[this.id]]}isTight(){return this.size>=2}}var zp=0,mc=1,Io=2,yn=3,$a=4,or=5,Ms=6,wt=7,zr=[new En(zp,0,!1),new En(mc,0,!0),new En(Io,1,!1),new En(yn,1,!0),new En($a,2,!1),new En(or,2,!0),new En(Ms,3,!1),new En(wt,3,!0)],HM=[$a,or,$a,or,Ms,wt,Ms,wt],_M=[or,or,or,or,wt,wt,wt,wt],qM=[Io,yn,$a,or,Ms,wt,Ms,wt],$M=[yn,yn,or,or,wt,wt,wt,wt],jM=[mc,mc,yn,yn,or,or,wt,wt],VM=[zp,mc,Io,yn,Io,yn,Io,yn],de={DISPLAY:zr[zp],TEXT:zr[Io],SCRIPT:zr[$a],SCRIPTSCRIPT:zr[Ms]},wh=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function WM(r){for(var e=0;e<wh.length;e++)for(var t=wh[e],n=0;n<t.blocks.length;n++){var i=t.blocks[n];if(r>=i[0]&&r<=i[1])return t.name}return null}var Q0=[];wh.forEach(r=>r.blocks.forEach(e=>Q0.push(...e)));function f6(r){for(var e=0;e<Q0.length;e+=2)if(r>=Q0[e]&&r<=Q0[e+1])return!0;return!1}var Qe=r=>r+" "+r,bo=80,UM=function(e,t){return"M95,"+(622+e+t)+`
880
+ `+t}}function vh(r,e){return r.marker?Mg(r.marker,e).repeat(3):Mg(r.fence,e)}function Mg(r,e){return typeof r=="string"?r:r[e]}const NM="yaml";function EM(r){const e=this,t=r||NM,n=e.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(wM(t)),o.push(kM(t)),s.push(TM(t))}var Al,Nl,El,fs,ps,ms,Ir,Dl,Ol,gs,$n,ys,Rl,Il,R4,Qc=(R4=class{constructor(r){P(this,Al);P(this,Nl);P(this,El);P(this,fs);P(this,ps);P(this,ms);P(this,Ir);P(this,Dl);P(this,Ol);P(this,gs);P(this,$n);P(this,ys);P(this,Rl);P(this,Il);I(this,ms,!1),this.onShow=()=>{},this.onHide=()=>{},I(this,$n,e=>{qr(e,this.element,{placement:C(this,fs).placement??"top",middleware:[Vh(),Ki(C(this,Dl)),Yy(C(this,Ol)),...C(this,El)],...C(this,fs)}).then(({x:t,y:n})=>{Object.assign(this.element.style,{left:`${t}px`,top:`${n}px`})}).catch(console.error)}),I(this,ys,e=>C(this,ps)!==e.dom.parentElement),I(this,Rl,(e,t)=>{var h;const{state:n,composing:i}=e,{selection:o,doc:s}=n,{ranges:a}=o,l=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=t&&t.doc.eq(s)&&t.selection.eq(o);if(C(this,ms)||((C(this,ps)??e.dom.parentElement??document.body).appendChild(this.element),I(this,ms,!0)),i||u)return;if((h=C(this,Ir))==null||h.call(this),I(this,Ir,void 0),!C(this,Nl).call(this,e,t)){this.hide();return}const d={getBoundingClientRect:()=>Bc(e,l,c),contextElement:e.dom};C(this,ys).call(this,e)?I(this,Ir,Dm(d,this.element,()=>C(this,$n).call(this,d))):C(this,$n).call(this,d),this.show()}),this.update=(e,t)=>{C(this,gs).call(this,e,t)},I(this,Il,e=>{const{doc:t,selection:n}=e.state,{empty:i,from:o,to:s}=n,a=!t.textBetween(o,s).length&&e.state.selection instanceof Q,l=this.element.contains(document.activeElement),c=!e.hasFocus()&&!l,u=!e.editable;return!(c||i||a||u)}),this.destroy=()=>{var e;(e=C(this,Ir))==null||e.call(this),C(this,gs).cancel()},this.show=(e,t)=>{var n;if(this.element.dataset.show="true",e){(n=C(this,Ir))==null||n.call(this),I(this,Ir,void 0);const i={...e,contextElement:t==null?void 0:t.dom};t&&C(this,ys).call(this,t)?I(this,Ir,Dm(i,this.element,()=>C(this,$n).call(this,i))):C(this,$n).call(this,i)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=r.content,I(this,Al,r.debounce??200),I(this,Nl,r.shouldShow??C(this,Il)),I(this,Dl,r.offset),I(this,Ol,r.shift),I(this,El,r.middleware??[]),I(this,fs,r.floatingUIOptions??{}),I(this,ps,r.root),this.element.dataset.show="false",I(this,gs,K3(C(this,Rl),C(this,Al)))}},Al=new WeakMap,Nl=new WeakMap,El=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakMap,Ir=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,gs=new WeakMap,$n=new WeakMap,ys=new WeakMap,Rl=new WeakMap,Il=new WeakMap,R4);function eu(r){const e=ye({},`${r}_TOOLTIP_SPEC`),t=Fe(i=>{const o=i.get(e.key);return new Ce({key:new Me(`${r}_TOOLTIP`),...o})}),n=[e,t];return n.key=e.key,n.pluginKey=t.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${r}`},t.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${r}`},n}class V extends Error{constructor(e,t){var n="KaTeX parse error: "+e,i,o,s=t&&t.loc;if(s&&s.start<=s.end){var a=s.lexer.input;i=s.start,o=s.end,i===a.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=a.slice(i,o).replace(/[^]/g,"$&̲"),c;i>15?c="…"+a.slice(i-15,i):c=a.slice(0,i);var u;o+15<a.length?u=a.slice(o,o+15)+"…":u=a.slice(o),n+=c+l+u}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,V.prototype),this.position=i,i!=null&&o!=null&&(this.length=o-i),this.rawMessage=e}}var DM=/([A-Z])/g,OM=r=>r.replace(DM,"-$1").toLowerCase(),RM={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},IM=/[&><"']/g,ht=r=>String(r).replace(IM,e=>RM[e]),Z0=r=>r.type==="ordgroup"||r.type==="color"?r.body.length===1?Z0(r.body[0]):r:r.type==="font"?Z0(r.body):r,zM=new Set(["mathord","textord","atom"]),xn=r=>zM.has(Z0(r).type),LM=r=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(r);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},bh={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:r=>"#"+r},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(r,e)=>(e.push(r),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:r=>Math.max(0,r),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:r=>Math.max(0,r),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:r=>Math.max(0,r),cli:"-e, --max-expand <n>",cliProcessor:r=>r==="Infinity"?1/0:parseInt(r)},globalGroup:{type:"boolean",cli:!1}};function BM(r){if(typeof r!="string")return r.enum[0];switch(r){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function PM(r){if(r.default!==void 0)return r.default;var e=Array.isArray(r.type)?r.type[0]:r.type;return BM(e)}function FM(r,e,t,n){var i=t[e];r[e]=i!==void 0?n.processor?n.processor(i):i:PM(n)}class Ip{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var t of Object.keys(bh)){var n=bh[t];n&&FM(this,t,e,n)}}reportNonstrict(e,t,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,t,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new V("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+t+" ["+e+"]"))}}useStrictBehavior(e,t,n){var i=this.strict;if(typeof i=="function")try{i=i(e,t,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+t+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var t=LM(e.url);if(t==null)return!1;e.protocol=t}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class En{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return zr[HM[this.id]]}sub(){return zr[_M[this.id]]}fracNum(){return zr[qM[this.id]]}fracDen(){return zr[jM[this.id]]}cramp(){return zr[$M[this.id]]}text(){return zr[VM[this.id]]}isTight(){return this.size>=2}}var zp=0,mc=1,Io=2,yn=3,ja=4,or=5,Ms=6,wt=7,zr=[new En(zp,0,!1),new En(mc,0,!0),new En(Io,1,!1),new En(yn,1,!0),new En(ja,2,!1),new En(or,2,!0),new En(Ms,3,!1),new En(wt,3,!0)],HM=[ja,or,ja,or,Ms,wt,Ms,wt],_M=[or,or,or,or,wt,wt,wt,wt],qM=[Io,yn,ja,or,Ms,wt,Ms,wt],jM=[yn,yn,or,or,wt,wt,wt,wt],$M=[mc,mc,yn,yn,or,or,wt,wt],VM=[zp,mc,Io,yn,Io,yn,Io,yn],de={DISPLAY:zr[zp],TEXT:zr[Io],SCRIPT:zr[ja],SCRIPTSCRIPT:zr[Ms]},wh=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function WM(r){for(var e=0;e<wh.length;e++)for(var t=wh[e],n=0;n<t.blocks.length;n++){var i=t.blocks[n];if(r>=i[0]&&r<=i[1])return t.name}return null}var Q0=[];wh.forEach(r=>r.blocks.forEach(e=>Q0.push(...e)));function f6(r){for(var e=0;e<Q0.length;e+=2)if(r>=Q0[e]&&r<=Q0[e+1])return!0;return!1}var Qe=r=>r+" "+r,bo=80,UM=function(e,t){return"M95,"+(622+e+t)+`
881
881
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
882
882
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
883
883
  c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
@@ -1127,14 +1127,14 @@ c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6
1127
1127
  c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
1128
1128
  c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
1129
1129
  l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1130
- -470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw new Error("Unknown stretchy delimiter.")}};function rT(r){return"toText"in r}class Hs{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e="",t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(rT(e))return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}var xh={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},nT={ex:!0,em:!0,mu:!0},p6=function(e){return typeof e!="string"&&(e=e.unit),e in xh||e in nT||e==="ex"},Pe=function(e,t){var n;if(e.unit in xh)n=xh[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit==="mu")n=t.fontMetrics().cssEmPerMu;else{var i;if(t.style.isTight()?i=t.havingStyle(t.style.text()):i=t,e.unit==="ex")n=i.fontMetrics().xHeight;else if(e.unit==="em")n=i.fontMetrics().quad;else throw new V("Invalid unit: '"+e.unit+"'");i!==t&&(n*=i.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},G=function(e){return+e.toFixed(4)+"em"},Xn=function(e){return e.filter(t=>t).join(" ")},Lp=function(e){var t="";for(var n of Object.keys(e)){var i=e[n];i!==void 0&&(t+=OM(n)+":"+i+";")}return t},m6=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push("mtight");var i=t.getColor();i&&(this.style.color=i)}},g6=function(e){var t=document.createElement(e);t.className=Xn(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var i=0;i<this.children.length;i++)t.appendChild(this.children[i].toNode());return t},iT=/[\s"'>/=\x00-\x1f]/,y6=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+ht(Xn(this.classes))+'"');var n=Lp(this.style);n&&(t+=' style="'+ht(n)+'"');for(var i of Object.keys(this.attributes)){if(iT.test(i))throw new V("Invalid attribute name '"+i+"'");t+=" "+i+'="'+ht(this.attributes[i])+'"'}t+=">";for(var o=0;o<this.children.length;o++)t+=this.children[o].toMarkup();return t+="</"+e+">",t};class _s{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,m6.call(this,e,n,i),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g6.call(this,"span")}toMarkup(){return y6.call(this,"span")}}class tu{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,m6.call(this,t,i),this.children=n||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g6.call(this,"a")}toMarkup(){return y6.call(this,"a")}}class oT{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){var e='<img src="'+ht(this.src)+'"'+(' alt="'+ht(this.alt)+'"'),t=Lp(this.style);return t&&(e+=' style="'+ht(t)+'"'),e+="'/>",e}}var sT={î:"ı̂",ï:"ı̈",í:"ı́",ì:"ı̀"};class Wt{constructor(e,t,n,i,o,s,a,l){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=i||0,this.skew=o||0,this.width=s||0,this.classes=a||[],this.style=l||{},this.maxFontSize=0;var c=WM(this.text.charCodeAt(0));c&&this.classes.push(c+"_fallback"),/[îïíì]/.test(this.text)&&(this.text=sT[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement("span"),t.style.marginRight=G(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=Xn(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="<span";this.classes.length&&(e=!0,t+=' class="',t+=ht(Xn(this.classes)),t+='"');var n="";this.italic>0&&(n+="margin-right:"+G(this.italic)+";"),n+=Lp(this.style),n&&(e=!0,t+=' style="'+ht(n)+'"');var i=ht(this.text);return e?(t+=">",t+=i,t+="</span>",t):i}}class bn{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var i=0;i<this.children.length;i++)t.appendChild(this.children[i].toNode());return t}toMarkup(){var e='<svg xmlns="http://www.w3.org/2000/svg"';for(var t of Object.keys(this.attributes))e+=" "+t+'="'+ht(this.attributes[t])+'"';e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</svg>",e}}class Zn{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"path");return this.alternate?t.setAttribute("d",this.alternate):t.setAttribute("d",Tg[this.pathName]),t}toMarkup(){return this.alternate?'<path d="'+ht(this.alternate)+'"/>':'<path d="'+ht(Tg[this.pathName])+'"/>'}}class kh{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"line");for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);return t}toMarkup(){var e="<line";for(var t of Object.keys(this.attributes))e+=" "+t+'="'+ht(this.attributes[t])+'"';return e+="/>",e}}function aT(r){if(r instanceof Wt)return r;throw new Error("Expected symbolNode but got "+String(r)+".")}function lT(r){if(r instanceof _s)return r;throw new Error("Expected span<HtmlDomNode> but got "+String(r)+".")}var cT=r=>r instanceof _s||r instanceof tu||r instanceof Hs,Pr={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},N0={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},Ag={Å:"A",Ð:"D",Þ:"o",å:"a",ð:"d",þ:"o",А:"A",Б:"B",В:"B",Г:"F",Д:"A",Е:"E",Ж:"K",З:"3",И:"N",Й:"N",К:"K",Л:"N",М:"M",Н:"H",О:"O",П:"N",Р:"P",С:"C",Т:"T",У:"y",Ф:"O",Х:"X",Ц:"U",Ч:"h",Ш:"W",Щ:"W",Ъ:"B",Ы:"X",Ь:"B",Э:"3",Ю:"X",Я:"R",а:"a",б:"b",в:"a",г:"r",д:"y",е:"e",ж:"m",з:"e",и:"n",й:"n",к:"n",л:"n",м:"m",н:"n",о:"o",п:"n",р:"p",с:"c",т:"o",у:"y",ф:"b",х:"x",ц:"n",ч:"n",ш:"w",щ:"w",ъ:"a",ы:"m",ь:"a",э:"e",ю:"m",я:"r"};function uT(r,e){Pr[r]=e}function Bp(r,e,t){if(!Pr[e])throw new Error("Font metrics not found for font: "+e+".");var n=r.charCodeAt(0),i=Pr[e][n];if(!i&&r[0]in Ag&&(n=Ag[r[0]].charCodeAt(0),i=Pr[e][n]),!i&&t==="text"&&f6(n)&&(i=Pr[e][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var hd={};function dT(r){var e;if(r>=5?e=0:r>=3?e=1:e=2,!hd[e]){var t=hd[e]={cssEmPerMu:N0.quad[e]/18};for(var n in N0)N0.hasOwnProperty(n)&&(t[n]=N0[n][e])}return hd[e]}var Ie={math:{},text:{}};function p(r,e,t,n,i,o){Ie[r][i]={font:e,group:t,replace:n},o&&n&&(Ie[r][n]=Ie[r][i])}var g="math",q="text",v="main",M="ams",ze="accent-token",Z="bin",Ct="close",qs="inner",ie="mathord",Ze="op-token",Gt="open",Yl="punct",T="rel",kn="spacing",E="textord";p(g,v,T,"≡","\\equiv",!0);p(g,v,T,"≺","\\prec",!0);p(g,v,T,"≻","\\succ",!0);p(g,v,T,"∼","\\sim",!0);p(g,v,T,"⊥","\\perp");p(g,v,T,"⪯","\\preceq",!0);p(g,v,T,"⪰","\\succeq",!0);p(g,v,T,"≃","\\simeq",!0);p(g,v,T,"∣","\\mid",!0);p(g,v,T,"≪","\\ll",!0);p(g,v,T,"≫","\\gg",!0);p(g,v,T,"≍","\\asymp",!0);p(g,v,T,"∥","\\parallel");p(g,v,T,"⋈","\\bowtie",!0);p(g,v,T,"⌣","\\smile",!0);p(g,v,T,"⊑","\\sqsubseteq",!0);p(g,v,T,"⊒","\\sqsupseteq",!0);p(g,v,T,"≐","\\doteq",!0);p(g,v,T,"⌢","\\frown",!0);p(g,v,T,"∋","\\ni",!0);p(g,v,T,"∝","\\propto",!0);p(g,v,T,"⊢","\\vdash",!0);p(g,v,T,"⊣","\\dashv",!0);p(g,v,T,"∋","\\owns");p(g,v,Yl,".","\\ldotp");p(g,v,Yl,"⋅","\\cdotp");p(g,v,Yl,"⋅","·");p(q,v,E,"⋅","·");p(g,v,E,"#","\\#");p(q,v,E,"#","\\#");p(g,v,E,"&","\\&");p(q,v,E,"&","\\&");p(g,v,E,"ℵ","\\aleph",!0);p(g,v,E,"∀","\\forall",!0);p(g,v,E,"ℏ","\\hbar",!0);p(g,v,E,"∃","\\exists",!0);p(g,v,E,"∇","\\nabla",!0);p(g,v,E,"♭","\\flat",!0);p(g,v,E,"ℓ","\\ell",!0);p(g,v,E,"♮","\\natural",!0);p(g,v,E,"♣","\\clubsuit",!0);p(g,v,E,"℘","\\wp",!0);p(g,v,E,"♯","\\sharp",!0);p(g,v,E,"♢","\\diamondsuit",!0);p(g,v,E,"ℜ","\\Re",!0);p(g,v,E,"♡","\\heartsuit",!0);p(g,v,E,"ℑ","\\Im",!0);p(g,v,E,"♠","\\spadesuit",!0);p(g,v,E,"§","\\S",!0);p(q,v,E,"§","\\S");p(g,v,E,"¶","\\P",!0);p(q,v,E,"¶","\\P");p(g,v,E,"†","\\dag");p(q,v,E,"†","\\dag");p(q,v,E,"†","\\textdagger");p(g,v,E,"‡","\\ddag");p(q,v,E,"‡","\\ddag");p(q,v,E,"‡","\\textdaggerdbl");p(g,v,Ct,"⎱","\\rmoustache",!0);p(g,v,Gt,"⎰","\\lmoustache",!0);p(g,v,Ct,"⟯","\\rgroup",!0);p(g,v,Gt,"⟮","\\lgroup",!0);p(g,v,Z,"∓","\\mp",!0);p(g,v,Z,"⊖","\\ominus",!0);p(g,v,Z,"⊎","\\uplus",!0);p(g,v,Z,"⊓","\\sqcap",!0);p(g,v,Z,"∗","\\ast");p(g,v,Z,"⊔","\\sqcup",!0);p(g,v,Z,"◯","\\bigcirc",!0);p(g,v,Z,"∙","\\bullet",!0);p(g,v,Z,"‡","\\ddagger");p(g,v,Z,"≀","\\wr",!0);p(g,v,Z,"⨿","\\amalg");p(g,v,Z,"&","\\And");p(g,v,T,"⟵","\\longleftarrow",!0);p(g,v,T,"⇐","\\Leftarrow",!0);p(g,v,T,"⟸","\\Longleftarrow",!0);p(g,v,T,"⟶","\\longrightarrow",!0);p(g,v,T,"⇒","\\Rightarrow",!0);p(g,v,T,"⟹","\\Longrightarrow",!0);p(g,v,T,"↔","\\leftrightarrow",!0);p(g,v,T,"⟷","\\longleftrightarrow",!0);p(g,v,T,"⇔","\\Leftrightarrow",!0);p(g,v,T,"⟺","\\Longleftrightarrow",!0);p(g,v,T,"↦","\\mapsto",!0);p(g,v,T,"⟼","\\longmapsto",!0);p(g,v,T,"↗","\\nearrow",!0);p(g,v,T,"↩","\\hookleftarrow",!0);p(g,v,T,"↪","\\hookrightarrow",!0);p(g,v,T,"↘","\\searrow",!0);p(g,v,T,"↼","\\leftharpoonup",!0);p(g,v,T,"⇀","\\rightharpoonup",!0);p(g,v,T,"↙","\\swarrow",!0);p(g,v,T,"↽","\\leftharpoondown",!0);p(g,v,T,"⇁","\\rightharpoondown",!0);p(g,v,T,"↖","\\nwarrow",!0);p(g,v,T,"⇌","\\rightleftharpoons",!0);p(g,M,T,"≮","\\nless",!0);p(g,M,T,"","\\@nleqslant");p(g,M,T,"","\\@nleqq");p(g,M,T,"⪇","\\lneq",!0);p(g,M,T,"≨","\\lneqq",!0);p(g,M,T,"","\\@lvertneqq");p(g,M,T,"⋦","\\lnsim",!0);p(g,M,T,"⪉","\\lnapprox",!0);p(g,M,T,"⊀","\\nprec",!0);p(g,M,T,"⋠","\\npreceq",!0);p(g,M,T,"⋨","\\precnsim",!0);p(g,M,T,"⪹","\\precnapprox",!0);p(g,M,T,"≁","\\nsim",!0);p(g,M,T,"","\\@nshortmid");p(g,M,T,"∤","\\nmid",!0);p(g,M,T,"⊬","\\nvdash",!0);p(g,M,T,"⊭","\\nvDash",!0);p(g,M,T,"⋪","\\ntriangleleft");p(g,M,T,"⋬","\\ntrianglelefteq",!0);p(g,M,T,"⊊","\\subsetneq",!0);p(g,M,T,"","\\@varsubsetneq");p(g,M,T,"⫋","\\subsetneqq",!0);p(g,M,T,"","\\@varsubsetneqq");p(g,M,T,"≯","\\ngtr",!0);p(g,M,T,"","\\@ngeqslant");p(g,M,T,"","\\@ngeqq");p(g,M,T,"⪈","\\gneq",!0);p(g,M,T,"≩","\\gneqq",!0);p(g,M,T,"","\\@gvertneqq");p(g,M,T,"⋧","\\gnsim",!0);p(g,M,T,"⪊","\\gnapprox",!0);p(g,M,T,"⊁","\\nsucc",!0);p(g,M,T,"⋡","\\nsucceq",!0);p(g,M,T,"⋩","\\succnsim",!0);p(g,M,T,"⪺","\\succnapprox",!0);p(g,M,T,"≆","\\ncong",!0);p(g,M,T,"","\\@nshortparallel");p(g,M,T,"∦","\\nparallel",!0);p(g,M,T,"⊯","\\nVDash",!0);p(g,M,T,"⋫","\\ntriangleright");p(g,M,T,"⋭","\\ntrianglerighteq",!0);p(g,M,T,"","\\@nsupseteqq");p(g,M,T,"⊋","\\supsetneq",!0);p(g,M,T,"","\\@varsupsetneq");p(g,M,T,"⫌","\\supsetneqq",!0);p(g,M,T,"","\\@varsupsetneqq");p(g,M,T,"⊮","\\nVdash",!0);p(g,M,T,"⪵","\\precneqq",!0);p(g,M,T,"⪶","\\succneqq",!0);p(g,M,T,"","\\@nsubseteqq");p(g,M,Z,"⊴","\\unlhd");p(g,M,Z,"⊵","\\unrhd");p(g,M,T,"↚","\\nleftarrow",!0);p(g,M,T,"↛","\\nrightarrow",!0);p(g,M,T,"⇍","\\nLeftarrow",!0);p(g,M,T,"⇏","\\nRightarrow",!0);p(g,M,T,"↮","\\nleftrightarrow",!0);p(g,M,T,"⇎","\\nLeftrightarrow",!0);p(g,M,T,"△","\\vartriangle");p(g,M,E,"ℏ","\\hslash");p(g,M,E,"▽","\\triangledown");p(g,M,E,"◊","\\lozenge");p(g,M,E,"Ⓢ","\\circledS");p(g,M,E,"®","\\circledR");p(q,M,E,"®","\\circledR");p(g,M,E,"∡","\\measuredangle",!0);p(g,M,E,"∄","\\nexists");p(g,M,E,"℧","\\mho");p(g,M,E,"Ⅎ","\\Finv",!0);p(g,M,E,"⅁","\\Game",!0);p(g,M,E,"‵","\\backprime");p(g,M,E,"▲","\\blacktriangle");p(g,M,E,"▼","\\blacktriangledown");p(g,M,E,"■","\\blacksquare");p(g,M,E,"⧫","\\blacklozenge");p(g,M,E,"★","\\bigstar");p(g,M,E,"∢","\\sphericalangle",!0);p(g,M,E,"∁","\\complement",!0);p(g,M,E,"ð","\\eth",!0);p(q,v,E,"ð","ð");p(g,M,E,"╱","\\diagup");p(g,M,E,"╲","\\diagdown");p(g,M,E,"□","\\square");p(g,M,E,"□","\\Box");p(g,M,E,"◊","\\Diamond");p(g,M,E,"¥","\\yen",!0);p(q,M,E,"¥","\\yen",!0);p(g,M,E,"✓","\\checkmark",!0);p(q,M,E,"✓","\\checkmark");p(g,M,E,"ℶ","\\beth",!0);p(g,M,E,"ℸ","\\daleth",!0);p(g,M,E,"ℷ","\\gimel",!0);p(g,M,E,"ϝ","\\digamma",!0);p(g,M,E,"ϰ","\\varkappa");p(g,M,Gt,"┌","\\@ulcorner",!0);p(g,M,Ct,"┐","\\@urcorner",!0);p(g,M,Gt,"└","\\@llcorner",!0);p(g,M,Ct,"┘","\\@lrcorner",!0);p(g,M,T,"≦","\\leqq",!0);p(g,M,T,"⩽","\\leqslant",!0);p(g,M,T,"⪕","\\eqslantless",!0);p(g,M,T,"≲","\\lesssim",!0);p(g,M,T,"⪅","\\lessapprox",!0);p(g,M,T,"≊","\\approxeq",!0);p(g,M,Z,"⋖","\\lessdot");p(g,M,T,"⋘","\\lll",!0);p(g,M,T,"≶","\\lessgtr",!0);p(g,M,T,"⋚","\\lesseqgtr",!0);p(g,M,T,"⪋","\\lesseqqgtr",!0);p(g,M,T,"≑","\\doteqdot");p(g,M,T,"≓","\\risingdotseq",!0);p(g,M,T,"≒","\\fallingdotseq",!0);p(g,M,T,"∽","\\backsim",!0);p(g,M,T,"⋍","\\backsimeq",!0);p(g,M,T,"⫅","\\subseteqq",!0);p(g,M,T,"⋐","\\Subset",!0);p(g,M,T,"⊏","\\sqsubset",!0);p(g,M,T,"≼","\\preccurlyeq",!0);p(g,M,T,"⋞","\\curlyeqprec",!0);p(g,M,T,"≾","\\precsim",!0);p(g,M,T,"⪷","\\precapprox",!0);p(g,M,T,"⊲","\\vartriangleleft");p(g,M,T,"⊴","\\trianglelefteq");p(g,M,T,"⊨","\\vDash",!0);p(g,M,T,"⊪","\\Vvdash",!0);p(g,M,T,"⌣","\\smallsmile");p(g,M,T,"⌢","\\smallfrown");p(g,M,T,"≏","\\bumpeq",!0);p(g,M,T,"≎","\\Bumpeq",!0);p(g,M,T,"≧","\\geqq",!0);p(g,M,T,"⩾","\\geqslant",!0);p(g,M,T,"⪖","\\eqslantgtr",!0);p(g,M,T,"≳","\\gtrsim",!0);p(g,M,T,"⪆","\\gtrapprox",!0);p(g,M,Z,"⋗","\\gtrdot");p(g,M,T,"⋙","\\ggg",!0);p(g,M,T,"≷","\\gtrless",!0);p(g,M,T,"⋛","\\gtreqless",!0);p(g,M,T,"⪌","\\gtreqqless",!0);p(g,M,T,"≖","\\eqcirc",!0);p(g,M,T,"≗","\\circeq",!0);p(g,M,T,"≜","\\triangleq",!0);p(g,M,T,"∼","\\thicksim");p(g,M,T,"≈","\\thickapprox");p(g,M,T,"⫆","\\supseteqq",!0);p(g,M,T,"⋑","\\Supset",!0);p(g,M,T,"⊐","\\sqsupset",!0);p(g,M,T,"≽","\\succcurlyeq",!0);p(g,M,T,"⋟","\\curlyeqsucc",!0);p(g,M,T,"≿","\\succsim",!0);p(g,M,T,"⪸","\\succapprox",!0);p(g,M,T,"⊳","\\vartriangleright");p(g,M,T,"⊵","\\trianglerighteq");p(g,M,T,"⊩","\\Vdash",!0);p(g,M,T,"∣","\\shortmid");p(g,M,T,"∥","\\shortparallel");p(g,M,T,"≬","\\between",!0);p(g,M,T,"⋔","\\pitchfork",!0);p(g,M,T,"∝","\\varpropto");p(g,M,T,"◀","\\blacktriangleleft");p(g,M,T,"∴","\\therefore",!0);p(g,M,T,"∍","\\backepsilon");p(g,M,T,"▶","\\blacktriangleright");p(g,M,T,"∵","\\because",!0);p(g,M,T,"⋘","\\llless");p(g,M,T,"⋙","\\gggtr");p(g,M,Z,"⊲","\\lhd");p(g,M,Z,"⊳","\\rhd");p(g,M,T,"≂","\\eqsim",!0);p(g,v,T,"⋈","\\Join");p(g,M,T,"≑","\\Doteq",!0);p(g,M,Z,"∔","\\dotplus",!0);p(g,M,Z,"∖","\\smallsetminus");p(g,M,Z,"⋒","\\Cap",!0);p(g,M,Z,"⋓","\\Cup",!0);p(g,M,Z,"⩞","\\doublebarwedge",!0);p(g,M,Z,"⊟","\\boxminus",!0);p(g,M,Z,"⊞","\\boxplus",!0);p(g,M,Z,"⋇","\\divideontimes",!0);p(g,M,Z,"⋉","\\ltimes",!0);p(g,M,Z,"⋊","\\rtimes",!0);p(g,M,Z,"⋋","\\leftthreetimes",!0);p(g,M,Z,"⋌","\\rightthreetimes",!0);p(g,M,Z,"⋏","\\curlywedge",!0);p(g,M,Z,"⋎","\\curlyvee",!0);p(g,M,Z,"⊝","\\circleddash",!0);p(g,M,Z,"⊛","\\circledast",!0);p(g,M,Z,"⋅","\\centerdot");p(g,M,Z,"⊺","\\intercal",!0);p(g,M,Z,"⋒","\\doublecap");p(g,M,Z,"⋓","\\doublecup");p(g,M,Z,"⊠","\\boxtimes",!0);p(g,M,T,"⇢","\\dashrightarrow",!0);p(g,M,T,"⇠","\\dashleftarrow",!0);p(g,M,T,"⇇","\\leftleftarrows",!0);p(g,M,T,"⇆","\\leftrightarrows",!0);p(g,M,T,"⇚","\\Lleftarrow",!0);p(g,M,T,"↞","\\twoheadleftarrow",!0);p(g,M,T,"↢","\\leftarrowtail",!0);p(g,M,T,"↫","\\looparrowleft",!0);p(g,M,T,"⇋","\\leftrightharpoons",!0);p(g,M,T,"↶","\\curvearrowleft",!0);p(g,M,T,"↺","\\circlearrowleft",!0);p(g,M,T,"↰","\\Lsh",!0);p(g,M,T,"⇈","\\upuparrows",!0);p(g,M,T,"↿","\\upharpoonleft",!0);p(g,M,T,"⇃","\\downharpoonleft",!0);p(g,v,T,"⊶","\\origof",!0);p(g,v,T,"⊷","\\imageof",!0);p(g,M,T,"⊸","\\multimap",!0);p(g,M,T,"↭","\\leftrightsquigarrow",!0);p(g,M,T,"⇉","\\rightrightarrows",!0);p(g,M,T,"⇄","\\rightleftarrows",!0);p(g,M,T,"↠","\\twoheadrightarrow",!0);p(g,M,T,"↣","\\rightarrowtail",!0);p(g,M,T,"↬","\\looparrowright",!0);p(g,M,T,"↷","\\curvearrowright",!0);p(g,M,T,"↻","\\circlearrowright",!0);p(g,M,T,"↱","\\Rsh",!0);p(g,M,T,"⇊","\\downdownarrows",!0);p(g,M,T,"↾","\\upharpoonright",!0);p(g,M,T,"⇂","\\downharpoonright",!0);p(g,M,T,"⇝","\\rightsquigarrow",!0);p(g,M,T,"⇝","\\leadsto");p(g,M,T,"⇛","\\Rrightarrow",!0);p(g,M,T,"↾","\\restriction");p(g,v,E,"‘","`");p(g,v,E,"$","\\$");p(q,v,E,"$","\\$");p(q,v,E,"$","\\textdollar");p(g,v,E,"%","\\%");p(q,v,E,"%","\\%");p(g,v,E,"_","\\_");p(q,v,E,"_","\\_");p(q,v,E,"_","\\textunderscore");p(g,v,E,"∠","\\angle",!0);p(g,v,E,"∞","\\infty",!0);p(g,v,E,"′","\\prime");p(g,v,E,"△","\\triangle");p(g,v,E,"Γ","\\Gamma",!0);p(g,v,E,"Δ","\\Delta",!0);p(g,v,E,"Θ","\\Theta",!0);p(g,v,E,"Λ","\\Lambda",!0);p(g,v,E,"Ξ","\\Xi",!0);p(g,v,E,"Π","\\Pi",!0);p(g,v,E,"Σ","\\Sigma",!0);p(g,v,E,"Υ","\\Upsilon",!0);p(g,v,E,"Φ","\\Phi",!0);p(g,v,E,"Ψ","\\Psi",!0);p(g,v,E,"Ω","\\Omega",!0);p(g,v,E,"A","Α");p(g,v,E,"B","Β");p(g,v,E,"E","Ε");p(g,v,E,"Z","Ζ");p(g,v,E,"H","Η");p(g,v,E,"I","Ι");p(g,v,E,"K","Κ");p(g,v,E,"M","Μ");p(g,v,E,"N","Ν");p(g,v,E,"O","Ο");p(g,v,E,"P","Ρ");p(g,v,E,"T","Τ");p(g,v,E,"X","Χ");p(g,v,E,"¬","\\neg",!0);p(g,v,E,"¬","\\lnot");p(g,v,E,"⊤","\\top");p(g,v,E,"⊥","\\bot");p(g,v,E,"∅","\\emptyset");p(g,M,E,"∅","\\varnothing");p(g,v,ie,"α","\\alpha",!0);p(g,v,ie,"β","\\beta",!0);p(g,v,ie,"γ","\\gamma",!0);p(g,v,ie,"δ","\\delta",!0);p(g,v,ie,"ϵ","\\epsilon",!0);p(g,v,ie,"ζ","\\zeta",!0);p(g,v,ie,"η","\\eta",!0);p(g,v,ie,"θ","\\theta",!0);p(g,v,ie,"ι","\\iota",!0);p(g,v,ie,"κ","\\kappa",!0);p(g,v,ie,"λ","\\lambda",!0);p(g,v,ie,"μ","\\mu",!0);p(g,v,ie,"ν","\\nu",!0);p(g,v,ie,"ξ","\\xi",!0);p(g,v,ie,"ο","\\omicron",!0);p(g,v,ie,"π","\\pi",!0);p(g,v,ie,"ρ","\\rho",!0);p(g,v,ie,"σ","\\sigma",!0);p(g,v,ie,"τ","\\tau",!0);p(g,v,ie,"υ","\\upsilon",!0);p(g,v,ie,"ϕ","\\phi",!0);p(g,v,ie,"χ","\\chi",!0);p(g,v,ie,"ψ","\\psi",!0);p(g,v,ie,"ω","\\omega",!0);p(g,v,ie,"ε","\\varepsilon",!0);p(g,v,ie,"ϑ","\\vartheta",!0);p(g,v,ie,"ϖ","\\varpi",!0);p(g,v,ie,"ϱ","\\varrho",!0);p(g,v,ie,"ς","\\varsigma",!0);p(g,v,ie,"φ","\\varphi",!0);p(g,v,Z,"∗","*",!0);p(g,v,Z,"+","+");p(g,v,Z,"−","-",!0);p(g,v,Z,"⋅","\\cdot",!0);p(g,v,Z,"∘","\\circ",!0);p(g,v,Z,"÷","\\div",!0);p(g,v,Z,"±","\\pm",!0);p(g,v,Z,"×","\\times",!0);p(g,v,Z,"∩","\\cap",!0);p(g,v,Z,"∪","\\cup",!0);p(g,v,Z,"∖","\\setminus",!0);p(g,v,Z,"∧","\\land");p(g,v,Z,"∨","\\lor");p(g,v,Z,"∧","\\wedge",!0);p(g,v,Z,"∨","\\vee",!0);p(g,v,E,"√","\\surd");p(g,v,Gt,"⟨","\\langle",!0);p(g,v,Gt,"∣","\\lvert");p(g,v,Gt,"∥","\\lVert");p(g,v,Ct,"?","?");p(g,v,Ct,"!","!");p(g,v,Ct,"⟩","\\rangle",!0);p(g,v,Ct,"∣","\\rvert");p(g,v,Ct,"∥","\\rVert");p(g,v,T,"=","=");p(g,v,T,":",":");p(g,v,T,"≈","\\approx",!0);p(g,v,T,"≅","\\cong",!0);p(g,v,T,"≥","\\ge");p(g,v,T,"≥","\\geq",!0);p(g,v,T,"←","\\gets");p(g,v,T,">","\\gt",!0);p(g,v,T,"∈","\\in",!0);p(g,v,T,"","\\@not");p(g,v,T,"⊂","\\subset",!0);p(g,v,T,"⊃","\\supset",!0);p(g,v,T,"⊆","\\subseteq",!0);p(g,v,T,"⊇","\\supseteq",!0);p(g,M,T,"⊈","\\nsubseteq",!0);p(g,M,T,"⊉","\\nsupseteq",!0);p(g,v,T,"⊨","\\models");p(g,v,T,"←","\\leftarrow",!0);p(g,v,T,"≤","\\le");p(g,v,T,"≤","\\leq",!0);p(g,v,T,"<","\\lt",!0);p(g,v,T,"→","\\rightarrow",!0);p(g,v,T,"→","\\to");p(g,M,T,"≱","\\ngeq",!0);p(g,M,T,"≰","\\nleq",!0);p(g,v,kn," ","\\ ");p(g,v,kn," ","\\space");p(g,v,kn," ","\\nobreakspace");p(q,v,kn," ","\\ ");p(q,v,kn," "," ");p(q,v,kn," ","\\space");p(q,v,kn," ","\\nobreakspace");p(g,v,kn,"","\\nobreak");p(g,v,kn,"","\\allowbreak");p(g,v,Yl,",",",");p(g,v,Yl,";",";");p(g,M,Z,"⊼","\\barwedge",!0);p(g,M,Z,"⊻","\\veebar",!0);p(g,v,Z,"⊙","\\odot",!0);p(g,v,Z,"⊕","\\oplus",!0);p(g,v,Z,"⊗","\\otimes",!0);p(g,v,E,"∂","\\partial",!0);p(g,v,Z,"⊘","\\oslash",!0);p(g,M,Z,"⊚","\\circledcirc",!0);p(g,M,Z,"⊡","\\boxdot",!0);p(g,v,Z,"△","\\bigtriangleup");p(g,v,Z,"▽","\\bigtriangledown");p(g,v,Z,"†","\\dagger");p(g,v,Z,"⋄","\\diamond");p(g,v,Z,"⋆","\\star");p(g,v,Z,"◃","\\triangleleft");p(g,v,Z,"▹","\\triangleright");p(g,v,Gt,"{","\\{");p(q,v,E,"{","\\{");p(q,v,E,"{","\\textbraceleft");p(g,v,Ct,"}","\\}");p(q,v,E,"}","\\}");p(q,v,E,"}","\\textbraceright");p(g,v,Gt,"{","\\lbrace");p(g,v,Ct,"}","\\rbrace");p(g,v,Gt,"[","\\lbrack",!0);p(q,v,E,"[","\\lbrack",!0);p(g,v,Ct,"]","\\rbrack",!0);p(q,v,E,"]","\\rbrack",!0);p(g,v,Gt,"(","\\lparen",!0);p(g,v,Ct,")","\\rparen",!0);p(q,v,E,"<","\\textless",!0);p(q,v,E,">","\\textgreater",!0);p(g,v,Gt,"⌊","\\lfloor",!0);p(g,v,Ct,"⌋","\\rfloor",!0);p(g,v,Gt,"⌈","\\lceil",!0);p(g,v,Ct,"⌉","\\rceil",!0);p(g,v,E,"\\","\\backslash");p(g,v,E,"∣","|");p(g,v,E,"∣","\\vert");p(q,v,E,"|","\\textbar",!0);p(g,v,E,"∥","\\|");p(g,v,E,"∥","\\Vert");p(q,v,E,"∥","\\textbardbl");p(q,v,E,"~","\\textasciitilde");p(q,v,E,"\\","\\textbackslash");p(q,v,E,"^","\\textasciicircum");p(g,v,T,"↑","\\uparrow",!0);p(g,v,T,"⇑","\\Uparrow",!0);p(g,v,T,"↓","\\downarrow",!0);p(g,v,T,"⇓","\\Downarrow",!0);p(g,v,T,"↕","\\updownarrow",!0);p(g,v,T,"⇕","\\Updownarrow",!0);p(g,v,Ze,"∐","\\coprod");p(g,v,Ze,"⋁","\\bigvee");p(g,v,Ze,"⋀","\\bigwedge");p(g,v,Ze,"⨄","\\biguplus");p(g,v,Ze,"⋂","\\bigcap");p(g,v,Ze,"⋃","\\bigcup");p(g,v,Ze,"∫","\\int");p(g,v,Ze,"∫","\\intop");p(g,v,Ze,"∬","\\iint");p(g,v,Ze,"∭","\\iiint");p(g,v,Ze,"∏","\\prod");p(g,v,Ze,"∑","\\sum");p(g,v,Ze,"⨂","\\bigotimes");p(g,v,Ze,"⨁","\\bigoplus");p(g,v,Ze,"⨀","\\bigodot");p(g,v,Ze,"∮","\\oint");p(g,v,Ze,"∯","\\oiint");p(g,v,Ze,"∰","\\oiiint");p(g,v,Ze,"⨆","\\bigsqcup");p(g,v,Ze,"∫","\\smallint");p(q,v,qs,"…","\\textellipsis");p(g,v,qs,"…","\\mathellipsis");p(q,v,qs,"…","\\ldots",!0);p(g,v,qs,"…","\\ldots",!0);p(g,v,qs,"⋯","\\@cdots",!0);p(g,v,qs,"⋱","\\ddots",!0);p(g,v,E,"⋮","\\varvdots");p(q,v,E,"⋮","\\varvdots");p(g,v,ze,"ˊ","\\acute");p(g,v,ze,"ˋ","\\grave");p(g,v,ze,"¨","\\ddot");p(g,v,ze,"~","\\tilde");p(g,v,ze,"ˉ","\\bar");p(g,v,ze,"˘","\\breve");p(g,v,ze,"ˇ","\\check");p(g,v,ze,"^","\\hat");p(g,v,ze,"⃗","\\vec");p(g,v,ze,"˙","\\dot");p(g,v,ze,"˚","\\mathring");p(g,v,ie,"","\\@imath");p(g,v,ie,"","\\@jmath");p(g,v,E,"ı","ı");p(g,v,E,"ȷ","ȷ");p(q,v,E,"ı","\\i",!0);p(q,v,E,"ȷ","\\j",!0);p(q,v,E,"ß","\\ss",!0);p(q,v,E,"æ","\\ae",!0);p(q,v,E,"œ","\\oe",!0);p(q,v,E,"ø","\\o",!0);p(q,v,E,"Æ","\\AE",!0);p(q,v,E,"Œ","\\OE",!0);p(q,v,E,"Ø","\\O",!0);p(q,v,ze,"ˊ","\\'");p(q,v,ze,"ˋ","\\`");p(q,v,ze,"ˆ","\\^");p(q,v,ze,"˜","\\~");p(q,v,ze,"ˉ","\\=");p(q,v,ze,"˘","\\u");p(q,v,ze,"˙","\\.");p(q,v,ze,"¸","\\c");p(q,v,ze,"˚","\\r");p(q,v,ze,"ˇ","\\v");p(q,v,ze,"¨",'\\"');p(q,v,ze,"˝","\\H");p(q,v,ze,"◯","\\textcircled");var v6={"--":!0,"---":!0,"``":!0,"''":!0};p(q,v,E,"–","--",!0);p(q,v,E,"–","\\textendash");p(q,v,E,"—","---",!0);p(q,v,E,"—","\\textemdash");p(q,v,E,"‘","`",!0);p(q,v,E,"‘","\\textquoteleft");p(q,v,E,"’","'",!0);p(q,v,E,"’","\\textquoteright");p(q,v,E,"“","``",!0);p(q,v,E,"“","\\textquotedblleft");p(q,v,E,"”","''",!0);p(q,v,E,"”","\\textquotedblright");p(g,v,E,"°","\\degree",!0);p(q,v,E,"°","\\degree");p(q,v,E,"°","\\textdegree",!0);p(g,v,E,"£","\\pounds");p(g,v,E,"£","\\mathsterling",!0);p(q,v,E,"£","\\pounds");p(q,v,E,"£","\\textsterling",!0);p(g,M,E,"✠","\\maltese");p(q,M,E,"✠","\\maltese");var Ng='0123456789/@."';for(var fd=0;fd<Ng.length;fd++){var Eg=Ng.charAt(fd);p(g,v,E,Eg,Eg)}var Dg='0123456789!@*()-=+";:?/.,';for(var pd=0;pd<Dg.length;pd++){var Og=Dg.charAt(pd);p(q,v,E,Og,Og)}var gc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var md=0;md<gc.length;md++){var E0=gc.charAt(md);p(g,v,ie,E0,E0),p(q,v,E,E0,E0)}p(g,M,E,"C","ℂ");p(q,M,E,"C","ℂ");p(g,M,E,"H","ℍ");p(q,M,E,"H","ℍ");p(g,M,E,"N","ℕ");p(q,M,E,"N","ℕ");p(g,M,E,"P","ℙ");p(q,M,E,"P","ℙ");p(g,M,E,"Q","ℚ");p(q,M,E,"Q","ℚ");p(g,M,E,"R","ℝ");p(q,M,E,"R","ℝ");p(g,M,E,"Z","ℤ");p(q,M,E,"Z","ℤ");p(g,v,ie,"h","ℎ");p(q,v,ie,"h","ℎ");var ae;for(var yt=0;yt<gc.length;yt++){var He=gc.charAt(yt);ae=String.fromCharCode(55349,56320+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56372+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56424+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56580+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56684+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56736+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56788+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56840+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56944+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),yt<26&&(ae=String.fromCharCode(55349,56632+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56476+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae))}ae="𝕜";p(g,v,ie,"k",ae);p(q,v,E,"k",ae);for(var pi=0;pi<10;pi++){var Dn=pi.toString();ae=String.fromCharCode(55349,57294+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57314+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57324+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57334+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae)}var Sh="ÐÞþ";for(var gd=0;gd<Sh.length;gd++){var D0=Sh.charAt(gd);p(g,v,ie,D0,D0),p(q,v,E,D0,D0)}var Ch={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},Rg={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},Ig={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},hT={mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},vi={mathClass:"",textClass:"",font:""},zg={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},Lg={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},Bg={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},Mh={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},Th={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},Pg={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},Ah={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},Fg=[Ch,Ch,Rg,Rg,Ig,Ig,hT,vi,vi,vi,zg,zg,Lg,Lg,Bg,Bg,Mh,Mh,Th,Th,Pg,Pg,vi,vi,Ah,Ah],fT=[Ch,vi,Mh,Th,Ah],pT=r=>{var e=r.charCodeAt(0),t=r.charCodeAt(1),n=(e-55296)*1024+(t-56320)+65536;if(119808<=n&&n<120484){var i=Math.floor((n-119808)/26);return Fg[i]}else if(120782<=n&&n<=120831){var o=Math.floor((n-120782)/10);return fT[o]}else{if(n===120485||n===120486)return Fg[0];if(120486<n&&n<120782)return vi;throw new V("Unsupported character: "+r)}},ru=function(e,t,n){if(Ie[n][e]){var i=Ie[n][e].replace;i&&(e=i)}return{value:e,metrics:Bp(e,t,n)}},bt=function(e,t,n,i,o){var s=ru(e,t,n),a=s.metrics;e=s.value;var l;if(a){var c=a.italic;(n==="text"||i&&i.font==="mathit")&&(c=0),l=new Wt(e,a.height,a.depth,c,a.skew,a.width,o)}else typeof console<"u"&&console.warn("No character metrics "+("for '"+e+"' in style '"+t+"' and mode '"+n+"'")),l=new Wt(e,0,0,0,0,0,o);if(i){l.maxFontSize=i.sizeMultiplier,i.style.isTight()&&l.classes.push("mtight");var u=i.getColor();u&&(l.style.color=u)}return l},Pp=function(e,t,n,i){return i===void 0&&(i=[]),n.font==="boldsymbol"&&ru(e,"Main-Bold",t).metrics?bt(e,"Main-Bold",t,n,i.concat(["mathbf"])):e==="\\"||Ie[t][e].font==="main"?bt(e,"Main-Regular",t,n,i):bt(e,"AMS-Regular",t,n,i.concat(["amsrm"]))},mT=function(e,t,n){return n!=="textord"&&ru(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}},nu=function(e,t){var n=e.type==="mathord"?"mathord":"textord",i=e.mode,o=e.text,s=["mord"],{font:a,fontFamily:l,fontWeight:c,fontShape:u}=t,d=i==="math"||i==="text"&&!!a,h=d?a:l,f="",m="";if(o.charCodeAt(0)===55349){var y=pT(o);f=y.font,m=y[i+"Class"]}if(f)return bt(o,f,i,t,s.concat(m));if(h){var x,b;if(h==="boldsymbol"){var S=mT(o,i,n);x=S.fontName,b=[S.fontClass]}else d?(x=Nh[a].fontName,b=[a]):(x=O0(l,c,u),b=[l,c,u]);if(ru(o,x,i).metrics)return bt(o,x,i,t,s.concat(b));if(v6.hasOwnProperty(o)&&x.slice(0,10)==="Typewriter"){for(var A=[],D=0;D<o.length;D++)A.push(bt(o[D],x,i,t,s.concat(b)));return Sn(A)}}if(n==="mathord")return bt(o,"Math-Italic",i,t,s.concat(["mathnormal"]));if(n==="textord"){var O=Ie[i][o]&&Ie[i][o].font;if(O==="ams"){var L=O0("amsrm",c,u);return bt(o,L,i,t,s.concat("amsrm",c,u))}else if(O==="main"||!O){var N=O0("textrm",c,u);return bt(o,N,i,t,s.concat(c,u))}else{var $=O0(O,c,u);return bt(o,$,i,t,s.concat($,c,u))}}else throw new Error("unexpected type: "+n+" in makeOrd")},gT=(r,e)=>{if(Xn(r.classes)!==Xn(e.classes)||r.skew!==e.skew||r.maxFontSize!==e.maxFontSize||r.italic!==0&&r.hasClass("mathnormal"))return!1;if(r.classes.length===1){var t=r.classes[0];if(t==="mbin"||t==="mord")return!1}for(var n of Object.keys(r.style))if(r.style[n]!==e.style[n])return!1;for(var i of Object.keys(e.style))if(r.style[i]!==e.style[i])return!1;return!0},b6=r=>{for(var e=0;e<r.length-1;e++){var t=r[e],n=r[e+1];t instanceof Wt&&n instanceof Wt&&gT(t,n)&&(t.text+=n.text,t.height=Math.max(t.height,n.height),t.depth=Math.max(t.depth,n.depth),t.italic=n.italic,r.splice(e+1,1),e--)}return r},Fp=function(e){for(var t=0,n=0,i=0,o=0;o<e.children.length;o++){var s=e.children[o];s.height>t&&(t=s.height),s.depth>n&&(n=s.depth),s.maxFontSize>i&&(i=s.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=i},j=function(e,t,n,i){var o=new _s(e,t,n,i);return Fp(o),o},Qn=(r,e,t,n)=>new _s(r,e,t,n),Ts=function(e,t,n){var i=j([e],[],t);return i.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i.style.borderBottomWidth=G(i.height),i.maxFontSize=1,i},yT=function(e,t,n,i){var o=new tu(e,t,n,i);return Fp(o),o},Sn=function(e){var t=new Hs(e);return Fp(t),t},As=function(e,t){return e instanceof Hs?j([],[e],t):e},vT=function(e){if(e.positionType==="individualShift"){for(var t=e.children,n=[t[0]],i=-t[0].shift-t[0].elem.depth,o=i,s=1;s<t.length;s++){var a=-t[s].shift-o-t[s].elem.depth,l=a-(t[s-1].elem.height+t[s-1].elem.depth);o=o+a,n.push({type:"kern",size:l}),n.push(t[s])}return{children:n,depth:i}}var c;if(e.positionType==="top"){for(var u=e.positionData,d=0;d<e.children.length;d++){var h=e.children[d];u-=h.type==="kern"?h.size:h.elem.height+h.elem.depth}c=u}else if(e.positionType==="bottom")c=-e.positionData;else{var f=e.children[0];if(f.type!=="elem")throw new Error('First child must have type "elem".');if(e.positionType==="shift")c=-f.elem.depth-e.positionData;else if(e.positionType==="firstBaseline")c=-f.elem.depth;else throw new Error("Invalid positionType "+e.positionType+".")}return{children:e.children,depth:c}},be=function(e,t){for(var{children:n,depth:i}=vT(e),o=0,s=0;s<n.length;s++){var a=n[s];if(a.type==="elem"){var l=a.elem;o=Math.max(o,l.maxFontSize,l.height)}}o+=2;var c=j(["pstrut"],[]);c.style.height=G(o);for(var u=[],d=i,h=i,f=i,m=0;m<n.length;m++){var y=n[m];if(y.type==="kern")f+=y.size;else{var x=y.elem,b=y.wrapperClasses||[],S=y.wrapperStyle||{},A=j(b,[c,x],void 0,S);A.style.top=G(-o-f-x.depth),y.marginLeft&&(A.style.marginLeft=y.marginLeft),y.marginRight&&(A.style.marginRight=y.marginRight),u.push(A),f+=x.height+x.depth}d=Math.min(d,f),h=Math.max(h,f)}var D=j(["vlist"],u);D.style.height=G(h);var O;if(d<0){var L=j([],[]),N=j(["vlist"],[L]);N.style.height=G(-d);var $=j(["vlist-s"],[new Wt("​")]);O=[j(["vlist-r"],[D,$]),j(["vlist-r"],[N])]}else O=[j(["vlist-r"],[D])];var K=j(["vlist-t"],O);return O.length===2&&K.classes.push("vlist-t2"),K.height=h,K.depth=-d,K},w6=(r,e)=>{var t=j(["mspace"],[],e),n=Pe(r,e);return t.style.marginRight=G(n),t},O0=(r,e,t)=>{var n,i;switch(r){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=r}return e==="textbf"&&t==="textit"?i="BoldItalic":e==="textbf"?i="Bold":t==="textit"?i="Italic":i="Regular",n+"-"+i},Nh={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},x6={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},k6=function(e,t){var[n,i,o]=x6[e],s=new Zn(n),a=new bn([s],{width:G(i),height:G(o),style:"width:"+G(i),viewBox:"0 0 "+1e3*i+" "+1e3*o,preserveAspectRatio:"xMinYMin"}),l=Qn(["overlay"],[a],t);return l.height=o,l.style.height=G(o),l.style.width=G(i),l},Be={number:3,unit:"mu"},mi={number:4,unit:"mu"},Jr={number:5,unit:"mu"},bT={mord:{mop:Be,mbin:mi,mrel:Jr,minner:Be},mop:{mord:Be,mop:Be,mrel:Jr,minner:Be},mbin:{mord:mi,mop:mi,mopen:mi,minner:mi},mrel:{mord:Jr,mop:Jr,mopen:Jr,minner:Jr},mopen:{},mclose:{mop:Be,mbin:mi,mrel:Jr,minner:Be},mpunct:{mord:Be,mop:Be,mrel:Jr,mopen:Be,mclose:Be,mpunct:Be,minner:Be},minner:{mord:Be,mop:Be,mbin:mi,mrel:Jr,mopen:Be,mpunct:Be,minner:Be}},wT={mord:{mop:Be},mop:{mord:Be,mop:Be},mbin:{},mrel:{},mopen:{},mclose:{mop:Be},mpunct:{},minner:{mop:Be}},S6={},ja={},Va={};function X(r){for(var{type:e,names:t,htmlBuilder:n,mathmlBuilder:i}=r,o=0;o<t.length;++o)S6[t[o]]=r;e&&(n&&(ja[e]=n),i&&(Va[e]=i))}function io(r){var{type:e,htmlBuilder:t,mathmlBuilder:n}=r;t&&(ja[e]=t),n&&(Va[e]=n)}var yc=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},Ye=function(e){return e.type==="ordgroup"?e.body:[e]},xT=new Set(["leftmost","mbin","mopen","mrel","mop","mpunct"]),kT=new Set(["rightmost","mrel","mclose","mpunct"]),ST={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT},CT={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},tt=function(e,t,n,i){i===void 0&&(i=[null,null]);for(var o=[],s=0;s<e.length;s++){var a=we(e[s],t);if(a instanceof Hs){var l=a.children;o.push(...l)}else o.push(a)}if(b6(o),!n)return o;var c=t;if(e.length===1){var u=e[0];u.type==="sizing"?c=t.havingSize(u.size):u.type==="styling"&&(c=t.havingStyle(ST[u.style]))}var d=j([i[0]||"leftmost"],[],t),h=j([i[1]||"rightmost"],[],t),f=n==="root";return Eh(o,(m,y)=>{var x=y.classes[0],b=m.classes[0];x==="mbin"&&kT.has(b)?y.classes[0]="mord":b==="mbin"&&xT.has(x)&&(m.classes[0]="mord")},{node:d},h,f),Eh(o,(m,y)=>{var x,b,S=Oh(y),A=Oh(m),D=S&&A?m.hasClass("mtight")?(x=wT[S])==null?void 0:x[A]:(b=bT[S])==null?void 0:b[A]:null;if(D)return w6(D,c)},{node:d},h,f),o},Eh=function(e,t,n,i,o){i&&e.push(i);for(var s=0;s<e.length;s++){var a=e[s],l=C6(a);if(l){Eh(l.children,t,n,null,o);continue}var c=!a.hasClass("mspace");if(c){var u=t(a,n.node);u&&(n.insertAfter?n.insertAfter(u):(e.unshift(u),s++))}c?n.node=a:o&&a.hasClass("newline")&&(n.node=j(["leftmost"])),n.insertAfter=(d=>h=>{e.splice(d+1,0,h),s++})(s)}i&&e.pop()},C6=function(e){return e instanceof Hs||e instanceof tu||e instanceof _s&&e.hasClass("enclosing")?e:null},Dh=function(e,t){var n=C6(e);if(n){var i=n.children;if(i.length){if(t==="right")return Dh(i[i.length-1],"right");if(t==="left")return Dh(i[0],"left")}}return e},Oh=function(e,t){if(!e)return null;t&&(e=Dh(e,t));var n=e.classes[0];return CT[n]||null},Wa=function(e,t){var n=["nulldelimiter"].concat(e.baseSizingClasses());return j(t.concat(n))},we=function(e,t,n){if(!e)return j();if(ja[e.type]){var i=ja[e.type](e,t);if(n&&t.size!==n.size){i=j(t.sizingClasses(n),[i],t);var o=t.sizeMultiplier/n.sizeMultiplier;i.height*=o,i.depth*=o}return i}else throw new V("Got group of unknown type: '"+e.type+"'")};function R0(r,e){var t=j(["base"],r,e),n=j(["strut"]);return n.style.height=G(t.height+t.depth),t.depth&&(n.style.verticalAlign=G(-t.depth)),t.children.unshift(n),t}function Rh(r,e){var t=null;r.length===1&&r[0].type==="tag"&&(t=r[0].tag,r=r[0].body);var n=tt(r,e,"root"),i;n.length===2&&n[1].hasClass("tag")&&(i=n.pop());for(var o=[],s=[],a=0;a<n.length;a++)if(s.push(n[a]),n[a].hasClass("mbin")||n[a].hasClass("mrel")||n[a].hasClass("allowbreak")){for(var l=!1;a<n.length-1&&n[a+1].hasClass("mspace")&&!n[a+1].hasClass("newline");)a++,s.push(n[a]),n[a].hasClass("nobreak")&&(l=!0);l||(o.push(R0(s,e)),s=[])}else n[a].hasClass("newline")&&(s.pop(),s.length>0&&(o.push(R0(s,e)),s=[]),o.push(n[a]));s.length>0&&o.push(R0(s,e));var c;t?(c=R0(tt(t,e,!0),e),c.classes=["tag"],o.push(c)):i&&o.push(i);var u=j(["katex-html"],o);if(u.setAttribute("aria-hidden","true"),c){var d=c.children[0];d.style.height=G(u.height+u.depth),u.depth&&(d.style.verticalAlign=G(-u.depth))}return u}function M6(r){return new Hs(r)}class W{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=Xn(this.classes));for(var n=0;n<this.children.length;n++)if(this.children[n]instanceof Je&&this.children[n+1]instanceof Je){for(var i=this.children[n].toText()+this.children[++n].toText();this.children[n+1]instanceof Je;)i+=this.children[++n].toText();e.appendChild(new Je(i).toNode())}else e.appendChild(this.children[n].toNode());return e}toMarkup(){var e="<"+this.type;for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="',e+=ht(this.attributes[t]),e+='"');this.classes.length>0&&(e+=' class ="'+ht(Xn(this.classes))+'"'),e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</"+this.type+">",e}toText(){return this.children.map(e=>e.toText()).join("")}}class Je{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ht(this.toText())}toText(){return this.text}}class T6{constructor(e){this.width=void 0,this.character=void 0,this.width=e,e>=.05555&&e<=.05556?this.character=" ":e>=.1666&&e<=.1667?this.character=" ":e>=.2222&&e<=.2223?this.character=" ":e>=.2777&&e<=.2778?this.character="  ":e>=-.05556&&e<=-.05555?this.character=" ⁣":e>=-.1667&&e<=-.1666?this.character=" ⁣":e>=-.2223&&e<=-.2222?this.character=" ⁣":e>=-.2778&&e<=-.2777?this.character=" ⁣":this.character=null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",G(this.width)),e}toMarkup(){return this.character?"<mtext>"+this.character+"</mtext>":'<mspace width="'+G(this.width)+'"/>'}toText(){return this.character?this.character:" "}}var MT=new Set(["\\imath","\\jmath"]),TT=new Set(["mrow","mtable"]),ur=function(e,t,n){return Ie[t][e]&&Ie[t][e].replace&&e.charCodeAt(0)!==55349&&!(v6.hasOwnProperty(e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt"))&&(e=Ie[t][e].replace),new Je(e)},Hp=function(e){return e.length===1?e[0]:new W("mrow",e)},AT={mathit:"italic",boldsymbol:r=>r.type==="textord"?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},_p=(r,e)=>{if(r.mode==="text"){if(e.fontFamily==="texttt")return"monospace";if(e.fontFamily==="textsf")return e.fontShape==="textit"&&e.fontWeight==="textbf"?"sans-serif-bold-italic":e.fontShape==="textit"?"sans-serif-italic":e.fontWeight==="textbf"?"bold-sans-serif":"sans-serif";if(e.fontShape==="textit"&&e.fontWeight==="textbf")return"bold-italic";if(e.fontShape==="textit")return"italic";if(e.fontWeight==="textbf")return"bold"}var t=e.font;if(!t||t==="mathnormal")return null;var n=r.mode,i=AT[t];if(i)return typeof i=="function"?i(r):i;var o=r.text;if(MT.has(o))return null;if(Ie[n][o]){var s=Ie[n][o].replace;s&&(o=s)}var a=Nh[t].fontName;return Bp(o,a,n)?Nh[t].variant:null};function yd(r){if(!r)return!1;if(r.type==="mi"&&r.children.length===1){var e=r.children[0];return e instanceof Je&&e.text==="."}else if(r.type==="mo"&&r.children.length===1&&r.getAttribute("separator")==="true"&&r.getAttribute("lspace")==="0em"&&r.getAttribute("rspace")==="0em"){var t=r.children[0];return t instanceof Je&&t.text===","}else return!1}var Yt=function(e,t,n){if(e.length===1){var i=Ne(e[0],t);return n&&i instanceof W&&i.type==="mo"&&(i.setAttribute("lspace","0em"),i.setAttribute("rspace","0em")),[i]}for(var o=[],s,a=0;a<e.length;a++){var l=Ne(e[a],t);if(l instanceof W&&s instanceof W){if(l.type==="mtext"&&s.type==="mtext"&&l.getAttribute("mathvariant")===s.getAttribute("mathvariant")){s.children.push(...l.children);continue}else if(l.type==="mn"&&s.type==="mn"){s.children.push(...l.children);continue}else if(yd(l)&&s.type==="mn"){s.children.push(...l.children);continue}else if(l.type==="mn"&&yd(s))l.children=[...s.children,...l.children],o.pop();else if((l.type==="msup"||l.type==="msub")&&l.children.length>=1&&(s.type==="mn"||yd(s))){var c=l.children[0];c instanceof W&&c.type==="mn"&&(c.children=[...s.children,...c.children],o.pop())}else if(s.type==="mi"&&s.children.length===1){var u=s.children[0];if(u instanceof Je&&u.text==="̸"&&(l.type==="mo"||l.type==="mi"||l.type==="mn")){var d=l.children[0];d instanceof Je&&d.text.length>0&&(d.text=d.text.slice(0,1)+"̸"+d.text.slice(1),o.pop())}}}o.push(l),s=l}return o},ei=function(e,t,n){return Hp(Yt(e,t,n))},Ne=function(e,t){if(!e)return new W("mrow");if(Va[e.type])return Va[e.type](e,t);throw new V("Got group of unknown type: '"+e.type+"'")};function Hg(r,e,t,n,i){var o=Yt(r,t),s;o.length===1&&o[0]instanceof W&&TT.has(o[0].type)?s=o[0]:s=new W("mrow",o);var a=new W("annotation",[new Je(e)]);a.setAttribute("encoding","application/x-tex");var l=new W("semantics",[s,a]),c=new W("math",[l]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");var u=i?"katex":"katex-mathml";return j([u],[c])}var NT=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],_g=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],qg=function(e,t){return t.size<2?e:NT[e-1][t.size-1]};class en{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||en.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=_g[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new en(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:qg(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:_g[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=qg(en.BASESIZE,e);return this.size===t&&this.textSize===en.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==en.BASESIZE?["sizing","reset-size"+this.size,"size"+en.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=dT(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}en.BASESIZE=6;var A6=function(e){return new en({style:e.displayMode?de.DISPLAY:de.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},N6=function(e,t){if(t.displayMode){var n=["katex-display"];t.leqno&&n.push("leqno"),t.fleqn&&n.push("fleqn"),e=j(n,[e])}return e},ET=function(e,t,n){var i=A6(n),o;if(n.output==="mathml")return Hg(e,t,i,n.displayMode,!0);if(n.output==="html"){var s=Rh(e,i);o=j(["katex"],[s])}else{var a=Hg(e,t,i,n.displayMode,!1),l=Rh(e,i);o=j(["katex"],[a,l])}return N6(o,n)},DT=function(e,t,n){var i=A6(n),o=Rh(e,i),s=j(["katex"],[o]);return N6(s,n)},OT={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",underbracket:"⎵",overbracket:"⎴",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xrightleftarrows:"⇄",xrightequilibrium:"⇌",xleftequilibrium:"⇋","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="},iu=function(e){var t=new W("mo",[new Je(OT[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},RT={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},IT=new Set(["widehat","widecheck","widetilde","utilde"]),ou=function(e,t){function n(){var a=4e5,l=e.label.slice(1);if(IT.has(l)&&"base"in e){var c=e.base.type==="ordgroup"?e.base.body.length:1,u,d,h;if(c>5)l==="widehat"||l==="widecheck"?(u=420,a=2364,h=.42,d=l+"4"):(u=312,a=2340,h=.34,d="tilde4");else{var f=[1,1,2,2,3,3][c];l==="widehat"||l==="widecheck"?(a=[0,1062,2364,2364,2364][f],u=[0,239,300,360,420][f],h=[0,.24,.3,.3,.36,.42][f],d=l+f):(a=[0,600,1033,2339,2340][f],u=[0,260,286,306,312][f],h=[0,.26,.286,.3,.306,.34][f],d="tilde"+f)}var m=new Zn(d),y=new bn([m],{width:"100%",height:G(h),viewBox:"0 0 "+a+" "+u,preserveAspectRatio:"none"});return{span:Qn([],[y],t),minWidth:0,height:h}}else{var x=[],b=RT[l];if(!b)throw new Error('No SVG data for "'+l+'".');var[S,A,D]=b,O=D/1e3,L=S.length,N,$;if(L===1){if(b.length!==4)throw new Error('Expected 4-tuple for single-path SVG data "'+l+'".');N=["hide-tail"],$=[b[3]]}else if(L===2)N=["halfarrow-left","halfarrow-right"],$=["xMinYMin","xMaxYMin"];else if(L===3)N=["brace-left","brace-center","brace-right"],$=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support
1131
- `+L+" children.");for(var K=0;K<L;K++){var ne=new Zn(S[K]),pe=new bn([ne],{width:"400em",height:G(O),viewBox:"0 0 "+a+" "+D,preserveAspectRatio:$[K]+" slice"}),se=Qn([N[K]],[pe],t);if(L===1)return{span:se,minWidth:A,height:O};se.style.height=G(O),x.push(se)}return{span:j(["stretchy"],x,t),minWidth:A,height:O}}}var{span:i,minWidth:o,height:s}=n();return i.height=s,i.style.height=G(s),o>0&&(i.style.minWidth=G(o)),i},zT=function(e,t,n,i,o){var s,a=e.height+e.depth+n+i;if(/fbox|color|angl/.test(t)){if(s=j(["stretchy",t],[],o),t==="fbox"){var l=o.color&&o.getColor();l&&(s.style.borderColor=l)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new kh({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&c.push(new kh({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var u=new bn(c,{width:"100%",height:G(a)});s=Qn([],[u],o)}return s.height=a,s.style.height=G(a),s},LT={bin:1,close:1,inner:1,open:1,punct:1,rel:1},BT={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1};function PT(r){return r in LT}function he(r,e){if(!r||r.type!==e)throw new Error("Expected node of type "+e+", but got "+(r?"node of type "+r.type:String(r)));return r}function su(r){var e=au(r);if(!e)throw new Error("Expected node of symbol group type, but got "+(r?"node of type "+r.type:String(r)));return e}function au(r){return r&&(r.type==="atom"||BT.hasOwnProperty(r.type))?r:null}var E6=r=>{if(r instanceof Wt)return r;if(cT(r)&&r.children.length===1)return E6(r.children[0])},D6=(r,e)=>{var t,n,i;r&&r.type==="supsub"?(n=he(r.base,"accent"),t=n.base,r.base=t,i=lT(we(r,e)),r.base=n):(n=he(r,"accent"),t=n.base);var o=we(t,e.havingCrampedStyle()),s=n.isShifty&&xn(t),a=0;if(s){var l,c;a=(l=(c=E6(o))==null?void 0:c.skew)!=null?l:0}var u=n.label==="\\c",d=u?o.height+o.depth:Math.min(o.height,e.fontMetrics().xHeight),h;if(n.isStretchy)h=ou(n,e),h=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:a>0?{width:"calc(100% - "+G(2*a)+")",marginLeft:G(2*a)}:void 0}]});else{var f,m;n.label==="\\vec"?(f=k6("vec",e),m=x6.vec[1]):(f=nu({type:"textord",mode:n.mode,text:n.label},e),f=aT(f),f.italic=0,m=f.width,u&&(d+=f.depth)),h=j(["accent-body"],[f]);var y=n.label==="\\textcircled";y&&(h.classes.push("accent-full"),d=o.height);var x=a;y||(x-=m/2),h.style.left=G(x),n.label==="\\textcircled"&&(h.style.top=".2em"),h=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:-d},{type:"elem",elem:h}]})}var b=j(["mord","accent"],[h],e);return i?(i.children[0]=b,i.height=Math.max(b.height,i.height),i.classes[0]="mord",i):b},FT=(r,e)=>{var t=r.isStretchy?iu(r.label):new W("mo",[ur(r.label,r.mode)]),n=new W("mover",[Ne(r.base,e),t]);return n.setAttribute("accent","true"),n},HT=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(r=>"\\"+r).join("|"));X({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],numArgs:1,handler:(r,e)=>{var t=yc(e[0]),n=!HT.test(r.funcName),i=!n||r.funcName==="\\widehat"||r.funcName==="\\widetilde"||r.funcName==="\\widecheck";return{type:"accent",mode:r.parser.mode,label:r.funcName,isStretchy:n,isShifty:i,base:t}},htmlBuilder:D6,mathmlBuilder:FT});X({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"],handler:(r,e)=>{var t=e[0],n=r.parser.mode;return n==="math"&&(r.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+r.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:r.funcName,isStretchy:!1,isShifty:!0,base:t}}});X({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],numArgs:1,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"accentUnder",mode:t.mode,label:n,base:i}},htmlBuilder:(r,e)=>{var t=we(r.base,e),n=ou(r,e),i=r.label==="\\utilde"?.12:0,o=be({positionType:"top",positionData:t.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:t}]});return j(["mord","accentunder"],[o],e)},mathmlBuilder:(r,e)=>{var t=iu(r.label),n=new W("munder",[Ne(r.base,e),t]);return n.setAttribute("accentunder","true"),n}});var I0=r=>{var e=new W("mpadded",r?[r]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};X({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],numArgs:1,numOptionalArgs:1,handler(r,e,t){var{parser:n,funcName:i}=r;return{type:"xArrow",mode:n.mode,label:i,body:e[0],below:t[0]}},htmlBuilder(r,e){var t=e.style,n=e.havingStyle(t.sup()),i=As(we(r.body,n,e),e),o=r.label.slice(0,2)==="\\x"?"x":"cd";i.classes.push(o+"-arrow-pad");var s;r.below&&(n=e.havingStyle(t.sub()),s=As(we(r.below,n,e),e),s.classes.push(o+"-arrow-pad"));var a=ou(r,e),l=-e.fontMetrics().axisHeight+.5*a.height,c=-e.fontMetrics().axisHeight-.5*a.height-.111;(i.depth>.25||r.label==="\\xleftequilibrium")&&(c-=i.depth);var u;if(s){var d=-e.fontMetrics().axisHeight+s.height+.5*a.height+.111;u=be({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]},{type:"elem",elem:s,shift:d}]})}else u=be({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]}]});return j(["mrel","x-arrow"],[u],e)},mathmlBuilder(r,e){var t=iu(r.label);t.setAttribute("minsize",r.label.charAt(0)==="x"?"1.75em":"3.0em");var n;if(r.body){var i=I0(Ne(r.body,e));if(r.below){var o=I0(Ne(r.below,e));n=new W("munderover",[t,o,i])}else n=new W("mover",[t,i])}else if(r.below){var s=I0(Ne(r.below,e));n=new W("munder",[t,s])}else n=I0(),n=new W("mover",[t,n]);return n}});function _T(r,e){var t=tt(r.body,e,!0);return j([r.mclass],t,e)}function qT(r,e){var t,n=Yt(r.body,e);return r.mclass==="minner"?t=new W("mpadded",n):r.mclass==="mord"?r.isCharacterBox?(t=n[0],t.type="mi"):t=new W("mi",n):(r.isCharacterBox?(t=n[0],t.type="mo"):t=new W("mo",n),r.mclass==="mbin"?(t.attributes.lspace="0.22em",t.attributes.rspace="0.22em"):r.mclass==="mpunct"?(t.attributes.lspace="0em",t.attributes.rspace="0.17em"):(r.mclass==="mopen"||r.mclass==="mclose")&&(t.attributes.lspace="0em",t.attributes.rspace="0em")),t}X({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],numArgs:1,primitive:!0,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"mclass",mode:t.mode,mclass:"m"+n.slice(5),body:Ye(i),isCharacterBox:xn(i)}},htmlBuilder:_T,mathmlBuilder:qT});var lu=r=>{var e=r.type==="ordgroup"&&r.body.length?r.body[0]:r;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};X({type:"mclass",names:["\\@binrel"],numArgs:2,handler(r,e){var{parser:t}=r;return{type:"mclass",mode:t.mode,mclass:lu(e[0]),body:Ye(e[1]),isCharacterBox:xn(e[1])}}});X({type:"mclass",names:["\\stackrel","\\overset","\\underset"],numArgs:2,handler(r,e){var{parser:t,funcName:n}=r,i=e[1],o=e[0],s;n!=="\\stackrel"?s=lu(i):s="mrel";var a={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:Ye(i)},l=n==="\\underset"?{type:"supsub",mode:o.mode,base:a,sub:o}:{type:"supsub",mode:o.mode,base:a,sup:o};return{type:"mclass",mode:t.mode,mclass:s,body:[l],isCharacterBox:xn(l)}}});X({type:"pmb",names:["\\pmb"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"pmb",mode:t.mode,mclass:lu(e[0]),body:Ye(e[0])}},htmlBuilder(r,e){var t=tt(r.body,e,!0),n=j([r.mclass],t,e);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(r,e){var t=Yt(r.body,e),n=new W("mstyle",t);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});var $T={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},$g=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),jg=r=>r.type==="textord"&&r.text==="@",jT=(r,e)=>(r.type==="mathord"||r.type==="atom")&&r.text===e;function VT(r,e,t){var n=$T[r];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return t.callFunction(n,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var i=t.callFunction("\\\\cdleft",[e[0]],[]),o={type:"atom",text:n,mode:"math",family:"rel"},s=t.callFunction("\\Big",[o],[]),a=t.callFunction("\\\\cdright",[e[1]],[]),l={type:"ordgroup",mode:"math",body:[i,s,a]};return t.callFunction("\\\\cdparent",[l],[])}case"\\\\cdlongequal":return t.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var c={type:"textord",text:"\\Vert",mode:"math"};return t.callFunction("\\Big",[c],[])}default:return{type:"textord",text:" ",mode:"math"}}}function WT(r){var e=[];for(r.gullet.beginGroup(),r.gullet.macros.set("\\cr","\\\\\\relax"),r.gullet.beginGroup();;){e.push(r.parseExpression(!1,"\\\\")),r.gullet.endGroup(),r.gullet.beginGroup();var t=r.fetch().text;if(t==="&"||t==="\\\\")r.consume();else if(t==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new V("Expected \\\\ or \\cr or \\end",r.nextToken)}for(var n=[],i=[n],o=0;o<e.length;o++){for(var s=e[o],a=$g(),l=0;l<s.length;l++)if(!jg(s[l]))a.body.push(s[l]);else{n.push(a),l+=1;var c=su(s[l]).text,u=new Array(2);if(u[0]={type:"ordgroup",mode:"math",body:[]},u[1]={type:"ordgroup",mode:"math",body:[]},!"=|.".includes(c))if("<>AV".includes(c))for(var d=0;d<2;d++){for(var h=!0,f=l+1;f<s.length;f++){if(jT(s[f],c)){h=!1,l=f;break}if(jg(s[f]))throw new V("Missing a "+c+" character to complete a CD arrow.",s[f]);u[d].body.push(s[f])}if(h)throw new V("Missing a "+c+" character to complete a CD arrow.",s[l])}else throw new V('Expected one of "<>AV=|." after @',s[l]);var m=VT(c,u,r),y={type:"styling",body:[m],mode:"math",style:"display",resetFont:!0};n.push(y),a=$g()}o%2===0?n.push(a):n.shift(),n=[],i.push(n)}r.gullet.endGroup(),r.gullet.endGroup();var x=new Array(i[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:x,colSeparationType:"CD",hLinesBeforeRow:new Array(i.length+1).fill([])}}X({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r;return{type:"cdlabel",mode:t.mode,side:n.slice(4),label:e[0]}},htmlBuilder(r,e){var t=e.havingStyle(e.style.sup()),n=As(we(r.label,t,e),e);return n.classes.push("cd-label-"+r.side),n.style.bottom=G(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(r,e){var t=new W("mrow",[Ne(r.label,e)]);return t=new W("mpadded",[t]),t.setAttribute("width","0"),r.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new W("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});X({type:"cdlabelparent",names:["\\\\cdparent"],numArgs:1,handler(r,e){var{parser:t}=r;return{type:"cdlabelparent",mode:t.mode,fragment:e[0]}},htmlBuilder(r,e){var t=As(we(r.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(r,e){return new W("mrow",[Ne(r.fragment,e)])}});X({type:"textord",names:["\\@char"],numArgs:1,allowedInText:!0,handler(r,e){for(var{parser:t}=r,n=he(e[0],"ordgroup"),i=n.body,o="",s=0;s<i.length;s++){var a=he(i[s],"textord");o+=a.text}var l=parseInt(o),c;if(isNaN(l))throw new V("\\@char has non-numeric argument "+o);if(l<0||l>=1114111)throw new V("\\@char with invalid code point "+o);return l<=65535?c=String.fromCharCode(l):(l-=65536,c=String.fromCharCode((l>>10)+55296,(l&1023)+56320)),{type:"textord",mode:t.mode,text:c}}});var UT=(r,e)=>{var t=tt(r.body,e.withColor(r.color),!1);return Sn(t)},KT=(r,e)=>{var t=Yt(r.body,e.withColor(r.color)),n=new W("mstyle",t);return n.setAttribute("mathcolor",r.color),n};X({type:"color",names:["\\textcolor"],numArgs:2,allowedInText:!0,argTypes:["color","original"],handler(r,e){var{parser:t}=r,n=he(e[0],"color-token").color,i=e[1];return{type:"color",mode:t.mode,color:n,body:Ye(i)}},htmlBuilder:UT,mathmlBuilder:KT});X({type:"color",names:["\\color"],numArgs:1,allowedInText:!0,argTypes:["color"],handler(r,e){var{parser:t,breakOnTokenText:n}=r,i=he(e[0],"color-token").color;t.gullet.macros.set("\\current@color",i);var o=t.parseExpression(!0,n);return{type:"color",mode:t.mode,color:i,body:o}}});X({type:"cr",names:["\\\\"],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(r,e,t){var{parser:n}=r,i=n.gullet.future().text==="["?n.parseSizeGroup(!0):null,o=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:o,size:i&&he(i,"size").value}},htmlBuilder(r,e){var t=j(["mspace"],[],e);return r.newLine&&(t.classes.push("newline"),r.size&&(t.style.marginTop=G(Pe(r.size,e)))),t},mathmlBuilder(r,e){var t=new W("mspace");return r.newLine&&(t.setAttribute("linebreak","newline"),r.size&&t.setAttribute("height",G(Pe(r.size,e)))),t}});var Ih={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},O6=r=>{var e=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new V("Expected a control sequence",r);return e},GT=r=>{var e=r.gullet.popToken();return e.text==="="&&(e=r.gullet.popToken(),e.text===" "&&(e=r.gullet.popToken())),e},R6=(r,e,t,n)=>{var i=r.gullet.macros.get(t.text);i==null&&(t.noexpand=!0,i={tokens:[t],numArgs:0,unexpandable:!r.gullet.isExpandable(t.text)}),r.gullet.macros.set(e,i,n)};X({type:"internal",names:["\\global","\\long","\\\\globallong"],numArgs:0,allowedInText:!0,handler(r){var{parser:e,funcName:t}=r;e.consumeSpaces();var n=e.fetch();if(Ih[n.text])return(t==="\\global"||t==="\\\\globallong")&&(n.text=Ih[n.text]),he(e.parseFunction(),"internal");throw new V("Invalid token after macro prefix",n)}});X({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=e.gullet.popToken(),i=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new V("Expected a control sequence",n);for(var o=0,s,a=[[]];e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){s=e.gullet.future(),a[o].push("{");break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new V('Invalid argument number "'+n.text+'"');if(parseInt(n.text)!==o+1)throw new V('Argument number "'+n.text+'" out of order');o++,a.push([])}else{if(n.text==="EOF")throw new V("Expected a macro definition");a[o].push(n.text)}var{tokens:l}=e.gullet.consumeArg();return s&&l.unshift(s),(t==="\\edef"||t==="\\xdef")&&(l=e.gullet.expandTokens(l),l.reverse()),e.gullet.macros.set(i,{tokens:l,numArgs:o,delimiters:a},t===Ih[t]),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\let","\\\\globallet"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=O6(e.gullet.popToken());e.gullet.consumeSpaces();var i=GT(e);return R6(e,n,i,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\futurelet","\\\\globalfuture"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=O6(e.gullet.popToken()),i=e.gullet.popToken(),o=e.gullet.popToken();return R6(e,n,o,t==="\\\\globalfuture"),e.gullet.pushToken(o),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}});var ca=function(e,t,n){var i=Ie.math[e]&&Ie.math[e].replace,o=Bp(i||e,t,n);if(!o)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return o},qp=function(e,t,n,i){var o=n.havingBaseStyle(t),s=j(i.concat(o.sizingClasses(n)),[e],n),a=o.sizeMultiplier/n.sizeMultiplier;return s.height*=a,s.depth*=a,s.maxFontSize=o.sizeMultiplier,s},I6=function(e,t,n){var i=t.havingBaseStyle(n),o=(1-t.sizeMultiplier/i.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=G(o),e.height-=o,e.depth+=o},YT=function(e,t,n,i,o,s){var a=bt(e,"Main-Regular",o,i),l=qp(a,t,i,s);return I6(l,i,t),l},JT=function(e,t,n,i){return bt(e,"Size"+t+"-Regular",n,i)},z6=function(e,t,n,i,o,s){var a=JT(e,t,o,i),l=qp(j(["delimsizing","size"+t],[a],i),de.TEXT,i,s);return n&&I6(l,i,de.TEXT),l},vd=function(e,t,n){var i;t==="Size1-Regular"?i="delim-size1":i="delim-size4";var o=j(["delimsizinginner",i],[j([],[bt(e,t,n)])]);return{type:"elem",elem:o}},bd=function(e,t,n){var i=Pr["Size4-Regular"][e.charCodeAt(0)]?Pr["Size4-Regular"][e.charCodeAt(0)][4]:Pr["Size1-Regular"][e.charCodeAt(0)][4],o=new Zn("inner",eT(e,Math.round(1e3*t))),s=new bn([o],{width:G(i),height:G(t),style:"width:"+G(i),viewBox:"0 0 "+1e3*i+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),a=Qn([],[s],n);return a.height=t,a.style.height=G(t),a.style.width=G(i),{type:"elem",elem:a}},zh=.008,z0={type:"kern",size:-1*zh},XT=new Set(["|","\\lvert","\\rvert","\\vert"]),ZT=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),L6=function(e,t,n,i,o,s){var a,l,c,u,d="",h=0;a=c=u=e,l=null;var f="Size1-Regular";e==="\\uparrow"?c=u="⏐":e==="\\Uparrow"?c=u="‖":e==="\\downarrow"?a=c="⏐":e==="\\Downarrow"?a=c="‖":e==="\\updownarrow"?(a="\\uparrow",c="⏐",u="\\downarrow"):e==="\\Updownarrow"?(a="\\Uparrow",c="‖",u="\\Downarrow"):XT.has(e)?(c="∣",d="vert",h=333):ZT.has(e)?(c="∥",d="doublevert",h=556):e==="["||e==="\\lbrack"?(a="⎡",c="⎢",u="⎣",f="Size4-Regular",d="lbrack",h=667):e==="]"||e==="\\rbrack"?(a="⎤",c="⎥",u="⎦",f="Size4-Regular",d="rbrack",h=667):e==="\\lfloor"||e==="⌊"?(c=a="⎢",u="⎣",f="Size4-Regular",d="lfloor",h=667):e==="\\lceil"||e==="⌈"?(a="⎡",c=u="⎢",f="Size4-Regular",d="lceil",h=667):e==="\\rfloor"||e==="⌋"?(c=a="⎥",u="⎦",f="Size4-Regular",d="rfloor",h=667):e==="\\rceil"||e==="⌉"?(a="⎤",c=u="⎥",f="Size4-Regular",d="rceil",h=667):e==="("||e==="\\lparen"?(a="⎛",c="⎜",u="⎝",f="Size4-Regular",d="lparen",h=875):e===")"||e==="\\rparen"?(a="⎞",c="⎟",u="⎠",f="Size4-Regular",d="rparen",h=875):e==="\\{"||e==="\\lbrace"?(a="⎧",l="⎨",u="⎩",c="⎪",f="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(a="⎫",l="⎬",u="⎭",c="⎪",f="Size4-Regular"):e==="\\lgroup"||e==="⟮"?(a="⎧",u="⎩",c="⎪",f="Size4-Regular"):e==="\\rgroup"||e==="⟯"?(a="⎫",u="⎭",c="⎪",f="Size4-Regular"):e==="\\lmoustache"||e==="⎰"?(a="⎧",u="⎭",c="⎪",f="Size4-Regular"):(e==="\\rmoustache"||e==="⎱")&&(a="⎫",u="⎩",c="⎪",f="Size4-Regular");var m=ca(a,f,o),y=m.height+m.depth,x=ca(c,f,o),b=x.height+x.depth,S=ca(u,f,o),A=S.height+S.depth,D=0,O=1;if(l!==null){var L=ca(l,f,o);D=L.height+L.depth,O=2}var N=y+A+D,$=Math.max(0,Math.ceil((t-N)/(O*b))),K=N+$*O*b,ne=i.fontMetrics().axisHeight;n&&(ne*=i.sizeMultiplier);var pe=K/2-ne,se=[];if(d.length>0){var lt=K-y-A,Re=Math.round(K*1e3),Ue=tT(d,Math.round(lt*1e3)),je=new Zn(d,Ue),Bt=G(h/1e3),pr=G(Re/1e3),Cn=new bn([je],{width:Bt,height:pr,viewBox:"0 0 "+h+" "+Re}),Jt=Qn([],[Cn],i);Jt.height=Re/1e3,Jt.style.width=Bt,Jt.style.height=pr,se.push({type:"elem",elem:Jt})}else{if(se.push(vd(u,f,o)),se.push(z0),l===null){var mr=K-y-A+2*zh;se.push(bd(c,mr,i))}else{var ai=(K-y-A-D)/2+2*zh;se.push(bd(c,ai,i)),se.push(z0),se.push(vd(l,f,o)),se.push(z0),se.push(bd(c,ai,i))}se.push(z0),se.push(vd(a,f,o))}var Pt=i.havingBaseStyle(de.TEXT),oo=be({positionType:"bottom",positionData:pe,children:se});return qp(j(["delimsizing","mult"],[oo],Pt),de.TEXT,i,s)},wd=80,xd=.08,kd=function(e,t,n,i,o){var s=QM(e,i,n),a=new Zn(e,s),l=new bn([a],{width:"400em",height:G(t),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});return Qn(["hide-tail"],[l],o)},QT=function(e,t){var n=t.havingBaseSizing(),i=_6("\\surd",e*n.sizeMultiplier,H6,n),o=n.sizeMultiplier,s=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),a,l,c,u,d;return i.type==="small"?(u=1e3+1e3*s+wd,e<1?o=1:e<1.4&&(o=.7),l=(1+s+xd)/o,c=(1+s)/o,a=kd("sqrtMain",l,u,s,t),a.style.minWidth="0.853em",d=.833/o):i.type==="large"?(u=(1e3+wd)*Ca[i.size],c=(Ca[i.size]+s)/o,l=(Ca[i.size]+s+xd)/o,a=kd("sqrtSize"+i.size,l,u,s,t),a.style.minWidth="1.02em",d=1/o):(l=e+s+xd,c=e+s,u=Math.floor(1e3*e+s)+wd,a=kd("sqrtTall",l,u,s,t),a.style.minWidth="0.742em",d=1.056),a.height=c,a.style.height=G(l),{span:a,advanceWidth:d,ruleWidth:(t.fontMetrics().sqrtRuleThickness+s)*o}},B6=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"]),eA=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"]),P6=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Ca=[0,1.2,1.8,2.4,3],F6=function(e,t,n,i,o){if(e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle"),B6.has(e)||P6.has(e))return z6(e,t,!1,n,i,o);if(eA.has(e))return L6(e,Ca[t],!1,n,i,o);throw new V("Illegal delimiter: '"+e+"'")},tA=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],rA=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"stack"}],H6=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],nA=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";var t=e.type;throw new Error("Add support for delim type '"+t+"' here.")},_6=function(e,t,n,i){for(var o=Math.min(2,3-i.style.size),s=o;s<n.length;s++){var a=n[s];if(a.type==="stack")break;var l=ca(e,nA(a),"math"),c=l.height+l.depth;if(a.type==="small"){var u=i.havingBaseStyle(a.style);c*=u.sizeMultiplier}if(c>t)return a}return n[n.length-1]},Lh=function(e,t,n,i,o,s){e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle");var a;P6.has(e)?a=tA:B6.has(e)?a=H6:a=rA;var l=_6(e,t,a,i);return l.type==="small"?YT(e,l.style,n,i,o,s):l.type==="large"?z6(e,l.size,n,i,o,s):L6(e,t,n,i,o,s)},Sd=function(e,t,n,i,o,s){var a=i.fontMetrics().axisHeight*i.sizeMultiplier,l=901,c=5/i.fontMetrics().ptPerEm,u=Math.max(t-a,n+a),d=Math.max(u/500*l,2*u-c);return Lh(e,d,!0,i,o,s)},Vg={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},iA=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function Wg(r){return"isMiddle"in r}function cu(r,e){var t=au(r);if(t&&iA.has(t.text))return t;throw t?new V("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",r):new V("Invalid delimiter type '"+r.type+"'",r)}X({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],numArgs:1,argTypes:["primitive"],handler:(r,e)=>{var t=cu(e[0],r);return{type:"delimsizing",mode:r.parser.mode,size:Vg[r.funcName].size,mclass:Vg[r.funcName].mclass,delim:t.text}},htmlBuilder:(r,e)=>r.delim==="."?j([r.mclass]):F6(r.delim,r.size,e,r.mode,[r.mclass]),mathmlBuilder:r=>{var e=[];r.delim!=="."&&e.push(ur(r.delim,r.mode));var t=new W("mo",e);r.mclass==="mopen"||r.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var n=G(Ca[r.size]);return t.setAttribute("minsize",n),t.setAttribute("maxsize",n),t}});function Ug(r){if(!r.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}X({type:"leftright-right",names:["\\right"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=r.parser.gullet.macros.get("\\current@color");if(t&&typeof t!="string")throw new V("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:r.parser.mode,delim:cu(e[0],r).text,color:t}}});X({type:"leftright",names:["\\left"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=cu(e[0],r),n=r.parser;++n.leftrightDepth;var i=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);var o=he(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:i,left:t.text,right:o.delim,rightColor:o.color}},htmlBuilder:(r,e)=>{Ug(r);for(var t=tt(r.body,e,!0,["mopen","mclose"]),n=0,i=0,o=!1,s=0;s<t.length;s++){var a=t[s];Wg(a)?o=!0:(n=Math.max(t[s].height,n),i=Math.max(t[s].depth,i))}n*=e.sizeMultiplier,i*=e.sizeMultiplier;var l;if(r.left==="."?l=Wa(e,["mopen"]):l=Sd(r.left,n,i,e,r.mode,["mopen"]),t.unshift(l),o)for(var c=1;c<t.length;c++){var u=t[c];if(Wg(u)){var d=u.isMiddle;t[c]=Sd(d.delim,n,i,d.options,r.mode,[])}}var h;if(r.right===".")h=Wa(e,["mclose"]);else{var f=r.rightColor?e.withColor(r.rightColor):e;h=Sd(r.right,n,i,f,r.mode,["mclose"])}return t.push(h),j(["minner"],t,e)},mathmlBuilder:(r,e)=>{Ug(r);var t=Yt(r.body,e);if(r.left!=="."){var n=new W("mo",[ur(r.left,r.mode)]);n.setAttribute("fence","true"),t.unshift(n)}if(r.right!=="."){var i=new W("mo",[ur(r.right,r.mode)]);i.setAttribute("fence","true"),r.rightColor&&i.setAttribute("mathcolor",r.rightColor),t.push(i)}return Hp(t)}});X({type:"middle",names:["\\middle"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=cu(e[0],r);if(!r.parser.leftrightDepth)throw new V("\\middle without preceding \\left",t);return{type:"middle",mode:r.parser.mode,delim:t.text}},htmlBuilder:(r,e)=>{var t;return r.delim==="."?t=Wa(e,[]):(t=F6(r.delim,1,e,r.mode,[]),t.isMiddle={delim:r.delim,options:e}),t},mathmlBuilder:(r,e)=>{var t=r.delim==="\\vert"||r.delim==="|"?ur("|","text"):ur(r.delim,r.mode),n=new W("mo",[t]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});var oA=(r,e)=>{var t=As(we(r.body,e),e),n=r.label.slice(1),i=e.sizeMultiplier,o,s,a=xn(r.body);if(n==="sout")o=j(["stretchy","sout"]),o.height=e.fontMetrics().defaultRuleThickness/i,s=-.5*e.fontMetrics().xHeight;else if(n==="phase"){var l=Pe({number:.6,unit:"pt"},e),c=Pe({number:.35,unit:"ex"},e),u=e.havingBaseSizing();i=i/u.sizeMultiplier;var d=t.height+t.depth+l+c;t.style.paddingLeft=G(d/2+l);var h=Math.floor(1e3*d*i),f=XM(h),m=new bn([new Zn("phase",f)],{width:"400em",height:G(h/1e3),viewBox:"0 0 400000 "+h,preserveAspectRatio:"xMinYMin slice"});o=Qn(["hide-tail"],[m],e),o.style.height=G(d),s=t.depth+l+c}else{/cancel/.test(n)?a||t.classes.push("cancel-pad"):n==="angl"?t.classes.push("anglpad"):t.classes.push("boxpad");var y,x,b=0;/box/.test(n)?(b=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),y=e.fontMetrics().fboxsep+(n==="colorbox"?0:b),x=y):n==="angl"?(b=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),y=4*b,x=Math.max(0,.25-t.depth)):(y=a?.2:0,x=y),o=zT(t,n,y,x,e),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=G(b)):n==="angl"&&b!==.049&&(o.style.borderTopWidth=G(b),o.style.borderRightWidth=G(b)),s=t.depth+x,r.backgroundColor&&(o.style.backgroundColor=r.backgroundColor,r.borderColor&&(o.style.borderColor=r.borderColor))}var S;if(r.backgroundColor)S=be({positionType:"individualShift",children:[{type:"elem",elem:o,shift:s},{type:"elem",elem:t,shift:0}]});else{var A=/cancel|phase/.test(n)?["svg-align"]:[];S=be({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:o,shift:s,wrapperClasses:A}]})}return/cancel/.test(n)&&(S.height=t.height,S.depth=t.depth),/cancel/.test(n)&&!a?j(["mord","cancel-lap"],[S],e):j(["mord"],[S],e)},sA=(r,e)=>{var t,n=new W(r.label.includes("colorbox")?"mpadded":"menclose",[Ne(r.body,e)]);switch(r.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(t=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*t+"pt"),n.setAttribute("height","+"+2*t+"pt"),n.setAttribute("lspace",t+"pt"),n.setAttribute("voffset",t+"pt"),r.label==="\\fcolorbox"){var i=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);n.setAttribute("style","border: "+G(i)+" solid "+r.borderColor)}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return r.backgroundColor&&n.setAttribute("mathbackground",r.backgroundColor),n};X({type:"enclose",names:["\\colorbox"],numArgs:2,allowedInText:!0,argTypes:["color","hbox"],handler(r,e,t){var{parser:n,funcName:i}=r,o=he(e[0],"color-token").color,s=e[1];return{type:"enclose",mode:n.mode,label:i,backgroundColor:o,body:s}},htmlBuilder:oA,mathmlBuilder:sA});X({type:"enclose",names:["\\fcolorbox"],numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"],handler(r,e,t){var{parser:n,funcName:i}=r,o=he(e[0],"color-token").color,s=he(e[1],"color-token").color,a=e[2];return{type:"enclose",mode:n.mode,label:i,backgroundColor:s,borderColor:o,body:a}}});X({type:"enclose",names:["\\fbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\fbox",body:e[0]}}});X({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"enclose",mode:t.mode,label:n,body:i}}});X({type:"enclose",names:["\\sout"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r;t.mode==="math"&&t.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");var i=e[0];return{type:"enclose",mode:t.mode,label:n,body:i}}});X({type:"enclose",names:["\\angl"],numArgs:1,argTypes:["hbox"],allowedInText:!1,handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\angl",body:e[0]}}});var q6={};function Ur(r){for(var{type:e,names:t,props:n,handler:i,htmlBuilder:o,mathmlBuilder:s}=r,a={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},l=0;l<t.length;++l)q6[t[l]]=a;o&&(ja[e]=o),s&&(Va[e]=s)}var $6={};function w(r,e){$6[r]=e}class Ot{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new Ot(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}}class Vt{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new Vt(t,Ot.range(this,e))}}function Kg(r){var e=[];r.consumeSpaces();var t=r.fetch().text;for(t==="\\relax"&&(r.consume(),r.consumeSpaces(),t=r.fetch().text);t==="\\hline"||t==="\\hdashline";)r.consume(),e.push(t==="\\hdashline"),r.consumeSpaces(),t=r.fetch().text;return e}var uu=r=>{var e=r.parser.settings;if(!e.displayMode)throw new V("{"+r.envName+"} can be used only in display mode.")},aA=new Set(["gather","gather*"]);function $p(r){if(!r.includes("ed"))return!r.includes("*")}function si(r,e,t){var{hskipBeforeAndAfter:n,addJot:i,cols:o,arraystretch:s,colSeparationType:a,autoTag:l,singleRow:c,emptySingleRow:u,maxNumCols:d,leqno:h}=e;if(r.gullet.beginGroup(),c||r.gullet.macros.set("\\cr","\\\\\\relax"),!s){var f=r.gullet.expandMacroAsText("\\arraystretch");if(f==null)s=1;else if(s=parseFloat(f),!s||s<0)throw new V("Invalid \\arraystretch: "+f)}r.gullet.beginGroup();var m=[],y=[m],x=[],b=[],S=l!=null?[]:void 0;function A(){l&&r.gullet.macros.set("\\@eqnsw","1",!0)}function D(){S&&(r.gullet.macros.get("\\df@tag")?(S.push(r.subparse([new Vt("\\df@tag")])),r.gullet.macros.set("\\df@tag",void 0,!0)):S.push(!!l&&r.gullet.macros.get("\\@eqnsw")==="1"))}for(A(),b.push(Kg(r));;){var O=r.parseExpression(!1,c?"\\end":"\\\\");r.gullet.endGroup(),r.gullet.beginGroup();var L={type:"ordgroup",mode:r.mode,body:O};t&&(L={type:"styling",mode:r.mode,style:t,resetFont:!0,body:[L]}),m.push(L);var N=r.fetch().text;if(N==="&"){if(d&&m.length===d){if(c||a)throw new V("Too many tab characters: &",r.nextToken);r.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}r.consume()}else if(N==="\\end"){D(),m.length===1&&L.type==="styling"&&L.body.length===1&&L.body[0].type==="ordgroup"&&L.body[0].body.length===0&&(y.length>1||!u)&&y.pop(),b.length<y.length+1&&b.push([]);break}else if(N==="\\\\"){r.consume();var $=void 0;r.gullet.future().text!==" "&&($=r.parseSizeGroup(!0)),x.push($?$.value:null),D(),b.push(Kg(r)),m=[],y.push(m),A()}else throw new V("Expected & or \\\\ or \\cr or \\end",r.nextToken)}return r.gullet.endGroup(),r.gullet.endGroup(),{type:"array",mode:r.mode,addJot:i,arraystretch:s,body:y,cols:o,rowGaps:x,hskipBeforeAndAfter:n,hLinesBeforeRow:b,colSeparationType:a,tags:S,leqno:h}}function jp(r){return r.slice(0,1)==="d"?"display":"text"}var Kr=function(e,t){var n,i,o=e.body.length,s=e.hLinesBeforeRow,a=0,l=new Array(o),c=[],u=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),d=1/t.fontMetrics().ptPerEm,h=5*d;if(e.colSeparationType&&e.colSeparationType==="small"){var f=t.havingStyle(de.SCRIPT).sizeMultiplier;h=.2778*(f/t.sizeMultiplier)}var m=e.colSeparationType==="CD"?Pe({number:3,unit:"ex"},t):12*d,y=3*d,x=e.arraystretch*m,b=.7*x,S=.3*x,A=0;function D(Xt){for(var Zt=0;Zt<Xt.length;++Zt)Zt>0&&(A+=.25),c.push({pos:A,isDashed:Xt[Zt]})}for(D(s[0]),n=0;n<e.body.length;++n){var O=e.body[n],L=b,N=S;a<O.length&&(a=O.length);var $={cells:new Array(O.length),height:0,depth:0,pos:0};for(i=0;i<O.length;++i){var K=we(O[i],t);N<K.depth&&(N=K.depth),L<K.height&&(L=K.height),$.cells[i]=K}var ne=e.rowGaps[n],pe=0;ne&&(pe=Pe(ne,t),pe>0&&(pe+=S,N<pe&&(N=pe),pe=0)),e.addJot&&n<e.body.length-1&&(N+=y),$.height=L,$.depth=N,A+=L,$.pos=A,A+=N+pe,l[n]=$,D(s[n+1])}var se=A/2+t.fontMetrics().axisHeight,lt=e.cols||[],Re=[],Ue,je,Bt=[];if(e.tags&&e.tags.some(Xt=>Xt))for(n=0;n<o;++n){var pr=l[n],Cn=pr.pos-se,Jt=e.tags[n],mr=void 0;Jt===!0?mr=j(["eqn-num"],[],t):Jt===!1?mr=j([],[],t):mr=j([],tt(Jt,t,!0),t),mr.depth=pr.depth,mr.height=pr.height,Bt.push({type:"elem",elem:mr,shift:Cn})}for(i=0,je=0;i<a||je<lt.length;++i,++je){for(var ai,Pt=lt[je],oo=!0;((Te=Pt)==null?void 0:Te.type)==="separator";){var Te;if(oo||(Ue=j(["arraycolsep"],[]),Ue.style.width=G(t.fontMetrics().doubleRuleSep),Re.push(Ue)),Pt.separator==="|"||Pt.separator===":"){var mu=Pt.separator==="|"?"solid":"dashed",Mn=j(["vertical-separator"],[],t);Mn.style.height=G(A),Mn.style.borderRightWidth=G(u),Mn.style.borderRightStyle=mu,Mn.style.margin="0 "+G(-u/2);var Jl=A-se;Jl&&(Mn.style.verticalAlign=G(-Jl)),Re.push(Mn)}else throw new V("Invalid separator type: "+Pt.separator);je++,Pt=lt[je],oo=!1}if(!(i>=a)){var Tn=void 0;if(i>0||e.hskipBeforeAndAfter){var Xl,Zl;Tn=(Xl=(Zl=Pt)==null?void 0:Zl.pregap)!=null?Xl:h,Tn!==0&&(Ue=j(["arraycolsep"],[]),Ue.style.width=G(Tn),Re.push(Ue))}var js=[];for(n=0;n<o;++n){var so=l[n],li=so.cells[i];if(li){var Ee=so.pos-se;li.depth=so.depth,li.height=so.height,js.push({type:"elem",elem:li,shift:Ee})}}var Vs=be({positionType:"individualShift",children:js}),De=j(["col-align-"+(((ai=Pt)==null?void 0:ai.align)||"c")],[Vs]);if(Re.push(De),i<a-1||e.hskipBeforeAndAfter){var ao,Ft;Tn=(ao=(Ft=Pt)==null?void 0:Ft.postgap)!=null?ao:h,Tn!==0&&(Ue=j(["arraycolsep"],[]),Ue.style.width=G(Tn),Re.push(Ue))}}}var Ar=j(["mtable"],Re);if(c.length>0){for(var Ql=Ts("hline",t,u),Nr=Ts("hdashline",t,u),lo=[{type:"elem",elem:Ar,shift:0}];c.length>0;){var co=c.pop(),Ws=co.pos-se;co.isDashed?lo.push({type:"elem",elem:Nr,shift:Ws}):lo.push({type:"elem",elem:Ql,shift:Ws})}Ar=be({positionType:"individualShift",children:lo})}if(Bt.length===0)return j(["mord"],[Ar],t);var e0=be({positionType:"individualShift",children:Bt}),Er=j(["tag"],[e0],t);return Sn([Ar,Er])},lA={c:"center ",l:"left ",r:"right "},Gr=function(e,t){for(var n=[],i=new W("mtd",[],["mtr-glue"]),o=new W("mtd",[],["mml-eqn-num"]),s=0;s<e.body.length;s++){for(var a=e.body[s],l=[],c=0;c<a.length;c++)l.push(new W("mtd",[Ne(a[c],t)]));e.tags&&e.tags[s]&&(l.unshift(i),l.push(i),e.leqno?l.unshift(o):l.push(o)),n.push(new W("mtr",l))}var u=new W("mtable",n),d=e.arraystretch===.5?.1:.16+e.arraystretch-1+(e.addJot?.09:0);u.setAttribute("rowspacing",G(d));var h="",f="";if(e.cols&&e.cols.length>0){var m=e.cols,y="",x=!1,b=0,S=m.length;m[0].type==="separator"&&(h+="top ",b=1),m[m.length-1].type==="separator"&&(h+="bottom ",S-=1);for(var A=b;A<S;A++){var D=m[A];D.type==="align"?(f+=lA[D.align],x&&(y+="none "),x=!0):D.type==="separator"&&x&&(y+=D.separator==="|"?"solid ":"dashed ",x=!1)}u.setAttribute("columnalign",f.trim()),/[sd]/.test(y)&&u.setAttribute("columnlines",y.trim())}if(e.colSeparationType==="align"){for(var O=e.cols||[],L="",N=1;N<O.length;N++)L+=N%2?"0em ":"1em ";u.setAttribute("columnspacing",L.trim())}else e.colSeparationType==="alignat"||e.colSeparationType==="gather"?u.setAttribute("columnspacing","0em"):e.colSeparationType==="small"?u.setAttribute("columnspacing","0.2778em"):e.colSeparationType==="CD"?u.setAttribute("columnspacing","0.5em"):u.setAttribute("columnspacing","1em");var $="",K=e.hLinesBeforeRow;h+=K[0].length>0?"left ":"",h+=K[K.length-1].length>0?"right ":"";for(var ne=1;ne<K.length-1;ne++)$+=K[ne].length===0?"none ":K[ne][0]?"dashed ":"solid ";return/[sd]/.test($)&&u.setAttribute("rowlines",$.trim()),h!==""&&(u=new W("menclose",[u]),u.setAttribute("notation",h.trim())),e.arraystretch&&e.arraystretch<1&&(u=new W("mstyle",[u]),u.setAttribute("scriptlevel","1")),u},j6=function(e,t){e.envName.includes("ed")||uu(e);var n=[],i=e.envName==="split",o=si(e.parser,{cols:n,addJot:!0,autoTag:i?void 0:$p(e.envName),emptySingleRow:!0,colSeparationType:e.envName.includes("at")?"alignat":"align",maxNumCols:i?2:void 0,leqno:e.parser.settings.leqno},"display"),s=0,a=0,l={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&t[0].type==="ordgroup"){for(var c="",u=0;u<t[0].body.length;u++){var d=he(t[0].body[u],"textord");c+=d.text}s=Number(c),a=s*2}var h=!a;o.body.forEach(function(x){for(var b=1;b<x.length;b+=2){var S=he(x[b],"styling"),A=he(S.body[0],"ordgroup");A.body.unshift(l)}if(h)a<x.length&&(a=x.length);else{var D=x.length/2;if(s<D)throw new V("Too many math in a row: "+("expected "+s+", but got "+D),x[0])}});for(var f=0;f<a;++f){var m="r",y=0;f%2===1?m="l":f>0&&h&&(y=1),n[f]={type:"align",align:m,pregap:y,postgap:0}}return o.colSeparationType=h?"align":"alignat",o};Ur({type:"array",names:["array","darray"],props:{numArgs:1},handler(r,e){var t=au(e[0]),n=t?[e[0]]:he(e[0],"ordgroup").body,i=n.map(function(s){var a=su(s),l=a.text;if("lcr".includes(l))return{type:"align",align:l};if(l==="|")return{type:"separator",separator:"|"};if(l===":")return{type:"separator",separator:":"};throw new V("Unknown column alignment: "+l,s)}),o={cols:i,hskipBeforeAndAfter:!0,maxNumCols:i.length};return si(r.parser,o,jp(r.envName))},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(r){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[r.envName.replace("*","")],t="c",n={hskipBeforeAndAfter:!1,cols:[{type:"align",align:t}]};if(r.envName.charAt(r.envName.length-1)==="*"){var i=r.parser;if(i.consumeSpaces(),i.fetch().text==="["){if(i.consume(),i.consumeSpaces(),t=i.fetch().text,!"lcr".includes(t))throw new V("Expected l or c or r",i.nextToken);i.consume(),i.consumeSpaces(),i.expect("]"),i.consume(),n.cols=[{type:"align",align:t}]}}var o=si(r.parser,n,jp(r.envName)),s=Math.max(0,...o.body.map(a=>a.length));return o.cols=new Array(s).fill({type:"align",align:t}),e?{type:"leftright",mode:r.mode,body:[o],left:e[0],right:e[1],rightColor:void 0}:o},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(r){var e={arraystretch:.5},t=si(r.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["subarray"],props:{numArgs:1},handler(r,e){var t=au(e[0]),n=t?[e[0]]:he(e[0],"ordgroup").body,i=n.map(function(a){var l=su(a),c=l.text;if("lc".includes(c))return{type:"align",align:c};throw new V("Unknown column alignment: "+c,a)});if(i.length>1)throw new V("{subarray} can contain only one column");var o={cols:i,hskipBeforeAndAfter:!1,arraystretch:.5},s=si(r.parser,o,"script");if(s.body.length>0&&s.body[0].length>1)throw new V("{subarray} can contain only one column");return s},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(r){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},t=si(r.parser,e,jp(r.envName));return{type:"leftright",mode:r.mode,body:[t],left:r.envName.includes("r")?".":"\\{",right:r.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:j6,htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(r){aA.has(r.envName)&&uu(r);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:$p(r.envName),emptySingleRow:!0,leqno:r.parser.settings.leqno};return si(r.parser,e,"display")},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:j6,htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(r){uu(r);var e={autoTag:$p(r.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:r.parser.settings.leqno};return si(r.parser,e,"display")},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["CD"],props:{numArgs:0},handler(r){return uu(r),WT(r.parser)},htmlBuilder:Kr,mathmlBuilder:Gr});w("\\nonumber","\\gdef\\@eqnsw{0}");w("\\notag","\\nonumber");X({type:"text",names:["\\hline","\\hdashline"],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(r,e){throw new V(r.funcName+" valid only within array environment")}});var Gg=q6;X({type:"environment",names:["\\begin","\\end"],numArgs:1,argTypes:["text"],handler(r,e){var{parser:t,funcName:n}=r,i=e[0];if(i.type!=="ordgroup")throw new V("Invalid environment name",i);for(var o="",s=0;s<i.body.length;++s)o+=he(i.body[s],"textord").text;if(n==="\\begin"){if(!Gg.hasOwnProperty(o))throw new V("No such environment: "+o,i);var a=Gg[o],{args:l,optArgs:c}=t.parseArguments("\\begin{"+o+"}",a),u={mode:t.mode,envName:o,parser:t},d=a.handler(u,l,c);t.expect("\\end",!1);var h=t.nextToken,f=he(t.parseFunction(),"environment");if(f.name!==o)throw new V("Mismatch: \\begin{"+o+"} matched by \\end{"+f.name+"}",h);return d}return{type:"environment",mode:t.mode,name:o,nameGroup:i}}});var cA=(r,e)=>{var t=r.font,n=e.withFont(t);return we(r.body,n)},uA=(r,e)=>{var t=r.font,n=e.withFont(t);return Ne(r.body,n)},Yg={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak"};X({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],numArgs:1,allowedInArgument:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=yc(e[0]),o=n in Yg?Yg[n]:n;return{type:"font",mode:t.mode,font:o.slice(1),body:i}},htmlBuilder:cA,mathmlBuilder:uA});X({type:"mclass",names:["\\boldsymbol","\\bm"],numArgs:1,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"mclass",mode:t.mode,mclass:lu(n),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:n}],isCharacterBox:xn(n)}}});X({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],numArgs:0,allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n,breakOnTokenText:i}=r,{mode:o}=t,s=t.parseExpression(!0,i);return{type:"font",mode:o,font:"math"+n.slice(1),body:{type:"ordgroup",mode:t.mode,body:s}}}});var dA=(r,e)=>{var t=e.style,n=t.fracNum(),i=t.fracDen(),o;o=e.havingStyle(n);var s=we(r.numer,o,e);if(r.continued){var a=8.5/e.fontMetrics().ptPerEm,l=3.5/e.fontMetrics().ptPerEm;s.height=s.height<a?a:s.height,s.depth=s.depth<l?l:s.depth}o=e.havingStyle(i);var c=we(r.denom,o,e),u,d,h;r.hasBarLine?(r.barSize?(d=Pe(r.barSize,e),u=Ts("frac-line",e,d)):u=Ts("frac-line",e),d=u.height,h=u.height):(u=null,d=0,h=e.fontMetrics().defaultRuleThickness);var f,m,y;t.size===de.DISPLAY.size?(f=e.fontMetrics().num1,d>0?m=3*h:m=7*h,y=e.fontMetrics().denom1):(d>0?(f=e.fontMetrics().num2,m=h):(f=e.fontMetrics().num3,m=3*h),y=e.fontMetrics().denom2);var x;if(u){var S=e.fontMetrics().axisHeight;f-s.depth-(S+.5*d)<m&&(f+=m-(f-s.depth-(S+.5*d))),S-.5*d-(c.height-y)<m&&(y+=m-(S-.5*d-(c.height-y)));var A=-(S-.5*d);x=be({positionType:"individualShift",children:[{type:"elem",elem:c,shift:y},{type:"elem",elem:u,shift:A},{type:"elem",elem:s,shift:-f}]})}else{var b=f-s.depth-(c.height-y);b<m&&(f+=.5*(m-b),y+=.5*(m-b)),x=be({positionType:"individualShift",children:[{type:"elem",elem:c,shift:y},{type:"elem",elem:s,shift:-f}]})}o=e.havingStyle(t),x.height*=o.sizeMultiplier/e.sizeMultiplier,x.depth*=o.sizeMultiplier/e.sizeMultiplier;var D;t.size===de.DISPLAY.size?D=e.fontMetrics().delim1:t.size===de.SCRIPTSCRIPT.size?D=e.havingStyle(de.SCRIPT).fontMetrics().delim2:D=e.fontMetrics().delim2;var O,L;return r.leftDelim==null?O=Wa(e,["mopen"]):O=Lh(r.leftDelim,D,!0,e.havingStyle(t),r.mode,["mopen"]),r.continued?L=j([]):r.rightDelim==null?L=Wa(e,["mclose"]):L=Lh(r.rightDelim,D,!0,e.havingStyle(t),r.mode,["mclose"]),j(["mord"].concat(o.sizingClasses(e)),[O,j(["mfrac"],[x]),L],e)},hA=(r,e)=>{var t=new W("mfrac",[Ne(r.numer,e),Ne(r.denom,e)]);if(!r.hasBarLine)t.setAttribute("linethickness","0px");else if(r.barSize){var n=Pe(r.barSize,e);t.setAttribute("linethickness",G(n))}if(r.leftDelim!=null||r.rightDelim!=null){var i=[];if(r.leftDelim!=null){var o=new W("mo",[new Je(r.leftDelim.replace("\\",""))]);o.setAttribute("fence","true"),i.push(o)}if(i.push(t),r.rightDelim!=null){var s=new W("mo",[new Je(r.rightDelim.replace("\\",""))]);s.setAttribute("fence","true"),i.push(s)}return Hp(i)}return t},V6=(r,e)=>{if(!e)return r;var t={type:"styling",mode:r.mode,style:e,body:[r]};return t};X({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],numArgs:2,allowedInArgument:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],o=e[1],s,a=null,l=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":s=!0;break;case"\\\\atopfrac":s=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":s=!1,a="(",l=")";break;case"\\\\bracefrac":s=!1,a="\\{",l="\\}";break;case"\\\\brackfrac":s=!1,a="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}var c=n==="\\cfrac",u=null;return c||n.startsWith("\\d")?u="display":n.startsWith("\\t")&&(u="text"),V6({type:"genfrac",mode:t.mode,numer:i,denom:o,continued:c,hasBarLine:s,leftDelim:a,rightDelim:l,barSize:null},u)},htmlBuilder:dA,mathmlBuilder:hA});X({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],numArgs:0,infix:!0,handler(r){var{parser:e,funcName:t,token:n}=r,i;switch(t){case"\\over":i="\\frac";break;case"\\choose":i="\\binom";break;case"\\atop":i="\\\\atopfrac";break;case"\\brace":i="\\\\bracefrac";break;case"\\brack":i="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:i,token:n}}});var Jg=["display","text","script","scriptscript"],Xg=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};X({type:"genfrac",names:["\\genfrac"],numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"],handler(r,e){var{parser:t}=r,n=e[4],i=e[5],o=yc(e[0]),s=o.type==="atom"&&o.family==="open"?Xg(o.text):null,a=yc(e[1]),l=a.type==="atom"&&a.family==="close"?Xg(a.text):null,c=he(e[2],"size"),u,d=null;c.isBlank?u=!0:(d=c.value,u=d.number>0);var h=null,f=e[3];if(f.type==="ordgroup"){if(f.body.length>0){var m=he(f.body[0],"textord");h=Jg[Number(m.text)]}}else f=he(f,"textord"),h=Jg[Number(f.text)];return V6({type:"genfrac",mode:t.mode,numer:n,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:s,rightDelim:l},h)}});X({type:"infix",names:["\\above"],numArgs:1,argTypes:["size"],infix:!0,handler(r,e){var{parser:t,funcName:n,token:i}=r;return{type:"infix",mode:t.mode,replaceWith:"\\\\abovefrac",size:he(e[0],"size").value,token:i}}});X({type:"genfrac",names:["\\\\abovefrac"],numArgs:3,argTypes:["math","size","math"],handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],o=he(e[1],"infix").size;if(!o)throw new Error("\\\\abovefrac expected size, but got "+String(o));var s=e[2],a=o.number>0;return{type:"genfrac",mode:t.mode,numer:i,denom:s,continued:!1,hasBarLine:a,barSize:o,leftDelim:null,rightDelim:null}}});var W6=(r,e)=>{var t=e.style,n,i;r.type==="supsub"?(n=r.sup?we(r.sup,e.havingStyle(t.sup()),e):we(r.sub,e.havingStyle(t.sub()),e),i=he(r.base,"horizBrace")):i=he(r,"horizBrace");var o=we(i.base,e.havingBaseStyle(de.DISPLAY)),s=ou(i,e),a;if(i.isOver?a=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.1},{type:"elem",elem:s,wrapperClasses:["svg-align"]}]}):a=be({positionType:"bottom",positionData:o.depth+.1+s.height,children:[{type:"elem",elem:s,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:o}]}),n){var l=j(["minner",i.isOver?"mover":"munder"],[a],e);i.isOver?a=be({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:n}]}):a=be({positionType:"bottom",positionData:l.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:l}]})}return j(["minner",i.isOver?"mover":"munder"],[a],e)},fA=(r,e)=>{var t=iu(r.label);return new W(r.isOver?"mover":"munder",[Ne(r.base,e),t])};X({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r;return{type:"horizBrace",mode:t.mode,label:n,isOver:n.includes("\\over"),base:e[0]}},htmlBuilder:W6,mathmlBuilder:fA});X({type:"href",names:["\\href"],numArgs:2,argTypes:["url","original"],allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[1],i=he(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:t.mode,href:i,body:Ye(n)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(r,e)=>{var t=tt(r.body,e,!1);return yT(r.href,[],t,e)},mathmlBuilder:(r,e)=>{var t=ei(r.body,e);return t instanceof W||(t=new W("mrow",[t])),t.setAttribute("href",r.href),t}});X({type:"href",names:["\\url"],numArgs:1,argTypes:["url"],allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=he(e[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:n}))return t.formatUnsupportedCmd("\\url");for(var i=[],o=0;o<n.length;o++){var s=n[o];s==="~"&&(s="\\textasciitilde"),i.push({type:"textord",mode:"text",text:s})}var a={type:"text",mode:t.mode,font:"\\texttt",body:i};return{type:"href",mode:t.mode,href:n,body:Ye(a)}}});X({type:"hbox",names:["\\hbox"],numArgs:1,argTypes:["text"],allowedInText:!0,primitive:!0,handler(r,e){var{parser:t}=r;return{type:"hbox",mode:t.mode,body:Ye(e[0])}},htmlBuilder(r,e){var t=tt(r.body,e.withFont(""),!1);return Sn(t)},mathmlBuilder(r,e){return new W("mrow",Yt(r.body,e.withFont("")))}});X({type:"html",names:["\\htmlClass","\\htmlId","\\htmlStyle","\\htmlData"],numArgs:2,argTypes:["raw","original"],allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n,token:i}=r,o=he(e[0],"raw").string,s=e[1];t.settings.strict&&t.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var a,l={};switch(n){case"\\htmlClass":l.class=o,a={command:"\\htmlClass",class:o};break;case"\\htmlId":l.id=o,a={command:"\\htmlId",id:o};break;case"\\htmlStyle":l.style=o,a={command:"\\htmlStyle",style:o};break;case"\\htmlData":{for(var c=o.split(","),u=0;u<c.length;u++){var d=c[u],h=d.indexOf("=");if(h<0)throw new V("\\htmlData key/value '"+d+"' missing equals sign");var f=d.slice(0,h),m=d.slice(h+1);l["data-"+f.trim()]=m}a={command:"\\htmlData",attributes:l};break}default:throw new Error("Unrecognized html command")}return t.settings.isTrusted(a)?{type:"html",mode:t.mode,attributes:l,body:Ye(s)}:t.formatUnsupportedCmd(n)},htmlBuilder:(r,e)=>{var t=tt(r.body,e,!1),n=["enclosing"];r.attributes.class&&n.push(...r.attributes.class.trim().split(/\s+/));var i=j(n,t,e);for(var o in r.attributes)o!=="class"&&r.attributes.hasOwnProperty(o)&&i.setAttribute(o,r.attributes[o]);return i},mathmlBuilder:(r,e)=>ei(r.body,e)});X({type:"htmlmathml",names:["\\html@mathml"],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r;return{type:"htmlmathml",mode:t.mode,html:Ye(e[0]),mathml:Ye(e[1])}},htmlBuilder:(r,e)=>{var t=tt(r.html,e,!1);return Sn(t)},mathmlBuilder:(r,e)=>ei(r.mathml,e)});var Cd=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new V("Invalid size: '"+e+"' in \\includegraphics");var n={number:+(t[1]+t[2]),unit:t[3]};if(!p6(n))throw new V("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n};X({type:"includegraphics",names:["\\includegraphics"],numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1,handler:(r,e,t)=>{var{parser:n}=r,i={number:0,unit:"em"},o={number:.9,unit:"em"},s={number:0,unit:"em"},a="";if(t[0])for(var l=he(t[0],"raw").string,c=l.split(","),u=0;u<c.length;u++){var d=c[u].split("=");if(d.length===2){var h=d[1].trim();switch(d[0].trim()){case"alt":a=h;break;case"width":i=Cd(h);break;case"height":o=Cd(h);break;case"totalheight":s=Cd(h);break;default:throw new V("Invalid key: '"+d[0]+"' in \\includegraphics.")}}}var f=he(e[0],"url").url;return a===""&&(a=f,a=a.replace(/^.*[\\/]/,""),a=a.substring(0,a.lastIndexOf("."))),n.settings.isTrusted({command:"\\includegraphics",url:f})?{type:"includegraphics",mode:n.mode,alt:a,width:i,height:o,totalheight:s,src:f}:n.formatUnsupportedCmd("\\includegraphics")},htmlBuilder:(r,e)=>{var t=Pe(r.height,e),n=0;r.totalheight.number>0&&(n=Pe(r.totalheight,e)-t);var i=0;r.width.number>0&&(i=Pe(r.width,e));var o={height:G(t+n)};i>0&&(o.width=G(i)),n>0&&(o.verticalAlign=G(-n));var s=new oT(r.src,r.alt,o);return s.height=t,s.depth=n,s},mathmlBuilder:(r,e)=>{var t=new W("mglyph",[]);t.setAttribute("alt",r.alt);var n=Pe(r.height,e),i=0;if(r.totalheight.number>0&&(i=Pe(r.totalheight,e)-n,t.setAttribute("valign",G(-i))),t.setAttribute("height",G(n+i)),r.width.number>0){var o=Pe(r.width,e);t.setAttribute("width",G(o))}return t.setAttribute("src",r.src),t}});X({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r,i=he(e[0],"size");if(t.settings.strict){var o=n[1]==="m",s=i.value.unit==="mu";o?(s||t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, "+("not "+i.value.unit+" units")),t.mode!=="math"&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):s&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:t.mode,dimension:i.value}},htmlBuilder(r,e){return w6(r.dimension,e)},mathmlBuilder(r,e){var t=Pe(r.dimension,e);return new T6(t)}});X({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"lap",mode:t.mode,alignment:n.slice(5),body:i}},htmlBuilder:(r,e)=>{var t;r.alignment==="clap"?(t=j([],[we(r.body,e)]),t=j(["inner"],[t],e)):t=j(["inner"],[we(r.body,e)]);var n=j(["fix"],[]),i=j([r.alignment],[t,n],e),o=j(["strut"]);return o.style.height=G(i.height+i.depth),i.depth&&(o.style.verticalAlign=G(-i.depth)),i.children.unshift(o),i=j(["thinbox"],[i],e),j(["mord","vbox"],[i],e)},mathmlBuilder:(r,e)=>{var t=new W("mpadded",[Ne(r.body,e)]);if(r.alignment!=="rlap"){var n=r.alignment==="llap"?"-1":"-0.5";t.setAttribute("lspace",n+"width")}return t.setAttribute("width","0px"),t}});X({type:"styling",names:["\\(","$"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(r,e){var{funcName:t,parser:n}=r,i=n.mode;n.switchMode("math");var o=t==="\\("?"\\)":"$",s=n.parseExpression(!1,o);return n.expect(o),n.switchMode(i),{type:"styling",mode:n.mode,style:"text",resetFont:!0,body:s}}});X({type:"text",names:["\\)","\\]"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(r,e){throw new V("Mismatched "+r.funcName)}});var Zg=(r,e)=>{switch(e.style.size){case de.DISPLAY.size:return r.display;case de.TEXT.size:return r.text;case de.SCRIPT.size:return r.script;case de.SCRIPTSCRIPT.size:return r.scriptscript;default:return r.text}};X({type:"mathchoice",names:["\\mathchoice"],numArgs:4,primitive:!0,handler:(r,e)=>{var{parser:t}=r;return{type:"mathchoice",mode:t.mode,display:Ye(e[0]),text:Ye(e[1]),script:Ye(e[2]),scriptscript:Ye(e[3])}},htmlBuilder:(r,e)=>{var t=Zg(r,e),n=tt(t,e,!1);return Sn(n)},mathmlBuilder:(r,e)=>{var t=Zg(r,e);return ei(t,e)}});var U6=(r,e,t,n,i,o,s)=>{r=j([],[r]);var a=t&&xn(t),l,c;if(e){var u=we(e,n.havingStyle(i.sup()),n);c={elem:u,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-u.depth)}}if(t){var d=we(t,n.havingStyle(i.sub()),n);l={elem:d,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-d.height)}}var h;if(c&&l){var f=n.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+r.depth+s;h=be({positionType:"bottom",positionData:f,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:G(-o)},{type:"kern",size:l.kern},{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:G(o)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else if(l){var m=r.height-s;h=be({positionType:"top",positionData:m,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:G(-o)},{type:"kern",size:l.kern},{type:"elem",elem:r}]})}else if(c){var y=r.depth+s;h=be({positionType:"bottom",positionData:y,children:[{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:G(o)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else return r;var x=[h];if(l&&o!==0&&!a){var b=j(["mspace"],[],n);b.style.marginRight=G(o),x.unshift(b)}return j(["mop","op-limits"],x,n)},K6=new Set(["\\smallint"]),G6=(r,e)=>{var t,n,i=!1,o;r.type==="supsub"?(t=r.sup,n=r.sub,o=he(r.base,"op"),i=!0):o=he(r,"op");var s=e.style,a=!1;s.size===de.DISPLAY.size&&o.symbol&&!K6.has(o.name)&&(a=!0);var l,c;if(o.symbol){var u=a?"Size2-Regular":"Size1-Regular",d="";if((o.name==="\\oiint"||o.name==="\\oiiint")&&(d=o.name.slice(1),o.name=d==="oiint"?"\\iint":"\\iiint"),l=bt(o.name,u,"math",e,["mop","op-symbol",a?"large-op":"small-op"]),c=l.italic,d.length>0){var h=k6(d+"Size"+(a?"2":"1"),e);l=be({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:h,shift:a?.08:0}]}),o.name="\\"+d,l.classes.unshift("mop"),l.italic=c}}else if(o.body){var f=tt(o.body,e,!0);f.length===1&&f[0]instanceof Wt?(l=f[0],l.classes[0]="mop"):l=j(["mop"],f,e)}else{for(var m=[],y=1;y<o.name.length;y++)m.push(Pp(o.name[y],o.mode,e));l=j(["mop"],m,e)}var x=0,b=0;if((l instanceof Wt||o.name==="\\oiint"||o.name==="\\oiiint")&&!o.suppressBaseShift){var S;x=(l.height-l.depth)/2-e.fontMetrics().axisHeight,b=(S=l.italic)!=null?S:0}return i?U6(l,t,n,e,s,b,x):(x&&(l.style.position="relative",l.style.top=G(x)),l)},pA=(r,e)=>{var t;if(r.symbol)t=new W("mo",[ur(r.name,r.mode)]),K6.has(r.name)&&t.setAttribute("largeop","false");else if(r.body)t=new W("mo",Yt(r.body,e));else{t=new W("mi",[new Je(r.name.slice(1))]);var n=new W("mo",[ur("⁡","text")]);r.parentIsSupSub?t=new W("mrow",[t,n]):t=M6([t,n])}return t},mA={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};X({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],numArgs:0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=n;return i.length===1&&(i=mA[i]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:G6,mathmlBuilder:pA});X({type:"op",names:["\\mathop"],numArgs:1,primitive:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:Ye(n)}}});var gA={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};X({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],numArgs:0,handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:t}}});X({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],numArgs:0,handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:t}}});X({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","∫","∬","∭","∮","∯","∰"],numArgs:0,allowedInArgument:!0,handler(r){var{parser:e,funcName:t}=r,n=t;return n.length===1&&(n=gA[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var Y6=(r,e)=>{var t,n,i=!1,o;r.type==="supsub"?(t=r.sup,n=r.sub,o=he(r.base,"operatorname"),i=!0):o=he(r,"operatorname");var s;if(o.body.length>0){for(var a=o.body.map(d=>{var h="text"in d?d.text:void 0;return typeof h=="string"?{type:"textord",mode:d.mode,text:h}:d}),l=tt(a,e.withFont("mathrm"),!0),c=0;c<l.length;c++){var u=l[c];u instanceof Wt&&(u.text=u.text.replace(/\u2212/,"-").replace(/\u2217/,"*"))}s=j(["mop"],l,e)}else s=j(["mop"],[],e);return i?U6(s,t,n,e,e.style,0,0):s},yA=(r,e)=>{for(var t=Yt(r.body,e.withFont("mathrm")),n=!0,i=0;i<t.length;i++){var o=t[i];if(!(o instanceof T6))if(o instanceof W)switch(o.type){case"mi":case"mn":case"mspace":case"mtext":break;case"mo":{var s=o.children[0];o.children.length===1&&s instanceof Je?s.text=s.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):n=!1;break}default:n=!1}else n=!1}if(n){var a=t.map(u=>u.toText()).join("");t=[new Je(a)]}var l=new W("mi",t);l.setAttribute("mathvariant","normal");var c=new W("mo",[ur("⁡","text")]);return r.parentIsSupSub?new W("mrow",[l,c]):M6([l,c])};X({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],numArgs:1,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"operatorname",mode:t.mode,body:Ye(i),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:Y6,mathmlBuilder:yA});w("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");io({type:"ordgroup",htmlBuilder(r,e){return r.semisimple?Sn(tt(r.body,e,!1)):j(["mord"],tt(r.body,e,!0),e)},mathmlBuilder(r,e){return ei(r.body,e,!0)}});X({type:"overline",names:["\\overline"],numArgs:1,handler(r,e){var{parser:t}=r,n=e[0];return{type:"overline",mode:t.mode,body:n}},htmlBuilder(r,e){var t=we(r.body,e.havingCrampedStyle()),n=Ts("overline-line",e),i=e.fontMetrics().defaultRuleThickness,o=be({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*i},{type:"elem",elem:n},{type:"kern",size:i}]});return j(["mord","overline"],[o],e)},mathmlBuilder(r,e){var t=new W("mo",[new Je("‾")]);t.setAttribute("stretchy","true");var n=new W("mover",[Ne(r.body,e),t]);return n.setAttribute("accent","true"),n}});X({type:"phantom",names:["\\phantom"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"phantom",mode:t.mode,body:Ye(n)}},htmlBuilder:(r,e)=>{var t=tt(r.body,e.withPhantom(),!1);return Sn(t)},mathmlBuilder:(r,e)=>{var t=Yt(r.body,e);return new W("mphantom",t)}});w("\\hphantom","\\smash{\\phantom{#1}}");X({type:"vphantom",names:["\\vphantom"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"vphantom",mode:t.mode,body:n}},htmlBuilder:(r,e)=>{var t=j(["inner"],[we(r.body,e.withPhantom())]),n=j(["fix"],[]);return j(["mord","rlap"],[t,n],e)},mathmlBuilder:(r,e)=>{var t=Yt(Ye(r.body),e),n=new W("mphantom",t),i=new W("mpadded",[n]);return i.setAttribute("width","0px"),i}});X({type:"raisebox",names:["\\raisebox"],numArgs:2,argTypes:["size","hbox"],allowedInText:!0,handler(r,e){var{parser:t}=r,n=he(e[0],"size").value,i=e[1];return{type:"raisebox",mode:t.mode,dy:n,body:i}},htmlBuilder(r,e){var t=we(r.body,e),n=Pe(r.dy,e);return be({positionType:"shift",positionData:-n,children:[{type:"elem",elem:t}]})},mathmlBuilder(r,e){var t=new W("mpadded",[Ne(r.body,e)]),n=r.dy.number+r.dy.unit;return t.setAttribute("voffset",n),t}});X({type:"internal",names:["\\relax"],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(r){var{parser:e}=r;return{type:"internal",mode:e.mode}}});X({type:"rule",names:["\\rule"],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"],handler(r,e,t){var{parser:n}=r,i=t[0],o=he(e[0],"size"),s=he(e[1],"size");return{type:"rule",mode:n.mode,shift:i&&he(i,"size").value,width:o.value,height:s.value}},htmlBuilder(r,e){var t=j(["mord","rule"],[],e),n=Pe(r.width,e),i=Pe(r.height,e),o=r.shift?Pe(r.shift,e):0;return t.style.borderRightWidth=G(n),t.style.borderTopWidth=G(i),t.style.bottom=G(o),t.width=n,t.height=i+o,t.depth=-o,t.maxFontSize=i*1.125*e.sizeMultiplier,t},mathmlBuilder(r,e){var t=Pe(r.width,e),n=Pe(r.height,e),i=r.shift?Pe(r.shift,e):0,o=e.color&&e.getColor()||"black",s=new W("mspace");s.setAttribute("mathbackground",o),s.setAttribute("width",G(t)),s.setAttribute("height",G(n));var a=new W("mpadded",[s]);return i>=0?a.setAttribute("height",G(i)):(a.setAttribute("height",G(i)),a.setAttribute("depth",G(-i))),a.setAttribute("voffset",G(i)),a}});function J6(r,e,t){for(var n=tt(r,e,!1),i=e.sizeMultiplier/t.sizeMultiplier,o=0;o<n.length;o++){var s=n[o].classes.indexOf("sizing");s<0?Array.prototype.push.apply(n[o].classes,e.sizingClasses(t)):n[o].classes[s+1]==="reset-size"+e.size&&(n[o].classes[s+1]="reset-size"+t.size),n[o].height*=i,n[o].depth*=i}return Sn(n)}var Qg=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],vA=(r,e)=>{var t=e.havingSize(r.size);return J6(r.body,t,e)};X({type:"sizing",names:Qg,numArgs:0,allowedInText:!0,handler:(r,e)=>{var{breakOnTokenText:t,funcName:n,parser:i}=r,o=i.parseExpression(!1,t);return{type:"sizing",mode:i.mode,size:Qg.indexOf(n)+1,body:o}},htmlBuilder:vA,mathmlBuilder:(r,e)=>{var t=e.havingSize(r.size),n=Yt(r.body,t),i=new W("mstyle",n);return i.setAttribute("mathsize",G(t.sizeMultiplier)),i}});X({type:"smash",names:["\\smash"],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(r,e,t)=>{var{parser:n}=r,i=!1,o=!1,s=t[0]&&he(t[0],"ordgroup");if(s)for(var a,l=0;l<s.body.length;++l){var c=s.body[l];if(a=su(c).text,a==="t")i=!0;else if(a==="b")o=!0;else{i=!1,o=!1;break}}else i=!0,o=!0;var u=e[0];return{type:"smash",mode:n.mode,body:u,smashHeight:i,smashDepth:o}},htmlBuilder:(r,e)=>{var t=j([],[we(r.body,e)]);if(!r.smashHeight&&!r.smashDepth)return t;if(r.smashHeight&&(t.height=0),r.smashDepth&&(t.depth=0),r.smashHeight&&r.smashDepth)return j(["mord","smash"],[t],e);if(t.children)for(var n=0;n<t.children.length;n++)r.smashHeight&&(t.children[n].height=0),r.smashDepth&&(t.children[n].depth=0);var i=be({positionType:"firstBaseline",children:[{type:"elem",elem:t}]});return j(["mord"],[i],e)},mathmlBuilder:(r,e)=>{var t=new W("mpadded",[Ne(r.body,e)]);return r.smashHeight&&t.setAttribute("height","0px"),r.smashDepth&&t.setAttribute("depth","0px"),t}});X({type:"sqrt",names:["\\sqrt"],numArgs:1,numOptionalArgs:1,handler(r,e,t){var{parser:n}=r,i=t[0],o=e[0];return{type:"sqrt",mode:n.mode,body:o,index:i}},htmlBuilder(r,e){var t=we(r.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=As(t,e);var n=e.fontMetrics(),i=n.defaultRuleThickness,o=i;e.style.id<de.TEXT.id&&(o=e.fontMetrics().xHeight);var s=i+o/4,a=t.height+t.depth+s+i,{span:l,ruleWidth:c,advanceWidth:u}=QT(a,e),d=l.height-c;d>t.height+t.depth+s&&(s=(s+d-t.height-t.depth)/2);var h=l.height-t.height-s-c;t.style.paddingLeft=G(u);var f=be({positionType:"firstBaseline",children:[{type:"elem",elem:t,wrapperClasses:["svg-align"]},{type:"kern",size:-(t.height+h)},{type:"elem",elem:l},{type:"kern",size:c}]});if(r.index){var m=e.havingStyle(de.SCRIPTSCRIPT),y=we(r.index,m,e),x=.6*(f.height-f.depth),b=be({positionType:"shift",positionData:-x,children:[{type:"elem",elem:y}]}),S=j(["root"],[b]);return j(["mord","sqrt"],[S,f],e)}else return j(["mord","sqrt"],[f],e)},mathmlBuilder(r,e){var{body:t,index:n}=r;return n?new W("mroot",[Ne(t,e),Ne(n,e)]):new W("msqrt",[Ne(t,e)])}});var Bh={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT};function bA(r){return r in Bh}X({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],numArgs:0,allowedInText:!0,primitive:!0,handler(r,e){var{breakOnTokenText:t,funcName:n,parser:i}=r,o=i.parseExpression(!0,t),s=n.slice(1,n.length-5);if(!bA(s))throw new Error("Unknown style: "+s);return{type:"styling",mode:i.mode,style:s,body:o}},htmlBuilder(r,e){var t=Bh[r.style],n=e.havingStyle(t);return r.resetFont&&(n=n.withFont("")),J6(r.body,n,e)},mathmlBuilder(r,e){var t=Bh[r.style],n=e.havingStyle(t);r.resetFont&&(n=n.withFont(""));var i=Yt(r.body,n),o=new W("mstyle",i),s={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},a=s[r.style];return o.setAttribute("scriptlevel",a[0]),o.setAttribute("displaystyle",a[1]),o}});var wA=function(e,t){var n=e.base;if(n)if(n.type==="op"){var i=n.limits&&(t.style.size===de.DISPLAY.size||n.alwaysHandleSupSub);return i?G6:null}else if(n.type==="operatorname"){var o=n.alwaysHandleSupSub&&(t.style.size===de.DISPLAY.size||n.limits);return o?Y6:null}else{if(n.type==="accent")return xn(n.base)?D6:null;if(n.type==="horizBrace"){var s=!e.sub;return s===n.isOver?W6:null}else return null}else return null};io({type:"supsub",htmlBuilder(r,e){var t=wA(r,e);if(t)return t(r,e);var{base:n,sup:i,sub:o}=r,s=we(n,e),a,l,c=e.fontMetrics(),u=0,d=0,h=n&&xn(n);if(i){var f=e.havingStyle(e.style.sup());a=we(i,f,e),h||(u=s.height-f.fontMetrics().supDrop*f.sizeMultiplier/e.sizeMultiplier)}if(o){var m=e.havingStyle(e.style.sub());l=we(o,m,e),h||(d=s.depth+m.fontMetrics().subDrop*m.sizeMultiplier/e.sizeMultiplier)}var y;e.style===de.DISPLAY?y=c.sup1:e.style.cramped?y=c.sup3:y=c.sup2;var x=e.sizeMultiplier,b=G(.5/c.ptPerEm/x),S=null;if(l){var A=r.base&&r.base.type==="op"&&r.base.name&&(r.base.name==="\\oiint"||r.base.name==="\\oiiint");if(s instanceof Wt||A){var D;S=G(-((D=s.italic)!=null?D:0))}}var O;if(a&&l){u=Math.max(u,y,a.depth+.25*c.xHeight),d=Math.max(d,c.sub2);var L=c.defaultRuleThickness,N=4*L;if(u-a.depth-(l.height-d)<N){d=N-(u-a.depth)+l.height;var $=.8*c.xHeight-(u-a.depth);$>0&&(u+=$,d-=$)}var K=[{type:"elem",elem:l,shift:d,marginRight:b,marginLeft:S},{type:"elem",elem:a,shift:-u,marginRight:b}];O=be({positionType:"individualShift",children:K})}else if(l){d=Math.max(d,c.sub1,l.height-.8*c.xHeight);var ne=[{type:"elem",elem:l,marginLeft:S,marginRight:b}];O=be({positionType:"shift",positionData:d,children:ne})}else if(a)u=Math.max(u,y,a.depth+.25*c.xHeight),O=be({positionType:"shift",positionData:-u,children:[{type:"elem",elem:a,marginRight:b}]});else throw new Error("supsub must have either sup or sub.");var pe=Oh(s,"right")||"mord";return j([pe],[s,j(["msupsub"],[O])],e)},mathmlBuilder(r,e){var t=!1,n,i;r.base&&r.base.type==="horizBrace"&&(i=!!r.sup,i===r.base.isOver&&(t=!0,n=r.base.isOver)),r.base&&(r.base.type==="op"||r.base.type==="operatorname")&&(r.base.parentIsSupSub=!0);var o=[Ne(r.base,e)];r.sub&&o.push(Ne(r.sub,e)),r.sup&&o.push(Ne(r.sup,e));var s;if(t)s=n?"mover":"munder";else if(r.sub)if(r.sup){var c=r.base;c&&c.type==="op"&&c.limits&&e.style===de.DISPLAY||c&&c.type==="operatorname"&&c.alwaysHandleSupSub&&(e.style===de.DISPLAY||c.limits)?s="munderover":s="msubsup"}else{var l=r.base;l&&l.type==="op"&&l.limits&&(e.style===de.DISPLAY||l.alwaysHandleSupSub)||l&&l.type==="operatorname"&&l.alwaysHandleSupSub&&(l.limits||e.style===de.DISPLAY)?s="munder":s="msub"}else{var a=r.base;a&&a.type==="op"&&a.limits&&(e.style===de.DISPLAY||a.alwaysHandleSupSub)||a&&a.type==="operatorname"&&a.alwaysHandleSupSub&&(a.limits||e.style===de.DISPLAY)?s="mover":s="msup"}return new W(s,o)}});io({type:"atom",htmlBuilder(r,e){return Pp(r.text,r.mode,e,["m"+r.family])},mathmlBuilder(r,e){var t=new W("mo",[ur(r.text,r.mode)]);if(r.family==="bin"){var n=_p(r,e);n==="bold-italic"&&t.setAttribute("mathvariant",n)}else r.family==="punct"?t.setAttribute("separator","true"):(r.family==="open"||r.family==="close")&&t.setAttribute("stretchy","false");return t}});var X6={mi:"italic",mn:"normal",mtext:"normal"};io({type:"mathord",htmlBuilder(r,e){return nu(r,e)},mathmlBuilder(r,e){var t=new W("mi",[ur(r.text,r.mode,e)]),n=_p(r,e)||"italic";return n!==X6[t.type]&&t.setAttribute("mathvariant",n),t}});io({type:"textord",htmlBuilder(r,e){return nu(r,e)},mathmlBuilder(r,e){var t=ur(r.text,r.mode,e),n=_p(r,e)||"normal",i;return r.mode==="text"?i=new W("mtext",[t]):/[0-9]/.test(r.text)?i=new W("mn",[t]):r.text==="\\prime"?i=new W("mo",[t]):i=new W("mi",[t]),n!==X6[i.type]&&i.setAttribute("mathvariant",n),i}});var Md={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Td={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};io({type:"spacing",htmlBuilder(r,e){if(Td.hasOwnProperty(r.text)){var t=Td[r.text].className||"";if(r.mode==="text"){var n=nu(r,e);return n.classes.push(t),n}else return j(["mspace",t],[Pp(r.text,r.mode,e)],e)}else{if(Md.hasOwnProperty(r.text))return j(["mspace",Md[r.text]],[],e);throw new V('Unknown type of space "'+r.text+'"')}},mathmlBuilder(r,e){var t;if(Td.hasOwnProperty(r.text))t=new W("mtext",[new Je(" ")]);else{if(Md.hasOwnProperty(r.text))return new W("mspace");throw new V('Unknown type of space "'+r.text+'"')}return t}});var e4=()=>{var r=new W("mtd",[]);return r.setAttribute("width","50%"),r};io({type:"tag",mathmlBuilder(r,e){var t=new W("mtable",[new W("mtr",[e4(),new W("mtd",[ei(r.body,e)]),e4(),new W("mtd",[ei(r.tag,e)])])]);return t.setAttribute("width","100%"),t}});var t4={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},r4={"\\textbf":"textbf","\\textmd":"textmd"},xA={"\\textit":"textit","\\textup":"textup"},n4=(r,e)=>{var t=r.font;if(t){if(t4[t])return e.withTextFontFamily(t4[t]);if(r4[t])return e.withTextFontWeight(r4[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(xA[t])};X({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"text",mode:t.mode,body:Ye(i),font:n}},htmlBuilder(r,e){var t=n4(r,e),n=tt(r.body,t,!0);return j(["mord","text"],n,t)},mathmlBuilder(r,e){var t=n4(r,e);return ei(r.body,t)}});X({type:"underline",names:["\\underline"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"underline",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=we(r.body,e),n=Ts("underline-line",e),i=e.fontMetrics().defaultRuleThickness,o=be({positionType:"top",positionData:t.height,children:[{type:"kern",size:i},{type:"elem",elem:n},{type:"kern",size:3*i},{type:"elem",elem:t}]});return j(["mord","underline"],[o],e)},mathmlBuilder(r,e){var t=new W("mo",[new Je("‾")]);t.setAttribute("stretchy","true");var n=new W("munder",[Ne(r.body,e),t]);return n.setAttribute("accentunder","true"),n}});X({type:"vcenter",names:["\\vcenter"],numArgs:1,argTypes:["original"],allowedInText:!1,handler(r,e){var{parser:t}=r;return{type:"vcenter",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=we(r.body,e),n=e.fontMetrics().axisHeight,i=.5*(t.height-n-(t.depth+n));return be({positionType:"shift",positionData:i,children:[{type:"elem",elem:t}]})},mathmlBuilder(r,e){var t=new W("mpadded",[Ne(r.body,e)],["vcenter"]);return new W("mrow",[t])}});X({type:"verb",names:["\\verb"],numArgs:0,allowedInText:!0,handler(r,e,t){throw new V("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(r,e){for(var t=i4(r),n=[],i=e.havingStyle(e.style.text()),o=0;o<t.length;o++){var s=t[o];s==="~"&&(s="\\textasciitilde"),n.push(bt(s,"Typewriter-Regular",r.mode,i,["mord","texttt"]))}return j(["mord","text"].concat(i.sizingClasses(e)),b6(n),i)},mathmlBuilder(r,e){var t=new Je(i4(r)),n=new W("mtext",[t]);return n.setAttribute("mathvariant","monospace"),n}});var i4=r=>r.body.replace(/ /g,r.star?"␣":" "),Wn=S6,Z6=`[ \r
1130
+ -470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw new Error("Unknown stretchy delimiter.")}};function rT(r){return"toText"in r}class Hs{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e="",t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(rT(e))return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}var xh={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},nT={ex:!0,em:!0,mu:!0},p6=function(e){return typeof e!="string"&&(e=e.unit),e in xh||e in nT||e==="ex"},Pe=function(e,t){var n;if(e.unit in xh)n=xh[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit==="mu")n=t.fontMetrics().cssEmPerMu;else{var i;if(t.style.isTight()?i=t.havingStyle(t.style.text()):i=t,e.unit==="ex")n=i.fontMetrics().xHeight;else if(e.unit==="em")n=i.fontMetrics().quad;else throw new V("Invalid unit: '"+e.unit+"'");i!==t&&(n*=i.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},G=function(e){return+e.toFixed(4)+"em"},Xn=function(e){return e.filter(t=>t).join(" ")},Lp=function(e){var t="";for(var n of Object.keys(e)){var i=e[n];i!==void 0&&(t+=OM(n)+":"+i+";")}return t},m6=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push("mtight");var i=t.getColor();i&&(this.style.color=i)}},g6=function(e){var t=document.createElement(e);t.className=Xn(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var i=0;i<this.children.length;i++)t.appendChild(this.children[i].toNode());return t},iT=/[\s"'>/=\x00-\x1f]/,y6=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+ht(Xn(this.classes))+'"');var n=Lp(this.style);n&&(t+=' style="'+ht(n)+'"');for(var i of Object.keys(this.attributes)){if(iT.test(i))throw new V("Invalid attribute name '"+i+"'");t+=" "+i+'="'+ht(this.attributes[i])+'"'}t+=">";for(var o=0;o<this.children.length;o++)t+=this.children[o].toMarkup();return t+="</"+e+">",t};class _s{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,m6.call(this,e,n,i),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g6.call(this,"span")}toMarkup(){return y6.call(this,"span")}}class tu{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,m6.call(this,t,i),this.children=n||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g6.call(this,"a")}toMarkup(){return y6.call(this,"a")}}class oT{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){var e='<img src="'+ht(this.src)+'"'+(' alt="'+ht(this.alt)+'"'),t=Lp(this.style);return t&&(e+=' style="'+ht(t)+'"'),e+="'/>",e}}var sT={î:"ı̂",ï:"ı̈",í:"ı́",ì:"ı̀"};class Wt{constructor(e,t,n,i,o,s,a,l){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=i||0,this.skew=o||0,this.width=s||0,this.classes=a||[],this.style=l||{},this.maxFontSize=0;var c=WM(this.text.charCodeAt(0));c&&this.classes.push(c+"_fallback"),/[îïíì]/.test(this.text)&&(this.text=sT[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement("span"),t.style.marginRight=G(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=Xn(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="<span";this.classes.length&&(e=!0,t+=' class="',t+=ht(Xn(this.classes)),t+='"');var n="";this.italic>0&&(n+="margin-right:"+G(this.italic)+";"),n+=Lp(this.style),n&&(e=!0,t+=' style="'+ht(n)+'"');var i=ht(this.text);return e?(t+=">",t+=i,t+="</span>",t):i}}class bn{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var i=0;i<this.children.length;i++)t.appendChild(this.children[i].toNode());return t}toMarkup(){var e='<svg xmlns="http://www.w3.org/2000/svg"';for(var t of Object.keys(this.attributes))e+=" "+t+'="'+ht(this.attributes[t])+'"';e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</svg>",e}}class Zn{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"path");return this.alternate?t.setAttribute("d",this.alternate):t.setAttribute("d",Tg[this.pathName]),t}toMarkup(){return this.alternate?'<path d="'+ht(this.alternate)+'"/>':'<path d="'+ht(Tg[this.pathName])+'"/>'}}class kh{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"line");for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);return t}toMarkup(){var e="<line";for(var t of Object.keys(this.attributes))e+=" "+t+'="'+ht(this.attributes[t])+'"';return e+="/>",e}}function aT(r){if(r instanceof Wt)return r;throw new Error("Expected symbolNode but got "+String(r)+".")}function lT(r){if(r instanceof _s)return r;throw new Error("Expected span<HtmlDomNode> but got "+String(r)+".")}var cT=r=>r instanceof _s||r instanceof tu||r instanceof Hs,Pr={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},N0={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},Ag={Å:"A",Ð:"D",Þ:"o",å:"a",ð:"d",þ:"o",А:"A",Б:"B",В:"B",Г:"F",Д:"A",Е:"E",Ж:"K",З:"3",И:"N",Й:"N",К:"K",Л:"N",М:"M",Н:"H",О:"O",П:"N",Р:"P",С:"C",Т:"T",У:"y",Ф:"O",Х:"X",Ц:"U",Ч:"h",Ш:"W",Щ:"W",Ъ:"B",Ы:"X",Ь:"B",Э:"3",Ю:"X",Я:"R",а:"a",б:"b",в:"a",г:"r",д:"y",е:"e",ж:"m",з:"e",и:"n",й:"n",к:"n",л:"n",м:"m",н:"n",о:"o",п:"n",р:"p",с:"c",т:"o",у:"y",ф:"b",х:"x",ц:"n",ч:"n",ш:"w",щ:"w",ъ:"a",ы:"m",ь:"a",э:"e",ю:"m",я:"r"};function uT(r,e){Pr[r]=e}function Bp(r,e,t){if(!Pr[e])throw new Error("Font metrics not found for font: "+e+".");var n=r.charCodeAt(0),i=Pr[e][n];if(!i&&r[0]in Ag&&(n=Ag[r[0]].charCodeAt(0),i=Pr[e][n]),!i&&t==="text"&&f6(n)&&(i=Pr[e][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var hd={};function dT(r){var e;if(r>=5?e=0:r>=3?e=1:e=2,!hd[e]){var t=hd[e]={cssEmPerMu:N0.quad[e]/18};for(var n in N0)N0.hasOwnProperty(n)&&(t[n]=N0[n][e])}return hd[e]}var Ie={math:{},text:{}};function p(r,e,t,n,i,o){Ie[r][i]={font:e,group:t,replace:n},o&&n&&(Ie[r][n]=Ie[r][i])}var g="math",q="text",v="main",M="ams",ze="accent-token",Z="bin",Ct="close",qs="inner",ie="mathord",Ze="op-token",Gt="open",Yl="punct",T="rel",kn="spacing",E="textord";p(g,v,T,"≡","\\equiv",!0);p(g,v,T,"≺","\\prec",!0);p(g,v,T,"≻","\\succ",!0);p(g,v,T,"∼","\\sim",!0);p(g,v,T,"⊥","\\perp");p(g,v,T,"⪯","\\preceq",!0);p(g,v,T,"⪰","\\succeq",!0);p(g,v,T,"≃","\\simeq",!0);p(g,v,T,"∣","\\mid",!0);p(g,v,T,"≪","\\ll",!0);p(g,v,T,"≫","\\gg",!0);p(g,v,T,"≍","\\asymp",!0);p(g,v,T,"∥","\\parallel");p(g,v,T,"⋈","\\bowtie",!0);p(g,v,T,"⌣","\\smile",!0);p(g,v,T,"⊑","\\sqsubseteq",!0);p(g,v,T,"⊒","\\sqsupseteq",!0);p(g,v,T,"≐","\\doteq",!0);p(g,v,T,"⌢","\\frown",!0);p(g,v,T,"∋","\\ni",!0);p(g,v,T,"∝","\\propto",!0);p(g,v,T,"⊢","\\vdash",!0);p(g,v,T,"⊣","\\dashv",!0);p(g,v,T,"∋","\\owns");p(g,v,Yl,".","\\ldotp");p(g,v,Yl,"⋅","\\cdotp");p(g,v,Yl,"⋅","·");p(q,v,E,"⋅","·");p(g,v,E,"#","\\#");p(q,v,E,"#","\\#");p(g,v,E,"&","\\&");p(q,v,E,"&","\\&");p(g,v,E,"ℵ","\\aleph",!0);p(g,v,E,"∀","\\forall",!0);p(g,v,E,"ℏ","\\hbar",!0);p(g,v,E,"∃","\\exists",!0);p(g,v,E,"∇","\\nabla",!0);p(g,v,E,"♭","\\flat",!0);p(g,v,E,"ℓ","\\ell",!0);p(g,v,E,"♮","\\natural",!0);p(g,v,E,"♣","\\clubsuit",!0);p(g,v,E,"℘","\\wp",!0);p(g,v,E,"♯","\\sharp",!0);p(g,v,E,"♢","\\diamondsuit",!0);p(g,v,E,"ℜ","\\Re",!0);p(g,v,E,"♡","\\heartsuit",!0);p(g,v,E,"ℑ","\\Im",!0);p(g,v,E,"♠","\\spadesuit",!0);p(g,v,E,"§","\\S",!0);p(q,v,E,"§","\\S");p(g,v,E,"¶","\\P",!0);p(q,v,E,"¶","\\P");p(g,v,E,"†","\\dag");p(q,v,E,"†","\\dag");p(q,v,E,"†","\\textdagger");p(g,v,E,"‡","\\ddag");p(q,v,E,"‡","\\ddag");p(q,v,E,"‡","\\textdaggerdbl");p(g,v,Ct,"⎱","\\rmoustache",!0);p(g,v,Gt,"⎰","\\lmoustache",!0);p(g,v,Ct,"⟯","\\rgroup",!0);p(g,v,Gt,"⟮","\\lgroup",!0);p(g,v,Z,"∓","\\mp",!0);p(g,v,Z,"⊖","\\ominus",!0);p(g,v,Z,"⊎","\\uplus",!0);p(g,v,Z,"⊓","\\sqcap",!0);p(g,v,Z,"∗","\\ast");p(g,v,Z,"⊔","\\sqcup",!0);p(g,v,Z,"◯","\\bigcirc",!0);p(g,v,Z,"∙","\\bullet",!0);p(g,v,Z,"‡","\\ddagger");p(g,v,Z,"≀","\\wr",!0);p(g,v,Z,"⨿","\\amalg");p(g,v,Z,"&","\\And");p(g,v,T,"⟵","\\longleftarrow",!0);p(g,v,T,"⇐","\\Leftarrow",!0);p(g,v,T,"⟸","\\Longleftarrow",!0);p(g,v,T,"⟶","\\longrightarrow",!0);p(g,v,T,"⇒","\\Rightarrow",!0);p(g,v,T,"⟹","\\Longrightarrow",!0);p(g,v,T,"↔","\\leftrightarrow",!0);p(g,v,T,"⟷","\\longleftrightarrow",!0);p(g,v,T,"⇔","\\Leftrightarrow",!0);p(g,v,T,"⟺","\\Longleftrightarrow",!0);p(g,v,T,"↦","\\mapsto",!0);p(g,v,T,"⟼","\\longmapsto",!0);p(g,v,T,"↗","\\nearrow",!0);p(g,v,T,"↩","\\hookleftarrow",!0);p(g,v,T,"↪","\\hookrightarrow",!0);p(g,v,T,"↘","\\searrow",!0);p(g,v,T,"↼","\\leftharpoonup",!0);p(g,v,T,"⇀","\\rightharpoonup",!0);p(g,v,T,"↙","\\swarrow",!0);p(g,v,T,"↽","\\leftharpoondown",!0);p(g,v,T,"⇁","\\rightharpoondown",!0);p(g,v,T,"↖","\\nwarrow",!0);p(g,v,T,"⇌","\\rightleftharpoons",!0);p(g,M,T,"≮","\\nless",!0);p(g,M,T,"","\\@nleqslant");p(g,M,T,"","\\@nleqq");p(g,M,T,"⪇","\\lneq",!0);p(g,M,T,"≨","\\lneqq",!0);p(g,M,T,"","\\@lvertneqq");p(g,M,T,"⋦","\\lnsim",!0);p(g,M,T,"⪉","\\lnapprox",!0);p(g,M,T,"⊀","\\nprec",!0);p(g,M,T,"⋠","\\npreceq",!0);p(g,M,T,"⋨","\\precnsim",!0);p(g,M,T,"⪹","\\precnapprox",!0);p(g,M,T,"≁","\\nsim",!0);p(g,M,T,"","\\@nshortmid");p(g,M,T,"∤","\\nmid",!0);p(g,M,T,"⊬","\\nvdash",!0);p(g,M,T,"⊭","\\nvDash",!0);p(g,M,T,"⋪","\\ntriangleleft");p(g,M,T,"⋬","\\ntrianglelefteq",!0);p(g,M,T,"⊊","\\subsetneq",!0);p(g,M,T,"","\\@varsubsetneq");p(g,M,T,"⫋","\\subsetneqq",!0);p(g,M,T,"","\\@varsubsetneqq");p(g,M,T,"≯","\\ngtr",!0);p(g,M,T,"","\\@ngeqslant");p(g,M,T,"","\\@ngeqq");p(g,M,T,"⪈","\\gneq",!0);p(g,M,T,"≩","\\gneqq",!0);p(g,M,T,"","\\@gvertneqq");p(g,M,T,"⋧","\\gnsim",!0);p(g,M,T,"⪊","\\gnapprox",!0);p(g,M,T,"⊁","\\nsucc",!0);p(g,M,T,"⋡","\\nsucceq",!0);p(g,M,T,"⋩","\\succnsim",!0);p(g,M,T,"⪺","\\succnapprox",!0);p(g,M,T,"≆","\\ncong",!0);p(g,M,T,"","\\@nshortparallel");p(g,M,T,"∦","\\nparallel",!0);p(g,M,T,"⊯","\\nVDash",!0);p(g,M,T,"⋫","\\ntriangleright");p(g,M,T,"⋭","\\ntrianglerighteq",!0);p(g,M,T,"","\\@nsupseteqq");p(g,M,T,"⊋","\\supsetneq",!0);p(g,M,T,"","\\@varsupsetneq");p(g,M,T,"⫌","\\supsetneqq",!0);p(g,M,T,"","\\@varsupsetneqq");p(g,M,T,"⊮","\\nVdash",!0);p(g,M,T,"⪵","\\precneqq",!0);p(g,M,T,"⪶","\\succneqq",!0);p(g,M,T,"","\\@nsubseteqq");p(g,M,Z,"⊴","\\unlhd");p(g,M,Z,"⊵","\\unrhd");p(g,M,T,"↚","\\nleftarrow",!0);p(g,M,T,"↛","\\nrightarrow",!0);p(g,M,T,"⇍","\\nLeftarrow",!0);p(g,M,T,"⇏","\\nRightarrow",!0);p(g,M,T,"↮","\\nleftrightarrow",!0);p(g,M,T,"⇎","\\nLeftrightarrow",!0);p(g,M,T,"△","\\vartriangle");p(g,M,E,"ℏ","\\hslash");p(g,M,E,"▽","\\triangledown");p(g,M,E,"◊","\\lozenge");p(g,M,E,"Ⓢ","\\circledS");p(g,M,E,"®","\\circledR");p(q,M,E,"®","\\circledR");p(g,M,E,"∡","\\measuredangle",!0);p(g,M,E,"∄","\\nexists");p(g,M,E,"℧","\\mho");p(g,M,E,"Ⅎ","\\Finv",!0);p(g,M,E,"⅁","\\Game",!0);p(g,M,E,"‵","\\backprime");p(g,M,E,"▲","\\blacktriangle");p(g,M,E,"▼","\\blacktriangledown");p(g,M,E,"■","\\blacksquare");p(g,M,E,"⧫","\\blacklozenge");p(g,M,E,"★","\\bigstar");p(g,M,E,"∢","\\sphericalangle",!0);p(g,M,E,"∁","\\complement",!0);p(g,M,E,"ð","\\eth",!0);p(q,v,E,"ð","ð");p(g,M,E,"╱","\\diagup");p(g,M,E,"╲","\\diagdown");p(g,M,E,"□","\\square");p(g,M,E,"□","\\Box");p(g,M,E,"◊","\\Diamond");p(g,M,E,"¥","\\yen",!0);p(q,M,E,"¥","\\yen",!0);p(g,M,E,"✓","\\checkmark",!0);p(q,M,E,"✓","\\checkmark");p(g,M,E,"ℶ","\\beth",!0);p(g,M,E,"ℸ","\\daleth",!0);p(g,M,E,"ℷ","\\gimel",!0);p(g,M,E,"ϝ","\\digamma",!0);p(g,M,E,"ϰ","\\varkappa");p(g,M,Gt,"┌","\\@ulcorner",!0);p(g,M,Ct,"┐","\\@urcorner",!0);p(g,M,Gt,"└","\\@llcorner",!0);p(g,M,Ct,"┘","\\@lrcorner",!0);p(g,M,T,"≦","\\leqq",!0);p(g,M,T,"⩽","\\leqslant",!0);p(g,M,T,"⪕","\\eqslantless",!0);p(g,M,T,"≲","\\lesssim",!0);p(g,M,T,"⪅","\\lessapprox",!0);p(g,M,T,"≊","\\approxeq",!0);p(g,M,Z,"⋖","\\lessdot");p(g,M,T,"⋘","\\lll",!0);p(g,M,T,"≶","\\lessgtr",!0);p(g,M,T,"⋚","\\lesseqgtr",!0);p(g,M,T,"⪋","\\lesseqqgtr",!0);p(g,M,T,"≑","\\doteqdot");p(g,M,T,"≓","\\risingdotseq",!0);p(g,M,T,"≒","\\fallingdotseq",!0);p(g,M,T,"∽","\\backsim",!0);p(g,M,T,"⋍","\\backsimeq",!0);p(g,M,T,"⫅","\\subseteqq",!0);p(g,M,T,"⋐","\\Subset",!0);p(g,M,T,"⊏","\\sqsubset",!0);p(g,M,T,"≼","\\preccurlyeq",!0);p(g,M,T,"⋞","\\curlyeqprec",!0);p(g,M,T,"≾","\\precsim",!0);p(g,M,T,"⪷","\\precapprox",!0);p(g,M,T,"⊲","\\vartriangleleft");p(g,M,T,"⊴","\\trianglelefteq");p(g,M,T,"⊨","\\vDash",!0);p(g,M,T,"⊪","\\Vvdash",!0);p(g,M,T,"⌣","\\smallsmile");p(g,M,T,"⌢","\\smallfrown");p(g,M,T,"≏","\\bumpeq",!0);p(g,M,T,"≎","\\Bumpeq",!0);p(g,M,T,"≧","\\geqq",!0);p(g,M,T,"⩾","\\geqslant",!0);p(g,M,T,"⪖","\\eqslantgtr",!0);p(g,M,T,"≳","\\gtrsim",!0);p(g,M,T,"⪆","\\gtrapprox",!0);p(g,M,Z,"⋗","\\gtrdot");p(g,M,T,"⋙","\\ggg",!0);p(g,M,T,"≷","\\gtrless",!0);p(g,M,T,"⋛","\\gtreqless",!0);p(g,M,T,"⪌","\\gtreqqless",!0);p(g,M,T,"≖","\\eqcirc",!0);p(g,M,T,"≗","\\circeq",!0);p(g,M,T,"≜","\\triangleq",!0);p(g,M,T,"∼","\\thicksim");p(g,M,T,"≈","\\thickapprox");p(g,M,T,"⫆","\\supseteqq",!0);p(g,M,T,"⋑","\\Supset",!0);p(g,M,T,"⊐","\\sqsupset",!0);p(g,M,T,"≽","\\succcurlyeq",!0);p(g,M,T,"⋟","\\curlyeqsucc",!0);p(g,M,T,"≿","\\succsim",!0);p(g,M,T,"⪸","\\succapprox",!0);p(g,M,T,"⊳","\\vartriangleright");p(g,M,T,"⊵","\\trianglerighteq");p(g,M,T,"⊩","\\Vdash",!0);p(g,M,T,"∣","\\shortmid");p(g,M,T,"∥","\\shortparallel");p(g,M,T,"≬","\\between",!0);p(g,M,T,"⋔","\\pitchfork",!0);p(g,M,T,"∝","\\varpropto");p(g,M,T,"◀","\\blacktriangleleft");p(g,M,T,"∴","\\therefore",!0);p(g,M,T,"∍","\\backepsilon");p(g,M,T,"▶","\\blacktriangleright");p(g,M,T,"∵","\\because",!0);p(g,M,T,"⋘","\\llless");p(g,M,T,"⋙","\\gggtr");p(g,M,Z,"⊲","\\lhd");p(g,M,Z,"⊳","\\rhd");p(g,M,T,"≂","\\eqsim",!0);p(g,v,T,"⋈","\\Join");p(g,M,T,"≑","\\Doteq",!0);p(g,M,Z,"∔","\\dotplus",!0);p(g,M,Z,"∖","\\smallsetminus");p(g,M,Z,"⋒","\\Cap",!0);p(g,M,Z,"⋓","\\Cup",!0);p(g,M,Z,"⩞","\\doublebarwedge",!0);p(g,M,Z,"⊟","\\boxminus",!0);p(g,M,Z,"⊞","\\boxplus",!0);p(g,M,Z,"⋇","\\divideontimes",!0);p(g,M,Z,"⋉","\\ltimes",!0);p(g,M,Z,"⋊","\\rtimes",!0);p(g,M,Z,"⋋","\\leftthreetimes",!0);p(g,M,Z,"⋌","\\rightthreetimes",!0);p(g,M,Z,"⋏","\\curlywedge",!0);p(g,M,Z,"⋎","\\curlyvee",!0);p(g,M,Z,"⊝","\\circleddash",!0);p(g,M,Z,"⊛","\\circledast",!0);p(g,M,Z,"⋅","\\centerdot");p(g,M,Z,"⊺","\\intercal",!0);p(g,M,Z,"⋒","\\doublecap");p(g,M,Z,"⋓","\\doublecup");p(g,M,Z,"⊠","\\boxtimes",!0);p(g,M,T,"⇢","\\dashrightarrow",!0);p(g,M,T,"⇠","\\dashleftarrow",!0);p(g,M,T,"⇇","\\leftleftarrows",!0);p(g,M,T,"⇆","\\leftrightarrows",!0);p(g,M,T,"⇚","\\Lleftarrow",!0);p(g,M,T,"↞","\\twoheadleftarrow",!0);p(g,M,T,"↢","\\leftarrowtail",!0);p(g,M,T,"↫","\\looparrowleft",!0);p(g,M,T,"⇋","\\leftrightharpoons",!0);p(g,M,T,"↶","\\curvearrowleft",!0);p(g,M,T,"↺","\\circlearrowleft",!0);p(g,M,T,"↰","\\Lsh",!0);p(g,M,T,"⇈","\\upuparrows",!0);p(g,M,T,"↿","\\upharpoonleft",!0);p(g,M,T,"⇃","\\downharpoonleft",!0);p(g,v,T,"⊶","\\origof",!0);p(g,v,T,"⊷","\\imageof",!0);p(g,M,T,"⊸","\\multimap",!0);p(g,M,T,"↭","\\leftrightsquigarrow",!0);p(g,M,T,"⇉","\\rightrightarrows",!0);p(g,M,T,"⇄","\\rightleftarrows",!0);p(g,M,T,"↠","\\twoheadrightarrow",!0);p(g,M,T,"↣","\\rightarrowtail",!0);p(g,M,T,"↬","\\looparrowright",!0);p(g,M,T,"↷","\\curvearrowright",!0);p(g,M,T,"↻","\\circlearrowright",!0);p(g,M,T,"↱","\\Rsh",!0);p(g,M,T,"⇊","\\downdownarrows",!0);p(g,M,T,"↾","\\upharpoonright",!0);p(g,M,T,"⇂","\\downharpoonright",!0);p(g,M,T,"⇝","\\rightsquigarrow",!0);p(g,M,T,"⇝","\\leadsto");p(g,M,T,"⇛","\\Rrightarrow",!0);p(g,M,T,"↾","\\restriction");p(g,v,E,"‘","`");p(g,v,E,"$","\\$");p(q,v,E,"$","\\$");p(q,v,E,"$","\\textdollar");p(g,v,E,"%","\\%");p(q,v,E,"%","\\%");p(g,v,E,"_","\\_");p(q,v,E,"_","\\_");p(q,v,E,"_","\\textunderscore");p(g,v,E,"∠","\\angle",!0);p(g,v,E,"∞","\\infty",!0);p(g,v,E,"′","\\prime");p(g,v,E,"△","\\triangle");p(g,v,E,"Γ","\\Gamma",!0);p(g,v,E,"Δ","\\Delta",!0);p(g,v,E,"Θ","\\Theta",!0);p(g,v,E,"Λ","\\Lambda",!0);p(g,v,E,"Ξ","\\Xi",!0);p(g,v,E,"Π","\\Pi",!0);p(g,v,E,"Σ","\\Sigma",!0);p(g,v,E,"Υ","\\Upsilon",!0);p(g,v,E,"Φ","\\Phi",!0);p(g,v,E,"Ψ","\\Psi",!0);p(g,v,E,"Ω","\\Omega",!0);p(g,v,E,"A","Α");p(g,v,E,"B","Β");p(g,v,E,"E","Ε");p(g,v,E,"Z","Ζ");p(g,v,E,"H","Η");p(g,v,E,"I","Ι");p(g,v,E,"K","Κ");p(g,v,E,"M","Μ");p(g,v,E,"N","Ν");p(g,v,E,"O","Ο");p(g,v,E,"P","Ρ");p(g,v,E,"T","Τ");p(g,v,E,"X","Χ");p(g,v,E,"¬","\\neg",!0);p(g,v,E,"¬","\\lnot");p(g,v,E,"⊤","\\top");p(g,v,E,"⊥","\\bot");p(g,v,E,"∅","\\emptyset");p(g,M,E,"∅","\\varnothing");p(g,v,ie,"α","\\alpha",!0);p(g,v,ie,"β","\\beta",!0);p(g,v,ie,"γ","\\gamma",!0);p(g,v,ie,"δ","\\delta",!0);p(g,v,ie,"ϵ","\\epsilon",!0);p(g,v,ie,"ζ","\\zeta",!0);p(g,v,ie,"η","\\eta",!0);p(g,v,ie,"θ","\\theta",!0);p(g,v,ie,"ι","\\iota",!0);p(g,v,ie,"κ","\\kappa",!0);p(g,v,ie,"λ","\\lambda",!0);p(g,v,ie,"μ","\\mu",!0);p(g,v,ie,"ν","\\nu",!0);p(g,v,ie,"ξ","\\xi",!0);p(g,v,ie,"ο","\\omicron",!0);p(g,v,ie,"π","\\pi",!0);p(g,v,ie,"ρ","\\rho",!0);p(g,v,ie,"σ","\\sigma",!0);p(g,v,ie,"τ","\\tau",!0);p(g,v,ie,"υ","\\upsilon",!0);p(g,v,ie,"ϕ","\\phi",!0);p(g,v,ie,"χ","\\chi",!0);p(g,v,ie,"ψ","\\psi",!0);p(g,v,ie,"ω","\\omega",!0);p(g,v,ie,"ε","\\varepsilon",!0);p(g,v,ie,"ϑ","\\vartheta",!0);p(g,v,ie,"ϖ","\\varpi",!0);p(g,v,ie,"ϱ","\\varrho",!0);p(g,v,ie,"ς","\\varsigma",!0);p(g,v,ie,"φ","\\varphi",!0);p(g,v,Z,"∗","*",!0);p(g,v,Z,"+","+");p(g,v,Z,"−","-",!0);p(g,v,Z,"⋅","\\cdot",!0);p(g,v,Z,"∘","\\circ",!0);p(g,v,Z,"÷","\\div",!0);p(g,v,Z,"±","\\pm",!0);p(g,v,Z,"×","\\times",!0);p(g,v,Z,"∩","\\cap",!0);p(g,v,Z,"∪","\\cup",!0);p(g,v,Z,"∖","\\setminus",!0);p(g,v,Z,"∧","\\land");p(g,v,Z,"∨","\\lor");p(g,v,Z,"∧","\\wedge",!0);p(g,v,Z,"∨","\\vee",!0);p(g,v,E,"√","\\surd");p(g,v,Gt,"⟨","\\langle",!0);p(g,v,Gt,"∣","\\lvert");p(g,v,Gt,"∥","\\lVert");p(g,v,Ct,"?","?");p(g,v,Ct,"!","!");p(g,v,Ct,"⟩","\\rangle",!0);p(g,v,Ct,"∣","\\rvert");p(g,v,Ct,"∥","\\rVert");p(g,v,T,"=","=");p(g,v,T,":",":");p(g,v,T,"≈","\\approx",!0);p(g,v,T,"≅","\\cong",!0);p(g,v,T,"≥","\\ge");p(g,v,T,"≥","\\geq",!0);p(g,v,T,"←","\\gets");p(g,v,T,">","\\gt",!0);p(g,v,T,"∈","\\in",!0);p(g,v,T,"","\\@not");p(g,v,T,"⊂","\\subset",!0);p(g,v,T,"⊃","\\supset",!0);p(g,v,T,"⊆","\\subseteq",!0);p(g,v,T,"⊇","\\supseteq",!0);p(g,M,T,"⊈","\\nsubseteq",!0);p(g,M,T,"⊉","\\nsupseteq",!0);p(g,v,T,"⊨","\\models");p(g,v,T,"←","\\leftarrow",!0);p(g,v,T,"≤","\\le");p(g,v,T,"≤","\\leq",!0);p(g,v,T,"<","\\lt",!0);p(g,v,T,"→","\\rightarrow",!0);p(g,v,T,"→","\\to");p(g,M,T,"≱","\\ngeq",!0);p(g,M,T,"≰","\\nleq",!0);p(g,v,kn," ","\\ ");p(g,v,kn," ","\\space");p(g,v,kn," ","\\nobreakspace");p(q,v,kn," ","\\ ");p(q,v,kn," "," ");p(q,v,kn," ","\\space");p(q,v,kn," ","\\nobreakspace");p(g,v,kn,"","\\nobreak");p(g,v,kn,"","\\allowbreak");p(g,v,Yl,",",",");p(g,v,Yl,";",";");p(g,M,Z,"⊼","\\barwedge",!0);p(g,M,Z,"⊻","\\veebar",!0);p(g,v,Z,"⊙","\\odot",!0);p(g,v,Z,"⊕","\\oplus",!0);p(g,v,Z,"⊗","\\otimes",!0);p(g,v,E,"∂","\\partial",!0);p(g,v,Z,"⊘","\\oslash",!0);p(g,M,Z,"⊚","\\circledcirc",!0);p(g,M,Z,"⊡","\\boxdot",!0);p(g,v,Z,"△","\\bigtriangleup");p(g,v,Z,"▽","\\bigtriangledown");p(g,v,Z,"†","\\dagger");p(g,v,Z,"⋄","\\diamond");p(g,v,Z,"⋆","\\star");p(g,v,Z,"◃","\\triangleleft");p(g,v,Z,"▹","\\triangleright");p(g,v,Gt,"{","\\{");p(q,v,E,"{","\\{");p(q,v,E,"{","\\textbraceleft");p(g,v,Ct,"}","\\}");p(q,v,E,"}","\\}");p(q,v,E,"}","\\textbraceright");p(g,v,Gt,"{","\\lbrace");p(g,v,Ct,"}","\\rbrace");p(g,v,Gt,"[","\\lbrack",!0);p(q,v,E,"[","\\lbrack",!0);p(g,v,Ct,"]","\\rbrack",!0);p(q,v,E,"]","\\rbrack",!0);p(g,v,Gt,"(","\\lparen",!0);p(g,v,Ct,")","\\rparen",!0);p(q,v,E,"<","\\textless",!0);p(q,v,E,">","\\textgreater",!0);p(g,v,Gt,"⌊","\\lfloor",!0);p(g,v,Ct,"⌋","\\rfloor",!0);p(g,v,Gt,"⌈","\\lceil",!0);p(g,v,Ct,"⌉","\\rceil",!0);p(g,v,E,"\\","\\backslash");p(g,v,E,"∣","|");p(g,v,E,"∣","\\vert");p(q,v,E,"|","\\textbar",!0);p(g,v,E,"∥","\\|");p(g,v,E,"∥","\\Vert");p(q,v,E,"∥","\\textbardbl");p(q,v,E,"~","\\textasciitilde");p(q,v,E,"\\","\\textbackslash");p(q,v,E,"^","\\textasciicircum");p(g,v,T,"↑","\\uparrow",!0);p(g,v,T,"⇑","\\Uparrow",!0);p(g,v,T,"↓","\\downarrow",!0);p(g,v,T,"⇓","\\Downarrow",!0);p(g,v,T,"↕","\\updownarrow",!0);p(g,v,T,"⇕","\\Updownarrow",!0);p(g,v,Ze,"∐","\\coprod");p(g,v,Ze,"⋁","\\bigvee");p(g,v,Ze,"⋀","\\bigwedge");p(g,v,Ze,"⨄","\\biguplus");p(g,v,Ze,"⋂","\\bigcap");p(g,v,Ze,"⋃","\\bigcup");p(g,v,Ze,"∫","\\int");p(g,v,Ze,"∫","\\intop");p(g,v,Ze,"∬","\\iint");p(g,v,Ze,"∭","\\iiint");p(g,v,Ze,"∏","\\prod");p(g,v,Ze,"∑","\\sum");p(g,v,Ze,"⨂","\\bigotimes");p(g,v,Ze,"⨁","\\bigoplus");p(g,v,Ze,"⨀","\\bigodot");p(g,v,Ze,"∮","\\oint");p(g,v,Ze,"∯","\\oiint");p(g,v,Ze,"∰","\\oiiint");p(g,v,Ze,"⨆","\\bigsqcup");p(g,v,Ze,"∫","\\smallint");p(q,v,qs,"…","\\textellipsis");p(g,v,qs,"…","\\mathellipsis");p(q,v,qs,"…","\\ldots",!0);p(g,v,qs,"…","\\ldots",!0);p(g,v,qs,"⋯","\\@cdots",!0);p(g,v,qs,"⋱","\\ddots",!0);p(g,v,E,"⋮","\\varvdots");p(q,v,E,"⋮","\\varvdots");p(g,v,ze,"ˊ","\\acute");p(g,v,ze,"ˋ","\\grave");p(g,v,ze,"¨","\\ddot");p(g,v,ze,"~","\\tilde");p(g,v,ze,"ˉ","\\bar");p(g,v,ze,"˘","\\breve");p(g,v,ze,"ˇ","\\check");p(g,v,ze,"^","\\hat");p(g,v,ze,"⃗","\\vec");p(g,v,ze,"˙","\\dot");p(g,v,ze,"˚","\\mathring");p(g,v,ie,"","\\@imath");p(g,v,ie,"","\\@jmath");p(g,v,E,"ı","ı");p(g,v,E,"ȷ","ȷ");p(q,v,E,"ı","\\i",!0);p(q,v,E,"ȷ","\\j",!0);p(q,v,E,"ß","\\ss",!0);p(q,v,E,"æ","\\ae",!0);p(q,v,E,"œ","\\oe",!0);p(q,v,E,"ø","\\o",!0);p(q,v,E,"Æ","\\AE",!0);p(q,v,E,"Œ","\\OE",!0);p(q,v,E,"Ø","\\O",!0);p(q,v,ze,"ˊ","\\'");p(q,v,ze,"ˋ","\\`");p(q,v,ze,"ˆ","\\^");p(q,v,ze,"˜","\\~");p(q,v,ze,"ˉ","\\=");p(q,v,ze,"˘","\\u");p(q,v,ze,"˙","\\.");p(q,v,ze,"¸","\\c");p(q,v,ze,"˚","\\r");p(q,v,ze,"ˇ","\\v");p(q,v,ze,"¨",'\\"');p(q,v,ze,"˝","\\H");p(q,v,ze,"◯","\\textcircled");var v6={"--":!0,"---":!0,"``":!0,"''":!0};p(q,v,E,"–","--",!0);p(q,v,E,"–","\\textendash");p(q,v,E,"—","---",!0);p(q,v,E,"—","\\textemdash");p(q,v,E,"‘","`",!0);p(q,v,E,"‘","\\textquoteleft");p(q,v,E,"’","'",!0);p(q,v,E,"’","\\textquoteright");p(q,v,E,"“","``",!0);p(q,v,E,"“","\\textquotedblleft");p(q,v,E,"”","''",!0);p(q,v,E,"”","\\textquotedblright");p(g,v,E,"°","\\degree",!0);p(q,v,E,"°","\\degree");p(q,v,E,"°","\\textdegree",!0);p(g,v,E,"£","\\pounds");p(g,v,E,"£","\\mathsterling",!0);p(q,v,E,"£","\\pounds");p(q,v,E,"£","\\textsterling",!0);p(g,M,E,"✠","\\maltese");p(q,M,E,"✠","\\maltese");var Ng='0123456789/@."';for(var fd=0;fd<Ng.length;fd++){var Eg=Ng.charAt(fd);p(g,v,E,Eg,Eg)}var Dg='0123456789!@*()-=+";:?/.,';for(var pd=0;pd<Dg.length;pd++){var Og=Dg.charAt(pd);p(q,v,E,Og,Og)}var gc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var md=0;md<gc.length;md++){var E0=gc.charAt(md);p(g,v,ie,E0,E0),p(q,v,E,E0,E0)}p(g,M,E,"C","ℂ");p(q,M,E,"C","ℂ");p(g,M,E,"H","ℍ");p(q,M,E,"H","ℍ");p(g,M,E,"N","ℕ");p(q,M,E,"N","ℕ");p(g,M,E,"P","ℙ");p(q,M,E,"P","ℙ");p(g,M,E,"Q","ℚ");p(q,M,E,"Q","ℚ");p(g,M,E,"R","ℝ");p(q,M,E,"R","ℝ");p(g,M,E,"Z","ℤ");p(q,M,E,"Z","ℤ");p(g,v,ie,"h","ℎ");p(q,v,ie,"h","ℎ");var ae;for(var yt=0;yt<gc.length;yt++){var He=gc.charAt(yt);ae=String.fromCharCode(55349,56320+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56372+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56424+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56580+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56684+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56736+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56788+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56840+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56944+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),yt<26&&(ae=String.fromCharCode(55349,56632+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae),ae=String.fromCharCode(55349,56476+yt),p(g,v,ie,He,ae),p(q,v,E,He,ae))}ae="𝕜";p(g,v,ie,"k",ae);p(q,v,E,"k",ae);for(var pi=0;pi<10;pi++){var Dn=pi.toString();ae=String.fromCharCode(55349,57294+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57314+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57324+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae),ae=String.fromCharCode(55349,57334+pi),p(g,v,ie,Dn,ae),p(q,v,E,Dn,ae)}var Sh="ÐÞþ";for(var gd=0;gd<Sh.length;gd++){var D0=Sh.charAt(gd);p(g,v,ie,D0,D0),p(q,v,E,D0,D0)}var Ch={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},Rg={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},Ig={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},hT={mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},vi={mathClass:"",textClass:"",font:""},zg={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},Lg={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},Bg={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},Mh={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},Th={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},Pg={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},Ah={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},Fg=[Ch,Ch,Rg,Rg,Ig,Ig,hT,vi,vi,vi,zg,zg,Lg,Lg,Bg,Bg,Mh,Mh,Th,Th,Pg,Pg,vi,vi,Ah,Ah],fT=[Ch,vi,Mh,Th,Ah],pT=r=>{var e=r.charCodeAt(0),t=r.charCodeAt(1),n=(e-55296)*1024+(t-56320)+65536;if(119808<=n&&n<120484){var i=Math.floor((n-119808)/26);return Fg[i]}else if(120782<=n&&n<=120831){var o=Math.floor((n-120782)/10);return fT[o]}else{if(n===120485||n===120486)return Fg[0];if(120486<n&&n<120782)return vi;throw new V("Unsupported character: "+r)}},ru=function(e,t,n){if(Ie[n][e]){var i=Ie[n][e].replace;i&&(e=i)}return{value:e,metrics:Bp(e,t,n)}},bt=function(e,t,n,i,o){var s=ru(e,t,n),a=s.metrics;e=s.value;var l;if(a){var c=a.italic;(n==="text"||i&&i.font==="mathit")&&(c=0),l=new Wt(e,a.height,a.depth,c,a.skew,a.width,o)}else typeof console<"u"&&console.warn("No character metrics "+("for '"+e+"' in style '"+t+"' and mode '"+n+"'")),l=new Wt(e,0,0,0,0,0,o);if(i){l.maxFontSize=i.sizeMultiplier,i.style.isTight()&&l.classes.push("mtight");var u=i.getColor();u&&(l.style.color=u)}return l},Pp=function(e,t,n,i){return i===void 0&&(i=[]),n.font==="boldsymbol"&&ru(e,"Main-Bold",t).metrics?bt(e,"Main-Bold",t,n,i.concat(["mathbf"])):e==="\\"||Ie[t][e].font==="main"?bt(e,"Main-Regular",t,n,i):bt(e,"AMS-Regular",t,n,i.concat(["amsrm"]))},mT=function(e,t,n){return n!=="textord"&&ru(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}},nu=function(e,t){var n=e.type==="mathord"?"mathord":"textord",i=e.mode,o=e.text,s=["mord"],{font:a,fontFamily:l,fontWeight:c,fontShape:u}=t,d=i==="math"||i==="text"&&!!a,h=d?a:l,f="",m="";if(o.charCodeAt(0)===55349){var y=pT(o);f=y.font,m=y[i+"Class"]}if(f)return bt(o,f,i,t,s.concat(m));if(h){var x,b;if(h==="boldsymbol"){var S=mT(o,i,n);x=S.fontName,b=[S.fontClass]}else d?(x=Nh[a].fontName,b=[a]):(x=O0(l,c,u),b=[l,c,u]);if(ru(o,x,i).metrics)return bt(o,x,i,t,s.concat(b));if(v6.hasOwnProperty(o)&&x.slice(0,10)==="Typewriter"){for(var A=[],D=0;D<o.length;D++)A.push(bt(o[D],x,i,t,s.concat(b)));return Sn(A)}}if(n==="mathord")return bt(o,"Math-Italic",i,t,s.concat(["mathnormal"]));if(n==="textord"){var O=Ie[i][o]&&Ie[i][o].font;if(O==="ams"){var L=O0("amsrm",c,u);return bt(o,L,i,t,s.concat("amsrm",c,u))}else if(O==="main"||!O){var N=O0("textrm",c,u);return bt(o,N,i,t,s.concat(c,u))}else{var j=O0(O,c,u);return bt(o,j,i,t,s.concat(j,c,u))}}else throw new Error("unexpected type: "+n+" in makeOrd")},gT=(r,e)=>{if(Xn(r.classes)!==Xn(e.classes)||r.skew!==e.skew||r.maxFontSize!==e.maxFontSize||r.italic!==0&&r.hasClass("mathnormal"))return!1;if(r.classes.length===1){var t=r.classes[0];if(t==="mbin"||t==="mord")return!1}for(var n of Object.keys(r.style))if(r.style[n]!==e.style[n])return!1;for(var i of Object.keys(e.style))if(r.style[i]!==e.style[i])return!1;return!0},b6=r=>{for(var e=0;e<r.length-1;e++){var t=r[e],n=r[e+1];t instanceof Wt&&n instanceof Wt&&gT(t,n)&&(t.text+=n.text,t.height=Math.max(t.height,n.height),t.depth=Math.max(t.depth,n.depth),t.italic=n.italic,r.splice(e+1,1),e--)}return r},Fp=function(e){for(var t=0,n=0,i=0,o=0;o<e.children.length;o++){var s=e.children[o];s.height>t&&(t=s.height),s.depth>n&&(n=s.depth),s.maxFontSize>i&&(i=s.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=i},$=function(e,t,n,i){var o=new _s(e,t,n,i);return Fp(o),o},Qn=(r,e,t,n)=>new _s(r,e,t,n),Ts=function(e,t,n){var i=$([e],[],t);return i.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i.style.borderBottomWidth=G(i.height),i.maxFontSize=1,i},yT=function(e,t,n,i){var o=new tu(e,t,n,i);return Fp(o),o},Sn=function(e){var t=new Hs(e);return Fp(t),t},As=function(e,t){return e instanceof Hs?$([],[e],t):e},vT=function(e){if(e.positionType==="individualShift"){for(var t=e.children,n=[t[0]],i=-t[0].shift-t[0].elem.depth,o=i,s=1;s<t.length;s++){var a=-t[s].shift-o-t[s].elem.depth,l=a-(t[s-1].elem.height+t[s-1].elem.depth);o=o+a,n.push({type:"kern",size:l}),n.push(t[s])}return{children:n,depth:i}}var c;if(e.positionType==="top"){for(var u=e.positionData,d=0;d<e.children.length;d++){var h=e.children[d];u-=h.type==="kern"?h.size:h.elem.height+h.elem.depth}c=u}else if(e.positionType==="bottom")c=-e.positionData;else{var f=e.children[0];if(f.type!=="elem")throw new Error('First child must have type "elem".');if(e.positionType==="shift")c=-f.elem.depth-e.positionData;else if(e.positionType==="firstBaseline")c=-f.elem.depth;else throw new Error("Invalid positionType "+e.positionType+".")}return{children:e.children,depth:c}},be=function(e,t){for(var{children:n,depth:i}=vT(e),o=0,s=0;s<n.length;s++){var a=n[s];if(a.type==="elem"){var l=a.elem;o=Math.max(o,l.maxFontSize,l.height)}}o+=2;var c=$(["pstrut"],[]);c.style.height=G(o);for(var u=[],d=i,h=i,f=i,m=0;m<n.length;m++){var y=n[m];if(y.type==="kern")f+=y.size;else{var x=y.elem,b=y.wrapperClasses||[],S=y.wrapperStyle||{},A=$(b,[c,x],void 0,S);A.style.top=G(-o-f-x.depth),y.marginLeft&&(A.style.marginLeft=y.marginLeft),y.marginRight&&(A.style.marginRight=y.marginRight),u.push(A),f+=x.height+x.depth}d=Math.min(d,f),h=Math.max(h,f)}var D=$(["vlist"],u);D.style.height=G(h);var O;if(d<0){var L=$([],[]),N=$(["vlist"],[L]);N.style.height=G(-d);var j=$(["vlist-s"],[new Wt("​")]);O=[$(["vlist-r"],[D,j]),$(["vlist-r"],[N])]}else O=[$(["vlist-r"],[D])];var K=$(["vlist-t"],O);return O.length===2&&K.classes.push("vlist-t2"),K.height=h,K.depth=-d,K},w6=(r,e)=>{var t=$(["mspace"],[],e),n=Pe(r,e);return t.style.marginRight=G(n),t},O0=(r,e,t)=>{var n,i;switch(r){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=r}return e==="textbf"&&t==="textit"?i="BoldItalic":e==="textbf"?i="Bold":t==="textit"?i="Italic":i="Regular",n+"-"+i},Nh={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},x6={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},k6=function(e,t){var[n,i,o]=x6[e],s=new Zn(n),a=new bn([s],{width:G(i),height:G(o),style:"width:"+G(i),viewBox:"0 0 "+1e3*i+" "+1e3*o,preserveAspectRatio:"xMinYMin"}),l=Qn(["overlay"],[a],t);return l.height=o,l.style.height=G(o),l.style.width=G(i),l},Be={number:3,unit:"mu"},mi={number:4,unit:"mu"},Jr={number:5,unit:"mu"},bT={mord:{mop:Be,mbin:mi,mrel:Jr,minner:Be},mop:{mord:Be,mop:Be,mrel:Jr,minner:Be},mbin:{mord:mi,mop:mi,mopen:mi,minner:mi},mrel:{mord:Jr,mop:Jr,mopen:Jr,minner:Jr},mopen:{},mclose:{mop:Be,mbin:mi,mrel:Jr,minner:Be},mpunct:{mord:Be,mop:Be,mrel:Jr,mopen:Be,mclose:Be,mpunct:Be,minner:Be},minner:{mord:Be,mop:Be,mbin:mi,mrel:Jr,mopen:Be,mpunct:Be,minner:Be}},wT={mord:{mop:Be},mop:{mord:Be,mop:Be},mbin:{},mrel:{},mopen:{},mclose:{mop:Be},mpunct:{},minner:{mop:Be}},S6={},$a={},Va={};function X(r){for(var{type:e,names:t,htmlBuilder:n,mathmlBuilder:i}=r,o=0;o<t.length;++o)S6[t[o]]=r;e&&(n&&($a[e]=n),i&&(Va[e]=i))}function io(r){var{type:e,htmlBuilder:t,mathmlBuilder:n}=r;t&&($a[e]=t),n&&(Va[e]=n)}var yc=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},Ye=function(e){return e.type==="ordgroup"?e.body:[e]},xT=new Set(["leftmost","mbin","mopen","mrel","mop","mpunct"]),kT=new Set(["rightmost","mrel","mclose","mpunct"]),ST={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT},CT={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},tt=function(e,t,n,i){i===void 0&&(i=[null,null]);for(var o=[],s=0;s<e.length;s++){var a=we(e[s],t);if(a instanceof Hs){var l=a.children;o.push(...l)}else o.push(a)}if(b6(o),!n)return o;var c=t;if(e.length===1){var u=e[0];u.type==="sizing"?c=t.havingSize(u.size):u.type==="styling"&&(c=t.havingStyle(ST[u.style]))}var d=$([i[0]||"leftmost"],[],t),h=$([i[1]||"rightmost"],[],t),f=n==="root";return Eh(o,(m,y)=>{var x=y.classes[0],b=m.classes[0];x==="mbin"&&kT.has(b)?y.classes[0]="mord":b==="mbin"&&xT.has(x)&&(m.classes[0]="mord")},{node:d},h,f),Eh(o,(m,y)=>{var x,b,S=Oh(y),A=Oh(m),D=S&&A?m.hasClass("mtight")?(x=wT[S])==null?void 0:x[A]:(b=bT[S])==null?void 0:b[A]:null;if(D)return w6(D,c)},{node:d},h,f),o},Eh=function(e,t,n,i,o){i&&e.push(i);for(var s=0;s<e.length;s++){var a=e[s],l=C6(a);if(l){Eh(l.children,t,n,null,o);continue}var c=!a.hasClass("mspace");if(c){var u=t(a,n.node);u&&(n.insertAfter?n.insertAfter(u):(e.unshift(u),s++))}c?n.node=a:o&&a.hasClass("newline")&&(n.node=$(["leftmost"])),n.insertAfter=(d=>h=>{e.splice(d+1,0,h),s++})(s)}i&&e.pop()},C6=function(e){return e instanceof Hs||e instanceof tu||e instanceof _s&&e.hasClass("enclosing")?e:null},Dh=function(e,t){var n=C6(e);if(n){var i=n.children;if(i.length){if(t==="right")return Dh(i[i.length-1],"right");if(t==="left")return Dh(i[0],"left")}}return e},Oh=function(e,t){if(!e)return null;t&&(e=Dh(e,t));var n=e.classes[0];return CT[n]||null},Wa=function(e,t){var n=["nulldelimiter"].concat(e.baseSizingClasses());return $(t.concat(n))},we=function(e,t,n){if(!e)return $();if($a[e.type]){var i=$a[e.type](e,t);if(n&&t.size!==n.size){i=$(t.sizingClasses(n),[i],t);var o=t.sizeMultiplier/n.sizeMultiplier;i.height*=o,i.depth*=o}return i}else throw new V("Got group of unknown type: '"+e.type+"'")};function R0(r,e){var t=$(["base"],r,e),n=$(["strut"]);return n.style.height=G(t.height+t.depth),t.depth&&(n.style.verticalAlign=G(-t.depth)),t.children.unshift(n),t}function Rh(r,e){var t=null;r.length===1&&r[0].type==="tag"&&(t=r[0].tag,r=r[0].body);var n=tt(r,e,"root"),i;n.length===2&&n[1].hasClass("tag")&&(i=n.pop());for(var o=[],s=[],a=0;a<n.length;a++)if(s.push(n[a]),n[a].hasClass("mbin")||n[a].hasClass("mrel")||n[a].hasClass("allowbreak")){for(var l=!1;a<n.length-1&&n[a+1].hasClass("mspace")&&!n[a+1].hasClass("newline");)a++,s.push(n[a]),n[a].hasClass("nobreak")&&(l=!0);l||(o.push(R0(s,e)),s=[])}else n[a].hasClass("newline")&&(s.pop(),s.length>0&&(o.push(R0(s,e)),s=[]),o.push(n[a]));s.length>0&&o.push(R0(s,e));var c;t?(c=R0(tt(t,e,!0),e),c.classes=["tag"],o.push(c)):i&&o.push(i);var u=$(["katex-html"],o);if(u.setAttribute("aria-hidden","true"),c){var d=c.children[0];d.style.height=G(u.height+u.depth),u.depth&&(d.style.verticalAlign=G(-u.depth))}return u}function M6(r){return new Hs(r)}class W{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=Xn(this.classes));for(var n=0;n<this.children.length;n++)if(this.children[n]instanceof Je&&this.children[n+1]instanceof Je){for(var i=this.children[n].toText()+this.children[++n].toText();this.children[n+1]instanceof Je;)i+=this.children[++n].toText();e.appendChild(new Je(i).toNode())}else e.appendChild(this.children[n].toNode());return e}toMarkup(){var e="<"+this.type;for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="',e+=ht(this.attributes[t]),e+='"');this.classes.length>0&&(e+=' class ="'+ht(Xn(this.classes))+'"'),e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</"+this.type+">",e}toText(){return this.children.map(e=>e.toText()).join("")}}class Je{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ht(this.toText())}toText(){return this.text}}class T6{constructor(e){this.width=void 0,this.character=void 0,this.width=e,e>=.05555&&e<=.05556?this.character=" ":e>=.1666&&e<=.1667?this.character=" ":e>=.2222&&e<=.2223?this.character=" ":e>=.2777&&e<=.2778?this.character="  ":e>=-.05556&&e<=-.05555?this.character=" ⁣":e>=-.1667&&e<=-.1666?this.character=" ⁣":e>=-.2223&&e<=-.2222?this.character=" ⁣":e>=-.2778&&e<=-.2777?this.character=" ⁣":this.character=null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",G(this.width)),e}toMarkup(){return this.character?"<mtext>"+this.character+"</mtext>":'<mspace width="'+G(this.width)+'"/>'}toText(){return this.character?this.character:" "}}var MT=new Set(["\\imath","\\jmath"]),TT=new Set(["mrow","mtable"]),ur=function(e,t,n){return Ie[t][e]&&Ie[t][e].replace&&e.charCodeAt(0)!==55349&&!(v6.hasOwnProperty(e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt"))&&(e=Ie[t][e].replace),new Je(e)},Hp=function(e){return e.length===1?e[0]:new W("mrow",e)},AT={mathit:"italic",boldsymbol:r=>r.type==="textord"?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},_p=(r,e)=>{if(r.mode==="text"){if(e.fontFamily==="texttt")return"monospace";if(e.fontFamily==="textsf")return e.fontShape==="textit"&&e.fontWeight==="textbf"?"sans-serif-bold-italic":e.fontShape==="textit"?"sans-serif-italic":e.fontWeight==="textbf"?"bold-sans-serif":"sans-serif";if(e.fontShape==="textit"&&e.fontWeight==="textbf")return"bold-italic";if(e.fontShape==="textit")return"italic";if(e.fontWeight==="textbf")return"bold"}var t=e.font;if(!t||t==="mathnormal")return null;var n=r.mode,i=AT[t];if(i)return typeof i=="function"?i(r):i;var o=r.text;if(MT.has(o))return null;if(Ie[n][o]){var s=Ie[n][o].replace;s&&(o=s)}var a=Nh[t].fontName;return Bp(o,a,n)?Nh[t].variant:null};function yd(r){if(!r)return!1;if(r.type==="mi"&&r.children.length===1){var e=r.children[0];return e instanceof Je&&e.text==="."}else if(r.type==="mo"&&r.children.length===1&&r.getAttribute("separator")==="true"&&r.getAttribute("lspace")==="0em"&&r.getAttribute("rspace")==="0em"){var t=r.children[0];return t instanceof Je&&t.text===","}else return!1}var Yt=function(e,t,n){if(e.length===1){var i=Ne(e[0],t);return n&&i instanceof W&&i.type==="mo"&&(i.setAttribute("lspace","0em"),i.setAttribute("rspace","0em")),[i]}for(var o=[],s,a=0;a<e.length;a++){var l=Ne(e[a],t);if(l instanceof W&&s instanceof W){if(l.type==="mtext"&&s.type==="mtext"&&l.getAttribute("mathvariant")===s.getAttribute("mathvariant")){s.children.push(...l.children);continue}else if(l.type==="mn"&&s.type==="mn"){s.children.push(...l.children);continue}else if(yd(l)&&s.type==="mn"){s.children.push(...l.children);continue}else if(l.type==="mn"&&yd(s))l.children=[...s.children,...l.children],o.pop();else if((l.type==="msup"||l.type==="msub")&&l.children.length>=1&&(s.type==="mn"||yd(s))){var c=l.children[0];c instanceof W&&c.type==="mn"&&(c.children=[...s.children,...c.children],o.pop())}else if(s.type==="mi"&&s.children.length===1){var u=s.children[0];if(u instanceof Je&&u.text==="̸"&&(l.type==="mo"||l.type==="mi"||l.type==="mn")){var d=l.children[0];d instanceof Je&&d.text.length>0&&(d.text=d.text.slice(0,1)+"̸"+d.text.slice(1),o.pop())}}}o.push(l),s=l}return o},ei=function(e,t,n){return Hp(Yt(e,t,n))},Ne=function(e,t){if(!e)return new W("mrow");if(Va[e.type])return Va[e.type](e,t);throw new V("Got group of unknown type: '"+e.type+"'")};function Hg(r,e,t,n,i){var o=Yt(r,t),s;o.length===1&&o[0]instanceof W&&TT.has(o[0].type)?s=o[0]:s=new W("mrow",o);var a=new W("annotation",[new Je(e)]);a.setAttribute("encoding","application/x-tex");var l=new W("semantics",[s,a]),c=new W("math",[l]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");var u=i?"katex":"katex-mathml";return $([u],[c])}var NT=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],_g=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],qg=function(e,t){return t.size<2?e:NT[e-1][t.size-1]};class en{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||en.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=_g[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new en(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:qg(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:_g[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=qg(en.BASESIZE,e);return this.size===t&&this.textSize===en.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==en.BASESIZE?["sizing","reset-size"+this.size,"size"+en.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=dT(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}en.BASESIZE=6;var A6=function(e){return new en({style:e.displayMode?de.DISPLAY:de.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},N6=function(e,t){if(t.displayMode){var n=["katex-display"];t.leqno&&n.push("leqno"),t.fleqn&&n.push("fleqn"),e=$(n,[e])}return e},ET=function(e,t,n){var i=A6(n),o;if(n.output==="mathml")return Hg(e,t,i,n.displayMode,!0);if(n.output==="html"){var s=Rh(e,i);o=$(["katex"],[s])}else{var a=Hg(e,t,i,n.displayMode,!1),l=Rh(e,i);o=$(["katex"],[a,l])}return N6(o,n)},DT=function(e,t,n){var i=A6(n),o=Rh(e,i),s=$(["katex"],[o]);return N6(s,n)},OT={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",underbracket:"⎵",overbracket:"⎴",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xrightleftarrows:"⇄",xrightequilibrium:"⇌",xleftequilibrium:"⇋","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="},iu=function(e){var t=new W("mo",[new Je(OT[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},RT={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},IT=new Set(["widehat","widecheck","widetilde","utilde"]),ou=function(e,t){function n(){var a=4e5,l=e.label.slice(1);if(IT.has(l)&&"base"in e){var c=e.base.type==="ordgroup"?e.base.body.length:1,u,d,h;if(c>5)l==="widehat"||l==="widecheck"?(u=420,a=2364,h=.42,d=l+"4"):(u=312,a=2340,h=.34,d="tilde4");else{var f=[1,1,2,2,3,3][c];l==="widehat"||l==="widecheck"?(a=[0,1062,2364,2364,2364][f],u=[0,239,300,360,420][f],h=[0,.24,.3,.3,.36,.42][f],d=l+f):(a=[0,600,1033,2339,2340][f],u=[0,260,286,306,312][f],h=[0,.26,.286,.3,.306,.34][f],d="tilde"+f)}var m=new Zn(d),y=new bn([m],{width:"100%",height:G(h),viewBox:"0 0 "+a+" "+u,preserveAspectRatio:"none"});return{span:Qn([],[y],t),minWidth:0,height:h}}else{var x=[],b=RT[l];if(!b)throw new Error('No SVG data for "'+l+'".');var[S,A,D]=b,O=D/1e3,L=S.length,N,j;if(L===1){if(b.length!==4)throw new Error('Expected 4-tuple for single-path SVG data "'+l+'".');N=["hide-tail"],j=[b[3]]}else if(L===2)N=["halfarrow-left","halfarrow-right"],j=["xMinYMin","xMaxYMin"];else if(L===3)N=["brace-left","brace-center","brace-right"],j=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support
1131
+ `+L+" children.");for(var K=0;K<L;K++){var ne=new Zn(S[K]),pe=new bn([ne],{width:"400em",height:G(O),viewBox:"0 0 "+a+" "+D,preserveAspectRatio:j[K]+" slice"}),se=Qn([N[K]],[pe],t);if(L===1)return{span:se,minWidth:A,height:O};se.style.height=G(O),x.push(se)}return{span:$(["stretchy"],x,t),minWidth:A,height:O}}}var{span:i,minWidth:o,height:s}=n();return i.height=s,i.style.height=G(s),o>0&&(i.style.minWidth=G(o)),i},zT=function(e,t,n,i,o){var s,a=e.height+e.depth+n+i;if(/fbox|color|angl/.test(t)){if(s=$(["stretchy",t],[],o),t==="fbox"){var l=o.color&&o.getColor();l&&(s.style.borderColor=l)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new kh({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&c.push(new kh({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var u=new bn(c,{width:"100%",height:G(a)});s=Qn([],[u],o)}return s.height=a,s.style.height=G(a),s},LT={bin:1,close:1,inner:1,open:1,punct:1,rel:1},BT={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1};function PT(r){return r in LT}function he(r,e){if(!r||r.type!==e)throw new Error("Expected node of type "+e+", but got "+(r?"node of type "+r.type:String(r)));return r}function su(r){var e=au(r);if(!e)throw new Error("Expected node of symbol group type, but got "+(r?"node of type "+r.type:String(r)));return e}function au(r){return r&&(r.type==="atom"||BT.hasOwnProperty(r.type))?r:null}var E6=r=>{if(r instanceof Wt)return r;if(cT(r)&&r.children.length===1)return E6(r.children[0])},D6=(r,e)=>{var t,n,i;r&&r.type==="supsub"?(n=he(r.base,"accent"),t=n.base,r.base=t,i=lT(we(r,e)),r.base=n):(n=he(r,"accent"),t=n.base);var o=we(t,e.havingCrampedStyle()),s=n.isShifty&&xn(t),a=0;if(s){var l,c;a=(l=(c=E6(o))==null?void 0:c.skew)!=null?l:0}var u=n.label==="\\c",d=u?o.height+o.depth:Math.min(o.height,e.fontMetrics().xHeight),h;if(n.isStretchy)h=ou(n,e),h=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:a>0?{width:"calc(100% - "+G(2*a)+")",marginLeft:G(2*a)}:void 0}]});else{var f,m;n.label==="\\vec"?(f=k6("vec",e),m=x6.vec[1]):(f=nu({type:"textord",mode:n.mode,text:n.label},e),f=aT(f),f.italic=0,m=f.width,u&&(d+=f.depth)),h=$(["accent-body"],[f]);var y=n.label==="\\textcircled";y&&(h.classes.push("accent-full"),d=o.height);var x=a;y||(x-=m/2),h.style.left=G(x),n.label==="\\textcircled"&&(h.style.top=".2em"),h=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:-d},{type:"elem",elem:h}]})}var b=$(["mord","accent"],[h],e);return i?(i.children[0]=b,i.height=Math.max(b.height,i.height),i.classes[0]="mord",i):b},FT=(r,e)=>{var t=r.isStretchy?iu(r.label):new W("mo",[ur(r.label,r.mode)]),n=new W("mover",[Ne(r.base,e),t]);return n.setAttribute("accent","true"),n},HT=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(r=>"\\"+r).join("|"));X({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],numArgs:1,handler:(r,e)=>{var t=yc(e[0]),n=!HT.test(r.funcName),i=!n||r.funcName==="\\widehat"||r.funcName==="\\widetilde"||r.funcName==="\\widecheck";return{type:"accent",mode:r.parser.mode,label:r.funcName,isStretchy:n,isShifty:i,base:t}},htmlBuilder:D6,mathmlBuilder:FT});X({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"],handler:(r,e)=>{var t=e[0],n=r.parser.mode;return n==="math"&&(r.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+r.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:r.funcName,isStretchy:!1,isShifty:!0,base:t}}});X({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],numArgs:1,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"accentUnder",mode:t.mode,label:n,base:i}},htmlBuilder:(r,e)=>{var t=we(r.base,e),n=ou(r,e),i=r.label==="\\utilde"?.12:0,o=be({positionType:"top",positionData:t.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:t}]});return $(["mord","accentunder"],[o],e)},mathmlBuilder:(r,e)=>{var t=iu(r.label),n=new W("munder",[Ne(r.base,e),t]);return n.setAttribute("accentunder","true"),n}});var I0=r=>{var e=new W("mpadded",r?[r]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};X({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],numArgs:1,numOptionalArgs:1,handler(r,e,t){var{parser:n,funcName:i}=r;return{type:"xArrow",mode:n.mode,label:i,body:e[0],below:t[0]}},htmlBuilder(r,e){var t=e.style,n=e.havingStyle(t.sup()),i=As(we(r.body,n,e),e),o=r.label.slice(0,2)==="\\x"?"x":"cd";i.classes.push(o+"-arrow-pad");var s;r.below&&(n=e.havingStyle(t.sub()),s=As(we(r.below,n,e),e),s.classes.push(o+"-arrow-pad"));var a=ou(r,e),l=-e.fontMetrics().axisHeight+.5*a.height,c=-e.fontMetrics().axisHeight-.5*a.height-.111;(i.depth>.25||r.label==="\\xleftequilibrium")&&(c-=i.depth);var u;if(s){var d=-e.fontMetrics().axisHeight+s.height+.5*a.height+.111;u=be({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]},{type:"elem",elem:s,shift:d}]})}else u=be({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]}]});return $(["mrel","x-arrow"],[u],e)},mathmlBuilder(r,e){var t=iu(r.label);t.setAttribute("minsize",r.label.charAt(0)==="x"?"1.75em":"3.0em");var n;if(r.body){var i=I0(Ne(r.body,e));if(r.below){var o=I0(Ne(r.below,e));n=new W("munderover",[t,o,i])}else n=new W("mover",[t,i])}else if(r.below){var s=I0(Ne(r.below,e));n=new W("munder",[t,s])}else n=I0(),n=new W("mover",[t,n]);return n}});function _T(r,e){var t=tt(r.body,e,!0);return $([r.mclass],t,e)}function qT(r,e){var t,n=Yt(r.body,e);return r.mclass==="minner"?t=new W("mpadded",n):r.mclass==="mord"?r.isCharacterBox?(t=n[0],t.type="mi"):t=new W("mi",n):(r.isCharacterBox?(t=n[0],t.type="mo"):t=new W("mo",n),r.mclass==="mbin"?(t.attributes.lspace="0.22em",t.attributes.rspace="0.22em"):r.mclass==="mpunct"?(t.attributes.lspace="0em",t.attributes.rspace="0.17em"):(r.mclass==="mopen"||r.mclass==="mclose")&&(t.attributes.lspace="0em",t.attributes.rspace="0em")),t}X({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],numArgs:1,primitive:!0,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"mclass",mode:t.mode,mclass:"m"+n.slice(5),body:Ye(i),isCharacterBox:xn(i)}},htmlBuilder:_T,mathmlBuilder:qT});var lu=r=>{var e=r.type==="ordgroup"&&r.body.length?r.body[0]:r;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};X({type:"mclass",names:["\\@binrel"],numArgs:2,handler(r,e){var{parser:t}=r;return{type:"mclass",mode:t.mode,mclass:lu(e[0]),body:Ye(e[1]),isCharacterBox:xn(e[1])}}});X({type:"mclass",names:["\\stackrel","\\overset","\\underset"],numArgs:2,handler(r,e){var{parser:t,funcName:n}=r,i=e[1],o=e[0],s;n!=="\\stackrel"?s=lu(i):s="mrel";var a={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:Ye(i)},l=n==="\\underset"?{type:"supsub",mode:o.mode,base:a,sub:o}:{type:"supsub",mode:o.mode,base:a,sup:o};return{type:"mclass",mode:t.mode,mclass:s,body:[l],isCharacterBox:xn(l)}}});X({type:"pmb",names:["\\pmb"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"pmb",mode:t.mode,mclass:lu(e[0]),body:Ye(e[0])}},htmlBuilder(r,e){var t=tt(r.body,e,!0),n=$([r.mclass],t,e);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(r,e){var t=Yt(r.body,e),n=new W("mstyle",t);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});var jT={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},jg=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),$g=r=>r.type==="textord"&&r.text==="@",$T=(r,e)=>(r.type==="mathord"||r.type==="atom")&&r.text===e;function VT(r,e,t){var n=jT[r];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return t.callFunction(n,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var i=t.callFunction("\\\\cdleft",[e[0]],[]),o={type:"atom",text:n,mode:"math",family:"rel"},s=t.callFunction("\\Big",[o],[]),a=t.callFunction("\\\\cdright",[e[1]],[]),l={type:"ordgroup",mode:"math",body:[i,s,a]};return t.callFunction("\\\\cdparent",[l],[])}case"\\\\cdlongequal":return t.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var c={type:"textord",text:"\\Vert",mode:"math"};return t.callFunction("\\Big",[c],[])}default:return{type:"textord",text:" ",mode:"math"}}}function WT(r){var e=[];for(r.gullet.beginGroup(),r.gullet.macros.set("\\cr","\\\\\\relax"),r.gullet.beginGroup();;){e.push(r.parseExpression(!1,"\\\\")),r.gullet.endGroup(),r.gullet.beginGroup();var t=r.fetch().text;if(t==="&"||t==="\\\\")r.consume();else if(t==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new V("Expected \\\\ or \\cr or \\end",r.nextToken)}for(var n=[],i=[n],o=0;o<e.length;o++){for(var s=e[o],a=jg(),l=0;l<s.length;l++)if(!$g(s[l]))a.body.push(s[l]);else{n.push(a),l+=1;var c=su(s[l]).text,u=new Array(2);if(u[0]={type:"ordgroup",mode:"math",body:[]},u[1]={type:"ordgroup",mode:"math",body:[]},!"=|.".includes(c))if("<>AV".includes(c))for(var d=0;d<2;d++){for(var h=!0,f=l+1;f<s.length;f++){if($T(s[f],c)){h=!1,l=f;break}if($g(s[f]))throw new V("Missing a "+c+" character to complete a CD arrow.",s[f]);u[d].body.push(s[f])}if(h)throw new V("Missing a "+c+" character to complete a CD arrow.",s[l])}else throw new V('Expected one of "<>AV=|." after @',s[l]);var m=VT(c,u,r),y={type:"styling",body:[m],mode:"math",style:"display",resetFont:!0};n.push(y),a=jg()}o%2===0?n.push(a):n.shift(),n=[],i.push(n)}r.gullet.endGroup(),r.gullet.endGroup();var x=new Array(i[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:x,colSeparationType:"CD",hLinesBeforeRow:new Array(i.length+1).fill([])}}X({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r;return{type:"cdlabel",mode:t.mode,side:n.slice(4),label:e[0]}},htmlBuilder(r,e){var t=e.havingStyle(e.style.sup()),n=As(we(r.label,t,e),e);return n.classes.push("cd-label-"+r.side),n.style.bottom=G(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(r,e){var t=new W("mrow",[Ne(r.label,e)]);return t=new W("mpadded",[t]),t.setAttribute("width","0"),r.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new W("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});X({type:"cdlabelparent",names:["\\\\cdparent"],numArgs:1,handler(r,e){var{parser:t}=r;return{type:"cdlabelparent",mode:t.mode,fragment:e[0]}},htmlBuilder(r,e){var t=As(we(r.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(r,e){return new W("mrow",[Ne(r.fragment,e)])}});X({type:"textord",names:["\\@char"],numArgs:1,allowedInText:!0,handler(r,e){for(var{parser:t}=r,n=he(e[0],"ordgroup"),i=n.body,o="",s=0;s<i.length;s++){var a=he(i[s],"textord");o+=a.text}var l=parseInt(o),c;if(isNaN(l))throw new V("\\@char has non-numeric argument "+o);if(l<0||l>=1114111)throw new V("\\@char with invalid code point "+o);return l<=65535?c=String.fromCharCode(l):(l-=65536,c=String.fromCharCode((l>>10)+55296,(l&1023)+56320)),{type:"textord",mode:t.mode,text:c}}});var UT=(r,e)=>{var t=tt(r.body,e.withColor(r.color),!1);return Sn(t)},KT=(r,e)=>{var t=Yt(r.body,e.withColor(r.color)),n=new W("mstyle",t);return n.setAttribute("mathcolor",r.color),n};X({type:"color",names:["\\textcolor"],numArgs:2,allowedInText:!0,argTypes:["color","original"],handler(r,e){var{parser:t}=r,n=he(e[0],"color-token").color,i=e[1];return{type:"color",mode:t.mode,color:n,body:Ye(i)}},htmlBuilder:UT,mathmlBuilder:KT});X({type:"color",names:["\\color"],numArgs:1,allowedInText:!0,argTypes:["color"],handler(r,e){var{parser:t,breakOnTokenText:n}=r,i=he(e[0],"color-token").color;t.gullet.macros.set("\\current@color",i);var o=t.parseExpression(!0,n);return{type:"color",mode:t.mode,color:i,body:o}}});X({type:"cr",names:["\\\\"],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(r,e,t){var{parser:n}=r,i=n.gullet.future().text==="["?n.parseSizeGroup(!0):null,o=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:o,size:i&&he(i,"size").value}},htmlBuilder(r,e){var t=$(["mspace"],[],e);return r.newLine&&(t.classes.push("newline"),r.size&&(t.style.marginTop=G(Pe(r.size,e)))),t},mathmlBuilder(r,e){var t=new W("mspace");return r.newLine&&(t.setAttribute("linebreak","newline"),r.size&&t.setAttribute("height",G(Pe(r.size,e)))),t}});var Ih={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},O6=r=>{var e=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new V("Expected a control sequence",r);return e},GT=r=>{var e=r.gullet.popToken();return e.text==="="&&(e=r.gullet.popToken(),e.text===" "&&(e=r.gullet.popToken())),e},R6=(r,e,t,n)=>{var i=r.gullet.macros.get(t.text);i==null&&(t.noexpand=!0,i={tokens:[t],numArgs:0,unexpandable:!r.gullet.isExpandable(t.text)}),r.gullet.macros.set(e,i,n)};X({type:"internal",names:["\\global","\\long","\\\\globallong"],numArgs:0,allowedInText:!0,handler(r){var{parser:e,funcName:t}=r;e.consumeSpaces();var n=e.fetch();if(Ih[n.text])return(t==="\\global"||t==="\\\\globallong")&&(n.text=Ih[n.text]),he(e.parseFunction(),"internal");throw new V("Invalid token after macro prefix",n)}});X({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=e.gullet.popToken(),i=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new V("Expected a control sequence",n);for(var o=0,s,a=[[]];e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){s=e.gullet.future(),a[o].push("{");break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new V('Invalid argument number "'+n.text+'"');if(parseInt(n.text)!==o+1)throw new V('Argument number "'+n.text+'" out of order');o++,a.push([])}else{if(n.text==="EOF")throw new V("Expected a macro definition");a[o].push(n.text)}var{tokens:l}=e.gullet.consumeArg();return s&&l.unshift(s),(t==="\\edef"||t==="\\xdef")&&(l=e.gullet.expandTokens(l),l.reverse()),e.gullet.macros.set(i,{tokens:l,numArgs:o,delimiters:a},t===Ih[t]),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\let","\\\\globallet"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=O6(e.gullet.popToken());e.gullet.consumeSpaces();var i=GT(e);return R6(e,n,i,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\futurelet","\\\\globalfuture"],numArgs:0,allowedInText:!0,primitive:!0,handler(r){var{parser:e,funcName:t}=r,n=O6(e.gullet.popToken()),i=e.gullet.popToken(),o=e.gullet.popToken();return R6(e,n,o,t==="\\\\globalfuture"),e.gullet.pushToken(o),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}});var ca=function(e,t,n){var i=Ie.math[e]&&Ie.math[e].replace,o=Bp(i||e,t,n);if(!o)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return o},qp=function(e,t,n,i){var o=n.havingBaseStyle(t),s=$(i.concat(o.sizingClasses(n)),[e],n),a=o.sizeMultiplier/n.sizeMultiplier;return s.height*=a,s.depth*=a,s.maxFontSize=o.sizeMultiplier,s},I6=function(e,t,n){var i=t.havingBaseStyle(n),o=(1-t.sizeMultiplier/i.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=G(o),e.height-=o,e.depth+=o},YT=function(e,t,n,i,o,s){var a=bt(e,"Main-Regular",o,i),l=qp(a,t,i,s);return I6(l,i,t),l},JT=function(e,t,n,i){return bt(e,"Size"+t+"-Regular",n,i)},z6=function(e,t,n,i,o,s){var a=JT(e,t,o,i),l=qp($(["delimsizing","size"+t],[a],i),de.TEXT,i,s);return n&&I6(l,i,de.TEXT),l},vd=function(e,t,n){var i;t==="Size1-Regular"?i="delim-size1":i="delim-size4";var o=$(["delimsizinginner",i],[$([],[bt(e,t,n)])]);return{type:"elem",elem:o}},bd=function(e,t,n){var i=Pr["Size4-Regular"][e.charCodeAt(0)]?Pr["Size4-Regular"][e.charCodeAt(0)][4]:Pr["Size1-Regular"][e.charCodeAt(0)][4],o=new Zn("inner",eT(e,Math.round(1e3*t))),s=new bn([o],{width:G(i),height:G(t),style:"width:"+G(i),viewBox:"0 0 "+1e3*i+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),a=Qn([],[s],n);return a.height=t,a.style.height=G(t),a.style.width=G(i),{type:"elem",elem:a}},zh=.008,z0={type:"kern",size:-1*zh},XT=new Set(["|","\\lvert","\\rvert","\\vert"]),ZT=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),L6=function(e,t,n,i,o,s){var a,l,c,u,d="",h=0;a=c=u=e,l=null;var f="Size1-Regular";e==="\\uparrow"?c=u="⏐":e==="\\Uparrow"?c=u="‖":e==="\\downarrow"?a=c="⏐":e==="\\Downarrow"?a=c="‖":e==="\\updownarrow"?(a="\\uparrow",c="⏐",u="\\downarrow"):e==="\\Updownarrow"?(a="\\Uparrow",c="‖",u="\\Downarrow"):XT.has(e)?(c="∣",d="vert",h=333):ZT.has(e)?(c="∥",d="doublevert",h=556):e==="["||e==="\\lbrack"?(a="⎡",c="⎢",u="⎣",f="Size4-Regular",d="lbrack",h=667):e==="]"||e==="\\rbrack"?(a="⎤",c="⎥",u="⎦",f="Size4-Regular",d="rbrack",h=667):e==="\\lfloor"||e==="⌊"?(c=a="⎢",u="⎣",f="Size4-Regular",d="lfloor",h=667):e==="\\lceil"||e==="⌈"?(a="⎡",c=u="⎢",f="Size4-Regular",d="lceil",h=667):e==="\\rfloor"||e==="⌋"?(c=a="⎥",u="⎦",f="Size4-Regular",d="rfloor",h=667):e==="\\rceil"||e==="⌉"?(a="⎤",c=u="⎥",f="Size4-Regular",d="rceil",h=667):e==="("||e==="\\lparen"?(a="⎛",c="⎜",u="⎝",f="Size4-Regular",d="lparen",h=875):e===")"||e==="\\rparen"?(a="⎞",c="⎟",u="⎠",f="Size4-Regular",d="rparen",h=875):e==="\\{"||e==="\\lbrace"?(a="⎧",l="⎨",u="⎩",c="⎪",f="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(a="⎫",l="⎬",u="⎭",c="⎪",f="Size4-Regular"):e==="\\lgroup"||e==="⟮"?(a="⎧",u="⎩",c="⎪",f="Size4-Regular"):e==="\\rgroup"||e==="⟯"?(a="⎫",u="⎭",c="⎪",f="Size4-Regular"):e==="\\lmoustache"||e==="⎰"?(a="⎧",u="⎭",c="⎪",f="Size4-Regular"):(e==="\\rmoustache"||e==="⎱")&&(a="⎫",u="⎩",c="⎪",f="Size4-Regular");var m=ca(a,f,o),y=m.height+m.depth,x=ca(c,f,o),b=x.height+x.depth,S=ca(u,f,o),A=S.height+S.depth,D=0,O=1;if(l!==null){var L=ca(l,f,o);D=L.height+L.depth,O=2}var N=y+A+D,j=Math.max(0,Math.ceil((t-N)/(O*b))),K=N+j*O*b,ne=i.fontMetrics().axisHeight;n&&(ne*=i.sizeMultiplier);var pe=K/2-ne,se=[];if(d.length>0){var lt=K-y-A,Re=Math.round(K*1e3),Ue=tT(d,Math.round(lt*1e3)),$e=new Zn(d,Ue),Bt=G(h/1e3),pr=G(Re/1e3),Cn=new bn([$e],{width:Bt,height:pr,viewBox:"0 0 "+h+" "+Re}),Jt=Qn([],[Cn],i);Jt.height=Re/1e3,Jt.style.width=Bt,Jt.style.height=pr,se.push({type:"elem",elem:Jt})}else{if(se.push(vd(u,f,o)),se.push(z0),l===null){var mr=K-y-A+2*zh;se.push(bd(c,mr,i))}else{var ai=(K-y-A-D)/2+2*zh;se.push(bd(c,ai,i)),se.push(z0),se.push(vd(l,f,o)),se.push(z0),se.push(bd(c,ai,i))}se.push(z0),se.push(vd(a,f,o))}var Pt=i.havingBaseStyle(de.TEXT),oo=be({positionType:"bottom",positionData:pe,children:se});return qp($(["delimsizing","mult"],[oo],Pt),de.TEXT,i,s)},wd=80,xd=.08,kd=function(e,t,n,i,o){var s=QM(e,i,n),a=new Zn(e,s),l=new bn([a],{width:"400em",height:G(t),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});return Qn(["hide-tail"],[l],o)},QT=function(e,t){var n=t.havingBaseSizing(),i=_6("\\surd",e*n.sizeMultiplier,H6,n),o=n.sizeMultiplier,s=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),a,l,c,u,d;return i.type==="small"?(u=1e3+1e3*s+wd,e<1?o=1:e<1.4&&(o=.7),l=(1+s+xd)/o,c=(1+s)/o,a=kd("sqrtMain",l,u,s,t),a.style.minWidth="0.853em",d=.833/o):i.type==="large"?(u=(1e3+wd)*Ca[i.size],c=(Ca[i.size]+s)/o,l=(Ca[i.size]+s+xd)/o,a=kd("sqrtSize"+i.size,l,u,s,t),a.style.minWidth="1.02em",d=1/o):(l=e+s+xd,c=e+s,u=Math.floor(1e3*e+s)+wd,a=kd("sqrtTall",l,u,s,t),a.style.minWidth="0.742em",d=1.056),a.height=c,a.style.height=G(l),{span:a,advanceWidth:d,ruleWidth:(t.fontMetrics().sqrtRuleThickness+s)*o}},B6=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"]),eA=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"]),P6=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Ca=[0,1.2,1.8,2.4,3],F6=function(e,t,n,i,o){if(e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle"),B6.has(e)||P6.has(e))return z6(e,t,!1,n,i,o);if(eA.has(e))return L6(e,Ca[t],!1,n,i,o);throw new V("Illegal delimiter: '"+e+"'")},tA=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],rA=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"stack"}],H6=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],nA=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";var t=e.type;throw new Error("Add support for delim type '"+t+"' here.")},_6=function(e,t,n,i){for(var o=Math.min(2,3-i.style.size),s=o;s<n.length;s++){var a=n[s];if(a.type==="stack")break;var l=ca(e,nA(a),"math"),c=l.height+l.depth;if(a.type==="small"){var u=i.havingBaseStyle(a.style);c*=u.sizeMultiplier}if(c>t)return a}return n[n.length-1]},Lh=function(e,t,n,i,o,s){e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle");var a;P6.has(e)?a=tA:B6.has(e)?a=H6:a=rA;var l=_6(e,t,a,i);return l.type==="small"?YT(e,l.style,n,i,o,s):l.type==="large"?z6(e,l.size,n,i,o,s):L6(e,t,n,i,o,s)},Sd=function(e,t,n,i,o,s){var a=i.fontMetrics().axisHeight*i.sizeMultiplier,l=901,c=5/i.fontMetrics().ptPerEm,u=Math.max(t-a,n+a),d=Math.max(u/500*l,2*u-c);return Lh(e,d,!0,i,o,s)},Vg={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},iA=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function Wg(r){return"isMiddle"in r}function cu(r,e){var t=au(r);if(t&&iA.has(t.text))return t;throw t?new V("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",r):new V("Invalid delimiter type '"+r.type+"'",r)}X({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],numArgs:1,argTypes:["primitive"],handler:(r,e)=>{var t=cu(e[0],r);return{type:"delimsizing",mode:r.parser.mode,size:Vg[r.funcName].size,mclass:Vg[r.funcName].mclass,delim:t.text}},htmlBuilder:(r,e)=>r.delim==="."?$([r.mclass]):F6(r.delim,r.size,e,r.mode,[r.mclass]),mathmlBuilder:r=>{var e=[];r.delim!=="."&&e.push(ur(r.delim,r.mode));var t=new W("mo",e);r.mclass==="mopen"||r.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var n=G(Ca[r.size]);return t.setAttribute("minsize",n),t.setAttribute("maxsize",n),t}});function Ug(r){if(!r.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}X({type:"leftright-right",names:["\\right"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=r.parser.gullet.macros.get("\\current@color");if(t&&typeof t!="string")throw new V("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:r.parser.mode,delim:cu(e[0],r).text,color:t}}});X({type:"leftright",names:["\\left"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=cu(e[0],r),n=r.parser;++n.leftrightDepth;var i=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);var o=he(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:i,left:t.text,right:o.delim,rightColor:o.color}},htmlBuilder:(r,e)=>{Ug(r);for(var t=tt(r.body,e,!0,["mopen","mclose"]),n=0,i=0,o=!1,s=0;s<t.length;s++){var a=t[s];Wg(a)?o=!0:(n=Math.max(t[s].height,n),i=Math.max(t[s].depth,i))}n*=e.sizeMultiplier,i*=e.sizeMultiplier;var l;if(r.left==="."?l=Wa(e,["mopen"]):l=Sd(r.left,n,i,e,r.mode,["mopen"]),t.unshift(l),o)for(var c=1;c<t.length;c++){var u=t[c];if(Wg(u)){var d=u.isMiddle;t[c]=Sd(d.delim,n,i,d.options,r.mode,[])}}var h;if(r.right===".")h=Wa(e,["mclose"]);else{var f=r.rightColor?e.withColor(r.rightColor):e;h=Sd(r.right,n,i,f,r.mode,["mclose"])}return t.push(h),$(["minner"],t,e)},mathmlBuilder:(r,e)=>{Ug(r);var t=Yt(r.body,e);if(r.left!=="."){var n=new W("mo",[ur(r.left,r.mode)]);n.setAttribute("fence","true"),t.unshift(n)}if(r.right!=="."){var i=new W("mo",[ur(r.right,r.mode)]);i.setAttribute("fence","true"),r.rightColor&&i.setAttribute("mathcolor",r.rightColor),t.push(i)}return Hp(t)}});X({type:"middle",names:["\\middle"],numArgs:1,primitive:!0,handler:(r,e)=>{var t=cu(e[0],r);if(!r.parser.leftrightDepth)throw new V("\\middle without preceding \\left",t);return{type:"middle",mode:r.parser.mode,delim:t.text}},htmlBuilder:(r,e)=>{var t;return r.delim==="."?t=Wa(e,[]):(t=F6(r.delim,1,e,r.mode,[]),t.isMiddle={delim:r.delim,options:e}),t},mathmlBuilder:(r,e)=>{var t=r.delim==="\\vert"||r.delim==="|"?ur("|","text"):ur(r.delim,r.mode),n=new W("mo",[t]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});var oA=(r,e)=>{var t=As(we(r.body,e),e),n=r.label.slice(1),i=e.sizeMultiplier,o,s,a=xn(r.body);if(n==="sout")o=$(["stretchy","sout"]),o.height=e.fontMetrics().defaultRuleThickness/i,s=-.5*e.fontMetrics().xHeight;else if(n==="phase"){var l=Pe({number:.6,unit:"pt"},e),c=Pe({number:.35,unit:"ex"},e),u=e.havingBaseSizing();i=i/u.sizeMultiplier;var d=t.height+t.depth+l+c;t.style.paddingLeft=G(d/2+l);var h=Math.floor(1e3*d*i),f=XM(h),m=new bn([new Zn("phase",f)],{width:"400em",height:G(h/1e3),viewBox:"0 0 400000 "+h,preserveAspectRatio:"xMinYMin slice"});o=Qn(["hide-tail"],[m],e),o.style.height=G(d),s=t.depth+l+c}else{/cancel/.test(n)?a||t.classes.push("cancel-pad"):n==="angl"?t.classes.push("anglpad"):t.classes.push("boxpad");var y,x,b=0;/box/.test(n)?(b=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),y=e.fontMetrics().fboxsep+(n==="colorbox"?0:b),x=y):n==="angl"?(b=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),y=4*b,x=Math.max(0,.25-t.depth)):(y=a?.2:0,x=y),o=zT(t,n,y,x,e),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=G(b)):n==="angl"&&b!==.049&&(o.style.borderTopWidth=G(b),o.style.borderRightWidth=G(b)),s=t.depth+x,r.backgroundColor&&(o.style.backgroundColor=r.backgroundColor,r.borderColor&&(o.style.borderColor=r.borderColor))}var S;if(r.backgroundColor)S=be({positionType:"individualShift",children:[{type:"elem",elem:o,shift:s},{type:"elem",elem:t,shift:0}]});else{var A=/cancel|phase/.test(n)?["svg-align"]:[];S=be({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:o,shift:s,wrapperClasses:A}]})}return/cancel/.test(n)&&(S.height=t.height,S.depth=t.depth),/cancel/.test(n)&&!a?$(["mord","cancel-lap"],[S],e):$(["mord"],[S],e)},sA=(r,e)=>{var t,n=new W(r.label.includes("colorbox")?"mpadded":"menclose",[Ne(r.body,e)]);switch(r.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(t=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*t+"pt"),n.setAttribute("height","+"+2*t+"pt"),n.setAttribute("lspace",t+"pt"),n.setAttribute("voffset",t+"pt"),r.label==="\\fcolorbox"){var i=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);n.setAttribute("style","border: "+G(i)+" solid "+r.borderColor)}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return r.backgroundColor&&n.setAttribute("mathbackground",r.backgroundColor),n};X({type:"enclose",names:["\\colorbox"],numArgs:2,allowedInText:!0,argTypes:["color","hbox"],handler(r,e,t){var{parser:n,funcName:i}=r,o=he(e[0],"color-token").color,s=e[1];return{type:"enclose",mode:n.mode,label:i,backgroundColor:o,body:s}},htmlBuilder:oA,mathmlBuilder:sA});X({type:"enclose",names:["\\fcolorbox"],numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"],handler(r,e,t){var{parser:n,funcName:i}=r,o=he(e[0],"color-token").color,s=he(e[1],"color-token").color,a=e[2];return{type:"enclose",mode:n.mode,label:i,backgroundColor:s,borderColor:o,body:a}}});X({type:"enclose",names:["\\fbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\fbox",body:e[0]}}});X({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"enclose",mode:t.mode,label:n,body:i}}});X({type:"enclose",names:["\\sout"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r;t.mode==="math"&&t.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");var i=e[0];return{type:"enclose",mode:t.mode,label:n,body:i}}});X({type:"enclose",names:["\\angl"],numArgs:1,argTypes:["hbox"],allowedInText:!1,handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\angl",body:e[0]}}});var q6={};function Ur(r){for(var{type:e,names:t,props:n,handler:i,htmlBuilder:o,mathmlBuilder:s}=r,a={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},l=0;l<t.length;++l)q6[t[l]]=a;o&&($a[e]=o),s&&(Va[e]=s)}var j6={};function w(r,e){j6[r]=e}class Ot{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new Ot(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}}class Vt{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new Vt(t,Ot.range(this,e))}}function Kg(r){var e=[];r.consumeSpaces();var t=r.fetch().text;for(t==="\\relax"&&(r.consume(),r.consumeSpaces(),t=r.fetch().text);t==="\\hline"||t==="\\hdashline";)r.consume(),e.push(t==="\\hdashline"),r.consumeSpaces(),t=r.fetch().text;return e}var uu=r=>{var e=r.parser.settings;if(!e.displayMode)throw new V("{"+r.envName+"} can be used only in display mode.")},aA=new Set(["gather","gather*"]);function jp(r){if(!r.includes("ed"))return!r.includes("*")}function si(r,e,t){var{hskipBeforeAndAfter:n,addJot:i,cols:o,arraystretch:s,colSeparationType:a,autoTag:l,singleRow:c,emptySingleRow:u,maxNumCols:d,leqno:h}=e;if(r.gullet.beginGroup(),c||r.gullet.macros.set("\\cr","\\\\\\relax"),!s){var f=r.gullet.expandMacroAsText("\\arraystretch");if(f==null)s=1;else if(s=parseFloat(f),!s||s<0)throw new V("Invalid \\arraystretch: "+f)}r.gullet.beginGroup();var m=[],y=[m],x=[],b=[],S=l!=null?[]:void 0;function A(){l&&r.gullet.macros.set("\\@eqnsw","1",!0)}function D(){S&&(r.gullet.macros.get("\\df@tag")?(S.push(r.subparse([new Vt("\\df@tag")])),r.gullet.macros.set("\\df@tag",void 0,!0)):S.push(!!l&&r.gullet.macros.get("\\@eqnsw")==="1"))}for(A(),b.push(Kg(r));;){var O=r.parseExpression(!1,c?"\\end":"\\\\");r.gullet.endGroup(),r.gullet.beginGroup();var L={type:"ordgroup",mode:r.mode,body:O};t&&(L={type:"styling",mode:r.mode,style:t,resetFont:!0,body:[L]}),m.push(L);var N=r.fetch().text;if(N==="&"){if(d&&m.length===d){if(c||a)throw new V("Too many tab characters: &",r.nextToken);r.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}r.consume()}else if(N==="\\end"){D(),m.length===1&&L.type==="styling"&&L.body.length===1&&L.body[0].type==="ordgroup"&&L.body[0].body.length===0&&(y.length>1||!u)&&y.pop(),b.length<y.length+1&&b.push([]);break}else if(N==="\\\\"){r.consume();var j=void 0;r.gullet.future().text!==" "&&(j=r.parseSizeGroup(!0)),x.push(j?j.value:null),D(),b.push(Kg(r)),m=[],y.push(m),A()}else throw new V("Expected & or \\\\ or \\cr or \\end",r.nextToken)}return r.gullet.endGroup(),r.gullet.endGroup(),{type:"array",mode:r.mode,addJot:i,arraystretch:s,body:y,cols:o,rowGaps:x,hskipBeforeAndAfter:n,hLinesBeforeRow:b,colSeparationType:a,tags:S,leqno:h}}function $p(r){return r.slice(0,1)==="d"?"display":"text"}var Kr=function(e,t){var n,i,o=e.body.length,s=e.hLinesBeforeRow,a=0,l=new Array(o),c=[],u=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),d=1/t.fontMetrics().ptPerEm,h=5*d;if(e.colSeparationType&&e.colSeparationType==="small"){var f=t.havingStyle(de.SCRIPT).sizeMultiplier;h=.2778*(f/t.sizeMultiplier)}var m=e.colSeparationType==="CD"?Pe({number:3,unit:"ex"},t):12*d,y=3*d,x=e.arraystretch*m,b=.7*x,S=.3*x,A=0;function D(Xt){for(var Zt=0;Zt<Xt.length;++Zt)Zt>0&&(A+=.25),c.push({pos:A,isDashed:Xt[Zt]})}for(D(s[0]),n=0;n<e.body.length;++n){var O=e.body[n],L=b,N=S;a<O.length&&(a=O.length);var j={cells:new Array(O.length),height:0,depth:0,pos:0};for(i=0;i<O.length;++i){var K=we(O[i],t);N<K.depth&&(N=K.depth),L<K.height&&(L=K.height),j.cells[i]=K}var ne=e.rowGaps[n],pe=0;ne&&(pe=Pe(ne,t),pe>0&&(pe+=S,N<pe&&(N=pe),pe=0)),e.addJot&&n<e.body.length-1&&(N+=y),j.height=L,j.depth=N,A+=L,j.pos=A,A+=N+pe,l[n]=j,D(s[n+1])}var se=A/2+t.fontMetrics().axisHeight,lt=e.cols||[],Re=[],Ue,$e,Bt=[];if(e.tags&&e.tags.some(Xt=>Xt))for(n=0;n<o;++n){var pr=l[n],Cn=pr.pos-se,Jt=e.tags[n],mr=void 0;Jt===!0?mr=$(["eqn-num"],[],t):Jt===!1?mr=$([],[],t):mr=$([],tt(Jt,t,!0),t),mr.depth=pr.depth,mr.height=pr.height,Bt.push({type:"elem",elem:mr,shift:Cn})}for(i=0,$e=0;i<a||$e<lt.length;++i,++$e){for(var ai,Pt=lt[$e],oo=!0;((Te=Pt)==null?void 0:Te.type)==="separator";){var Te;if(oo||(Ue=$(["arraycolsep"],[]),Ue.style.width=G(t.fontMetrics().doubleRuleSep),Re.push(Ue)),Pt.separator==="|"||Pt.separator===":"){var mu=Pt.separator==="|"?"solid":"dashed",Mn=$(["vertical-separator"],[],t);Mn.style.height=G(A),Mn.style.borderRightWidth=G(u),Mn.style.borderRightStyle=mu,Mn.style.margin="0 "+G(-u/2);var Jl=A-se;Jl&&(Mn.style.verticalAlign=G(-Jl)),Re.push(Mn)}else throw new V("Invalid separator type: "+Pt.separator);$e++,Pt=lt[$e],oo=!1}if(!(i>=a)){var Tn=void 0;if(i>0||e.hskipBeforeAndAfter){var Xl,Zl;Tn=(Xl=(Zl=Pt)==null?void 0:Zl.pregap)!=null?Xl:h,Tn!==0&&(Ue=$(["arraycolsep"],[]),Ue.style.width=G(Tn),Re.push(Ue))}var $s=[];for(n=0;n<o;++n){var so=l[n],li=so.cells[i];if(li){var Ee=so.pos-se;li.depth=so.depth,li.height=so.height,$s.push({type:"elem",elem:li,shift:Ee})}}var Vs=be({positionType:"individualShift",children:$s}),De=$(["col-align-"+(((ai=Pt)==null?void 0:ai.align)||"c")],[Vs]);if(Re.push(De),i<a-1||e.hskipBeforeAndAfter){var ao,Ft;Tn=(ao=(Ft=Pt)==null?void 0:Ft.postgap)!=null?ao:h,Tn!==0&&(Ue=$(["arraycolsep"],[]),Ue.style.width=G(Tn),Re.push(Ue))}}}var Ar=$(["mtable"],Re);if(c.length>0){for(var Ql=Ts("hline",t,u),Nr=Ts("hdashline",t,u),lo=[{type:"elem",elem:Ar,shift:0}];c.length>0;){var co=c.pop(),Ws=co.pos-se;co.isDashed?lo.push({type:"elem",elem:Nr,shift:Ws}):lo.push({type:"elem",elem:Ql,shift:Ws})}Ar=be({positionType:"individualShift",children:lo})}if(Bt.length===0)return $(["mord"],[Ar],t);var e0=be({positionType:"individualShift",children:Bt}),Er=$(["tag"],[e0],t);return Sn([Ar,Er])},lA={c:"center ",l:"left ",r:"right "},Gr=function(e,t){for(var n=[],i=new W("mtd",[],["mtr-glue"]),o=new W("mtd",[],["mml-eqn-num"]),s=0;s<e.body.length;s++){for(var a=e.body[s],l=[],c=0;c<a.length;c++)l.push(new W("mtd",[Ne(a[c],t)]));e.tags&&e.tags[s]&&(l.unshift(i),l.push(i),e.leqno?l.unshift(o):l.push(o)),n.push(new W("mtr",l))}var u=new W("mtable",n),d=e.arraystretch===.5?.1:.16+e.arraystretch-1+(e.addJot?.09:0);u.setAttribute("rowspacing",G(d));var h="",f="";if(e.cols&&e.cols.length>0){var m=e.cols,y="",x=!1,b=0,S=m.length;m[0].type==="separator"&&(h+="top ",b=1),m[m.length-1].type==="separator"&&(h+="bottom ",S-=1);for(var A=b;A<S;A++){var D=m[A];D.type==="align"?(f+=lA[D.align],x&&(y+="none "),x=!0):D.type==="separator"&&x&&(y+=D.separator==="|"?"solid ":"dashed ",x=!1)}u.setAttribute("columnalign",f.trim()),/[sd]/.test(y)&&u.setAttribute("columnlines",y.trim())}if(e.colSeparationType==="align"){for(var O=e.cols||[],L="",N=1;N<O.length;N++)L+=N%2?"0em ":"1em ";u.setAttribute("columnspacing",L.trim())}else e.colSeparationType==="alignat"||e.colSeparationType==="gather"?u.setAttribute("columnspacing","0em"):e.colSeparationType==="small"?u.setAttribute("columnspacing","0.2778em"):e.colSeparationType==="CD"?u.setAttribute("columnspacing","0.5em"):u.setAttribute("columnspacing","1em");var j="",K=e.hLinesBeforeRow;h+=K[0].length>0?"left ":"",h+=K[K.length-1].length>0?"right ":"";for(var ne=1;ne<K.length-1;ne++)j+=K[ne].length===0?"none ":K[ne][0]?"dashed ":"solid ";return/[sd]/.test(j)&&u.setAttribute("rowlines",j.trim()),h!==""&&(u=new W("menclose",[u]),u.setAttribute("notation",h.trim())),e.arraystretch&&e.arraystretch<1&&(u=new W("mstyle",[u]),u.setAttribute("scriptlevel","1")),u},$6=function(e,t){e.envName.includes("ed")||uu(e);var n=[],i=e.envName==="split",o=si(e.parser,{cols:n,addJot:!0,autoTag:i?void 0:jp(e.envName),emptySingleRow:!0,colSeparationType:e.envName.includes("at")?"alignat":"align",maxNumCols:i?2:void 0,leqno:e.parser.settings.leqno},"display"),s=0,a=0,l={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&t[0].type==="ordgroup"){for(var c="",u=0;u<t[0].body.length;u++){var d=he(t[0].body[u],"textord");c+=d.text}s=Number(c),a=s*2}var h=!a;o.body.forEach(function(x){for(var b=1;b<x.length;b+=2){var S=he(x[b],"styling"),A=he(S.body[0],"ordgroup");A.body.unshift(l)}if(h)a<x.length&&(a=x.length);else{var D=x.length/2;if(s<D)throw new V("Too many math in a row: "+("expected "+s+", but got "+D),x[0])}});for(var f=0;f<a;++f){var m="r",y=0;f%2===1?m="l":f>0&&h&&(y=1),n[f]={type:"align",align:m,pregap:y,postgap:0}}return o.colSeparationType=h?"align":"alignat",o};Ur({type:"array",names:["array","darray"],props:{numArgs:1},handler(r,e){var t=au(e[0]),n=t?[e[0]]:he(e[0],"ordgroup").body,i=n.map(function(s){var a=su(s),l=a.text;if("lcr".includes(l))return{type:"align",align:l};if(l==="|")return{type:"separator",separator:"|"};if(l===":")return{type:"separator",separator:":"};throw new V("Unknown column alignment: "+l,s)}),o={cols:i,hskipBeforeAndAfter:!0,maxNumCols:i.length};return si(r.parser,o,$p(r.envName))},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(r){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[r.envName.replace("*","")],t="c",n={hskipBeforeAndAfter:!1,cols:[{type:"align",align:t}]};if(r.envName.charAt(r.envName.length-1)==="*"){var i=r.parser;if(i.consumeSpaces(),i.fetch().text==="["){if(i.consume(),i.consumeSpaces(),t=i.fetch().text,!"lcr".includes(t))throw new V("Expected l or c or r",i.nextToken);i.consume(),i.consumeSpaces(),i.expect("]"),i.consume(),n.cols=[{type:"align",align:t}]}}var o=si(r.parser,n,$p(r.envName)),s=Math.max(0,...o.body.map(a=>a.length));return o.cols=new Array(s).fill({type:"align",align:t}),e?{type:"leftright",mode:r.mode,body:[o],left:e[0],right:e[1],rightColor:void 0}:o},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(r){var e={arraystretch:.5},t=si(r.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["subarray"],props:{numArgs:1},handler(r,e){var t=au(e[0]),n=t?[e[0]]:he(e[0],"ordgroup").body,i=n.map(function(a){var l=su(a),c=l.text;if("lc".includes(c))return{type:"align",align:c};throw new V("Unknown column alignment: "+c,a)});if(i.length>1)throw new V("{subarray} can contain only one column");var o={cols:i,hskipBeforeAndAfter:!1,arraystretch:.5},s=si(r.parser,o,"script");if(s.body.length>0&&s.body[0].length>1)throw new V("{subarray} can contain only one column");return s},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(r){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},t=si(r.parser,e,$p(r.envName));return{type:"leftright",mode:r.mode,body:[t],left:r.envName.includes("r")?".":"\\{",right:r.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:$6,htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(r){aA.has(r.envName)&&uu(r);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:jp(r.envName),emptySingleRow:!0,leqno:r.parser.settings.leqno};return si(r.parser,e,"display")},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:$6,htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(r){uu(r);var e={autoTag:jp(r.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:r.parser.settings.leqno};return si(r.parser,e,"display")},htmlBuilder:Kr,mathmlBuilder:Gr});Ur({type:"array",names:["CD"],props:{numArgs:0},handler(r){return uu(r),WT(r.parser)},htmlBuilder:Kr,mathmlBuilder:Gr});w("\\nonumber","\\gdef\\@eqnsw{0}");w("\\notag","\\nonumber");X({type:"text",names:["\\hline","\\hdashline"],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(r,e){throw new V(r.funcName+" valid only within array environment")}});var Gg=q6;X({type:"environment",names:["\\begin","\\end"],numArgs:1,argTypes:["text"],handler(r,e){var{parser:t,funcName:n}=r,i=e[0];if(i.type!=="ordgroup")throw new V("Invalid environment name",i);for(var o="",s=0;s<i.body.length;++s)o+=he(i.body[s],"textord").text;if(n==="\\begin"){if(!Gg.hasOwnProperty(o))throw new V("No such environment: "+o,i);var a=Gg[o],{args:l,optArgs:c}=t.parseArguments("\\begin{"+o+"}",a),u={mode:t.mode,envName:o,parser:t},d=a.handler(u,l,c);t.expect("\\end",!1);var h=t.nextToken,f=he(t.parseFunction(),"environment");if(f.name!==o)throw new V("Mismatch: \\begin{"+o+"} matched by \\end{"+f.name+"}",h);return d}return{type:"environment",mode:t.mode,name:o,nameGroup:i}}});var cA=(r,e)=>{var t=r.font,n=e.withFont(t);return we(r.body,n)},uA=(r,e)=>{var t=r.font,n=e.withFont(t);return Ne(r.body,n)},Yg={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak"};X({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],numArgs:1,allowedInArgument:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=yc(e[0]),o=n in Yg?Yg[n]:n;return{type:"font",mode:t.mode,font:o.slice(1),body:i}},htmlBuilder:cA,mathmlBuilder:uA});X({type:"mclass",names:["\\boldsymbol","\\bm"],numArgs:1,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"mclass",mode:t.mode,mclass:lu(n),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:n}],isCharacterBox:xn(n)}}});X({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],numArgs:0,allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n,breakOnTokenText:i}=r,{mode:o}=t,s=t.parseExpression(!0,i);return{type:"font",mode:o,font:"math"+n.slice(1),body:{type:"ordgroup",mode:t.mode,body:s}}}});var dA=(r,e)=>{var t=e.style,n=t.fracNum(),i=t.fracDen(),o;o=e.havingStyle(n);var s=we(r.numer,o,e);if(r.continued){var a=8.5/e.fontMetrics().ptPerEm,l=3.5/e.fontMetrics().ptPerEm;s.height=s.height<a?a:s.height,s.depth=s.depth<l?l:s.depth}o=e.havingStyle(i);var c=we(r.denom,o,e),u,d,h;r.hasBarLine?(r.barSize?(d=Pe(r.barSize,e),u=Ts("frac-line",e,d)):u=Ts("frac-line",e),d=u.height,h=u.height):(u=null,d=0,h=e.fontMetrics().defaultRuleThickness);var f,m,y;t.size===de.DISPLAY.size?(f=e.fontMetrics().num1,d>0?m=3*h:m=7*h,y=e.fontMetrics().denom1):(d>0?(f=e.fontMetrics().num2,m=h):(f=e.fontMetrics().num3,m=3*h),y=e.fontMetrics().denom2);var x;if(u){var S=e.fontMetrics().axisHeight;f-s.depth-(S+.5*d)<m&&(f+=m-(f-s.depth-(S+.5*d))),S-.5*d-(c.height-y)<m&&(y+=m-(S-.5*d-(c.height-y)));var A=-(S-.5*d);x=be({positionType:"individualShift",children:[{type:"elem",elem:c,shift:y},{type:"elem",elem:u,shift:A},{type:"elem",elem:s,shift:-f}]})}else{var b=f-s.depth-(c.height-y);b<m&&(f+=.5*(m-b),y+=.5*(m-b)),x=be({positionType:"individualShift",children:[{type:"elem",elem:c,shift:y},{type:"elem",elem:s,shift:-f}]})}o=e.havingStyle(t),x.height*=o.sizeMultiplier/e.sizeMultiplier,x.depth*=o.sizeMultiplier/e.sizeMultiplier;var D;t.size===de.DISPLAY.size?D=e.fontMetrics().delim1:t.size===de.SCRIPTSCRIPT.size?D=e.havingStyle(de.SCRIPT).fontMetrics().delim2:D=e.fontMetrics().delim2;var O,L;return r.leftDelim==null?O=Wa(e,["mopen"]):O=Lh(r.leftDelim,D,!0,e.havingStyle(t),r.mode,["mopen"]),r.continued?L=$([]):r.rightDelim==null?L=Wa(e,["mclose"]):L=Lh(r.rightDelim,D,!0,e.havingStyle(t),r.mode,["mclose"]),$(["mord"].concat(o.sizingClasses(e)),[O,$(["mfrac"],[x]),L],e)},hA=(r,e)=>{var t=new W("mfrac",[Ne(r.numer,e),Ne(r.denom,e)]);if(!r.hasBarLine)t.setAttribute("linethickness","0px");else if(r.barSize){var n=Pe(r.barSize,e);t.setAttribute("linethickness",G(n))}if(r.leftDelim!=null||r.rightDelim!=null){var i=[];if(r.leftDelim!=null){var o=new W("mo",[new Je(r.leftDelim.replace("\\",""))]);o.setAttribute("fence","true"),i.push(o)}if(i.push(t),r.rightDelim!=null){var s=new W("mo",[new Je(r.rightDelim.replace("\\",""))]);s.setAttribute("fence","true"),i.push(s)}return Hp(i)}return t},V6=(r,e)=>{if(!e)return r;var t={type:"styling",mode:r.mode,style:e,body:[r]};return t};X({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],numArgs:2,allowedInArgument:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],o=e[1],s,a=null,l=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":s=!0;break;case"\\\\atopfrac":s=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":s=!1,a="(",l=")";break;case"\\\\bracefrac":s=!1,a="\\{",l="\\}";break;case"\\\\brackfrac":s=!1,a="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}var c=n==="\\cfrac",u=null;return c||n.startsWith("\\d")?u="display":n.startsWith("\\t")&&(u="text"),V6({type:"genfrac",mode:t.mode,numer:i,denom:o,continued:c,hasBarLine:s,leftDelim:a,rightDelim:l,barSize:null},u)},htmlBuilder:dA,mathmlBuilder:hA});X({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],numArgs:0,infix:!0,handler(r){var{parser:e,funcName:t,token:n}=r,i;switch(t){case"\\over":i="\\frac";break;case"\\choose":i="\\binom";break;case"\\atop":i="\\\\atopfrac";break;case"\\brace":i="\\\\bracefrac";break;case"\\brack":i="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:i,token:n}}});var Jg=["display","text","script","scriptscript"],Xg=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};X({type:"genfrac",names:["\\genfrac"],numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"],handler(r,e){var{parser:t}=r,n=e[4],i=e[5],o=yc(e[0]),s=o.type==="atom"&&o.family==="open"?Xg(o.text):null,a=yc(e[1]),l=a.type==="atom"&&a.family==="close"?Xg(a.text):null,c=he(e[2],"size"),u,d=null;c.isBlank?u=!0:(d=c.value,u=d.number>0);var h=null,f=e[3];if(f.type==="ordgroup"){if(f.body.length>0){var m=he(f.body[0],"textord");h=Jg[Number(m.text)]}}else f=he(f,"textord"),h=Jg[Number(f.text)];return V6({type:"genfrac",mode:t.mode,numer:n,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:s,rightDelim:l},h)}});X({type:"infix",names:["\\above"],numArgs:1,argTypes:["size"],infix:!0,handler(r,e){var{parser:t,funcName:n,token:i}=r;return{type:"infix",mode:t.mode,replaceWith:"\\\\abovefrac",size:he(e[0],"size").value,token:i}}});X({type:"genfrac",names:["\\\\abovefrac"],numArgs:3,argTypes:["math","size","math"],handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],o=he(e[1],"infix").size;if(!o)throw new Error("\\\\abovefrac expected size, but got "+String(o));var s=e[2],a=o.number>0;return{type:"genfrac",mode:t.mode,numer:i,denom:s,continued:!1,hasBarLine:a,barSize:o,leftDelim:null,rightDelim:null}}});var W6=(r,e)=>{var t=e.style,n,i;r.type==="supsub"?(n=r.sup?we(r.sup,e.havingStyle(t.sup()),e):we(r.sub,e.havingStyle(t.sub()),e),i=he(r.base,"horizBrace")):i=he(r,"horizBrace");var o=we(i.base,e.havingBaseStyle(de.DISPLAY)),s=ou(i,e),a;if(i.isOver?a=be({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.1},{type:"elem",elem:s,wrapperClasses:["svg-align"]}]}):a=be({positionType:"bottom",positionData:o.depth+.1+s.height,children:[{type:"elem",elem:s,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:o}]}),n){var l=$(["minner",i.isOver?"mover":"munder"],[a],e);i.isOver?a=be({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:n}]}):a=be({positionType:"bottom",positionData:l.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:l}]})}return $(["minner",i.isOver?"mover":"munder"],[a],e)},fA=(r,e)=>{var t=iu(r.label);return new W(r.isOver?"mover":"munder",[Ne(r.base,e),t])};X({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],numArgs:1,handler(r,e){var{parser:t,funcName:n}=r;return{type:"horizBrace",mode:t.mode,label:n,isOver:n.includes("\\over"),base:e[0]}},htmlBuilder:W6,mathmlBuilder:fA});X({type:"href",names:["\\href"],numArgs:2,argTypes:["url","original"],allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[1],i=he(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:t.mode,href:i,body:Ye(n)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(r,e)=>{var t=tt(r.body,e,!1);return yT(r.href,[],t,e)},mathmlBuilder:(r,e)=>{var t=ei(r.body,e);return t instanceof W||(t=new W("mrow",[t])),t.setAttribute("href",r.href),t}});X({type:"href",names:["\\url"],numArgs:1,argTypes:["url"],allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=he(e[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:n}))return t.formatUnsupportedCmd("\\url");for(var i=[],o=0;o<n.length;o++){var s=n[o];s==="~"&&(s="\\textasciitilde"),i.push({type:"textord",mode:"text",text:s})}var a={type:"text",mode:t.mode,font:"\\texttt",body:i};return{type:"href",mode:t.mode,href:n,body:Ye(a)}}});X({type:"hbox",names:["\\hbox"],numArgs:1,argTypes:["text"],allowedInText:!0,primitive:!0,handler(r,e){var{parser:t}=r;return{type:"hbox",mode:t.mode,body:Ye(e[0])}},htmlBuilder(r,e){var t=tt(r.body,e.withFont(""),!1);return Sn(t)},mathmlBuilder(r,e){return new W("mrow",Yt(r.body,e.withFont("")))}});X({type:"html",names:["\\htmlClass","\\htmlId","\\htmlStyle","\\htmlData"],numArgs:2,argTypes:["raw","original"],allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n,token:i}=r,o=he(e[0],"raw").string,s=e[1];t.settings.strict&&t.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var a,l={};switch(n){case"\\htmlClass":l.class=o,a={command:"\\htmlClass",class:o};break;case"\\htmlId":l.id=o,a={command:"\\htmlId",id:o};break;case"\\htmlStyle":l.style=o,a={command:"\\htmlStyle",style:o};break;case"\\htmlData":{for(var c=o.split(","),u=0;u<c.length;u++){var d=c[u],h=d.indexOf("=");if(h<0)throw new V("\\htmlData key/value '"+d+"' missing equals sign");var f=d.slice(0,h),m=d.slice(h+1);l["data-"+f.trim()]=m}a={command:"\\htmlData",attributes:l};break}default:throw new Error("Unrecognized html command")}return t.settings.isTrusted(a)?{type:"html",mode:t.mode,attributes:l,body:Ye(s)}:t.formatUnsupportedCmd(n)},htmlBuilder:(r,e)=>{var t=tt(r.body,e,!1),n=["enclosing"];r.attributes.class&&n.push(...r.attributes.class.trim().split(/\s+/));var i=$(n,t,e);for(var o in r.attributes)o!=="class"&&r.attributes.hasOwnProperty(o)&&i.setAttribute(o,r.attributes[o]);return i},mathmlBuilder:(r,e)=>ei(r.body,e)});X({type:"htmlmathml",names:["\\html@mathml"],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r;return{type:"htmlmathml",mode:t.mode,html:Ye(e[0]),mathml:Ye(e[1])}},htmlBuilder:(r,e)=>{var t=tt(r.html,e,!1);return Sn(t)},mathmlBuilder:(r,e)=>ei(r.mathml,e)});var Cd=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new V("Invalid size: '"+e+"' in \\includegraphics");var n={number:+(t[1]+t[2]),unit:t[3]};if(!p6(n))throw new V("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n};X({type:"includegraphics",names:["\\includegraphics"],numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1,handler:(r,e,t)=>{var{parser:n}=r,i={number:0,unit:"em"},o={number:.9,unit:"em"},s={number:0,unit:"em"},a="";if(t[0])for(var l=he(t[0],"raw").string,c=l.split(","),u=0;u<c.length;u++){var d=c[u].split("=");if(d.length===2){var h=d[1].trim();switch(d[0].trim()){case"alt":a=h;break;case"width":i=Cd(h);break;case"height":o=Cd(h);break;case"totalheight":s=Cd(h);break;default:throw new V("Invalid key: '"+d[0]+"' in \\includegraphics.")}}}var f=he(e[0],"url").url;return a===""&&(a=f,a=a.replace(/^.*[\\/]/,""),a=a.substring(0,a.lastIndexOf("."))),n.settings.isTrusted({command:"\\includegraphics",url:f})?{type:"includegraphics",mode:n.mode,alt:a,width:i,height:o,totalheight:s,src:f}:n.formatUnsupportedCmd("\\includegraphics")},htmlBuilder:(r,e)=>{var t=Pe(r.height,e),n=0;r.totalheight.number>0&&(n=Pe(r.totalheight,e)-t);var i=0;r.width.number>0&&(i=Pe(r.width,e));var o={height:G(t+n)};i>0&&(o.width=G(i)),n>0&&(o.verticalAlign=G(-n));var s=new oT(r.src,r.alt,o);return s.height=t,s.depth=n,s},mathmlBuilder:(r,e)=>{var t=new W("mglyph",[]);t.setAttribute("alt",r.alt);var n=Pe(r.height,e),i=0;if(r.totalheight.number>0&&(i=Pe(r.totalheight,e)-n,t.setAttribute("valign",G(-i))),t.setAttribute("height",G(n+i)),r.width.number>0){var o=Pe(r.width,e);t.setAttribute("width",G(o))}return t.setAttribute("src",r.src),t}});X({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r,i=he(e[0],"size");if(t.settings.strict){var o=n[1]==="m",s=i.value.unit==="mu";o?(s||t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, "+("not "+i.value.unit+" units")),t.mode!=="math"&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):s&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:t.mode,dimension:i.value}},htmlBuilder(r,e){return w6(r.dimension,e)},mathmlBuilder(r,e){var t=Pe(r.dimension,e);return new T6(t)}});X({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"lap",mode:t.mode,alignment:n.slice(5),body:i}},htmlBuilder:(r,e)=>{var t;r.alignment==="clap"?(t=$([],[we(r.body,e)]),t=$(["inner"],[t],e)):t=$(["inner"],[we(r.body,e)]);var n=$(["fix"],[]),i=$([r.alignment],[t,n],e),o=$(["strut"]);return o.style.height=G(i.height+i.depth),i.depth&&(o.style.verticalAlign=G(-i.depth)),i.children.unshift(o),i=$(["thinbox"],[i],e),$(["mord","vbox"],[i],e)},mathmlBuilder:(r,e)=>{var t=new W("mpadded",[Ne(r.body,e)]);if(r.alignment!=="rlap"){var n=r.alignment==="llap"?"-1":"-0.5";t.setAttribute("lspace",n+"width")}return t.setAttribute("width","0px"),t}});X({type:"styling",names:["\\(","$"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(r,e){var{funcName:t,parser:n}=r,i=n.mode;n.switchMode("math");var o=t==="\\("?"\\)":"$",s=n.parseExpression(!1,o);return n.expect(o),n.switchMode(i),{type:"styling",mode:n.mode,style:"text",resetFont:!0,body:s}}});X({type:"text",names:["\\)","\\]"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(r,e){throw new V("Mismatched "+r.funcName)}});var Zg=(r,e)=>{switch(e.style.size){case de.DISPLAY.size:return r.display;case de.TEXT.size:return r.text;case de.SCRIPT.size:return r.script;case de.SCRIPTSCRIPT.size:return r.scriptscript;default:return r.text}};X({type:"mathchoice",names:["\\mathchoice"],numArgs:4,primitive:!0,handler:(r,e)=>{var{parser:t}=r;return{type:"mathchoice",mode:t.mode,display:Ye(e[0]),text:Ye(e[1]),script:Ye(e[2]),scriptscript:Ye(e[3])}},htmlBuilder:(r,e)=>{var t=Zg(r,e),n=tt(t,e,!1);return Sn(n)},mathmlBuilder:(r,e)=>{var t=Zg(r,e);return ei(t,e)}});var U6=(r,e,t,n,i,o,s)=>{r=$([],[r]);var a=t&&xn(t),l,c;if(e){var u=we(e,n.havingStyle(i.sup()),n);c={elem:u,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-u.depth)}}if(t){var d=we(t,n.havingStyle(i.sub()),n);l={elem:d,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-d.height)}}var h;if(c&&l){var f=n.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+r.depth+s;h=be({positionType:"bottom",positionData:f,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:G(-o)},{type:"kern",size:l.kern},{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:G(o)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else if(l){var m=r.height-s;h=be({positionType:"top",positionData:m,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:G(-o)},{type:"kern",size:l.kern},{type:"elem",elem:r}]})}else if(c){var y=r.depth+s;h=be({positionType:"bottom",positionData:y,children:[{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:G(o)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else return r;var x=[h];if(l&&o!==0&&!a){var b=$(["mspace"],[],n);b.style.marginRight=G(o),x.unshift(b)}return $(["mop","op-limits"],x,n)},K6=new Set(["\\smallint"]),G6=(r,e)=>{var t,n,i=!1,o;r.type==="supsub"?(t=r.sup,n=r.sub,o=he(r.base,"op"),i=!0):o=he(r,"op");var s=e.style,a=!1;s.size===de.DISPLAY.size&&o.symbol&&!K6.has(o.name)&&(a=!0);var l,c;if(o.symbol){var u=a?"Size2-Regular":"Size1-Regular",d="";if((o.name==="\\oiint"||o.name==="\\oiiint")&&(d=o.name.slice(1),o.name=d==="oiint"?"\\iint":"\\iiint"),l=bt(o.name,u,"math",e,["mop","op-symbol",a?"large-op":"small-op"]),c=l.italic,d.length>0){var h=k6(d+"Size"+(a?"2":"1"),e);l=be({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:h,shift:a?.08:0}]}),o.name="\\"+d,l.classes.unshift("mop"),l.italic=c}}else if(o.body){var f=tt(o.body,e,!0);f.length===1&&f[0]instanceof Wt?(l=f[0],l.classes[0]="mop"):l=$(["mop"],f,e)}else{for(var m=[],y=1;y<o.name.length;y++)m.push(Pp(o.name[y],o.mode,e));l=$(["mop"],m,e)}var x=0,b=0;if((l instanceof Wt||o.name==="\\oiint"||o.name==="\\oiiint")&&!o.suppressBaseShift){var S;x=(l.height-l.depth)/2-e.fontMetrics().axisHeight,b=(S=l.italic)!=null?S:0}return i?U6(l,t,n,e,s,b,x):(x&&(l.style.position="relative",l.style.top=G(x)),l)},pA=(r,e)=>{var t;if(r.symbol)t=new W("mo",[ur(r.name,r.mode)]),K6.has(r.name)&&t.setAttribute("largeop","false");else if(r.body)t=new W("mo",Yt(r.body,e));else{t=new W("mi",[new Je(r.name.slice(1))]);var n=new W("mo",[ur("⁡","text")]);r.parentIsSupSub?t=new W("mrow",[t,n]):t=M6([t,n])}return t},mA={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};X({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],numArgs:0,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=n;return i.length===1&&(i=mA[i]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:G6,mathmlBuilder:pA});X({type:"op",names:["\\mathop"],numArgs:1,primitive:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:Ye(n)}}});var gA={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};X({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],numArgs:0,handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:t}}});X({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],numArgs:0,handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:t}}});X({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","∫","∬","∭","∮","∯","∰"],numArgs:0,allowedInArgument:!0,handler(r){var{parser:e,funcName:t}=r,n=t;return n.length===1&&(n=gA[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var Y6=(r,e)=>{var t,n,i=!1,o;r.type==="supsub"?(t=r.sup,n=r.sub,o=he(r.base,"operatorname"),i=!0):o=he(r,"operatorname");var s;if(o.body.length>0){for(var a=o.body.map(d=>{var h="text"in d?d.text:void 0;return typeof h=="string"?{type:"textord",mode:d.mode,text:h}:d}),l=tt(a,e.withFont("mathrm"),!0),c=0;c<l.length;c++){var u=l[c];u instanceof Wt&&(u.text=u.text.replace(/\u2212/,"-").replace(/\u2217/,"*"))}s=$(["mop"],l,e)}else s=$(["mop"],[],e);return i?U6(s,t,n,e,e.style,0,0):s},yA=(r,e)=>{for(var t=Yt(r.body,e.withFont("mathrm")),n=!0,i=0;i<t.length;i++){var o=t[i];if(!(o instanceof T6))if(o instanceof W)switch(o.type){case"mi":case"mn":case"mspace":case"mtext":break;case"mo":{var s=o.children[0];o.children.length===1&&s instanceof Je?s.text=s.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):n=!1;break}default:n=!1}else n=!1}if(n){var a=t.map(u=>u.toText()).join("");t=[new Je(a)]}var l=new W("mi",t);l.setAttribute("mathvariant","normal");var c=new W("mo",[ur("⁡","text")]);return r.parentIsSupSub?new W("mrow",[l,c]):M6([l,c])};X({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],numArgs:1,handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"operatorname",mode:t.mode,body:Ye(i),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:Y6,mathmlBuilder:yA});w("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");io({type:"ordgroup",htmlBuilder(r,e){return r.semisimple?Sn(tt(r.body,e,!1)):$(["mord"],tt(r.body,e,!0),e)},mathmlBuilder(r,e){return ei(r.body,e,!0)}});X({type:"overline",names:["\\overline"],numArgs:1,handler(r,e){var{parser:t}=r,n=e[0];return{type:"overline",mode:t.mode,body:n}},htmlBuilder(r,e){var t=we(r.body,e.havingCrampedStyle()),n=Ts("overline-line",e),i=e.fontMetrics().defaultRuleThickness,o=be({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*i},{type:"elem",elem:n},{type:"kern",size:i}]});return $(["mord","overline"],[o],e)},mathmlBuilder(r,e){var t=new W("mo",[new Je("‾")]);t.setAttribute("stretchy","true");var n=new W("mover",[Ne(r.body,e),t]);return n.setAttribute("accent","true"),n}});X({type:"phantom",names:["\\phantom"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"phantom",mode:t.mode,body:Ye(n)}},htmlBuilder:(r,e)=>{var t=tt(r.body,e.withPhantom(),!1);return Sn(t)},mathmlBuilder:(r,e)=>{var t=Yt(r.body,e);return new W("mphantom",t)}});w("\\hphantom","\\smash{\\phantom{#1}}");X({type:"vphantom",names:["\\vphantom"],numArgs:1,allowedInText:!0,handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"vphantom",mode:t.mode,body:n}},htmlBuilder:(r,e)=>{var t=$(["inner"],[we(r.body,e.withPhantom())]),n=$(["fix"],[]);return $(["mord","rlap"],[t,n],e)},mathmlBuilder:(r,e)=>{var t=Yt(Ye(r.body),e),n=new W("mphantom",t),i=new W("mpadded",[n]);return i.setAttribute("width","0px"),i}});X({type:"raisebox",names:["\\raisebox"],numArgs:2,argTypes:["size","hbox"],allowedInText:!0,handler(r,e){var{parser:t}=r,n=he(e[0],"size").value,i=e[1];return{type:"raisebox",mode:t.mode,dy:n,body:i}},htmlBuilder(r,e){var t=we(r.body,e),n=Pe(r.dy,e);return be({positionType:"shift",positionData:-n,children:[{type:"elem",elem:t}]})},mathmlBuilder(r,e){var t=new W("mpadded",[Ne(r.body,e)]),n=r.dy.number+r.dy.unit;return t.setAttribute("voffset",n),t}});X({type:"internal",names:["\\relax"],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(r){var{parser:e}=r;return{type:"internal",mode:e.mode}}});X({type:"rule",names:["\\rule"],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"],handler(r,e,t){var{parser:n}=r,i=t[0],o=he(e[0],"size"),s=he(e[1],"size");return{type:"rule",mode:n.mode,shift:i&&he(i,"size").value,width:o.value,height:s.value}},htmlBuilder(r,e){var t=$(["mord","rule"],[],e),n=Pe(r.width,e),i=Pe(r.height,e),o=r.shift?Pe(r.shift,e):0;return t.style.borderRightWidth=G(n),t.style.borderTopWidth=G(i),t.style.bottom=G(o),t.width=n,t.height=i+o,t.depth=-o,t.maxFontSize=i*1.125*e.sizeMultiplier,t},mathmlBuilder(r,e){var t=Pe(r.width,e),n=Pe(r.height,e),i=r.shift?Pe(r.shift,e):0,o=e.color&&e.getColor()||"black",s=new W("mspace");s.setAttribute("mathbackground",o),s.setAttribute("width",G(t)),s.setAttribute("height",G(n));var a=new W("mpadded",[s]);return i>=0?a.setAttribute("height",G(i)):(a.setAttribute("height",G(i)),a.setAttribute("depth",G(-i))),a.setAttribute("voffset",G(i)),a}});function J6(r,e,t){for(var n=tt(r,e,!1),i=e.sizeMultiplier/t.sizeMultiplier,o=0;o<n.length;o++){var s=n[o].classes.indexOf("sizing");s<0?Array.prototype.push.apply(n[o].classes,e.sizingClasses(t)):n[o].classes[s+1]==="reset-size"+e.size&&(n[o].classes[s+1]="reset-size"+t.size),n[o].height*=i,n[o].depth*=i}return Sn(n)}var Qg=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],vA=(r,e)=>{var t=e.havingSize(r.size);return J6(r.body,t,e)};X({type:"sizing",names:Qg,numArgs:0,allowedInText:!0,handler:(r,e)=>{var{breakOnTokenText:t,funcName:n,parser:i}=r,o=i.parseExpression(!1,t);return{type:"sizing",mode:i.mode,size:Qg.indexOf(n)+1,body:o}},htmlBuilder:vA,mathmlBuilder:(r,e)=>{var t=e.havingSize(r.size),n=Yt(r.body,t),i=new W("mstyle",n);return i.setAttribute("mathsize",G(t.sizeMultiplier)),i}});X({type:"smash",names:["\\smash"],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(r,e,t)=>{var{parser:n}=r,i=!1,o=!1,s=t[0]&&he(t[0],"ordgroup");if(s)for(var a,l=0;l<s.body.length;++l){var c=s.body[l];if(a=su(c).text,a==="t")i=!0;else if(a==="b")o=!0;else{i=!1,o=!1;break}}else i=!0,o=!0;var u=e[0];return{type:"smash",mode:n.mode,body:u,smashHeight:i,smashDepth:o}},htmlBuilder:(r,e)=>{var t=$([],[we(r.body,e)]);if(!r.smashHeight&&!r.smashDepth)return t;if(r.smashHeight&&(t.height=0),r.smashDepth&&(t.depth=0),r.smashHeight&&r.smashDepth)return $(["mord","smash"],[t],e);if(t.children)for(var n=0;n<t.children.length;n++)r.smashHeight&&(t.children[n].height=0),r.smashDepth&&(t.children[n].depth=0);var i=be({positionType:"firstBaseline",children:[{type:"elem",elem:t}]});return $(["mord"],[i],e)},mathmlBuilder:(r,e)=>{var t=new W("mpadded",[Ne(r.body,e)]);return r.smashHeight&&t.setAttribute("height","0px"),r.smashDepth&&t.setAttribute("depth","0px"),t}});X({type:"sqrt",names:["\\sqrt"],numArgs:1,numOptionalArgs:1,handler(r,e,t){var{parser:n}=r,i=t[0],o=e[0];return{type:"sqrt",mode:n.mode,body:o,index:i}},htmlBuilder(r,e){var t=we(r.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=As(t,e);var n=e.fontMetrics(),i=n.defaultRuleThickness,o=i;e.style.id<de.TEXT.id&&(o=e.fontMetrics().xHeight);var s=i+o/4,a=t.height+t.depth+s+i,{span:l,ruleWidth:c,advanceWidth:u}=QT(a,e),d=l.height-c;d>t.height+t.depth+s&&(s=(s+d-t.height-t.depth)/2);var h=l.height-t.height-s-c;t.style.paddingLeft=G(u);var f=be({positionType:"firstBaseline",children:[{type:"elem",elem:t,wrapperClasses:["svg-align"]},{type:"kern",size:-(t.height+h)},{type:"elem",elem:l},{type:"kern",size:c}]});if(r.index){var m=e.havingStyle(de.SCRIPTSCRIPT),y=we(r.index,m,e),x=.6*(f.height-f.depth),b=be({positionType:"shift",positionData:-x,children:[{type:"elem",elem:y}]}),S=$(["root"],[b]);return $(["mord","sqrt"],[S,f],e)}else return $(["mord","sqrt"],[f],e)},mathmlBuilder(r,e){var{body:t,index:n}=r;return n?new W("mroot",[Ne(t,e),Ne(n,e)]):new W("msqrt",[Ne(t,e)])}});var Bh={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT};function bA(r){return r in Bh}X({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],numArgs:0,allowedInText:!0,primitive:!0,handler(r,e){var{breakOnTokenText:t,funcName:n,parser:i}=r,o=i.parseExpression(!0,t),s=n.slice(1,n.length-5);if(!bA(s))throw new Error("Unknown style: "+s);return{type:"styling",mode:i.mode,style:s,body:o}},htmlBuilder(r,e){var t=Bh[r.style],n=e.havingStyle(t);return r.resetFont&&(n=n.withFont("")),J6(r.body,n,e)},mathmlBuilder(r,e){var t=Bh[r.style],n=e.havingStyle(t);r.resetFont&&(n=n.withFont(""));var i=Yt(r.body,n),o=new W("mstyle",i),s={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},a=s[r.style];return o.setAttribute("scriptlevel",a[0]),o.setAttribute("displaystyle",a[1]),o}});var wA=function(e,t){var n=e.base;if(n)if(n.type==="op"){var i=n.limits&&(t.style.size===de.DISPLAY.size||n.alwaysHandleSupSub);return i?G6:null}else if(n.type==="operatorname"){var o=n.alwaysHandleSupSub&&(t.style.size===de.DISPLAY.size||n.limits);return o?Y6:null}else{if(n.type==="accent")return xn(n.base)?D6:null;if(n.type==="horizBrace"){var s=!e.sub;return s===n.isOver?W6:null}else return null}else return null};io({type:"supsub",htmlBuilder(r,e){var t=wA(r,e);if(t)return t(r,e);var{base:n,sup:i,sub:o}=r,s=we(n,e),a,l,c=e.fontMetrics(),u=0,d=0,h=n&&xn(n);if(i){var f=e.havingStyle(e.style.sup());a=we(i,f,e),h||(u=s.height-f.fontMetrics().supDrop*f.sizeMultiplier/e.sizeMultiplier)}if(o){var m=e.havingStyle(e.style.sub());l=we(o,m,e),h||(d=s.depth+m.fontMetrics().subDrop*m.sizeMultiplier/e.sizeMultiplier)}var y;e.style===de.DISPLAY?y=c.sup1:e.style.cramped?y=c.sup3:y=c.sup2;var x=e.sizeMultiplier,b=G(.5/c.ptPerEm/x),S=null;if(l){var A=r.base&&r.base.type==="op"&&r.base.name&&(r.base.name==="\\oiint"||r.base.name==="\\oiiint");if(s instanceof Wt||A){var D;S=G(-((D=s.italic)!=null?D:0))}}var O;if(a&&l){u=Math.max(u,y,a.depth+.25*c.xHeight),d=Math.max(d,c.sub2);var L=c.defaultRuleThickness,N=4*L;if(u-a.depth-(l.height-d)<N){d=N-(u-a.depth)+l.height;var j=.8*c.xHeight-(u-a.depth);j>0&&(u+=j,d-=j)}var K=[{type:"elem",elem:l,shift:d,marginRight:b,marginLeft:S},{type:"elem",elem:a,shift:-u,marginRight:b}];O=be({positionType:"individualShift",children:K})}else if(l){d=Math.max(d,c.sub1,l.height-.8*c.xHeight);var ne=[{type:"elem",elem:l,marginLeft:S,marginRight:b}];O=be({positionType:"shift",positionData:d,children:ne})}else if(a)u=Math.max(u,y,a.depth+.25*c.xHeight),O=be({positionType:"shift",positionData:-u,children:[{type:"elem",elem:a,marginRight:b}]});else throw new Error("supsub must have either sup or sub.");var pe=Oh(s,"right")||"mord";return $([pe],[s,$(["msupsub"],[O])],e)},mathmlBuilder(r,e){var t=!1,n,i;r.base&&r.base.type==="horizBrace"&&(i=!!r.sup,i===r.base.isOver&&(t=!0,n=r.base.isOver)),r.base&&(r.base.type==="op"||r.base.type==="operatorname")&&(r.base.parentIsSupSub=!0);var o=[Ne(r.base,e)];r.sub&&o.push(Ne(r.sub,e)),r.sup&&o.push(Ne(r.sup,e));var s;if(t)s=n?"mover":"munder";else if(r.sub)if(r.sup){var c=r.base;c&&c.type==="op"&&c.limits&&e.style===de.DISPLAY||c&&c.type==="operatorname"&&c.alwaysHandleSupSub&&(e.style===de.DISPLAY||c.limits)?s="munderover":s="msubsup"}else{var l=r.base;l&&l.type==="op"&&l.limits&&(e.style===de.DISPLAY||l.alwaysHandleSupSub)||l&&l.type==="operatorname"&&l.alwaysHandleSupSub&&(l.limits||e.style===de.DISPLAY)?s="munder":s="msub"}else{var a=r.base;a&&a.type==="op"&&a.limits&&(e.style===de.DISPLAY||a.alwaysHandleSupSub)||a&&a.type==="operatorname"&&a.alwaysHandleSupSub&&(a.limits||e.style===de.DISPLAY)?s="mover":s="msup"}return new W(s,o)}});io({type:"atom",htmlBuilder(r,e){return Pp(r.text,r.mode,e,["m"+r.family])},mathmlBuilder(r,e){var t=new W("mo",[ur(r.text,r.mode)]);if(r.family==="bin"){var n=_p(r,e);n==="bold-italic"&&t.setAttribute("mathvariant",n)}else r.family==="punct"?t.setAttribute("separator","true"):(r.family==="open"||r.family==="close")&&t.setAttribute("stretchy","false");return t}});var X6={mi:"italic",mn:"normal",mtext:"normal"};io({type:"mathord",htmlBuilder(r,e){return nu(r,e)},mathmlBuilder(r,e){var t=new W("mi",[ur(r.text,r.mode,e)]),n=_p(r,e)||"italic";return n!==X6[t.type]&&t.setAttribute("mathvariant",n),t}});io({type:"textord",htmlBuilder(r,e){return nu(r,e)},mathmlBuilder(r,e){var t=ur(r.text,r.mode,e),n=_p(r,e)||"normal",i;return r.mode==="text"?i=new W("mtext",[t]):/[0-9]/.test(r.text)?i=new W("mn",[t]):r.text==="\\prime"?i=new W("mo",[t]):i=new W("mi",[t]),n!==X6[i.type]&&i.setAttribute("mathvariant",n),i}});var Md={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Td={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};io({type:"spacing",htmlBuilder(r,e){if(Td.hasOwnProperty(r.text)){var t=Td[r.text].className||"";if(r.mode==="text"){var n=nu(r,e);return n.classes.push(t),n}else return $(["mspace",t],[Pp(r.text,r.mode,e)],e)}else{if(Md.hasOwnProperty(r.text))return $(["mspace",Md[r.text]],[],e);throw new V('Unknown type of space "'+r.text+'"')}},mathmlBuilder(r,e){var t;if(Td.hasOwnProperty(r.text))t=new W("mtext",[new Je(" ")]);else{if(Md.hasOwnProperty(r.text))return new W("mspace");throw new V('Unknown type of space "'+r.text+'"')}return t}});var e4=()=>{var r=new W("mtd",[]);return r.setAttribute("width","50%"),r};io({type:"tag",mathmlBuilder(r,e){var t=new W("mtable",[new W("mtr",[e4(),new W("mtd",[ei(r.body,e)]),e4(),new W("mtd",[ei(r.tag,e)])])]);return t.setAttribute("width","100%"),t}});var t4={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},r4={"\\textbf":"textbf","\\textmd":"textmd"},xA={"\\textit":"textit","\\textup":"textup"},n4=(r,e)=>{var t=r.font;if(t){if(t4[t])return e.withTextFontFamily(t4[t]);if(r4[t])return e.withTextFontWeight(r4[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(xA[t])};X({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0,handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"text",mode:t.mode,body:Ye(i),font:n}},htmlBuilder(r,e){var t=n4(r,e),n=tt(r.body,t,!0);return $(["mord","text"],n,t)},mathmlBuilder(r,e){var t=n4(r,e);return ei(r.body,t)}});X({type:"underline",names:["\\underline"],numArgs:1,allowedInText:!0,handler(r,e){var{parser:t}=r;return{type:"underline",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=we(r.body,e),n=Ts("underline-line",e),i=e.fontMetrics().defaultRuleThickness,o=be({positionType:"top",positionData:t.height,children:[{type:"kern",size:i},{type:"elem",elem:n},{type:"kern",size:3*i},{type:"elem",elem:t}]});return $(["mord","underline"],[o],e)},mathmlBuilder(r,e){var t=new W("mo",[new Je("‾")]);t.setAttribute("stretchy","true");var n=new W("munder",[Ne(r.body,e),t]);return n.setAttribute("accentunder","true"),n}});X({type:"vcenter",names:["\\vcenter"],numArgs:1,argTypes:["original"],allowedInText:!1,handler(r,e){var{parser:t}=r;return{type:"vcenter",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=we(r.body,e),n=e.fontMetrics().axisHeight,i=.5*(t.height-n-(t.depth+n));return be({positionType:"shift",positionData:i,children:[{type:"elem",elem:t}]})},mathmlBuilder(r,e){var t=new W("mpadded",[Ne(r.body,e)],["vcenter"]);return new W("mrow",[t])}});X({type:"verb",names:["\\verb"],numArgs:0,allowedInText:!0,handler(r,e,t){throw new V("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(r,e){for(var t=i4(r),n=[],i=e.havingStyle(e.style.text()),o=0;o<t.length;o++){var s=t[o];s==="~"&&(s="\\textasciitilde"),n.push(bt(s,"Typewriter-Regular",r.mode,i,["mord","texttt"]))}return $(["mord","text"].concat(i.sizingClasses(e)),b6(n),i)},mathmlBuilder(r,e){var t=new Je(i4(r)),n=new W("mtext",[t]);return n.setAttribute("mathvariant","monospace"),n}});var i4=r=>r.body.replace(/ /g,r.star?"␣":" "),Wn=S6,Z6=`[ \r
1132
1132
  ]`,kA="\\\\[a-zA-Z@]+",SA="\\\\[^\uD800-\uDFFF]",CA="("+kA+")"+Z6+"*",MA=`\\\\(
1133
1133
  |[ \r ]+
1134
1134
  ?)[ \r ]*`,Ph="[̀-ͯ]",TA=new RegExp(Ph+"+$"),AA="("+Z6+"+)|"+(MA+"|")+"([!-\\[\\]-‧‪-퟿豈-￿]"+(Ph+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(Ph+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+CA)+("|"+SA+")");class o4{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(AA,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Vt("EOF",new Ot(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new V("Unexpected character: '"+e[t]+"'",new Vt(e[t],new Ot(this,t,t+1)));var i=n[6]||n[3]||(n[2]?"\\ ":" ");if(this.catcodes[i]===14){var o=e.indexOf(`
1135
- `,this.tokenRegex.lastIndex);return o===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=o+1,this.lex()}return new Vt(i,new Ot(this,t,this.tokenRegex.lastIndex))}}class NA{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new V("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var i=0;i<this.undefStack.length;i++)delete this.undefStack[i][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var o=this.undefStack[this.undefStack.length-1];o&&!o.hasOwnProperty(e)&&(o[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}}var EA=$6;w("\\noexpand",function(r){var e=r.popToken();return r.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});w("\\expandafter",function(r){var e=r.popToken();return r.expandOnce(!0),{tokens:[e],numArgs:0}});w("\\@firstoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[0],numArgs:0}});w("\\@secondoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[1],numArgs:0}});w("\\@ifnextchar",function(r){var e=r.consumeArgs(3);r.consumeSpaces();var t=r.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});w("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");w("\\TextOrMath",function(r){var e=r.consumeArgs(2);return r.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});var s4={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};w("\\char",function(r){var e=r.popToken(),t,n=0;if(e.text==="'")t=8,e=r.popToken();else if(e.text==='"')t=16,e=r.popToken();else if(e.text==="`")if(e=r.popToken(),e.text[0]==="\\")n=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new V("\\char` missing argument");n=e.text.charCodeAt(0)}else t=10;if(t){if(n=s4[e.text],n==null||n>=t)throw new V("Invalid base-"+t+" digit "+e.text);for(var i;(i=s4[r.future().text])!=null&&i<t;)n*=t,n+=i,r.popToken()}return"\\@char{"+n+"}"});var Vp=(r,e,t,n)=>{var i=r.consumeArg().tokens;if(i.length!==1)throw new V("\\newcommand's first argument must be a macro name");var o=i[0].text,s=r.isDefined(o);if(s&&!e)throw new V("\\newcommand{"+o+"} attempting to redefine "+(o+"; use \\renewcommand"));if(!s&&!t)throw new V("\\renewcommand{"+o+"} when command "+o+" does not yet exist; use \\newcommand");var a=0;if(i=r.consumeArg().tokens,i.length===1&&i[0].text==="["){for(var l="",c=r.expandNextToken();c.text!=="]"&&c.text!=="EOF";)l+=c.text,c=r.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new V("Invalid number of arguments: "+l);a=parseInt(l),i=r.consumeArg().tokens}return s&&n||r.macros.set(o,{tokens:i,numArgs:a}),""};w("\\newcommand",r=>Vp(r,!1,!0,!1));w("\\renewcommand",r=>Vp(r,!0,!1,!1));w("\\providecommand",r=>Vp(r,!0,!0,!0));w("\\message",r=>{var e=r.consumeArgs(1)[0];return console.log(e.reverse().map(t=>t.text).join("")),""});w("\\errmessage",r=>{var e=r.consumeArgs(1)[0];return console.error(e.reverse().map(t=>t.text).join("")),""});w("\\show",r=>{var e=r.popToken(),t=e.text;return console.log(e,r.macros.get(t),Wn[t],Ie.math[t],Ie.text[t]),""});w("\\bgroup","{");w("\\egroup","}");w("~","\\nobreakspace");w("\\lq","`");w("\\rq","'");w("\\aa","\\r a");w("\\AA","\\r A");w("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}");w("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");w("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}");w("ℬ","\\mathscr{B}");w("ℰ","\\mathscr{E}");w("ℱ","\\mathscr{F}");w("ℋ","\\mathscr{H}");w("ℐ","\\mathscr{I}");w("ℒ","\\mathscr{L}");w("ℳ","\\mathscr{M}");w("ℛ","\\mathscr{R}");w("ℭ","\\mathfrak{C}");w("ℌ","\\mathfrak{H}");w("ℨ","\\mathfrak{Z}");w("\\Bbbk","\\Bbb{k}");w("\\llap","\\mathllap{\\textrm{#1}}");w("\\rlap","\\mathrlap{\\textrm{#1}}");w("\\clap","\\mathclap{\\textrm{#1}}");w("\\mathstrut","\\vphantom{(}");w("\\underbar","\\underline{\\text{#1}}");w("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}');w("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");w("\\ne","\\neq");w("≠","\\neq");w("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}");w("∉","\\notin");w("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}");w("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}");w("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}");w("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}");w("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}");w("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}");w("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}");w("⟂","\\perp");w("‼","\\mathclose{!\\mkern-0.8mu!}");w("∌","\\notni");w("⌜","\\ulcorner");w("⌝","\\urcorner");w("⌞","\\llcorner");w("⌟","\\lrcorner");w("©","\\copyright");w("®","\\textregistered");w("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');w("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');w("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');w("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');w("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");w("⋮","\\vdots");w("\\varGamma","\\mathit{\\Gamma}");w("\\varDelta","\\mathit{\\Delta}");w("\\varTheta","\\mathit{\\Theta}");w("\\varLambda","\\mathit{\\Lambda}");w("\\varXi","\\mathit{\\Xi}");w("\\varPi","\\mathit{\\Pi}");w("\\varSigma","\\mathit{\\Sigma}");w("\\varUpsilon","\\mathit{\\Upsilon}");w("\\varPhi","\\mathit{\\Phi}");w("\\varPsi","\\mathit{\\Psi}");w("\\varOmega","\\mathit{\\Omega}");w("\\substack","\\begin{subarray}{c}#1\\end{subarray}");w("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");w("\\boxed","\\fbox{$\\displaystyle{#1}$}");w("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");w("\\implies","\\DOTSB\\;\\Longrightarrow\\;");w("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");w("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");w("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");var a4={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},DA=new Set(["bin","rel"]);w("\\dots",function(r){var e="\\dotso",t=r.expandAfterFuture().text;return t in a4?e=a4[t]:(t.slice(0,4)==="\\not"||t in Ie.math&&DA.has(Ie.math[t].group))&&(e="\\dotsb"),e});var Wp={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};w("\\dotso",function(r){var e=r.future().text;return e in Wp?"\\ldots\\,":"\\ldots"});w("\\dotsc",function(r){var e=r.future().text;return e in Wp&&e!==","?"\\ldots\\,":"\\ldots"});w("\\cdots",function(r){var e=r.future().text;return e in Wp?"\\@cdots\\,":"\\@cdots"});w("\\dotsb","\\cdots");w("\\dotsm","\\cdots");w("\\dotsi","\\!\\cdots");w("\\dotsx","\\ldots\\,");w("\\DOTSI","\\relax");w("\\DOTSB","\\relax");w("\\DOTSX","\\relax");w("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");w("\\,","\\tmspace+{3mu}{.1667em}");w("\\thinspace","\\,");w("\\>","\\mskip{4mu}");w("\\:","\\tmspace+{4mu}{.2222em}");w("\\medspace","\\:");w("\\;","\\tmspace+{5mu}{.2777em}");w("\\thickspace","\\;");w("\\!","\\tmspace-{3mu}{.1667em}");w("\\negthinspace","\\!");w("\\negmedspace","\\tmspace-{4mu}{.2222em}");w("\\negthickspace","\\tmspace-{5mu}{.277em}");w("\\enspace","\\kern.5em ");w("\\enskip","\\hskip.5em\\relax");w("\\quad","\\hskip1em\\relax");w("\\qquad","\\hskip2em\\relax");w("\\tag","\\@ifstar\\tag@literal\\tag@paren");w("\\tag@paren","\\tag@literal{({#1})}");w("\\tag@literal",r=>{if(r.macros.get("\\df@tag"))throw new V("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});w("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");w("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");w("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");w("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");w("\\newline","\\\\\\relax");w("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var Q6=G(Pr["Main-Regular"][84][1]-.7*Pr["Main-Regular"][65][1]);w("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Q6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");w("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Q6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");w("\\hspace","\\@ifstar\\@hspacer\\@hspace");w("\\@hspace","\\hskip #1\\relax");w("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");w("\\ordinarycolon",":");w("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");w("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');w("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');w("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');w("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');w("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');w("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');w("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');w("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');w("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');w("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');w("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');w("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');w("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');w("∷","\\dblcolon");w("∹","\\eqcolon");w("≔","\\coloneqq");w("≕","\\eqqcolon");w("⩴","\\Coloneqq");w("\\ratio","\\vcentcolon");w("\\coloncolon","\\dblcolon");w("\\colonequals","\\coloneqq");w("\\coloncolonequals","\\Coloneqq");w("\\equalscolon","\\eqqcolon");w("\\equalscoloncolon","\\Eqqcolon");w("\\colonminus","\\coloneq");w("\\coloncolonminus","\\Coloneq");w("\\minuscolon","\\eqcolon");w("\\minuscoloncolon","\\Eqcolon");w("\\coloncolonapprox","\\Colonapprox");w("\\coloncolonsim","\\Colonsim");w("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}");w("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");w("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");w("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");w("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");w("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");w("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");w("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");w("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");w("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}");w("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}");w("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}");w("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}");w("\\nleqq","\\html@mathml{\\@nleqq}{≰}");w("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}");w("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}");w("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}");w("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}");w("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}");w("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}");w("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}");w("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}");w("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}");w("\\imath","\\html@mathml{\\@imath}{ı}");w("\\jmath","\\html@mathml{\\@jmath}{ȷ}");w("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}");w("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}");w("⟦","\\llbracket");w("⟧","\\rrbracket");w("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}");w("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}");w("⦃","\\lBrace");w("⦄","\\rBrace");w("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}");w("⦵","\\minuso");w("\\darr","\\downarrow");w("\\dArr","\\Downarrow");w("\\Darr","\\Downarrow");w("\\lang","\\langle");w("\\rang","\\rangle");w("\\uarr","\\uparrow");w("\\uArr","\\Uparrow");w("\\Uarr","\\Uparrow");w("\\N","\\mathbb{N}");w("\\R","\\mathbb{R}");w("\\Z","\\mathbb{Z}");w("\\alef","\\aleph");w("\\alefsym","\\aleph");w("\\Alpha","\\mathrm{A}");w("\\Beta","\\mathrm{B}");w("\\bull","\\bullet");w("\\Chi","\\mathrm{X}");w("\\clubs","\\clubsuit");w("\\cnums","\\mathbb{C}");w("\\Complex","\\mathbb{C}");w("\\Dagger","\\ddagger");w("\\diamonds","\\diamondsuit");w("\\empty","\\emptyset");w("\\Epsilon","\\mathrm{E}");w("\\Eta","\\mathrm{H}");w("\\exist","\\exists");w("\\harr","\\leftrightarrow");w("\\hArr","\\Leftrightarrow");w("\\Harr","\\Leftrightarrow");w("\\hearts","\\heartsuit");w("\\image","\\Im");w("\\infin","\\infty");w("\\Iota","\\mathrm{I}");w("\\isin","\\in");w("\\Kappa","\\mathrm{K}");w("\\larr","\\leftarrow");w("\\lArr","\\Leftarrow");w("\\Larr","\\Leftarrow");w("\\lrarr","\\leftrightarrow");w("\\lrArr","\\Leftrightarrow");w("\\Lrarr","\\Leftrightarrow");w("\\Mu","\\mathrm{M}");w("\\natnums","\\mathbb{N}");w("\\Nu","\\mathrm{N}");w("\\Omicron","\\mathrm{O}");w("\\plusmn","\\pm");w("\\rarr","\\rightarrow");w("\\rArr","\\Rightarrow");w("\\Rarr","\\Rightarrow");w("\\real","\\Re");w("\\reals","\\mathbb{R}");w("\\Reals","\\mathbb{R}");w("\\Rho","\\mathrm{P}");w("\\sdot","\\cdot");w("\\sect","\\S");w("\\spades","\\spadesuit");w("\\sub","\\subset");w("\\sube","\\subseteq");w("\\supe","\\supseteq");w("\\Tau","\\mathrm{T}");w("\\thetasym","\\vartheta");w("\\weierp","\\wp");w("\\Zeta","\\mathrm{Z}");w("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");w("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");w("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");w("\\bra","\\mathinner{\\langle{#1}|}");w("\\ket","\\mathinner{|{#1}\\rangle}");w("\\braket","\\mathinner{\\langle{#1}\\rangle}");w("\\Bra","\\left\\langle#1\\right|");w("\\Ket","\\left|#1\\right\\rangle");var ey=r=>e=>{var t=e.consumeArg().tokens,n=e.consumeArg().tokens,i=e.consumeArg().tokens,o=e.consumeArg().tokens,s=e.macros.get("|"),a=e.macros.get("\\|");e.macros.beginGroup();var l=d=>h=>{r&&(h.macros.set("|",s),i.length&&h.macros.set("\\|",a));var f=d;if(!d&&i.length){var m=h.future();m.text==="|"&&(h.popToken(),f=!0)}return{tokens:f?i:n,numArgs:0}};e.macros.set("|",l(!1)),i.length&&e.macros.set("\\|",l(!0));var c=e.consumeArg().tokens,u=e.expandTokens([...o,...c,...t]);return e.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};w("\\bra@ket",ey(!1));w("\\bra@set",ey(!0));w("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");w("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");w("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");w("\\angln","{\\angl n}");w("\\blue","\\textcolor{##6495ed}{#1}");w("\\orange","\\textcolor{##ffa500}{#1}");w("\\pink","\\textcolor{##ff00af}{#1}");w("\\red","\\textcolor{##df0030}{#1}");w("\\green","\\textcolor{##28ae7b}{#1}");w("\\gray","\\textcolor{gray}{#1}");w("\\purple","\\textcolor{##9d38bd}{#1}");w("\\blueA","\\textcolor{##ccfaff}{#1}");w("\\blueB","\\textcolor{##80f6ff}{#1}");w("\\blueC","\\textcolor{##63d9ea}{#1}");w("\\blueD","\\textcolor{##11accd}{#1}");w("\\blueE","\\textcolor{##0c7f99}{#1}");w("\\tealA","\\textcolor{##94fff5}{#1}");w("\\tealB","\\textcolor{##26edd5}{#1}");w("\\tealC","\\textcolor{##01d1c1}{#1}");w("\\tealD","\\textcolor{##01a995}{#1}");w("\\tealE","\\textcolor{##208170}{#1}");w("\\greenA","\\textcolor{##b6ffb0}{#1}");w("\\greenB","\\textcolor{##8af281}{#1}");w("\\greenC","\\textcolor{##74cf70}{#1}");w("\\greenD","\\textcolor{##1fab54}{#1}");w("\\greenE","\\textcolor{##0d923f}{#1}");w("\\goldA","\\textcolor{##ffd0a9}{#1}");w("\\goldB","\\textcolor{##ffbb71}{#1}");w("\\goldC","\\textcolor{##ff9c39}{#1}");w("\\goldD","\\textcolor{##e07d10}{#1}");w("\\goldE","\\textcolor{##a75a05}{#1}");w("\\redA","\\textcolor{##fca9a9}{#1}");w("\\redB","\\textcolor{##ff8482}{#1}");w("\\redC","\\textcolor{##f9685d}{#1}");w("\\redD","\\textcolor{##e84d39}{#1}");w("\\redE","\\textcolor{##bc2612}{#1}");w("\\maroonA","\\textcolor{##ffbde0}{#1}");w("\\maroonB","\\textcolor{##ff92c6}{#1}");w("\\maroonC","\\textcolor{##ed5fa6}{#1}");w("\\maroonD","\\textcolor{##ca337c}{#1}");w("\\maroonE","\\textcolor{##9e034e}{#1}");w("\\purpleA","\\textcolor{##ddd7ff}{#1}");w("\\purpleB","\\textcolor{##c6b9fc}{#1}");w("\\purpleC","\\textcolor{##aa87ff}{#1}");w("\\purpleD","\\textcolor{##7854ab}{#1}");w("\\purpleE","\\textcolor{##543b78}{#1}");w("\\mintA","\\textcolor{##f5f9e8}{#1}");w("\\mintB","\\textcolor{##edf2df}{#1}");w("\\mintC","\\textcolor{##e0e5cc}{#1}");w("\\grayA","\\textcolor{##f6f7f7}{#1}");w("\\grayB","\\textcolor{##f0f1f2}{#1}");w("\\grayC","\\textcolor{##e3e5e6}{#1}");w("\\grayD","\\textcolor{##d6d8da}{#1}");w("\\grayE","\\textcolor{##babec2}{#1}");w("\\grayF","\\textcolor{##888d93}{#1}");w("\\grayG","\\textcolor{##626569}{#1}");w("\\grayH","\\textcolor{##3b3e40}{#1}");w("\\grayI","\\textcolor{##21242c}{#1}");w("\\kaBlue","\\textcolor{##314453}{#1}");w("\\kaGreen","\\textcolor{##71B307}{#1}");var ty={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class OA{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new NA(EA,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new o4(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,i;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:i,end:n}=this.consumeArg(["]"])}else({tokens:i,start:t,end:n}=this.consumeArg());return this.pushToken(new Vt("EOF",n.loc)),this.pushTokens(i),new Vt("",Ot.range(t,n))}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var i=this.future(),o,s=0,a=0;do{if(o=this.popToken(),t.push(o),o.text==="{")++s;else if(o.text==="}"){if(--s,s===-1)throw new V("Extra }",o)}else if(o.text==="EOF")throw new V("Unexpected end of input in a macro argument, expected '"+(e&&n?e[a]:"}")+"'",o);if(e&&n)if((s===0||s===1&&e[a]==="{")&&o.text===e[a]){if(++a,a===e.length){t.splice(-a,a);break}}else a=0}while(s!==0||n);return i.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:i,end:o}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new V("The length of delimiters doesn't match the number of args!");for(var n=t[0],i=0;i<n.length;i++){var o=this.popToken();if(n[i]!==o.text)throw new V("Use of the macro doesn't match its definition",o)}}for(var s=[],a=0;a<e;a++)s.push(this.consumeArg(t&&t[a+1]).tokens);return s}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new V("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),n=t.text,i=t.noexpand?null:this._getExpansion(n);if(i==null||e&&i.unexpandable){if(e&&i==null&&n[0]==="\\"&&!this.isDefined(n))throw new V("Undefined control sequence: "+n);return this.pushToken(t),!1}this.countExpansion(1);var o=i.tokens,s=this.consumeArgs(i.numArgs,i.delimiters);if(i.numArgs){o=o.slice();for(var a=o.length-1;a>=0;--a){var l=o[a];if(l.text==="#"){if(a===0)throw new V("Incomplete placeholder at end of macro body",l);if(l=o[--a],l.text==="#")o.splice(a+1,1);else if(/^[1-9]$/.test(l.text))o.splice(a,2,...s[+l.text-1]);else throw new V("Not a valid argument number",l)}}}return this.pushTokens(o),o.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Vt(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var i=this.stack.pop();i.treatAsRelax&&(i.noexpand=!1,i.treatAsRelax=!1),t.push(i)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(n=>n.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var i=typeof t=="function"?t(this):t;if(typeof i=="string"){var o=0;if(i.includes("#"))for(var s=i.replace(/##/g,"");s.includes("#"+(o+1));)++o;for(var a=new o4(i,this.settings),l=[],c=a.lex();c.text!=="EOF";)l.push(c),c=a.lex();l.reverse();var u={tokens:l,numArgs:o};return u}return i}isDefined(e){return this.macros.has(e)||Wn.hasOwnProperty(e)||Ie.math.hasOwnProperty(e)||Ie.text.hasOwnProperty(e)||ty.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:Wn.hasOwnProperty(e)&&!Wn[e].primitive}}var l4=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,L0=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),Ad={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},c4={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class du{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new OA(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new V("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Vt("}")),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,n}parseExpression(e,t){for(var n=[];;){this.mode==="math"&&this.consumeSpaces();var i=this.fetch();if(du.endOfExpression.has(i.text)||t&&i.text===t||e&&Wn[i.text]&&Wn[i.text].infix)break;var o=this.parseAtom(t);if(o){if(o.type==="internal")continue}else break;n.push(o)}return this.mode==="text"&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(e){for(var t=-1,n,i=0;i<e.length;i++){var o=e[i];if(o.type==="infix"){if(t!==-1)throw new V("only one infix operator per group",o.token);t=i,n=o.replaceWith}}if(t!==-1&&n){var s,a,l=e.slice(0,t),c=e.slice(t+1);l.length===1&&l[0].type==="ordgroup"?s=l[0]:s={type:"ordgroup",mode:this.mode,body:l},c.length===1&&c[0].type==="ordgroup"?a=c[0]:a={type:"ordgroup",mode:this.mode,body:c};var u;return n==="\\\\abovefrac"?u=this.callFunction(n,[s,e[t],a],[]):u=this.callFunction(n,[s,a],[]),[u]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var i;do{var o;i=this.parseGroup(e)}while(((o=i)==null?void 0:o.type)==="internal");if(!i)throw new V("Expected group after '"+n+"'",t);return i}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:"textord",mode:"text",text:e[n]});var i={type:"text",mode:this.mode,body:t},o={type:"color",mode:this.mode,color:this.settings.errorColor,body:[i]};return o}parseAtom(e){var t=this.parseGroup("atom",e);if((t==null?void 0:t.type)==="internal"||this.mode==="text")return t;for(var n,i;;){this.consumeSpaces();var o=this.fetch();if(o.text==="\\limits"||o.text==="\\nolimits"){if(t&&t.type==="op")t.limits=o.text==="\\limits",t.alwaysHandleSupSub=!0;else if(t&&t.type==="operatorname")t.alwaysHandleSupSub&&(t.limits=o.text==="\\limits");else throw new V("Limit controls must follow a math operator",o);this.consume()}else if(o.text==="^"){if(n)throw new V("Double superscript",o);n=this.handleSupSubscript("superscript")}else if(o.text==="_"){if(i)throw new V("Double subscript",o);i=this.handleSupSubscript("subscript")}else if(o.text==="'"){if(n)throw new V("Double superscript",o);var s={type:"textord",mode:this.mode,text:"\\prime"},a=[s];for(this.consume();this.fetch().text==="'";)a.push(s),this.consume();this.fetch().text==="^"&&a.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:a}}else if(L0[o.text]){var l=l4.test(o.text),c=[];for(c.push(new Vt(L0[o.text])),this.consume();;){var u=this.fetch().text;if(!L0[u]||l4.test(u)!==l)break;c.unshift(new Vt(L0[u])),this.consume()}var d=this.subparse(c);l?i={type:"ordgroup",mode:"math",body:d}:n={type:"ordgroup",mode:"math",body:d}}else break}return n&&i?{type:"supsub",mode:this.mode,base:t,sup:n,sub:i}:n?{type:"supsub",mode:this.mode,base:t,sup:n}:i?{type:"supsub",mode:this.mode,base:t,sub:i}:t}parseFunction(e,t){var n=this.fetch(),i=n.text,o=Wn[i];if(!o)return null;if(this.consume(),t&&t!=="atom"&&!o.allowedInArgument)throw new V("Got function '"+i+"' with no arguments"+(t?" as "+t:""),n);if(this.mode==="text"&&!o.allowedInText)throw new V("Can't use function '"+i+"' in text mode",n);if(this.mode==="math"&&o.allowedInMath===!1)throw new V("Can't use function '"+i+"' in math mode",n);var{args:s,optArgs:a}=this.parseArguments(i,o);return this.callFunction(i,s,a,n,e)}callFunction(e,t,n,i,o){var s={funcName:e,parser:this,token:i,breakOnTokenText:o},a=Wn[e];if(a&&a.handler)return a.handler(s,t,n);throw new V("No function handler for "+e)}parseArguments(e,t){var n,i=(n=t.numOptionalArgs)!=null?n:0,o=t.numArgs+i;if(o===0)return{args:[],optArgs:[]};for(var s=[],a=[],l=0;l<o;l++){var c,u=(c=t.argTypes)==null?void 0:c[l],d=l<i;("primitive"in t&&t.primitive&&u==null||t.type==="sqrt"&&l===1&&a[0]==null)&&(u="primitive");var h=this.parseGroupOfType("argument to '"+e+"'",u,d);if(d)a.push(h);else if(h!=null)s.push(h);else throw new V("Null argument, please report this as a bug")}return{args:s,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case"color":return this.parseColorGroup(n);case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,t);case"hbox":{var i=this.parseArgumentGroup(n,"text");return i!=null?{type:"styling",mode:i.mode,body:[i],style:"text",resetFont:!0}:null}case"raw":{var o=this.parseStringGroup(n);return o!=null?{type:"raw",mode:"text",string:o.text}:null}case"primitive":{if(n)throw new V("A primitive argument cannot be optional");var s=this.parseGroup(e);if(s==null)throw new V("Expected group as "+e,this.fetch());return s}case"original":case void 0:return this.parseArgumentGroup(n);default:throw new V("Unknown group type as "+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n="",i;(i=this.fetch()).text!=="EOF";)n+=i.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),i=n,o="",s;(s=this.fetch()).text!=="EOF"&&e.test(o+s.text);)i=s,o+=i.text,this.consume();if(o==="")throw new V("Invalid "+t+": '"+n.text+"'",n);return n.range(i,o)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new V("Invalid color: '"+t.text+"'",t);var i=n[0];return/^[0-9a-f]{6}$/i.test(i)&&(i="#"+i),{type:"color-token",mode:this.mode,color:i}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),!e&&this.gullet.future().text!=="{"?t=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):t=this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text="0pt",n=!0);var i=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!i)throw new V("Invalid size: '"+t.text+"'",t);var o={number:+(i[1]+i[2]),unit:i[3]};if(!p6(o))throw new V("Invalid unit: '"+o.unit+"'",t);return{type:"size",mode:this.mode,value:o,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var i=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var o=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var s={type:"ordgroup",mode:this.mode,loc:n.loc,body:o};return t&&this.switchMode(i),s}parseGroup(e,t){var n=this.fetch(),i=n.text,o;if(i==="{"||i==="\\begingroup"){this.consume();var s=i==="{"?"}":"\\endgroup";this.gullet.beginGroup();var a=this.parseExpression(!1,s),l=this.fetch();this.expect(s),this.gullet.endGroup(),o={type:"ordgroup",mode:this.mode,loc:Ot.range(n,l),body:a,semisimple:i==="\\begingroup"||void 0}}else if(o=this.parseFunction(t,e)||this.parseSymbol(),o==null&&i[0]==="\\"&&!ty.hasOwnProperty(i)){if(this.settings.throwOnError)throw new V("Undefined control sequence: "+i,n);o=this.formatUnsupportedCmd(i),this.consume()}return o}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var i=e[n];if(i.type==="textord"){var o=i.text,s=e[n+1];if(!(!s||s.type!=="textord")){if(o==="-"&&s.text==="-"){var a=e[n+2];n+1<t&&a&&a.type==="textord"&&a.text==="-"?(e.splice(n,3,{type:"textord",mode:"text",loc:Ot.range(i,a),text:"---"}),t-=2):(e.splice(n,2,{type:"textord",mode:"text",loc:Ot.range(i,s),text:"--"}),t-=1)}(o==="'"||o==="`")&&s.text===o&&(e.splice(n,2,{type:"textord",mode:"text",loc:Ot.range(i,s),text:o+o}),t-=1)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),i=n.charAt(0)==="*";if(i&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new V(`\\verb assertion failed --
1136
- please report what input caused this bug`);return n=n.slice(1,-1),{type:"verb",mode:"text",body:n,star:i}}c4.hasOwnProperty(t[0])&&!Ie[this.mode][t[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+t[0]+'" used in math mode',e),t=c4[t[0]]+t.slice(1));var o=TA.exec(t);o&&(t=t.substring(0,o.index),t==="i"?t="ı":t==="j"&&(t="ȷ"));var s;if(Ie[this.mode][t]){this.settings.strict&&this.mode==="math"&&Sh.includes(t)&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var a=Ie[this.mode][t].group,l=Ot.range(e),c;PT(a)?c={type:"atom",mode:this.mode,family:a,loc:l,text:t}:c={type:a,mode:this.mode,loc:l,text:t},s=c}else if(t.charCodeAt(0)>=128)this.settings.strict&&(f6(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),s={type:"textord",mode:"text",loc:Ot.range(e),text:t};else return null;if(this.consume(),o)for(var u=0;u<o[0].length;u++){var d=o[0][u];if(!Ad[d])throw new V("Unknown accent ' "+d+"'",e);var h=Ad[d][this.mode]||Ad[d].text;if(!h)throw new V("Accent "+d+" unsupported in "+this.mode+" mode",e);s={type:"accent",mode:this.mode,loc:Ot.range(e),label:h,isStretchy:!1,isShifty:!0,base:s}}return s}}du.endOfExpression=new Set(["}","\\endgroup","\\end","\\right","&"]);var Up=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new du(e,t);delete n.gullet.macros.current["\\df@tag"];var i=n.parse();if(delete n.gullet.macros.current["\\current@color"],delete n.gullet.macros.current["\\color"],n.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new V("\\tag works only in display equations");i=[{type:"tag",mode:"text",body:i,tag:n.subparse([new Vt("\\df@tag")])}]}return i},ry=function(e,t,n){t.textContent="";var i=Kp(e,n).toNode();t.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),ry=function(){throw new V("KaTeX doesn't work in quirks mode.")});var RA=function(e,t){var n=Kp(e,t).toMarkup();return n},IA=function(e,t){var n=new Ip(t);return Up(e,n)},ny=function(e,t,n){if(n.throwOnError||!(e instanceof V))throw e;var i=j(["katex-error"],[new Wt(t)]);return i.setAttribute("title",e.toString()),i.setAttribute("style","color:"+n.errorColor),i},Kp=function(e,t){var n=new Ip(t);try{var i=Up(e,n);return ET(i,e,n)}catch(o){return ny(o,e,n)}},zA=function(e,t){var n=new Ip(t);try{var i=Up(e,n);return DT(i,e,n)}catch(o){return ny(o,e,n)}},LA="0.17.0",BA={Span:_s,Anchor:tu,SymbolNode:Wt,SvgNode:bn,PathNode:Zn,LineNode:kh},iy={version:LA,render:ry,renderToString:RA,ParseError:V,SETTINGS_SCHEMA:bh,__parse:IA,__renderToDomTree:Kp,__renderToHTMLTree:zA,__setFontMetrics:uT,__defineSymbol:p,__defineFunction:X,__defineMacro:w,__domTree:BA};function PA(){return{enter:{mathFlow:r,mathFlowFenceMeta:e,mathText:o},exit:{mathFlow:i,mathFlowFence:n,mathFlowFenceMeta:t,mathFlowValue:a,mathText:s,mathTextData:a}};function r(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function e(){this.buffer()}function t(){const l=this.resume(),c=this.stack[this.stack.length-1];Gs(c.type==="math"),c.meta=l}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];Gs(u.type==="math"),this.exit(l),u.value=c;const d=u.data.hChildren[0];Gs(d.type==="element"),Gs(d.tagName==="code"),d.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function o(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function s(l){const c=this.resume(),u=this.stack[this.stack.length-1];Gs(u.type==="inlineMath"),this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function a(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}function FA(r){let e=(r||{}).singleDollarTextMath;return e==null&&(e=!0),n.peek=i,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`
1135
+ `,this.tokenRegex.lastIndex);return o===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=o+1,this.lex()}return new Vt(i,new Ot(this,t,this.tokenRegex.lastIndex))}}class NA{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new V("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var i=0;i<this.undefStack.length;i++)delete this.undefStack[i][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var o=this.undefStack[this.undefStack.length-1];o&&!o.hasOwnProperty(e)&&(o[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}}var EA=j6;w("\\noexpand",function(r){var e=r.popToken();return r.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});w("\\expandafter",function(r){var e=r.popToken();return r.expandOnce(!0),{tokens:[e],numArgs:0}});w("\\@firstoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[0],numArgs:0}});w("\\@secondoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[1],numArgs:0}});w("\\@ifnextchar",function(r){var e=r.consumeArgs(3);r.consumeSpaces();var t=r.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});w("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");w("\\TextOrMath",function(r){var e=r.consumeArgs(2);return r.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});var s4={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};w("\\char",function(r){var e=r.popToken(),t,n=0;if(e.text==="'")t=8,e=r.popToken();else if(e.text==='"')t=16,e=r.popToken();else if(e.text==="`")if(e=r.popToken(),e.text[0]==="\\")n=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new V("\\char` missing argument");n=e.text.charCodeAt(0)}else t=10;if(t){if(n=s4[e.text],n==null||n>=t)throw new V("Invalid base-"+t+" digit "+e.text);for(var i;(i=s4[r.future().text])!=null&&i<t;)n*=t,n+=i,r.popToken()}return"\\@char{"+n+"}"});var Vp=(r,e,t,n)=>{var i=r.consumeArg().tokens;if(i.length!==1)throw new V("\\newcommand's first argument must be a macro name");var o=i[0].text,s=r.isDefined(o);if(s&&!e)throw new V("\\newcommand{"+o+"} attempting to redefine "+(o+"; use \\renewcommand"));if(!s&&!t)throw new V("\\renewcommand{"+o+"} when command "+o+" does not yet exist; use \\newcommand");var a=0;if(i=r.consumeArg().tokens,i.length===1&&i[0].text==="["){for(var l="",c=r.expandNextToken();c.text!=="]"&&c.text!=="EOF";)l+=c.text,c=r.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new V("Invalid number of arguments: "+l);a=parseInt(l),i=r.consumeArg().tokens}return s&&n||r.macros.set(o,{tokens:i,numArgs:a}),""};w("\\newcommand",r=>Vp(r,!1,!0,!1));w("\\renewcommand",r=>Vp(r,!0,!1,!1));w("\\providecommand",r=>Vp(r,!0,!0,!0));w("\\message",r=>{var e=r.consumeArgs(1)[0];return console.log(e.reverse().map(t=>t.text).join("")),""});w("\\errmessage",r=>{var e=r.consumeArgs(1)[0];return console.error(e.reverse().map(t=>t.text).join("")),""});w("\\show",r=>{var e=r.popToken(),t=e.text;return console.log(e,r.macros.get(t),Wn[t],Ie.math[t],Ie.text[t]),""});w("\\bgroup","{");w("\\egroup","}");w("~","\\nobreakspace");w("\\lq","`");w("\\rq","'");w("\\aa","\\r a");w("\\AA","\\r A");w("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}");w("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");w("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}");w("ℬ","\\mathscr{B}");w("ℰ","\\mathscr{E}");w("ℱ","\\mathscr{F}");w("ℋ","\\mathscr{H}");w("ℐ","\\mathscr{I}");w("ℒ","\\mathscr{L}");w("ℳ","\\mathscr{M}");w("ℛ","\\mathscr{R}");w("ℭ","\\mathfrak{C}");w("ℌ","\\mathfrak{H}");w("ℨ","\\mathfrak{Z}");w("\\Bbbk","\\Bbb{k}");w("\\llap","\\mathllap{\\textrm{#1}}");w("\\rlap","\\mathrlap{\\textrm{#1}}");w("\\clap","\\mathclap{\\textrm{#1}}");w("\\mathstrut","\\vphantom{(}");w("\\underbar","\\underline{\\text{#1}}");w("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}');w("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");w("\\ne","\\neq");w("≠","\\neq");w("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}");w("∉","\\notin");w("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}");w("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}");w("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}");w("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}");w("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}");w("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}");w("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}");w("⟂","\\perp");w("‼","\\mathclose{!\\mkern-0.8mu!}");w("∌","\\notni");w("⌜","\\ulcorner");w("⌝","\\urcorner");w("⌞","\\llcorner");w("⌟","\\lrcorner");w("©","\\copyright");w("®","\\textregistered");w("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');w("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');w("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');w("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');w("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");w("⋮","\\vdots");w("\\varGamma","\\mathit{\\Gamma}");w("\\varDelta","\\mathit{\\Delta}");w("\\varTheta","\\mathit{\\Theta}");w("\\varLambda","\\mathit{\\Lambda}");w("\\varXi","\\mathit{\\Xi}");w("\\varPi","\\mathit{\\Pi}");w("\\varSigma","\\mathit{\\Sigma}");w("\\varUpsilon","\\mathit{\\Upsilon}");w("\\varPhi","\\mathit{\\Phi}");w("\\varPsi","\\mathit{\\Psi}");w("\\varOmega","\\mathit{\\Omega}");w("\\substack","\\begin{subarray}{c}#1\\end{subarray}");w("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");w("\\boxed","\\fbox{$\\displaystyle{#1}$}");w("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");w("\\implies","\\DOTSB\\;\\Longrightarrow\\;");w("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");w("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");w("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");var a4={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},DA=new Set(["bin","rel"]);w("\\dots",function(r){var e="\\dotso",t=r.expandAfterFuture().text;return t in a4?e=a4[t]:(t.slice(0,4)==="\\not"||t in Ie.math&&DA.has(Ie.math[t].group))&&(e="\\dotsb"),e});var Wp={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};w("\\dotso",function(r){var e=r.future().text;return e in Wp?"\\ldots\\,":"\\ldots"});w("\\dotsc",function(r){var e=r.future().text;return e in Wp&&e!==","?"\\ldots\\,":"\\ldots"});w("\\cdots",function(r){var e=r.future().text;return e in Wp?"\\@cdots\\,":"\\@cdots"});w("\\dotsb","\\cdots");w("\\dotsm","\\cdots");w("\\dotsi","\\!\\cdots");w("\\dotsx","\\ldots\\,");w("\\DOTSI","\\relax");w("\\DOTSB","\\relax");w("\\DOTSX","\\relax");w("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");w("\\,","\\tmspace+{3mu}{.1667em}");w("\\thinspace","\\,");w("\\>","\\mskip{4mu}");w("\\:","\\tmspace+{4mu}{.2222em}");w("\\medspace","\\:");w("\\;","\\tmspace+{5mu}{.2777em}");w("\\thickspace","\\;");w("\\!","\\tmspace-{3mu}{.1667em}");w("\\negthinspace","\\!");w("\\negmedspace","\\tmspace-{4mu}{.2222em}");w("\\negthickspace","\\tmspace-{5mu}{.277em}");w("\\enspace","\\kern.5em ");w("\\enskip","\\hskip.5em\\relax");w("\\quad","\\hskip1em\\relax");w("\\qquad","\\hskip2em\\relax");w("\\tag","\\@ifstar\\tag@literal\\tag@paren");w("\\tag@paren","\\tag@literal{({#1})}");w("\\tag@literal",r=>{if(r.macros.get("\\df@tag"))throw new V("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});w("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");w("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");w("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");w("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");w("\\newline","\\\\\\relax");w("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var Q6=G(Pr["Main-Regular"][84][1]-.7*Pr["Main-Regular"][65][1]);w("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Q6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");w("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Q6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");w("\\hspace","\\@ifstar\\@hspacer\\@hspace");w("\\@hspace","\\hskip #1\\relax");w("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");w("\\ordinarycolon",":");w("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");w("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');w("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');w("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');w("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');w("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');w("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');w("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');w("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');w("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');w("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');w("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');w("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');w("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');w("∷","\\dblcolon");w("∹","\\eqcolon");w("≔","\\coloneqq");w("≕","\\eqqcolon");w("⩴","\\Coloneqq");w("\\ratio","\\vcentcolon");w("\\coloncolon","\\dblcolon");w("\\colonequals","\\coloneqq");w("\\coloncolonequals","\\Coloneqq");w("\\equalscolon","\\eqqcolon");w("\\equalscoloncolon","\\Eqqcolon");w("\\colonminus","\\coloneq");w("\\coloncolonminus","\\Coloneq");w("\\minuscolon","\\eqcolon");w("\\minuscoloncolon","\\Eqcolon");w("\\coloncolonapprox","\\Colonapprox");w("\\coloncolonsim","\\Colonsim");w("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}");w("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");w("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");w("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");w("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");w("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");w("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");w("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");w("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");w("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}");w("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}");w("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}");w("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}");w("\\nleqq","\\html@mathml{\\@nleqq}{≰}");w("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}");w("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}");w("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}");w("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}");w("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}");w("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}");w("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}");w("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}");w("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}");w("\\imath","\\html@mathml{\\@imath}{ı}");w("\\jmath","\\html@mathml{\\@jmath}{ȷ}");w("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}");w("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}");w("⟦","\\llbracket");w("⟧","\\rrbracket");w("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}");w("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}");w("⦃","\\lBrace");w("⦄","\\rBrace");w("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}");w("⦵","\\minuso");w("\\darr","\\downarrow");w("\\dArr","\\Downarrow");w("\\Darr","\\Downarrow");w("\\lang","\\langle");w("\\rang","\\rangle");w("\\uarr","\\uparrow");w("\\uArr","\\Uparrow");w("\\Uarr","\\Uparrow");w("\\N","\\mathbb{N}");w("\\R","\\mathbb{R}");w("\\Z","\\mathbb{Z}");w("\\alef","\\aleph");w("\\alefsym","\\aleph");w("\\Alpha","\\mathrm{A}");w("\\Beta","\\mathrm{B}");w("\\bull","\\bullet");w("\\Chi","\\mathrm{X}");w("\\clubs","\\clubsuit");w("\\cnums","\\mathbb{C}");w("\\Complex","\\mathbb{C}");w("\\Dagger","\\ddagger");w("\\diamonds","\\diamondsuit");w("\\empty","\\emptyset");w("\\Epsilon","\\mathrm{E}");w("\\Eta","\\mathrm{H}");w("\\exist","\\exists");w("\\harr","\\leftrightarrow");w("\\hArr","\\Leftrightarrow");w("\\Harr","\\Leftrightarrow");w("\\hearts","\\heartsuit");w("\\image","\\Im");w("\\infin","\\infty");w("\\Iota","\\mathrm{I}");w("\\isin","\\in");w("\\Kappa","\\mathrm{K}");w("\\larr","\\leftarrow");w("\\lArr","\\Leftarrow");w("\\Larr","\\Leftarrow");w("\\lrarr","\\leftrightarrow");w("\\lrArr","\\Leftrightarrow");w("\\Lrarr","\\Leftrightarrow");w("\\Mu","\\mathrm{M}");w("\\natnums","\\mathbb{N}");w("\\Nu","\\mathrm{N}");w("\\Omicron","\\mathrm{O}");w("\\plusmn","\\pm");w("\\rarr","\\rightarrow");w("\\rArr","\\Rightarrow");w("\\Rarr","\\Rightarrow");w("\\real","\\Re");w("\\reals","\\mathbb{R}");w("\\Reals","\\mathbb{R}");w("\\Rho","\\mathrm{P}");w("\\sdot","\\cdot");w("\\sect","\\S");w("\\spades","\\spadesuit");w("\\sub","\\subset");w("\\sube","\\subseteq");w("\\supe","\\supseteq");w("\\Tau","\\mathrm{T}");w("\\thetasym","\\vartheta");w("\\weierp","\\wp");w("\\Zeta","\\mathrm{Z}");w("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");w("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");w("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");w("\\bra","\\mathinner{\\langle{#1}|}");w("\\ket","\\mathinner{|{#1}\\rangle}");w("\\braket","\\mathinner{\\langle{#1}\\rangle}");w("\\Bra","\\left\\langle#1\\right|");w("\\Ket","\\left|#1\\right\\rangle");var ey=r=>e=>{var t=e.consumeArg().tokens,n=e.consumeArg().tokens,i=e.consumeArg().tokens,o=e.consumeArg().tokens,s=e.macros.get("|"),a=e.macros.get("\\|");e.macros.beginGroup();var l=d=>h=>{r&&(h.macros.set("|",s),i.length&&h.macros.set("\\|",a));var f=d;if(!d&&i.length){var m=h.future();m.text==="|"&&(h.popToken(),f=!0)}return{tokens:f?i:n,numArgs:0}};e.macros.set("|",l(!1)),i.length&&e.macros.set("\\|",l(!0));var c=e.consumeArg().tokens,u=e.expandTokens([...o,...c,...t]);return e.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};w("\\bra@ket",ey(!1));w("\\bra@set",ey(!0));w("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");w("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");w("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");w("\\angln","{\\angl n}");w("\\blue","\\textcolor{##6495ed}{#1}");w("\\orange","\\textcolor{##ffa500}{#1}");w("\\pink","\\textcolor{##ff00af}{#1}");w("\\red","\\textcolor{##df0030}{#1}");w("\\green","\\textcolor{##28ae7b}{#1}");w("\\gray","\\textcolor{gray}{#1}");w("\\purple","\\textcolor{##9d38bd}{#1}");w("\\blueA","\\textcolor{##ccfaff}{#1}");w("\\blueB","\\textcolor{##80f6ff}{#1}");w("\\blueC","\\textcolor{##63d9ea}{#1}");w("\\blueD","\\textcolor{##11accd}{#1}");w("\\blueE","\\textcolor{##0c7f99}{#1}");w("\\tealA","\\textcolor{##94fff5}{#1}");w("\\tealB","\\textcolor{##26edd5}{#1}");w("\\tealC","\\textcolor{##01d1c1}{#1}");w("\\tealD","\\textcolor{##01a995}{#1}");w("\\tealE","\\textcolor{##208170}{#1}");w("\\greenA","\\textcolor{##b6ffb0}{#1}");w("\\greenB","\\textcolor{##8af281}{#1}");w("\\greenC","\\textcolor{##74cf70}{#1}");w("\\greenD","\\textcolor{##1fab54}{#1}");w("\\greenE","\\textcolor{##0d923f}{#1}");w("\\goldA","\\textcolor{##ffd0a9}{#1}");w("\\goldB","\\textcolor{##ffbb71}{#1}");w("\\goldC","\\textcolor{##ff9c39}{#1}");w("\\goldD","\\textcolor{##e07d10}{#1}");w("\\goldE","\\textcolor{##a75a05}{#1}");w("\\redA","\\textcolor{##fca9a9}{#1}");w("\\redB","\\textcolor{##ff8482}{#1}");w("\\redC","\\textcolor{##f9685d}{#1}");w("\\redD","\\textcolor{##e84d39}{#1}");w("\\redE","\\textcolor{##bc2612}{#1}");w("\\maroonA","\\textcolor{##ffbde0}{#1}");w("\\maroonB","\\textcolor{##ff92c6}{#1}");w("\\maroonC","\\textcolor{##ed5fa6}{#1}");w("\\maroonD","\\textcolor{##ca337c}{#1}");w("\\maroonE","\\textcolor{##9e034e}{#1}");w("\\purpleA","\\textcolor{##ddd7ff}{#1}");w("\\purpleB","\\textcolor{##c6b9fc}{#1}");w("\\purpleC","\\textcolor{##aa87ff}{#1}");w("\\purpleD","\\textcolor{##7854ab}{#1}");w("\\purpleE","\\textcolor{##543b78}{#1}");w("\\mintA","\\textcolor{##f5f9e8}{#1}");w("\\mintB","\\textcolor{##edf2df}{#1}");w("\\mintC","\\textcolor{##e0e5cc}{#1}");w("\\grayA","\\textcolor{##f6f7f7}{#1}");w("\\grayB","\\textcolor{##f0f1f2}{#1}");w("\\grayC","\\textcolor{##e3e5e6}{#1}");w("\\grayD","\\textcolor{##d6d8da}{#1}");w("\\grayE","\\textcolor{##babec2}{#1}");w("\\grayF","\\textcolor{##888d93}{#1}");w("\\grayG","\\textcolor{##626569}{#1}");w("\\grayH","\\textcolor{##3b3e40}{#1}");w("\\grayI","\\textcolor{##21242c}{#1}");w("\\kaBlue","\\textcolor{##314453}{#1}");w("\\kaGreen","\\textcolor{##71B307}{#1}");var ty={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class OA{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new NA(EA,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new o4(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,i;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:i,end:n}=this.consumeArg(["]"])}else({tokens:i,start:t,end:n}=this.consumeArg());return this.pushToken(new Vt("EOF",n.loc)),this.pushTokens(i),new Vt("",Ot.range(t,n))}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var i=this.future(),o,s=0,a=0;do{if(o=this.popToken(),t.push(o),o.text==="{")++s;else if(o.text==="}"){if(--s,s===-1)throw new V("Extra }",o)}else if(o.text==="EOF")throw new V("Unexpected end of input in a macro argument, expected '"+(e&&n?e[a]:"}")+"'",o);if(e&&n)if((s===0||s===1&&e[a]==="{")&&o.text===e[a]){if(++a,a===e.length){t.splice(-a,a);break}}else a=0}while(s!==0||n);return i.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:i,end:o}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new V("The length of delimiters doesn't match the number of args!");for(var n=t[0],i=0;i<n.length;i++){var o=this.popToken();if(n[i]!==o.text)throw new V("Use of the macro doesn't match its definition",o)}}for(var s=[],a=0;a<e;a++)s.push(this.consumeArg(t&&t[a+1]).tokens);return s}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new V("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),n=t.text,i=t.noexpand?null:this._getExpansion(n);if(i==null||e&&i.unexpandable){if(e&&i==null&&n[0]==="\\"&&!this.isDefined(n))throw new V("Undefined control sequence: "+n);return this.pushToken(t),!1}this.countExpansion(1);var o=i.tokens,s=this.consumeArgs(i.numArgs,i.delimiters);if(i.numArgs){o=o.slice();for(var a=o.length-1;a>=0;--a){var l=o[a];if(l.text==="#"){if(a===0)throw new V("Incomplete placeholder at end of macro body",l);if(l=o[--a],l.text==="#")o.splice(a+1,1);else if(/^[1-9]$/.test(l.text))o.splice(a,2,...s[+l.text-1]);else throw new V("Not a valid argument number",l)}}}return this.pushTokens(o),o.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Vt(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var i=this.stack.pop();i.treatAsRelax&&(i.noexpand=!1,i.treatAsRelax=!1),t.push(i)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(n=>n.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var i=typeof t=="function"?t(this):t;if(typeof i=="string"){var o=0;if(i.includes("#"))for(var s=i.replace(/##/g,"");s.includes("#"+(o+1));)++o;for(var a=new o4(i,this.settings),l=[],c=a.lex();c.text!=="EOF";)l.push(c),c=a.lex();l.reverse();var u={tokens:l,numArgs:o};return u}return i}isDefined(e){return this.macros.has(e)||Wn.hasOwnProperty(e)||Ie.math.hasOwnProperty(e)||Ie.text.hasOwnProperty(e)||ty.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:Wn.hasOwnProperty(e)&&!Wn[e].primitive}}var l4=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,L0=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),Ad={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},c4={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class du{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new OA(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new V("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Vt("}")),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,n}parseExpression(e,t){for(var n=[];;){this.mode==="math"&&this.consumeSpaces();var i=this.fetch();if(du.endOfExpression.has(i.text)||t&&i.text===t||e&&Wn[i.text]&&Wn[i.text].infix)break;var o=this.parseAtom(t);if(o){if(o.type==="internal")continue}else break;n.push(o)}return this.mode==="text"&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(e){for(var t=-1,n,i=0;i<e.length;i++){var o=e[i];if(o.type==="infix"){if(t!==-1)throw new V("only one infix operator per group",o.token);t=i,n=o.replaceWith}}if(t!==-1&&n){var s,a,l=e.slice(0,t),c=e.slice(t+1);l.length===1&&l[0].type==="ordgroup"?s=l[0]:s={type:"ordgroup",mode:this.mode,body:l},c.length===1&&c[0].type==="ordgroup"?a=c[0]:a={type:"ordgroup",mode:this.mode,body:c};var u;return n==="\\\\abovefrac"?u=this.callFunction(n,[s,e[t],a],[]):u=this.callFunction(n,[s,a],[]),[u]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var i;do{var o;i=this.parseGroup(e)}while(((o=i)==null?void 0:o.type)==="internal");if(!i)throw new V("Expected group after '"+n+"'",t);return i}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:"textord",mode:"text",text:e[n]});var i={type:"text",mode:this.mode,body:t},o={type:"color",mode:this.mode,color:this.settings.errorColor,body:[i]};return o}parseAtom(e){var t=this.parseGroup("atom",e);if((t==null?void 0:t.type)==="internal"||this.mode==="text")return t;for(var n,i;;){this.consumeSpaces();var o=this.fetch();if(o.text==="\\limits"||o.text==="\\nolimits"){if(t&&t.type==="op")t.limits=o.text==="\\limits",t.alwaysHandleSupSub=!0;else if(t&&t.type==="operatorname")t.alwaysHandleSupSub&&(t.limits=o.text==="\\limits");else throw new V("Limit controls must follow a math operator",o);this.consume()}else if(o.text==="^"){if(n)throw new V("Double superscript",o);n=this.handleSupSubscript("superscript")}else if(o.text==="_"){if(i)throw new V("Double subscript",o);i=this.handleSupSubscript("subscript")}else if(o.text==="'"){if(n)throw new V("Double superscript",o);var s={type:"textord",mode:this.mode,text:"\\prime"},a=[s];for(this.consume();this.fetch().text==="'";)a.push(s),this.consume();this.fetch().text==="^"&&a.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:a}}else if(L0[o.text]){var l=l4.test(o.text),c=[];for(c.push(new Vt(L0[o.text])),this.consume();;){var u=this.fetch().text;if(!L0[u]||l4.test(u)!==l)break;c.unshift(new Vt(L0[u])),this.consume()}var d=this.subparse(c);l?i={type:"ordgroup",mode:"math",body:d}:n={type:"ordgroup",mode:"math",body:d}}else break}return n&&i?{type:"supsub",mode:this.mode,base:t,sup:n,sub:i}:n?{type:"supsub",mode:this.mode,base:t,sup:n}:i?{type:"supsub",mode:this.mode,base:t,sub:i}:t}parseFunction(e,t){var n=this.fetch(),i=n.text,o=Wn[i];if(!o)return null;if(this.consume(),t&&t!=="atom"&&!o.allowedInArgument)throw new V("Got function '"+i+"' with no arguments"+(t?" as "+t:""),n);if(this.mode==="text"&&!o.allowedInText)throw new V("Can't use function '"+i+"' in text mode",n);if(this.mode==="math"&&o.allowedInMath===!1)throw new V("Can't use function '"+i+"' in math mode",n);var{args:s,optArgs:a}=this.parseArguments(i,o);return this.callFunction(i,s,a,n,e)}callFunction(e,t,n,i,o){var s={funcName:e,parser:this,token:i,breakOnTokenText:o},a=Wn[e];if(a&&a.handler)return a.handler(s,t,n);throw new V("No function handler for "+e)}parseArguments(e,t){var n,i=(n=t.numOptionalArgs)!=null?n:0,o=t.numArgs+i;if(o===0)return{args:[],optArgs:[]};for(var s=[],a=[],l=0;l<o;l++){var c,u=(c=t.argTypes)==null?void 0:c[l],d=l<i;("primitive"in t&&t.primitive&&u==null||t.type==="sqrt"&&l===1&&a[0]==null)&&(u="primitive");var h=this.parseGroupOfType("argument to '"+e+"'",u,d);if(d)a.push(h);else if(h!=null)s.push(h);else throw new V("Null argument, please report this as a bug")}return{args:s,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case"color":return this.parseColorGroup(n);case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,t);case"hbox":{var i=this.parseArgumentGroup(n,"text");return i!=null?{type:"styling",mode:i.mode,body:[i],style:"text",resetFont:!0}:null}case"raw":{var o=this.parseStringGroup(n);return o!=null?{type:"raw",mode:"text",string:o.text}:null}case"primitive":{if(n)throw new V("A primitive argument cannot be optional");var s=this.parseGroup(e);if(s==null)throw new V("Expected group as "+e,this.fetch());return s}case"original":case void 0:return this.parseArgumentGroup(n);default:throw new V("Unknown group type as "+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n="",i;(i=this.fetch()).text!=="EOF";)n+=i.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),i=n,o="",s;(s=this.fetch()).text!=="EOF"&&e.test(o+s.text);)i=s,o+=i.text,this.consume();if(o==="")throw new V("Invalid "+t+": '"+n.text+"'",n);return n.range(i,o)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new V("Invalid color: '"+t.text+"'",t);var i=n[0];return/^[0-9a-f]{6}$/i.test(i)&&(i="#"+i),{type:"color-token",mode:this.mode,color:i}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),!e&&this.gullet.future().text!=="{"?t=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):t=this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text="0pt",n=!0);var i=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!i)throw new V("Invalid size: '"+t.text+"'",t);var o={number:+(i[1]+i[2]),unit:i[3]};if(!p6(o))throw new V("Invalid unit: '"+o.unit+"'",t);return{type:"size",mode:this.mode,value:o,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var i=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var o=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var s={type:"ordgroup",mode:this.mode,loc:n.loc,body:o};return t&&this.switchMode(i),s}parseGroup(e,t){var n=this.fetch(),i=n.text,o;if(i==="{"||i==="\\begingroup"){this.consume();var s=i==="{"?"}":"\\endgroup";this.gullet.beginGroup();var a=this.parseExpression(!1,s),l=this.fetch();this.expect(s),this.gullet.endGroup(),o={type:"ordgroup",mode:this.mode,loc:Ot.range(n,l),body:a,semisimple:i==="\\begingroup"||void 0}}else if(o=this.parseFunction(t,e)||this.parseSymbol(),o==null&&i[0]==="\\"&&!ty.hasOwnProperty(i)){if(this.settings.throwOnError)throw new V("Undefined control sequence: "+i,n);o=this.formatUnsupportedCmd(i),this.consume()}return o}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var i=e[n];if(i.type==="textord"){var o=i.text,s=e[n+1];if(!(!s||s.type!=="textord")){if(o==="-"&&s.text==="-"){var a=e[n+2];n+1<t&&a&&a.type==="textord"&&a.text==="-"?(e.splice(n,3,{type:"textord",mode:"text",loc:Ot.range(i,a),text:"---"}),t-=2):(e.splice(n,2,{type:"textord",mode:"text",loc:Ot.range(i,s),text:"--"}),t-=1)}(o==="'"||o==="`")&&s.text===o&&(e.splice(n,2,{type:"textord",mode:"text",loc:Ot.range(i,s),text:o+o}),t-=1)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),i=n.charAt(0)==="*";if(i&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new V(`\\verb assertion failed --
1136
+ please report what input caused this bug`);return n=n.slice(1,-1),{type:"verb",mode:"text",body:n,star:i}}c4.hasOwnProperty(t[0])&&!Ie[this.mode][t[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+t[0]+'" used in math mode',e),t=c4[t[0]]+t.slice(1));var o=TA.exec(t);o&&(t=t.substring(0,o.index),t==="i"?t="ı":t==="j"&&(t="ȷ"));var s;if(Ie[this.mode][t]){this.settings.strict&&this.mode==="math"&&Sh.includes(t)&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var a=Ie[this.mode][t].group,l=Ot.range(e),c;PT(a)?c={type:"atom",mode:this.mode,family:a,loc:l,text:t}:c={type:a,mode:this.mode,loc:l,text:t},s=c}else if(t.charCodeAt(0)>=128)this.settings.strict&&(f6(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),s={type:"textord",mode:"text",loc:Ot.range(e),text:t};else return null;if(this.consume(),o)for(var u=0;u<o[0].length;u++){var d=o[0][u];if(!Ad[d])throw new V("Unknown accent ' "+d+"'",e);var h=Ad[d][this.mode]||Ad[d].text;if(!h)throw new V("Accent "+d+" unsupported in "+this.mode+" mode",e);s={type:"accent",mode:this.mode,loc:Ot.range(e),label:h,isStretchy:!1,isShifty:!0,base:s}}return s}}du.endOfExpression=new Set(["}","\\endgroup","\\end","\\right","&"]);var Up=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new du(e,t);delete n.gullet.macros.current["\\df@tag"];var i=n.parse();if(delete n.gullet.macros.current["\\current@color"],delete n.gullet.macros.current["\\color"],n.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new V("\\tag works only in display equations");i=[{type:"tag",mode:"text",body:i,tag:n.subparse([new Vt("\\df@tag")])}]}return i},ry=function(e,t,n){t.textContent="";var i=Kp(e,n).toNode();t.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),ry=function(){throw new V("KaTeX doesn't work in quirks mode.")});var RA=function(e,t){var n=Kp(e,t).toMarkup();return n},IA=function(e,t){var n=new Ip(t);return Up(e,n)},ny=function(e,t,n){if(n.throwOnError||!(e instanceof V))throw e;var i=$(["katex-error"],[new Wt(t)]);return i.setAttribute("title",e.toString()),i.setAttribute("style","color:"+n.errorColor),i},Kp=function(e,t){var n=new Ip(t);try{var i=Up(e,n);return ET(i,e,n)}catch(o){return ny(o,e,n)}},zA=function(e,t){var n=new Ip(t);try{var i=Up(e,n);return DT(i,e,n)}catch(o){return ny(o,e,n)}},LA="0.17.0",BA={Span:_s,Anchor:tu,SymbolNode:Wt,SvgNode:bn,PathNode:Zn,LineNode:kh},iy={version:LA,render:ry,renderToString:RA,ParseError:V,SETTINGS_SCHEMA:bh,__parse:IA,__renderToDomTree:Kp,__renderToHTMLTree:zA,__setFontMetrics:uT,__defineSymbol:p,__defineFunction:X,__defineMacro:w,__domTree:BA};function PA(){return{enter:{mathFlow:r,mathFlowFenceMeta:e,mathText:o},exit:{mathFlow:i,mathFlowFence:n,mathFlowFenceMeta:t,mathFlowValue:a,mathText:s,mathTextData:a}};function r(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function e(){this.buffer()}function t(){const l=this.resume(),c=this.stack[this.stack.length-1];Gs(c.type==="math"),c.meta=l}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];Gs(u.type==="math"),this.exit(l),u.value=c;const d=u.data.hChildren[0];Gs(d.type==="element"),Gs(d.tagName==="code"),d.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function o(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function s(l){const c=this.resume(),u=this.stack[this.stack.length-1];Gs(u.type==="inlineMath"),this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function a(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}function FA(r){let e=(r||{}).singleDollarTextMath;return e==null&&(e=!0),n.peek=i,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`
1137
1137
  `,inConstruct:"mathFlowMeta"},{character:"$",after:e?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:t,inlineMath:n}};function t(o,s,a,l){const c=o.value||"",u=a.createTracker(l),d="$".repeat(Math.max(Jy(c,"$")+1,2)),h=a.enter("mathFlow");let f=u.move(d);if(o.meta){const m=a.enter("mathFlowMeta");f+=u.move(a.safe(o.meta,{after:`
1138
1138
  `,before:f,encode:["$"],...u.current()})),m()}return f+=u.move(`
1139
1139
  `),c&&(f+=u.move(c+`
1140
- `)),f+=u.move(d),h(),f}function n(o,s,a){let l=o.value||"",c=1;for(e||c++;new RegExp("(^|[^$])"+"\\$".repeat(c)+"([^$]|$)").test(l);)c++;const u="$".repeat(c);/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^\$|\$$/.test(l))&&(l=" "+l+" ");let d=-1;for(;++d<a.unsafe.length;){const h=a.unsafe[d];if(!h.atBreak)continue;const f=a.compilePattern(h);let m;for(;m=f.exec(l);){let y=m.index;l.codePointAt(y)===10&&l.codePointAt(y-1)===13&&y--,l=l.slice(0,y)+" "+l.slice(m.index+1)}}return u+l+u}function i(){return"$"}}const HA={tokenize:_A,concrete:!0,name:"mathFlow"},u4={tokenize:qA,partial:!0};function _A(r,e,t){const n=this,i=n.events[n.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let s=0;return a;function a(S){return r.enter("mathFlow"),r.enter("mathFlowFence"),r.enter("mathFlowFenceSequence"),l(S)}function l(S){return S===36?(r.consume(S),s++,l):s<2?t(S):(r.exit("mathFlowFenceSequence"),p0(r,c,"whitespace")(S))}function c(S){return S===null||wr(S)?d(S):(r.enter("mathFlowFenceMeta"),r.enter("chunkString",{contentType:"string"}),u(S))}function u(S){return S===null||wr(S)?(r.exit("chunkString"),r.exit("mathFlowFenceMeta"),d(S)):S===36?t(S):(r.consume(S),u)}function d(S){return r.exit("mathFlowFence"),n.interrupt?e(S):r.attempt(u4,h,x)(S)}function h(S){return r.attempt({tokenize:b,partial:!0},x,f)(S)}function f(S){return(o?p0(r,m,"linePrefix",o+1):m)(S)}function m(S){return S===null?x(S):wr(S)?r.attempt(u4,h,x)(S):(r.enter("mathFlowValue"),y(S))}function y(S){return S===null||wr(S)?(r.exit("mathFlowValue"),m(S)):(r.consume(S),y)}function x(S){return r.exit("mathFlow"),e(S)}function b(S,A,D){let O=0;return p0(S,L,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function L(K){return S.enter("mathFlowFence"),S.enter("mathFlowFenceSequence"),N(K)}function N(K){return K===36?(O++,S.consume(K),N):O<s?D(K):(S.exit("mathFlowFenceSequence"),p0(S,$,"whitespace")(K))}function $(K){return K===null||wr(K)?(S.exit("mathFlowFence"),A(K)):D(K)}}}function qA(r,e,t){const n=this;return i;function i(s){return s===null?e(s):(r.enter("lineEnding"),r.consume(s),r.exit("lineEnding"),o)}function o(s){return n.parser.lazy[n.now().line]?t(s):e(s)}}function $A(r){let t=(r||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:jA,previous:VA,name:"mathText"};function n(i,o,s){let a=0,l,c;return u;function u(y){return i.enter("mathText"),i.enter("mathTextSequence"),d(y)}function d(y){return y===36?(i.consume(y),a++,d):a<2&&!t?s(y):(i.exit("mathTextSequence"),h(y))}function h(y){return y===null?s(y):y===36?(c=i.enter("mathTextSequence"),l=0,m(y)):y===32?(i.enter("space"),i.consume(y),i.exit("space"),h):wr(y)?(i.enter("lineEnding"),i.consume(y),i.exit("lineEnding"),h):(i.enter("mathTextData"),f(y))}function f(y){return y===null||y===32||y===36||wr(y)?(i.exit("mathTextData"),h(y)):(i.consume(y),f)}function m(y){return y===36?(i.consume(y),l++,m):l===a?(i.exit("mathTextSequence"),i.exit("mathText"),o(y)):(c.type="mathTextData",f(y))}}}function jA(r){let e=r.length-4,t=3,n,i;if((r[t][1].type==="lineEnding"||r[t][1].type==="space")&&(r[e][1].type==="lineEnding"||r[e][1].type==="space")){for(n=t;++n<e;)if(r[n][1].type==="mathTextData"){r[e][1].type="mathTextPadding",r[t][1].type="mathTextPadding",t+=2,e-=2;break}}for(n=t-1,e++;++n<=e;)i===void 0?n!==e&&r[n][1].type!=="lineEnding"&&(i=n):(n===e||r[n][1].type==="lineEnding")&&(r[i][1].type="mathTextData",n!==i+2&&(r[i][1].end=r[n-1][1].end,r.splice(i+2,n-i-2),e-=n-i-2,n=i+2),i=void 0);return r}function VA(r){return r!==36||this.events[this.events.length-1][1].type==="characterEscape"}function WA(r){return{flow:{36:HA},text:{36:$A(r)}}}const UA={};function KA(r){const e=this,t=r||UA,n=e.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(WA(t)),o.push(PA()),s.push(FA(t))}const oy=B.createContext(null),GA=oy.Provider;function Tr(){const r=B.useContext(oy);if(!r)throw new Error("useEditorCtx must be used within <MarkdownEditor>");if(!r.current)throw new Error("Milkdown ctx is not ready yet");return r.current}function $s(r){return B.useSyncExternalStore(e=>(r.dom.addEventListener("blintz:editable",e),()=>r.dom.removeEventListener("blintz:editable",e)),()=>r.editable,()=>r.editable)}function _r(...r){return r.filter(Boolean).join(" ")}const YA=!0;function d4(r){return()=>r()}function sy(r){return r.$from.parent.type.name==="code_block"}function ay(r){var e,t;return((t=(e=r.$from.node(r.$from.depth-1))==null?void 0:e.type)==null?void 0:t.name)==="list_item"}function hu(r){return i6.sanitize(r)}function ke({icon:r,className:e,onPointerDown:t}){return z.jsx("span",{className:_r("milkdown-icon",e),onPointerDown:t,dangerouslySetInnerHTML:r?{__html:hu(r.trim())}:void 0})}const fu=ye({show:()=>{},hide:()=>{}},"crepeMenuAPICtx"),Gp=ye({onAdd:()=>{}},"crepeBlockHandleAPICtx"),Yp=ye(null,"crepeSlashStoreCtx");function JA(){const r=Tr(),e=B.useRef(null);return z.jsxs(z.Fragment,{children:[z.jsx("div",{ref:e,className:"operation-item",onPointerDown:t=>{var n;t.preventDefault(),t.stopPropagation(),(n=e.current)==null||n.classList.add("active")},onPointerUp:t=>{var n;t.preventDefault(),t.stopPropagation(),(n=e.current)==null||n.classList.remove("active"),r.get(Gp.key).onAdd()},children:z.jsx(ke,{icon:ph})}),z.jsx("div",{className:"operation-item",children:z.jsx(ke,{icon:xC})})]})}const Fh="image-block";function XA(r){return new Error(`Expected an HTMLElement, got ${String(r)}`)}const Hh=$e("image-block",()=>({inline:!1,group:"block",selectable:!0,draggable:!0,isolating:!0,marks:"",atom:!0,priority:100,attrs:{src:{default:"",validate:"string"},caption:{default:"",validate:"string"},ratio:{default:1,validate:"number"}},parseDOM:[{tag:`img[data-type="${Fh}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw XA(r);return{src:r.getAttribute("src")||"",caption:r.getAttribute("caption")||"",ratio:Number(r.getAttribute("ratio")??1)}}}],toDOM:r=>["img",{"data-type":Fh,...r.attrs}],parseMarkdown:{match:({type:r})=>r==="image-block",runner:(r,e,t)=>{const n=e.url,i=e.title;let o=Number(e.alt||1);(Number.isNaN(o)||o===0)&&(o=1),r.addNode(t,{src:n,caption:i,ratio:o})}},toMarkdown:{match:r=>r.type.name==="image-block",runner:(r,e)=>{r.openNode("paragraph"),r.addNode("image",void 0,void 0,{title:e.attrs.caption,url:e.attrs.src,alt:`${Number.parseFloat(e.attrs.ratio).toFixed(2)}`}),r.closeNode()}}}));var Li,zl;class ly{constructor(){P(this,Li,[]);We(this,"clear",()=>(I(this,Li,[]),this));P(this,zl,e=>{const t={group:e,addItem:(n,i)=>{const o={...i,key:n};return e.items.push(o),t},clear:()=>(e.items=[],t)};return t});We(this,"addGroup",(e,t)=>{const n={key:e,label:t,items:[]};return C(this,Li).push(n),C(this,zl).call(this,n)});We(this,"getGroup",e=>{const t=C(this,Li).find(n=>n.key===e);if(!t)throw new Error(`Group with key ${e} not found`);return C(this,zl).call(this,t)});We(this,"build",()=>C(this,Li))}}Li=new WeakMap,zl=new WeakMap;function h4(r){const e=new ly,t=e.addGroup("text","Text");t.addItem("text",{label:"Text",icon:VC,onRun:l=>{const c=l.get(ee),u=cr.type(l);c.call(Qt.key),c.call(J0.key,{nodeType:u})}});const n=[["h1",kC,1],["h2",MC,2],["h3",SC,3],["h4",CC,4],["h5",TC,5],["h6",AC,6]];for(const[l,c,u]of n)t.addItem(l,{label:`Heading ${u}`,icon:c,onRun:d=>{const h=d.get(ee),f=ii.type(d);h.call(Qt.key),h.call(J0.key,{nodeType:f,attrs:{level:u}})}});t.addItem("quote",{label:"Quote",icon:zC,onRun:l=>{const c=l.get(ee),u=zs.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),t.addItem("divider",{label:"Divider",icon:IC,onRun:l=>{const c=l.get(ee),u=Ls.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u})}});const i=e.addGroup("list","List");i.addItem("bullet-list",{label:"Bullet List",icon:RC,onRun:l=>{const c=l.get(ee),u=no.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),i.addItem("ordered-list",{label:"Ordered List",icon:DC,onRun:l=>{const c=l.get(ee),u=oi.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),i.addItem("task-list",{label:"Task List",icon:OC,onRun:l=>{const c=l.get(ee),u=fr.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u,attrs:{checked:!1}})}});const o=e.addGroup("advanced","Advanced");o.addItem("image",{label:"Image",icon:Dp,onRun:l=>{const c=l.get(ee),u=Hh.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u})}}),o.addItem("code",{label:"Code",icon:o6,onRun:l=>{const c=l.get(ee),u=jr.type(l);c.call(Qt.key),c.call(J0.key,{nodeType:u})}}),o.addItem("table",{label:"Table",icon:_C,onRun:l=>{const c=l.get(ee),u=l.get(ge);c.call(Qt.key);const{from:d}=u.state.selection;c.call(aa.key,{nodeType:lp(l,3,3)}),c.call(k3.key,{pos:d})}}),o.addItem("math",{label:"Math",icon:PC,onRun:l=>{const c=l.get(ee),u=jr.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u,attrs:{language:"LaTeX"}})}});let s=e.build();if(r){const l=r.toLowerCase();s=s.map(c=>({...c,items:c.items.filter(u=>u.label.toLowerCase().includes(l))})).filter(c=>c.items.length>0)}const a=s.flatMap(l=>l.items);return a.forEach((l,c)=>{Object.assign(l,{index:c})}),s.reduce((l,c)=>{const u=l+c.items.length;return Object.assign(c,{range:[l,u]}),u},0),{groups:s,size:a.length}}const ZA={show:!1,filter:""},QA={subscribe:()=>()=>{},getSnapshot:()=>ZA,set:()=>{}};function eN(){const r=Tr(),e=r.get(Yp.key)??QA,{show:t,filter:n}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),{groups:i,size:o}=B.useMemo(()=>h4(n),[n]),[s,a]=B.useState(0),l=B.useRef(null),c=B.useRef({x:-999,y:-999}),u=B.useRef(s);u.current=s;const d=B.useRef(i);d.current=i;const h=B.useRef(o);h.current=o;const f=B.useCallback(()=>r.get(fu.key).hide(),[r]),m=B.useCallback(D=>{const O=l.current,L=O==null?void 0:O.querySelector(`[data-index="${D}"]`),N=O==null?void 0:O.querySelector(".menu-groups");!L||!N||(N.scrollTop=L.offsetTop-N.offsetTop)},[]),y=B.useCallback((D,O)=>{const L=u.current,N=typeof D=="function"?D(L):D;O==null||O(N),a(N)},[]),x=B.useCallback(D=>{const O=e.getSnapshot().filter,L=h4(O).groups,N=O===n?D:0,$=L.flatMap(K=>K.items).at(N);$!=null&&$.onRun&&$.onRun(r),f()},[r,f,e,n]),b=B.useCallback(D=>{const O=h.current,L=d.current;if(D.key==="Escape"||D.key==="Enter"||D.key==="ArrowUp"||D.key==="ArrowDown"||D.key==="ArrowLeft"||D.key==="ArrowRight"){if(D.preventDefault(),D.stopPropagation(),D.key==="Escape"){f();return}if(D.key==="ArrowDown"){y(N=>N<O-1?N+1:N,m);return}if(D.key==="ArrowUp"){y(N=>N<=0?N:N-1,m);return}if(D.key==="ArrowLeft"){y(N=>{const $=L.find(ne=>ne.range[0]<=N&&ne.range[1]>N);if(!$)return N;const K=L[L.indexOf($)-1];return K?K.range[1]-1:N},m);return}if(D.key==="ArrowRight"){y(N=>{const $=L.find(ne=>ne.range[0]<=N&&ne.range[1]>N);if(!$)return N;const K=L[L.indexOf($)+1];return K?K.range[0]:N},m);return}D.key==="Enter"&&x(u.current)}},[f,y,x,m]);B.useEffect(()=>{if(t)return window.addEventListener("keydown",b,{capture:!0}),()=>window.removeEventListener("keydown",b,{capture:!0})},[t,b]),B.useEffect(()=>{o===0&&t?f():s>=o&&a(0)},[o,t,s,f]);const S=D=>{c.current={x:D.clientX,y:D.clientY}},A=D=>O=>{const L=c.current;O.clientX===L.x&&O.clientY===L.y||y(D)};return z.jsxs("div",{ref:l,onPointerDown:D=>D.preventDefault(),children:[z.jsx("nav",{className:"tab-group",children:z.jsx("ul",{children:i.map(D=>z.jsx("li",{onPointerDown:()=>y(D.range[0],m),className:s>=D.range[0]&&s<D.range[1]?"selected":"",children:D.label},D.key))})}),z.jsx("div",{className:"menu-groups",role:"listbox","aria-label":"Insert block",onPointerMove:S,children:i.map(D=>z.jsxs("div",{className:"menu-group",children:[z.jsx("h6",{children:D.label}),z.jsx("ul",{children:D.items.map(O=>z.jsxs("li",{"data-index":O.index,role:"option","aria-selected":s===O.index,"aria-label":O.label,className:s===O.index?"hover":"",onPointerEnter:A(O.index),onPointerDown:()=>{var L,N;(N=(L=l.current)==null?void 0:L.querySelector(`[data-index="${O.index}"]`))==null||N.classList.add("active")},onPointerUp:()=>{var L,N;(N=(L=l.current)==null?void 0:L.querySelector(`[data-index="${O.index}"]`))==null||N.classList.remove("active"),x(O.index)},children:[z.jsx(ke,{icon:O.icon}),z.jsx("span",{children:O.label})]},O.key))})]},D.key))})]})}const f4=new Set(["bullet_list","ordered_list"]),tN=Fe(()=>new Ce({key:new Me("MARKDOWN_EDITOR_ROBUST_BLOCK_DRAG"),view:r=>{const e=()=>{const t=r.dragging;if(!t||t.node)return;const{selection:n}=r.state;if(!(n instanceof re))return;let i=t.slice;const o=n.node;if(o.type.name==="list_item"){const s=n.$from.parent;if(f4.has(s.type.name)){const a=s.type.create(s.attrs,H.from(o));i=new Y(H.from(a),1,1)}}r.dragging={...t,slice:i,node:n}};return document.addEventListener("dragstart",e),{destroy:()=>document.removeEventListener("dragstart",e)}},appendTransaction:(r,e,t)=>{if(!r.some(o=>o.getMeta("uiEvent")==="drop"))return null;const n=t.tr;let i=!1;for(;;){let o=null;if(n.doc.descendants((s,a,l,c)=>{if(o!==null)return!1;if(!l||!f4.has(s.type.name))return!0;const u=c+1<l.childCount?l.child(c+1):null;if(u&&u.type===s.type){const d=a+s.nodeSize;if(Bl(n.doc,d))return o=d,!1}return!0}),o===null)break;n.join(o),i=!0}return i?n:null}}));function rN(){let r={show:!1,filter:""};const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>r,set:t=>{const n={...r,...t};n.show===r.show&&n.filter===r.filter||(r=n,e.forEach(i=>i()))}}}const cy=IS("CREPE_MENU");function nN(r,e){let t,n;const i=()=>(n||(n=document.createElement("div"),n.className="milkdown-block-handle",n.dataset.show="false"),n),o=()=>{const a=r.get(ge);if(!a.editable)return;a.hasFocus()||a.focus();const l=t==null?void 0:t.active;if(!l)return;const{state:c,dispatch:u}=a,d=l.$pos.pos+l.node.nodeSize;let h=c.tr.insert(d,cr.type(r).create());h=h.setSelection(Q.near(h.doc.resolve(d))),u(h.scrollIntoView()),t==null||t.hide(),r.get(fu.key).show(h.selection.from)};r.set(Gp.key,{onAdd:o}),r.set(Kc.key,{filterNodes:a=>!Fr(l=>["table","blockquote","math_inline"].includes(l.type.name))(a)});const s=e({component:JA,root:()=>i()});r.set(Jc.key,{view:a=>{const l=s(a);return t=new RS({ctx:r,content:i(),getOffset:()=>16,getPlacement:({active:c,blockDom:u})=>{if(c.node.type.name==="heading")return"left";let d=0;c.node.descendants(D=>{d+=D.childCount});const h=c.el,f=h.getBoundingClientRect(),m=u.getBoundingClientRect(),y=window.getComputedStyle(h),x=Number.parseInt(y.paddingTop,10)||0,b=Number.parseInt(y.paddingBottom,10)||0,S=f.height-x-b,A=m.height;return d>2||A<S?"left-start":"left"}}),t.update(),{update:(c,u)=>{var d;(d=l.update)==null||d.call(l,c,u),t==null||t.update()},destroy:()=>{var c;(c=l.destroy)==null||c.call(l),t==null||t.destroy(),t=void 0,n=void 0}}}})}function iN(r,e){const t=rN();r.set(Yp.key,t);let n,i,o=null;const s=()=>(i||(i=document.createElement("div"),i.className="milkdown-slash-menu",i.dataset.show="false"),i),a=d=>{if(!d.editable||sy(d.state.selection)||ay(d.state.selection))return!1;const h=n==null?void 0:n.getContent(d,f=>["paragraph","heading"].includes(f.type.name));if(h==null||!oN(d.state.selection))return!1;if(t.set({filter:h.startsWith("/")?h.slice(1):h}),typeof o=="number"){const f=d.state.doc.nodeSize-2,m=Math.min(o,f);return d.state.doc.resolve(m).node()!==d.state.doc.resolve(d.state.selection.from).node()?(o=null,!1):!0}return!!h.startsWith("/")},l=()=>{o=null,n==null||n.hide()},c=d=>{o=d,t.set({filter:""}),n==null||n.show()};r.set(fu.key,{show:c,hide:l});const u=e({component:eN,root:()=>s()});r.set(cy.key,{view:d=>{const h=u(d);return n=new zS({content:s(),debounce:20,shouldShow:a,offset:10}),n.onShow=()=>t.set({show:!0}),n.onHide=()=>t.set({show:!1}),n.update(d),{update:(f,m)=>{var x;const y=n==null?void 0:n.getContent(f,b=>["paragraph","heading"].includes(b.type.name));y!=null&&t.set({filter:y.startsWith("/")?y.slice(1):y}),(x=h.update)==null||x.call(h,f,m),n==null||n.update(f,m)},destroy:()=>{var f;(f=h.destroy)==null||f.call(h),n==null||n.destroy(),n=void 0,i=void 0,o=null}}}})}function oN(r){if(!(r instanceof Q))return!1;const{$head:e}=r;return e.parentOffset===e.parent.content.size}function sN(r,e){r.config(t=>nN(t,e)).config(t=>iN(t,e)).use(fu).use(Gp).use(Yp).use(Jc).use(cy).use(tN)}const aN=[ta.theme({"&":{color:"var(--crepe-color-on-surface)",backgroundColor:"var(--crepe-color-surface)"},".cm-content":{fontFamily:"var(--crepe-font-code)",caretColor:"var(--crepe-color-on-surface)"},".cm-scroller":{fontFamily:"var(--crepe-font-code)",lineHeight:"1.65",overflow:"auto"},".cm-gutters":{color:"var(--crepe-color-on-surface-variant)",backgroundColor:"var(--crepe-color-surface)",border:"none"},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:"var(--crepe-color-hover)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"var(--crepe-color-selected)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--crepe-color-on-surface)"},".cm-tooltip":{color:"var(--crepe-color-on-surface)",backgroundColor:"var(--crepe-color-surface-low)",borderColor:"var(--crepe-color-outline)"},".cm-searchMatch":{backgroundColor:"var(--crepe-color-secondary)",outline:"1px solid var(--crepe-color-primary)"}}),L4(k7.define([{tag:[rt.keyword,rt.modifier],color:"var(--blintz-syntax-keyword)"},{tag:[rt.string,rt.regexp],color:"var(--blintz-syntax-string)"},{tag:[rt.number,rt.bool,rt.null],color:"var(--blintz-syntax-number)"},{tag:rt.comment,color:"var(--blintz-syntax-comment)",fontStyle:"italic"},{tag:[rt.function(rt.variableName),rt.function(rt.propertyName)],color:"var(--blintz-syntax-function)"},{tag:[rt.typeName,rt.className,rt.tagName,rt.attributeName],color:"var(--blintz-syntax-type)"},{tag:[rt.operator,rt.punctuation],color:"var(--blintz-syntax-operator)"}]))];async function lN(r){try{return await navigator.clipboard.writeText(r)}catch{const e=document.createElement("textarea"),t=document.activeElement;e.value=r,e.setAttribute("readonly",""),e.style.contain="strict",e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="12pt";const n=document.getSelection(),i=n?n.rangeCount>0&&n.getRangeAt(0):null;document.body.appendChild(e),e.select(),e.selectionStart=0,e.selectionEnd=r.length,document.execCommand("copy"),document.body.removeChild(e),i&&(n.removeAllRanges(),n.addRange(i)),t&&t.focus()}}function cN({copyText:r,copyIcon:e,onCopy:t,text:n}){return z.jsxs("button",{type:"button",className:"copy-button",onClick:()=>{lN(n).then(()=>t(n)).catch(console.error)},children:[z.jsx(ke,{icon:e}),r]})}function uN({language:r,config:e,setLanguage:t,getAllLanguages:n,getReadOnly:i}){const o=B.useRef(null),s=B.useRef(null),a=B.useRef(null),[l,c]=B.useState(!1),[u,d]=B.useState("");B.useEffect(()=>{if(!l)return;d("");const m=o.current,y=s.current;if(!m||!y)return;qr(m,y,{placement:"bottom-start"}).then(({x:b,y:S})=>{Object.assign(y.style,{left:`${b}px`,top:`${S}px`})}).catch(console.error);const x=setTimeout(()=>{var b;return(b=a.current)==null?void 0:b.focus()},0);return()=>clearTimeout(x)},[l]),B.useEffect(()=>{if(!l)return;const m=y=>{var b,S;const x=y.target;(b=o.current)!=null&&b.contains(x)||(S=s.current)!=null&&S.contains(x)||c(!1)};return window.addEventListener("click",m),()=>window.removeEventListener("click",m)},[l]);const h=m=>{m.preventDefault(),m.stopPropagation(),!i()&&c(y=>!y)},f=B.useMemo(()=>{if(!l)return[];const m=n()??[],y=m.find(S=>S.name.toLowerCase()===r.toLowerCase()),x=u.toLowerCase(),b=m.filter(S=>(S.name.toLowerCase().includes(x)||S.alias.some(A=>A.toLowerCase().includes(x)))&&S!==y);return b.length===0?[]:y?[y,...b]:b},[l,u,r,n]);return z.jsxs(z.Fragment,{children:[z.jsxs("button",{type:"button",ref:o,className:"language-button","aria-label":"Code language","aria-expanded":l,disabled:i(),onClick:h,"data-expanded":String(l),children:[r||"Text",z.jsx("div",{className:"expand-icon",children:z.jsx(ke,{icon:e.expandIcon})})]}),z.jsx("div",{ref:s,className:"language-picker",children:l?z.jsxs("div",{className:"list-wrapper",children:[z.jsxs("div",{className:"search-box",children:[z.jsx("div",{className:"search-icon",children:z.jsx(ke,{icon:e.searchIcon})}),z.jsx("input",{ref:a,className:"search-input",placeholder:e.searchPlaceholder,"aria-label":e.searchPlaceholder,value:u,onChange:m=>d(m.target.value),onKeyDown:m=>{var y;m.key==="Escape"&&(c(!1),(y=o.current)==null||y.focus())}}),z.jsx("div",{className:_r("clear-icon",u.length===0&&"hidden"),onMouseDown:m=>{m.preventDefault(),d("")},children:z.jsx(ke,{icon:e.clearSearchIcon})})]}),z.jsx("ul",{className:"language-list",role:"listbox",onKeyDown:m=>{if(m.key==="Enter"){const y=document.activeElement;y instanceof HTMLElement&&y.dataset.language&&(t(y.dataset.language),c(!1))}},children:f.length?f.map(m=>{const y=m.name.toLowerCase()===r.toLowerCase();return z.jsx("li",{role:"option","aria-selected":y,tabIndex:0,className:"language-list-item","data-language":m.name,onClick:()=>{t(m.name),c(!1)},children:e.renderLanguage(m.name,y)},m.name)}):z.jsx("li",{className:"language-list-item no-result",children:e.noResultText})})]}):null})]})}const dN="http://www.w3.org/2000/svg";function hN(){const r=i6(),e={ADD_TAGS:["foreignObject"],ADD_ATTR:["xmlns"],HTML_INTEGRATION_POINTS:{foreignobject:!0}};return r.addHook("uponSanitizeElement",(t,n)=>{var i;if(n.tagName==="foreignobject"){const o=t.parentElement;(!o||o.namespaceURI!==dN)&&((i=t.parentNode)==null||i.removeChild(t))}}),t=>r.sanitize(t,e)}let p4;function fN(r){return p4??(p4=hN()),p4(r)}function pN({config:r,previewOnlyMode:e,preview:t}){const n=B.useRef(null);return B.useEffect(()=>{const i=n.current;if(i){for(;i.firstChild;)i.removeChild(i.firstChild);(typeof t=="string"||t instanceof Element)&&(i.innerHTML=fN(t))}},[t]),t?z.jsxs("div",{className:"preview-panel",children:[!e&&z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"preview-divider"}),z.jsx("div",{className:"preview-label",children:r.previewLabel})]}),z.jsx("div",{ref:n,className:"preview"})]}):null}const vc=new WeakMap;function mN(r,e){let t=vc.get(r);t||(t=new Set,vc.set(r,t)),t.add(e)}function gN(r,e){var t;(t=vc.get(r))==null||t.delete(e)}function m4(r,e){const t=vc.get(r);if(t)for(const n of t){const i=n.getPos();if(i==null)continue;const o=i+n.node.nodeSize;if(e>=i&&e<=o)return n}}class yN{constructor(e,t,n,i,o){We(this,"cm",null);We(this,"updating",!1);We(this,"languageName","");We(this,"languageConf",new Om);We(this,"readOnlyConf",new Om);We(this,"onTextChange",null);We(this,"node");We(this,"view");We(this,"getPos");We(this,"loader");We(this,"config");We(this,"forwardUpdate",e=>{if(!this.cm||this.updating||!this.cm.hasFocus)return;let t=(this.getPos()??0)+1;const{main:n}=e.state.selection,i=t+n.from,o=t+n.to,s=this.view.state.selection;if(e.docChanged||s.from!==i||s.to!==o){const a=this.view.state.tr;e.changes.iterChanges((l,c,u,d,h)=>{h.length?a.replaceWith(t+l,t+c,this.view.state.schema.text(h.toString())):a.delete(t+l,t+c),t+=d-u-(c-l)}),a.setSelection(Q.create(a.doc,i,o)),this.view.dispatch(a)}});We(this,"codeMirrorKeymap",()=>{const e=this.view;return[{key:"ArrowUp",run:()=>this.maybeEscape("line",-1)},{key:"ArrowLeft",run:()=>this.maybeEscape("char",-1)},{key:"ArrowDown",run:()=>this.maybeEscape("line",1)},{key:"ArrowRight",run:()=>this.maybeEscape("char",1)},{key:"Mod-Enter",run:()=>!e.editable||!g5(e.state,e.dispatch)?!1:(e.focus(),!0)},{key:"Mod-z",run:()=>e.editable&&wp(e.state,e.dispatch)},{key:"Shift-Mod-z",run:()=>e.editable&&hc(e.state,e.dispatch)},{key:"Mod-y",run:()=>e.editable&&hc(e.state,e.dispatch)},{key:"Backspace",run:()=>{if(!this.cm||!e.editable)return!1;const t=this.cm.state.selection.ranges;if(t.length>1)return!1;const n=t[0];if(n&&(!n.empty||n.anchor>0)||this.cm.state.doc.lines>=2)return!1;const i=this.view.state,o=this.getPos()??0,s=i.tr.replaceWith(o,o+this.node.nodeSize,i.schema.nodes.paragraph.createChecked({},this.node.content));return s.setSelection(Q.near(s.doc.resolve(o))),this.view.dispatch(s),this.view.focus(),!0}}]});We(this,"maybeEscape",(e,t)=>{if(!this.cm)return!1;const{state:n}=this.cm;let i=n.selection.main;if(!i.empty||(e==="line"&&(i=n.doc.lineAt(i.head)),t<0?i.from>0:i.to<n.doc.length))return!1;const o=(this.getPos()??0)+(t<0?0:this.node.nodeSize),s=Q.near(this.view.state.doc.resolve(o),t),a=this.view.state.tr.setSelection(s).scrollIntoView();return this.view.dispatch(a),this.view.focus(),!0});this.node=e,this.view=t,this.getPos=n,this.loader=i,this.config=o,mN(t,this)}init(e){return this.cm?this.cm:(this.cm=new ta({doc:this.node.textContent,root:this.view.root,extensions:[this.readOnlyConf.of([P0.readOnly.of(!this.view.editable),ta.editable.of(this.view.editable)]),z4(),Wh.of(this.codeMirrorKeymap()),this.languageConf.of([]),P0.changeFilter.of(()=>this.view.editable),...this.config.extensions,ta.updateListener.of(this.forwardUpdate)]}),e.appendChild(this.cm.dom),this.updateLanguage(),this.cm)}forceInit(){return this.cm?this.cm:this.init(document.createElement("div"))}updateLanguage(){if(!this.cm)return;const e=this.node.attrs.language??"";e!==this.languageName&&this.loader.load(e).then(t=>{this.cm&&(t?this.cm.dispatch({effects:this.languageConf.reconfigure(t)}):this.cm.dispatch({effects:this.languageConf.reconfigure([])}),this.languageName=e)}).catch(console.error)}setSelection(e,t){const n=this.forceInit();n.dom.isConnected&&(n.focus(),this.updating=!0,n.dispatch({selection:{anchor:e,head:t}}),this.updating=!1)}selectNode(){this.forceInit().focus()}update(e){if(e.type!==this.node.type)return!1;if(this.updating||(this.node=e,!this.cm))return!0;this.updateLanguage(),this.view.editable===this.cm.state.readOnly&&this.cm.dispatch({effects:this.readOnlyConf.reconfigure([P0.readOnly.of(!this.view.editable),ta.editable.of(this.view.editable)])});const t=vN(this.cm.state.doc.toString(),e.textContent);return t&&(this.updating=!0,this.cm.dispatch({changes:{from:t.from,to:t.to,insert:t.text},scrollIntoView:!0}),this.updating=!1),!0}destroy(){var e;gN(this.view,this),(e=this.cm)==null||e.destroy(),this.cm=null}}function vN(r,e){if(r===e)return null;let t=0,n=r.length,i=e.length;for(;t<n&&r.charCodeAt(t)===e.charCodeAt(t);)++t;for(;n>t&&i>t&&r.charCodeAt(n-1)===e.charCodeAt(i-1);)n--,i--;return{from:t,to:n,text:e.slice(t,i)}}const No={extensions:[],languages:[],expandIcon:"⬇",searchIcon:"🔍",clearSearchIcon:"⌫",searchPlaceholder:"Search language",noResultText:"No result",copyText:"Copy",copyIcon:"📋",onCopy:()=>{},renderLanguage:r=>r,renderPreview:()=>null,previewToggleButton:r=>r?"Edit":"Hide",previewLabel:"Preview",previewLoading:"Loading..."},bc=ye(No,"codeBlockConfigCtx");class bN{constructor(e){We(this,"map");We(this,"languages");this.languages=e,this.map={},e.forEach(t=>{t.alias.forEach(n=>{this.map[n]=t})})}getAll(){return this.languages.map(e=>({name:e.name,alias:e.alias}))}load(e){const t=this.map[e.toLowerCase()];return t?t.support?Promise.resolve(t.support):t.load():Promise.resolve(void 0)}}function wN(){const{node:r,view:e,getPos:t,setAttrs:n,selected:i}=Es(),o=Tr(),s=$s(e),a=o.get(bc.key),l=B.useRef(null),c=B.useRef(null),u=B.useMemo(()=>new bN(a.languages),[a.languages]),d=r.attrs.language??"",h=r.textContent,[f,m]=B.useState(null),[y,x]=B.useState(a.previewOnlyByDefault??!e.editable);return B.useEffect(()=>{const b=l.current;if(!b)return;const S=new yN(r,e,t,u,a);c.current=S;const A=S.init(b);return A.dom.parentElement!==b&&b.appendChild(A.dom),()=>{S.destroy(),c.current=null}},[]),B.useEffect(()=>{const b=c.current;b&&(b.view=e,b.getPos=t,b.config=a,b.loader=u,b.update(r))}),B.useEffect(()=>{var S;const b=(S=l.current)==null?void 0:S.parentElement;b&&b.classList.toggle("selected",i)},[i]),B.useEffect(()=>{const b=a.renderPreview(d,h,S=>m(S));if(b){m(b);return}if(b===void 0){m(S=>S||a.previewLoading);return}m(null)},[d,h]),z.jsxs(z.Fragment,{children:[z.jsxs("div",{className:"tools",contentEditable:!1,children:[z.jsx(uN,{language:d,config:a,setLanguage:b=>{n({language:b})},getAllLanguages:()=>u.getAll(),getReadOnly:()=>!s}),z.jsxs("div",{className:"tools-button-group",children:[z.jsx(cN,{copyIcon:a.copyIcon,copyText:a.copyText,onCopy:a.onCopy??(()=>{}),text:h}),f?z.jsx("button",{type:"button",className:"preview-toggle-button",onClick:()=>x(b=>!b),children:z.jsx(ke,{icon:a.previewToggleButton(y)})}):null]})]}),z.jsx("div",{ref:l,className:_r("codemirror-host",f&&y&&"hidden")}),z.jsx(pN,{config:a,previewOnlyMode:y,preview:f})]})}function xN(r,e){const t=Ha(jr.node,()=>e({component:wN,as:()=>{const n=document.createElement("div");return n.className="milkdown-code-block",n.contentEditable="false",n},stopEvent:()=>!0,selectNode:()=>{var o;const n=r.ctx.get(ge),i=n.state.selection;(o=m4(n,i.from))==null||o.selectNode()},setSelection:(n,i)=>{var a;const o=r.ctx.get(ge),s=o.state.selection;(a=m4(o,s.from))==null||a.setSelection(n,i)}}));r.config(n=>{const i=[Wh.of(B4.concat(S7)),UC,aN];n.update(bc.key,()=>({extensions:i,languages:C7,expandIcon:yC,searchIcon:LC,clearSearchIcon:WC,searchPlaceholder:"Search language",copyText:"Copy",copyIcon:s6,onCopy:()=>{},noResultText:"No result",renderLanguage:No.renderLanguage,renderPreview:No.renderPreview,previewToggleButton:o=>[o?a6:wC,o?"Edit":"Hide"].map(s=>s.trim()).join(" "),previewLabel:No.previewLabel,previewLoading:No.previewLoading,previewOnlyByDefault:No.previewOnlyByDefault}))}).use(bc).use(t)}function kN(r){r.config(e=>{e.update(Zc.key,()=>({class:"crepe-drop-cursor",width:4,color:!1}))}).use(cM).use(Fe(()=>uM()))}const SN=fk.filter(r=>r!==Ss.plugin&&r!==Ss.options),CN=new Set(["<br />","<br>","<br >","<br/>"]);function uy(r){if(!Array.isArray(r.children))return;const e=n=>n.type==="html"&&CN.has((n.value??"").trim()),t=["root","blockquote","listItem","list"].includes(r.type);r.children=r.children.filter(n=>{var i;return!(n.type==="paragraph"&&((i=n.children)!=null&&i.length)&&n.children.every(e))&&!(t&&e(n))}).map(n=>e(n)?{type:"break"}:n);for(const n of r.children)uy(n)}const MN=dr("markdownEditorStripEmptyLineBreaks",()=>()=>r=>{uy(r)}),TN=dr("remarkFrontmatter",()=>EM,"yaml"),B0="frontmatter",AN=$e(B0,()=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,parseDOM:[{tag:`pre[data-type="${B0}"]`,preserveWhitespace:"full"}],toDOM:()=>["pre",{"data-type":B0,class:"milkdown-frontmatter"},["code",{spellcheck:"false"},0]],parseMarkdown:{match:r=>r.type==="yaml",runner:(r,e,t)=>{const n=e.value??"";r.openNode(t),n.length>0&&r.addText(n),r.closeNode()}},toMarkdown:{match:r=>r.type.name===B0,runner:(r,e)=>{r.addNode("yaml",void 0,e.textContent)}}}));function NN(r){r.use(TN).use(AN)}function dy({src:r,readonly:e,setLink:t,imageIcon:n,uploadButton:i,confirmButton:o,uploadPlaceholderText:s,className:a,onUpload:l,onImageLoadError:c}){const u=B.useId(),d=B.useRef(null),[h,f]=B.useState(!1),[m,y]=B.useState(r??""),[x,b]=B.useState(((r==null?void 0:r.length)??0)!==0),S=L=>{const N=L.target.value;b(N.length!==0),y(N)},A=L=>{var N;L.key==="Enter"&&t(((N=d.current)==null?void 0:N.value)??"")},D=()=>{var L;t(((L=d.current)==null?void 0:L.value)??"")},O=L=>{var $;const N=($=L.target.files)==null?void 0:$[0];N&&l(N).then(K=>{K&&(t(K),b(!0))}).catch(K=>{console.error("An error occurred while uploading image"),console.error(K)})};return e?z.jsx("span",{className:"image-unavailable",children:"Image unavailable"}):z.jsxs("div",{className:_r("image-edit",a),children:[z.jsx(ke,{className:"image-icon",icon:n}),z.jsxs("div",{className:_r("link-importer",h&&"focus"),children:[z.jsx("input",{ref:d,"aria-label":"Image address",draggable:"true",onDragStart:L=>{L.preventDefault(),L.stopPropagation()},disabled:e,className:"link-input-area",value:m,onChange:S,onKeyDown:A,onFocus:()=>f(!0),onBlur:()=>f(!1)}),!x&&z.jsxs("div",{className:"placeholder",children:[z.jsx("input",{disabled:e,className:"hidden","aria-label":"Upload image",id:u,type:"file",accept:"image/*",onChange:O}),z.jsx("label",{className:"uploader",htmlFor:u,children:z.jsx(ke,{icon:i})}),z.jsx("span",{className:"text",onClick:()=>{var L;return(L=d.current)==null?void 0:L.focus()},children:s})]})]}),m&&z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"image-preview",children:z.jsx("img",{src:m,alt:"",onError:L=>Promise.resolve(c==null?void 0:c(L.nativeEvent)).catch(()=>{})})}),z.jsx("button",{type:"button","aria-label":"Insert image",className:"confirm",onClick:()=>D(),children:z.jsx(ke,{icon:o})})]})]})}function EN({src:r,caption:e,ratio:t,readonly:n,config:i,setAttr:o}){const s=B.useRef(null),a=B.useRef(0),[l,c]=B.useState(!!(e!=null&&e.length)),u=()=>{const b=s.current;if(!b)return;const S=b.closest(".milkdown-image-block");if(!S)return;let A=S.getBoundingClientRect().width;if(!A)return;i.maxWidth&&i.maxWidth<A&&(A=i.maxWidth);const D=b.naturalHeight,O=b.naturalWidth;let L=O<A?D:A*(D/O);i.maxHeight&&L>i.maxHeight&&(L=i.maxHeight);const N=(L*(t??1)).toFixed(2);b.dataset.origin=L.toFixed(2),b.dataset.height=N,b.style.height=`${N}px`,i.maxWidth&&(b.style.maxWidth=`${i.maxWidth}px`)},d=b=>{b.preventDefault(),b.stopPropagation(),!n&&c(S=>!S)},h=b=>{const S=b.target.value;a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{o("caption",S)},1e3)},f=b=>{const S=b.target.value;a.current&&(window.clearTimeout(a.current),a.current=0),o("caption",S)},m=B.useCallback(b=>{b.preventDefault();const S=s.current;if(!S)return;const A=S.getBoundingClientRect().top;let D=b.clientY-A;D<100&&(D=100),i.maxHeight&&D>i.maxHeight&&(D=i.maxHeight);const O=Number(D).toFixed(2);S.dataset.height=O,S.style.height=`${O}px`},[i.maxHeight]),y=B.useCallback(()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y);const b=s.current;if(!b)return;const S=Number(b.dataset.origin),A=Number(b.dataset.height),D=Number.parseFloat(Number(A/S).toFixed(2));Number.isNaN(D)||o("ratio",D)},[m,o]),x=b=>{n||(b.preventDefault(),b.stopPropagation(),window.addEventListener("pointermove",m),window.addEventListener("pointerup",y))};return B.useEffect(()=>()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y),a.current&&window.clearTimeout(a.current)},[m,y]),z.jsxs(z.Fragment,{children:[z.jsxs("div",{className:"image-wrapper",children:[!n&&z.jsx("div",{className:"operation",children:z.jsx("button",{type:"button","aria-label":"Toggle image caption","aria-pressed":l,className:"operation-item",onClick:d,children:z.jsx(ke,{icon:i.captionIcon})})}),z.jsx("img",{ref:s,"data-type":Fh,onLoad:u,src:r,alt:e,onError:b=>{var S;return Promise.resolve((S=i.onImageLoadError)==null?void 0:S.call(i,b.nativeEvent)).catch(()=>{})}}),!n&&z.jsx("div",{className:"image-resize-handle",onPointerDown:x})]}),n?e?z.jsx("div",{className:"caption-input",children:e}):null:l&&z.jsx("input",{"aria-label":"Image caption",draggable:"true",onDragStart:b=>{b.preventDefault(),b.stopPropagation()},className:"caption-input",placeholder:i==null?void 0:i.captionPlaceholderText,onChange:h,onBlur:f,defaultValue:e})]})}const DN={imageIcon:Dp,captionIcon:gC,uploadButton:"Upload file",confirmButton:Xc,uploadPlaceholderText:"or paste link",captionPlaceholderText:"Write Image Caption",onUpload:r=>Promise.resolve(URL.createObjectURL(r))},_h=ye(DN,"imageBlockConfigCtx"),ON={imageIcon:Dp,uploadButton:"Upload",confirmButton:Xc,uploadPlaceholderText:"or paste link",onUpload:r=>Promise.resolve(URL.createObjectURL(r))},hy=ye(ON,"inlineImageConfigCtx");function RN(){const{node:r,view:e,setAttrs:t,selected:n}=Es(),i=Tr().get(_h.key),{src:o,caption:s,ratio:a}=r.attrs,l=!$s(e),[c,u]=B.useState(o);B.useEffect(()=>{const h=i.proxyDomURL;if(!h){u(o);return}const f=h(o);if(typeof f=="string"){u(f);return}let m=!1;return f.then(y=>{m||u(y)}).catch(console.error),()=>{m=!0}},[o,i.proxyDomURL]);const d=(h,f)=>{e.editable&&t({[h]:h==="src"?hu(f):f})};return o!=null&&o.length?z.jsx(EN,{src:c,caption:s,ratio:a,readonly:l,config:i,setAttr:d}):z.jsx(dy,{src:o,readonly:l,setLink:h=>d("src",h),imageIcon:i.imageIcon,uploadButton:i.uploadButton,confirmButton:i.confirmButton,uploadPlaceholderText:i.uploadPlaceholderText,onUpload:i.onUpload,onImageLoadError:i.onImageLoadError,className:n?"selected":void 0})}function IN(){const{node:r,view:e,setAttrs:t}=Es(),n=Tr().get(hy.key),{src:i,alt:o,title:s}=r.attrs,a=!$s(e),[l,c]=B.useState(i);B.useEffect(()=>{const d=n.proxyDomURL;if(!d){c(i);return}const h=d(i);if(typeof h=="string"){c(h);return}let f=!1;return h.then(m=>{f||c(m)}).catch(console.error),()=>{f=!0}},[i,n.proxyDomURL]);const u=d=>{e.editable&&t({src:hu(d)})};return i!=null&&i.length?z.jsx("img",{className:"image-inline",src:l,alt:o,title:s}):z.jsx(dy,{src:i,readonly:a,setLink:u,imageIcon:n.imageIcon,uploadButton:n.uploadButton,confirmButton:n.confirmButton,uploadPlaceholderText:n.uploadPlaceholderText,onUpload:n.onUpload,className:"empty-image-inline"})}function zN(r){return Qi(r,"paragraph",(e,t,n)=>{var c,u;if(t==null||!n||((c=e.children)==null?void 0:c.length)!==1)return;const i=(u=e.children)==null?void 0:u[0];if(!i||i.type!=="image")return;const{url:o,alt:s,title:a}=i,l={type:"image-block",url:o,alt:s,title:a};n.children.splice(t,1,l)})}const LN=dr("remark-image-block",()=>()=>zN);function BN(r,e){const t=Ha(Hh.node,()=>e({component:RN,as:()=>{const i=document.createElement("div");return i.className="milkdown-image-block",i},stopEvent:i=>i.target instanceof HTMLInputElement})),n=Ha(ro.node,()=>e({component:IN,as:()=>{const i=document.createElement("span");return i.className="milkdown-image-inline",i},stopEvent:i=>i.target instanceof HTMLInputElement}));r.config(i=>{i.update(Oo.key,o=>({...o,uploader:async(s,a)=>{const l=a.nodes["image-block"]??a.nodes.image;if(!l)return[];const c=a.nodes["image-block"]?i.get(_h.key).onUpload:void 0,u=[];for(let d=0;d<s.length;d++){const h=s.item(d);h&&h.type.includes("image")&&u.push(h)}return await Promise.all(u.map(async d=>{const h=c?await c(d):URL.createObjectURL(d);return l.createAndFill({src:h})}))}}))}).use(_h).use(hy).use(Hh).use(LN).use(t).use(n)}const Jp=ye(null,"crepeLatexInlineEditStoreCtx"),PN={value:"",token:0,onConfirm:()=>{}},FN={subscribe:()=>()=>{},getSnapshot:()=>PN};function HN(){const r=Tr().get(Jp.key)??FN,{value:e,token:t,onConfirm:n}=B.useSyncExternalStore(r.subscribe,r.getSnapshot),[i,o]=B.useState(e);B.useEffect(()=>o(e),[t,e]);const s=()=>n(i);return z.jsxs("div",{className:"container",children:[z.jsx("input",{className:"latex-input","aria-label":"Math expression",placeholder:"Enter LaTeX...",value:i,onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&(a.preventDefault(),s())},onChange:a=>o(a.target.value)}),z.jsx("button",{type:"button",className:"button","aria-label":"Apply math expression",onPointerDown:a=>{a.preventDefault()},onClick:s,children:z.jsx(ke,{icon:Xc})})]})}const ua="math_inline",wc=$e(ua,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${ua}"]`,getAttrs:r=>({value:r.dataset.value??""})}],toDOM:r=>{const e=r.attrs.value??"",t=document.createElement("span");return t.dataset.type=ua,t.dataset.value=e,iy.render(e,t,{throwOnError:!1}),t},parseMarkdown:{match:r=>r.type==="inlineMath",runner:(r,e,t)=>{r.addNode(t,{value:e.value})}},toMarkdown:{match:r=>r.type.name===ua,runner:(r,e)=>{r.addNode("inlineMath",void 0,e.attrs.value)}}})),_N=jr.extendSchema(r=>e=>{const t=r(e);return{...t,toMarkdown:{match:t.toMarkdown.match,runner:(n,i)=>{var o;if((i.attrs.language??"").toLowerCase()==="latex")n.addNode("math",void 0,((o=i.content.firstChild)==null?void 0:o.text)||"");else return t.toMarkdown.runner(n,i)}}}}),qN=le("ToggleLatex",r=>()=>(e,t)=>{const{hasNode:n,pos:i,target:o}=D5(e,wc.type(r)),{selection:s,doc:a,tr:l}=e;if(!n){const f=a.textBetween(s.from,s.to),m=l.replaceSelectionWith(wc.type(r).create({value:f}));return t&&t(m.setSelection(re.create(m.doc,s.from))),!0}const{from:c,to:u}=s;if(!o||i<0)return!1;let d=l.delete(i,i+1);const h=o.attrs.value;return d=d.insertText(h,i),t&&t(d.setSelection(Q.create(d.doc,c,u+h.length-1))),!0}),$N=mt(r=>Qw(/(?:\$)([^$]+)(?:\$)$/,wc.type(r),{getAttr:e=>({value:e[1]??""})})),jN=mt(r=>df(/^\$\$[\s\n]$/,jr.type(r),()=>({language:"LaTeX"}))),VN=dr("remarkMath",()=>KA);function WN(r){return Qi(r,"math",(e,t,n)=>{t==null||!n||n.children.splice(t,1,{type:"code",lang:"LaTeX",value:e.value??""})})}const UN=dr("remarkMathBlock",()=>()=>WN);function KN(r,e){return iy.renderToString(r,{...e,throwOnError:!1,displayMode:!0})}function GN(r){let e=r;const t=new Set;return{subscribe:n=>(t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,set:n=>{e=n,t.forEach(i=>i())}}}function YN(){return GN({value:"",token:0,onConfirm:()=>{}})}const g4=eu("CREPE_INLINE_LATEX");function JN(r,e){const t=YN();r.set(Jp.key,t);let n,i,o=0,s=-1;const a=()=>(i||(i=document.createElement("div"),i.className="milkdown-latex-inline-edit",i.dataset.show="false"),i),l=u=>d=>{const h=r.get(ge);h.dispatch(h.state.tr.setNodeAttribute(u,"value",d)),requestAnimationFrame(()=>h.focus())},c=u=>{if(!u.editable)return s=-1,!1;const{selection:d}=u.state;if(!(d instanceof re)||d.node.type.name!==ua)return s=-1,!1;const h=d.from;return h!==s&&(s=h,o+=1,t.set({value:d.node.attrs.value??"",token:o,onConfirm:l(h)})),!0};return e({component:HN,root:()=>a(),update:(u,d)=>{n||(n=new Qc({content:a(),debounce:0,offset:10,floatingUIOptions:{placement:"bottom"},shouldShow:c})),n.update(u,d)},destroy:()=>{n==null||n.destroy(),n=void 0,i=void 0,s=-1}})}function XN(r,e){r.config(t=>{t.update(bc.key,n=>({...n,renderPreview:(i,o,s)=>i.toLowerCase()==="latex"&&o.length>0?KN(o):n.renderPreview(i,o,s)})),t.set(g4.key,{view:JN(t,e)})}).use(VN).use(UN).use(wc).use(g4).use($N).use(jN).use(_N).use(qN).use(Jp)}const xc=ye({mode:"preview"},"crepeLinkTooltipStateCtx"),Ns=ye({addLink:()=>{},editLink:()=>{},removeLink:()=>{}},"crepeLinkTooltipAPICtx"),Xp=ye({linkIcon:s6,editButton:a6,removeButton:mh,confirmButton:Xc,inputPlaceholder:"Paste link...",onCopyLink:()=>{}},"crepeLinkTooltipConfigCtx"),Zp=ye(null,"crepeLinkPreviewStoreCtx"),Qp=ye(null,"crepeLinkEditStoreCtx"),ZN={src:"",token:0,onConfirm:()=>{},onCancel:()=>{}},QN={subscribe:()=>()=>{},getSnapshot:()=>ZN};function eE(){const r=Tr(),e=r.get(Qp.key)??QN,{src:t,token:n,onConfirm:i,onCancel:o}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),s=r.get(Xp.key),[a,l]=B.useState(t);B.useEffect(()=>l(t),[n,t]);const c=()=>i(a),u=d=>{d.stopPropagation(),d.key==="Enter"&&(d.preventDefault(),c()),d.key==="Escape"&&(d.preventDefault(),o())};return z.jsxs("div",{className:"link-edit",children:[z.jsx("input",{className:"input-area","aria-label":"Link address",placeholder:s.inputPlaceholder,value:a,onKeyDown:u,onChange:d=>l(d.target.value)}),a?z.jsx("button",{type:"button",className:"button confirm","aria-label":"Apply link",onPointerDown:d=>d.preventDefault(),onClick:c,children:z.jsx(ke,{icon:s.confirmButton})}):null]})}const tE={href:"",onEdit:()=>{},onRemove:()=>{}},rE={subscribe:()=>()=>{},getSnapshot:()=>tE};function nE(){const r=Tr(),e=r.get(Zp.key)??rE,{href:t,onEdit:n,onRemove:i}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),o=r.get(Xp.key),s=c=>{c.preventDefault(),navigator.clipboard&&t&&navigator.clipboard.writeText(t).then(()=>o.onCopyLink(t)).catch(u=>console.error(u))},a=c=>{c.preventDefault(),c.stopPropagation(),n()},l=c=>{c.preventDefault(),c.stopPropagation(),i()};return z.jsxs("div",{className:"link-preview",children:[z.jsx("button",{type:"button",className:"button link-icon","aria-label":"Copy link",onPointerDown:c=>c.preventDefault(),onClick:s,children:z.jsx(ke,{icon:o.linkIcon})}),z.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"link-display",children:t}),z.jsx("button",{type:"button",className:"button link-edit-button","aria-label":"Edit link",onPointerDown:c=>c.preventDefault(),onClick:a,children:z.jsx(ke,{icon:o.editButton})}),z.jsx("button",{type:"button",className:"button link-remove-button","aria-label":"Remove link",onPointerDown:c=>c.preventDefault(),onClick:l,children:z.jsx(ke,{icon:o.removeButton})})]})}const fy=le("CrepeToggleLink",r=>()=>e=>{const{doc:t,selection:n}=e,i=Cr.type(r);return t.rangeHasMark(n.from,n.to,i)?(r.get(Ns.key).removeLink(n.from,n.to),!0):(r.get(Ns.key).addLink(n.from,n.to),!0)});function py(r){let e=r;const t=new Set;return{subscribe:n=>(t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,set:n=>{e=n,t.forEach(i=>i())}}}function iE(){return py({href:"",onEdit:()=>{},onRemove:()=>{}})}function oE(){return py({src:"",token:0,onConfirm:()=>{},onCancel:()=>{}})}const em=eu("CREPE_LINK_PREVIEW"),my=eu("CREPE_LINK_EDIT");function sE(r,e,t,n,i){let o={start:-1,end:-1};return t.nodesBetween(n,i,(s,a)=>{if(o.start>-1)return!1;o.start===-1&&r.isInSet(s.marks)&&e===s&&(o={start:a,end:a+Math.max(s.textContent.length,1)})}),o}function aE(r,e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return;const{pos:i}=n,o=e.state.doc.nodeAt(i);if(!o)return;const s=o.marks.find(a=>a.type===Cr.mark.type(r));if(!(!s||!em.pluginKey()))return{show:!0,pos:i,node:o,mark:s}}function lE(r,e){let t;return(...n)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...n),e)}}const y4=50;function cE(r,e){const t=iE();r.set(Zp.key,t);let n,i,o,s=!1;const a=()=>(i||(i=document.createElement("div"),i.className="milkdown-link-preview",i.dataset.show="false"),i),l=()=>{s=!0},c=()=>{s=!1},u=()=>{n==null||n.hide(),n==null||n.element.removeEventListener("mouseenter",l),n==null||n.element.removeEventListener("mouseleave",c)},d=()=>{s||u()},h=(b,S,A,D)=>{!n||!o||(t.set({href:b.attrs.href,onEdit:()=>r.get(Ns.key).editLink(b,S,A),onRemove:()=>{r.get(Ns.key).removeLink(S,A),u()}}),n.show({getBoundingClientRect:()=>D},o),n.element.addEventListener("mouseenter",l),n.element.addEventListener("mouseleave",c))},f=e({component:nE,root:()=>a()}),m=b=>{const S=f(b);return o=b,n=new Qc({content:a(),debounce:0,shouldShow:()=>!1}),n.update(b),{update:(A,D)=>{var O;o=A,(O=S.update)==null||O.call(S,A,D)},destroy:()=>{var A;u(),(A=S.destroy)==null||A.call(S),n==null||n.destroy(),n=void 0,i=void 0,o=void 0}}},y=lE((b,S)=>{if(!n||!b.hasFocus()||r.get(xc.key).mode==="edit")return;const A=aE(r,b,S);if(A){const D=b.state.doc.resolve(A.pos),O=sE(A.mark,A.node,b.state.doc,D.before(),D.after()),L=O.start,N=O.end;h(A.mark,L,N,Bc(b,L,N));return}d()},y4),x=()=>{setTimeout(()=>d(),y4)};return r.set(em.key,{props:{handleDOMEvents:{mousemove:y,mouseleave:x}},view:m}),{hide:u}}function uE(r,e,t){const n=oE();r.set(Qp.key,n);let i,o,s=0,a={from:-1,to:-1,mark:null};const l=()=>(o||(o=document.createElement("div"),o.className="milkdown-link-edit",o.dataset.show="false"),o),c=b=>{const S=b.target;S&&(l().contains(S)||h())},u=()=>document.addEventListener("pointerdown",c,!0),d=()=>document.removeEventListener("pointerdown",c,!0);function h(){d(),i==null||i.hide(),r.update(xc.key,b=>({...b,mode:"preview"})),a={from:-1,to:-1,mark:null}}const f=b=>{const S=r.get(ge),{from:A,to:D,mark:O}=a,L=Cr.type(r),N=hu(b);if(O&&O.attrs.href===N){h();return}const $=S.state.tr;if(O&&$.removeMark(A,D,O),A===D){if(!N){h();return}const K=L.create({href:N});$.insertText(N,A),$.addMark(A,A+N.length,K)}else $.addMark(A,D,L.create({href:N}));S.dispatch($),h()},m=(b,S,A)=>{t(),s+=1,n.set({src:b,token:s,onConfirm:f,onCancel:h}),r.update(xc.key,O=>({...O,mode:"edit"}));const D=r.get(ge);D.dispatch(D.state.tr.setSelection(Q.create(D.state.doc,S,A))),i==null||i.show({getBoundingClientRect:()=>Bc(D,S,A)},D),u(),requestAnimationFrame(()=>{var O;(O=l().querySelector("input"))==null||O.focus()})};r.update(Ns.key,b=>({...b,addLink:(S,A)=>{a={from:S,to:A,mark:null},m("",S,A)},editLink:(S,A,D)=>{a={from:A,to:D,mark:S},m(S.attrs.href??"",A,D)},removeLink:(S,A)=>{const D=r.get(ge),O=D.state.tr;O.removeMark(S,A,Cr.type(r)),D.dispatch(O),h()}}));const y=e({component:eE,root:()=>l()}),x=b=>{const S=y(b);return i=new Qc({content:l(),debounce:0,shouldShow:()=>!1}),i.onHide=()=>{requestAnimationFrame(()=>b.dom.focus({preventScroll:!0}))},i.update(b),{update:(A,D)=>{var $;if(($=S.update)==null||$.call(S,A,D),a.from===-1&&a.to===-1)return;const{selection:O}=A.state;if(!(O instanceof Q))return;const{from:L,to:N}=O;L===a.from&&N===a.to||h()},destroy:()=>{var A;d(),(A=S.destroy)==null||A.call(S),i==null||i.destroy(),i=void 0,o=void 0}}};r.set(my.key,{view:x})}function dE(r,e){r.config(t=>{const n=cE(t,e);uE(t,e,n.hide)}).use(xc).use(Ns).use(Xp).use(Zp).use(Qp).use(em).use(my).use(fy)}function v4({label:r,listType:e,checked:t}){return t==null?e==="bullet"?'<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="2.5" /></svg>':r:t?BC:FC}function hE(){const{node:r,view:e,getPos:t,selected:n,contentRef:i}=Es(),{label:o,checked:s,listType:a}=r.attrs,l=!$s(e),c=()=>{if(!e.editable)return;const d=t();d!=null&&e.dispatch(e.state.tr.setNodeAttribute(d,"checked",!s))},u=s==null?a==="bullet"?"bullet":"ordered":s?"checked":"unchecked";return z.jsxs("div",{className:_r("milkdown-list-item-content",n&&"ProseMirror-selectednode"),children:[s==null?z.jsx("span",{className:"label-wrapper",contentEditable:!1,"aria-hidden":"true",children:z.jsx(ke,{className:_r("label",u),icon:v4({label:o,listType:a,checked:s})})}):z.jsx("button",{type:"button",role:"checkbox","aria-checked":s,"aria-label":r.textContent||"Task",disabled:l,className:"label-wrapper task-checkbox",contentEditable:!1,onPointerDown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{d.stopPropagation(),c()},children:z.jsx(ke,{className:_r("label",u),icon:v4({label:o,listType:a,checked:s})})}),z.jsx("div",{className:"children",ref:i})]})}const fE=Fe(r=>new Ce({key:new Me("MARKDOWN_EDITOR_ORDERED_LIST_LABEL_SYNC"),appendTransaction:(e,t,n)=>{if(t.doc.eq(n.doc))return null;const i=oi.type(r),o=fr.type(r);let s=n.tr,a=!1;return n.doc.descendants((l,c)=>{if(l.type!==i)return;const u=l.attrs.order??1;l.forEach((d,h,f)=>{if(d.type!==o)return;const m=`${f+u}.`;d.attrs.label!==m&&(s=s.setNodeMarkup(c+1+h,void 0,{...d.attrs,label:m,listType:"ordered"}),a=!0)})}),a?s.setMeta("addToHistory",!1):null}}));function pE(r,e){const t=Ha(fr.node,()=>e({component:hE,as:()=>{const n=document.createElement("li");return n.className="milkdown-list-item-block",n},contentAs:"div",stopEvent:()=>!1}));r.use(t).use(fE)}function mE(r){var e;return r.childCount<=1&&!((e=r.firstChild)!=null&&e.content.size)}function gE(r,e){const{selection:t}=r;if(!t.empty)return null;const n=t.$anchor,i=n.parent;if(i.content.size>0||Fr(s=>s.type.name==="table")(n))return null;const o=n.before();return qe.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":e})}const qh=ye({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),yE=Fe(r=>new Ce({key:new Me("CREPE_PLACEHOLDER"),props:{decorations:e=>{let t=!0;try{t=r.get(ge).editable}catch{t=!0}if(!t)return null;const n=r.get(qh.key);if(n.mode==="doc"&&!mE(e.doc)||sy(e.selection)||ay(e.selection))return null;const i=gE(e,n.text??"Please enter...");return i?Se.create(e.doc,[i]):null}}}));function vE(r,e){r.config(t=>{e&&t.update(qh.key,n=>({...n,...e}))}).use(yE).use(qh)}function bE(){var x;const{node:r,view:e,getPos:t}=Es(),n=Tr(),i=$s(e),[o,s]=B.useState(!1),[a,l]=B.useState({row:0,col:0}),c=B.useRef(null),u=B.useRef(null),d=B.useRef(null);B.useEffect(()=>{var S,A;if(!o)return;(A=(S=u.current)==null?void 0:S.querySelector("button:not(:disabled)"))==null||A.focus();const b=D=>{var O;D.target instanceof Node&&!((O=d.current)!=null&&O.contains(D.target))&&s(!1)};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[o]),B.useEffect(()=>{i||s(!1)},[i]);const h=()=>{if(!e.editable)return;const{$from:b}=e.state.selection,S=t();let A=0,D=0;if(S!=null&&b.pos>S&&b.pos<S+r.nodeSize){for(let O=0;O<=b.depth;O++)if(b.node(O).type.name==="table"){A=b.index(O),D=O<b.depth?b.index(O+1):0;break}}l({row:A,col:D}),s(!o)},f=b=>{if(!e.editable)return;const S=t();if(S==null)return;const A=n.get(ee),D=S+1;b==="add-row"||b==="delete-row"?(A.call(fn.key,{pos:D,index:a.row}),A.call(b==="add-row"?Uc.key:_a.key)):b==="add-col"||b==="delete-col"?(A.call(pn.key,{pos:D,index:a.col}),A.call(b==="add-col"?Wc.key:_a.key)):b==="row-up"||b==="row-down"?(A.call(fn.key,{pos:D,index:a.row}),A.call(jc.key,{pos:D,from:a.row,to:a.row+(b==="row-up"?-1:1)})):(A.call(pn.key,{pos:D,index:a.col}),A.call(Vc.key,{pos:D,from:a.col,to:a.col+(b==="col-left"?-1:1)})),s(!1),e.focus()};if(!i)return null;const m=r.childCount,y=((x=r.firstChild)==null?void 0:x.childCount)??0;return z.jsxs("div",{className:"milkdown-table-actions",contentEditable:!1,ref:d,children:[z.jsx("button",{type:"button",ref:c,"aria-label":"Table actions","aria-haspopup":"menu","aria-expanded":o,onPointerDown:b=>b.preventDefault(),onClick:h,children:"•••"}),o&&z.jsxs("div",{className:"milkdown-table-actions-menu",role:"menu","aria-label":"Table actions",ref:u,onKeyDown:b=>{var S,A,D;if(b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),s(!1),(S=c.current)==null||S.focus()),b.key==="ArrowDown"||b.key==="ArrowUp"){b.preventDefault(),b.stopPropagation();const O=Array.from(((A=u.current)==null?void 0:A.querySelectorAll("button:not(:disabled)"))??[]),L=O.indexOf(document.activeElement);(D=O[(L+(b.key==="ArrowDown"?1:O.length-1))%O.length])==null||D.focus()}},children:[z.jsxs("div",{className:"milkdown-table-actions-context",children:["Row ",a.row+1," · Column ",a.col+1]}),z.jsx("button",{role:"menuitem",type:"button",onClick:()=>f("add-row"),children:"Add row below"}),z.jsx("button",{role:"menuitem",type:"button",onClick:()=>f("add-col"),children:"Add column right"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row<=1,onClick:()=>f("row-up"),children:"Move row up"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row===0||a.row>=m-1,onClick:()=>f("row-down"),children:"Move row down"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.col===0,onClick:()=>f("col-left"),children:"Move column left"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.col>=y-1,onClick:()=>f("col-right"),children:"Move column right"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row===0,onClick:()=>f("delete-row"),children:"Delete row"}),z.jsx("button",{role:"menuitem",type:"button",disabled:y<=1,onClick:()=>f("delete-col"),children:"Delete column"})]})]})}const wE={renderButton:r=>{switch(r){case"add_row":return"+";case"add_col":return"+";case"delete_row":return"-";case"delete_col":return"-";case"align_col_left":return"left";case"align_col_center":return"center";case"align_col_right":return"right";case"col_drag_handle":return"=";case"row_drag_handle":return"="}}},$h=ye({...wE},"tableBlockConfigCtx");function jh(r,e){for(let t=0;t<r.childCount;t++)if(r.child(t)===e)return t;return-1}function xE(r,e){var t,n,i;if(e)try{const o=e.posAtCoords({left:r.clientX,top:r.clientY});if(!o)return;const s=o.inside;if(s==null||s<0)return;const a=e.state.doc.resolve(s),l=e.state.doc.nodeAt(s);if(!l)return;const c=["table_cell","table_header"],u=["table_row","table_header_row"],d=c.includes(l.type.name)?l:(t=Fr(y=>c.includes(y.type.name))(a))==null?void 0:t.node,h=(n=Fr(y=>u.includes(y.type.name))(a))==null?void 0:n.node,f=(i=Fr(y=>y.type.name==="table")(a))==null?void 0:i.node;if(!d||!h||!f)return;const m=jh(h,d);return[jh(f,h),m]}catch{return}}function pu(r,[e,t]){const n=r.current;if(!n)return;const i=n.querySelectorAll("tr"),o=i[e];if(!o)return;const s=i[0];if(!s)return;const a=s.children[t];if(!a)return;const l=o.children[t];if(l)return{row:o,col:l,headerCol:a}}function kE(r,e,t){if(!t||!e)return;const{selection:n}=e.state;if(!(n instanceof Ae))return;const{$from:i}=n,o=Rs(i);if(!(!o||o.node!==t)){if(n.isColSelection()){const{$head:s}=n,a=s.index(s.depth-1);tm({refs:r,index:[0,a],before:l=>{var c;(c=l.querySelector(".button-group"))==null||c.setAttribute("data-show","true")}});return}if(n.isRowSelection()){const{$head:s}=n,a=Fr(c=>c.type.name==="table_row"||c.type.name==="table_header_row")(s);if(!a)return;const l=jh(o.node,a.node);rm({refs:r,index:[l,0],before:c=>{var u;l>0&&((u=c.querySelector(".button-group"))==null||u.setAttribute("data-show","true"))}})}}}function tm({refs:r,index:e,before:t,after:n}){const{contentWrapperRef:i,colHandleRef:o,hoverIndex:s}=r,a=o.current;if(!a)return;s.current=e;const l=pu(i,e);if(!l)return;const{headerCol:c}=l;a.dataset.show="true",t&&t(a),qr(c,a,{placement:"top"}).then(({x:u,y:d})=>{Object.assign(a.style,{left:`${u}px`,top:`${d}px`}),n&&n(a)}).catch(console.error)}function rm({refs:r,index:e,before:t,after:n}){const{contentWrapperRef:i,rowHandleRef:o,hoverIndex:s}=r,a=o.current;if(!a)return;s.current=e;const l=pu(i,e);if(!l)return;const{row:c}=l;a.dataset.show="true",t&&t(a),qr(c,a,{placement:"left"}).then(({x:u,y:d})=>{Object.assign(a.style,{left:`${u}px`,top:`${d}px`}),n&&n(a)}).catch(console.error)}function SE(r,e){let t=0,n=null,i=null;const o=s=>{t=Date.now(),r(...s)};return(...s)=>{const a=Date.now(),l=e-(a-t);l<=0?(n&&(clearTimeout(n),n=null),o(s)):(i=s,n||(n=setTimeout(()=>{if(n=null,i){const c=i;i=null,o(c)}},l)))}}function gy(r){const{dragPreviewRef:e,tableWrapperRef:t,contentWrapperRef:n,yLineHandleRef:i,xLineHandleRef:o,colHandleRef:s,rowHandleRef:a}=r,l=e.current;if(!l)return;const c=t.current;if(!c)return;const u=n.current;if(!u)return;const d=u.querySelector("tbody");if(!d)return;const h=l.querySelector("tbody");if(!h)return;const f=i.current;if(!f)return;const m=o.current;if(!m)return;const y=s.current;if(!y)return;const x=a.current;if(x)return{preview:l,wrapper:c,content:u,contentRoot:d,previewRoot:h,yHandle:f,xHandle:m,colHandle:y,rowHandle:x}}function yy(r,e,t){const n=t==="x"?"left":"top",i=t==="x"?"right":"bottom",o=r.length-1,s=r.findIndex((l,c)=>{const u=l.getBoundingClientRect(),d=u[n],h=u[i];return d<=e&&e<=h||c===o&&e>h||c===0&&e<d}),a=r[s];return a?[a,s]:void 0}function CE(r,e){const t=r.querySelector("tr");if(!t)return;const n=Array.from(t.children);return yy(n,e,"x")}function ME(r,e){const t=Array.from(r.querySelectorAll("tr"));return yy(t,e,"y")}function vy(r){for(;r.firstChild;)r.removeChild(r.firstChild)}function by(r,e,t,n,i){const o=n.querySelector("tbody");if(!o)return;const{width:s,height:a}=o.getBoundingClientRect();if(r==="y"){const u=n.querySelectorAll("tr")[i];if(!u)return;t.appendChild(u.cloneNode(!0));const d=u.getBoundingClientRect().height;Object.assign(e.style,{width:`${s}px`,height:`${d}px`}),e.dataset.show="true";return}const l=n.querySelectorAll("tr");let c;Array.from(l).forEach(u=>{const d=u.children[i];if(!d)return;c===void 0&&(c=d.getBoundingClientRect().width);const h=d.parentElement;if(!h)return;const f=h.cloneNode(!1),m=d.cloneNode(!0);f.appendChild(m),t.appendChild(f)}),Object.assign(e.style,{width:`${c??0}px`,height:`${a}px`}),e.dataset.show="true"}function b4(r){var e;(e=r.querySelector(".button-group"))==null||e.setAttribute("data-show","false")}function wy(r,e,t,n){const{xHandle:i,yHandle:o,colHandle:s,rowHandle:a,preview:l}=t;i.dataset.displayType=r==="y"?"indicator":"none",o.dataset.displayType=r==="x"?"indicator":"none",r==="y"?(s.dataset.show="false",b4(a)):(a.dataset.show="false",b4(s));const{hoverIndex:c,dragInfo:u}=n,[d,h]=c.current;u.current={startCoords:[e.clientX,e.clientY],startIndex:r==="y"?d:h,endIndex:r==="y"?d:h,type:r==="y"?"row":"col"},l.dataset.direction=r==="y"?"vertical":"horizontal"}function xy(r,e,t,n){var o;if(!((o=t==null?void 0:t.get(ge))!=null&&o.editable))return;e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.effectAllowed="move");const i=gy(r);i&&requestAnimationFrame(()=>{n(i)})}function TE(r,e){return t=>{xy(r,t,e,n=>{wy("y",t,n,r);const{preview:i,content:o,previewRoot:s}=n;vy(s);const[a]=r.hoverIndex.current;by("y",i,s,o,a)})}}function AE(r,e){return t=>{xy(r,t,e,n=>{wy("x",t,n,r);const{preview:i,content:o,previewRoot:s}=n,[,a]=r.hoverIndex.current;vy(s),by("x",i,s,o,a)})}}function NE(r){return SE(e=>{const t=gy(r);if(!t)return;const{preview:n,content:i,contentRoot:o,xHandle:s,yHandle:a}=t,{dragInfo:l,hoverIndex:c}=r;if(n.dataset.show==="false")return;const u=pu(r.contentWrapperRef,c.current);if(!u||!o.querySelector("tr"))return;const d=l.current;if(!d)return;const h=o.offsetParent;if(!h)return;const f=h.offsetTop,m=h.offsetLeft;if(d.type==="col"){const y=u.col.getBoundingClientRect().width,{left:x,width:b}=o.getBoundingClientRect(),S=m-x,A=e.clientX+S-y/2,[D]=d.startCoords,O=D<e.clientX?"right":"left";n.style.top=`${f}px`;const L=A<x+S-20?x+S-20:A>x+b+S-y+20?x+b+S-y+20:A;n.style.left=`${L}px`;const N=CE(o,e.clientX);if(N){const[$,K]=N,ne=a.getBoundingClientRect().width,pe=i.getBoundingClientRect();d.endIndex=K,qr($,a,{placement:O==="left"?"left":"right",middleware:[Ki(O==="left"?-1*ne:0)]}).then(({x:se})=>{a.dataset.show="true",Object.assign(a.style,{height:`${pe.height}px`,left:`${se}px`,top:`${f}px`})}).catch(console.error)}}else if(d.type==="row"){const y=u.row.getBoundingClientRect().height,{top:x,height:b}=o.getBoundingClientRect(),S=f-x,A=e.clientY+S-y/2,[,D]=d.startCoords,O=D<e.clientY?"down":"up",L=A<x+S-20?x+S-20:A>x+b+S-y+20?x+b+S-y+20:A;n.style.top=`${L}px`,n.style.left=`${m}px`;const N=ME(o,e.clientY);if(N){const[$,K]=N,ne=s.getBoundingClientRect().height,pe=i.getBoundingClientRect();d.endIndex=K,qr($,s,{placement:O==="up"?"top":"bottom",middleware:[Ki(O==="up"?-1*ne:0)]}).then(({y:se})=>{s.dataset.show="true",Object.assign(s.style,{width:`${pe.width}px`,top:`${se}px`})}).catch(console.error)}}},20)}function EE(r,e,t){const{dragPreviewRef:n,yLineHandleRef:i,xLineHandleRef:o,dragInfo:s}=r,a=TE(r,e),l=AE(r,e),c=NE(r);return{dragCol:l,dragRow:a,onDragOver:c,onDragEnd:()=>{const u=n.current;if(!u||u.dataset.show==="false")return;const d=u.querySelector("tbody");for(;d!=null&&d.firstChild;)d.removeChild(d.firstChild);u.dataset.show="false",s.current=void 0},onDrop:()=>{const u=n.current;if(!u)return;const d=i.current;if(!d)return;const h=o.current;if(!h)return;const f=s.current;if(!f||!e||u.dataset.show==="false"||!r.colHandleRef.current||!r.rowHandleRef.current)return;d.dataset.show="false",h.dataset.show="false";const m=u.querySelector("tbody");for(;m!=null&&m.firstChild;)m.removeChild(m.firstChild);if(u.dataset.show="false",s.current=void 0,f.startIndex===f.endIndex||f.type==="row"&&(f.startIndex===0||f.endIndex===0))return;const y=e.get(ee),x={from:f.startIndex,to:f.endIndex,pos:((t==null?void 0:t())??0)+1};if(f.type==="col"){y.call(pn.key,{pos:x.pos,index:f.startIndex}),y.call(Vc.key,x);const b=[0,f.endIndex];tm({refs:r,index:b})}else{y.call(fn.key,{pos:x.pos,index:f.startIndex}),y.call(jc.key,x);const b=[f.endIndex,0];rm({refs:r,index:b})}requestAnimationFrame(()=>{e.get(ge).focus()})}}}function DE(r,e,t){const{xLineHandleRef:n,contentWrapperRef:i,colHandleRef:o,rowHandleRef:s,hoverIndex:a,lineHoverIndex:l}=r;return{onAddRow:()=>{var m;if(!e)return;const c=n.current;if(!c)return;const[u]=l.current;if(u<0||!e.get(ge).editable)return;const d=Array.from(((m=i.current)==null?void 0:m.querySelectorAll("tr"))??[]),h=e.get(ee),f=((t==null?void 0:t())??0)+1;d.length===u?(h.call(fn.key,{pos:f,index:u-1}),h.call(Uc.key)):(h.call(fn.key,{pos:f,index:u}),h.call(fp.key)),h.call(fn.key,{pos:f,index:u}),c.dataset.show="false"},onAddCol:()=>{var f,m;if(!e||!n.current)return;const[,c]=l.current;if(c<0||!e.get(ge).editable)return;const u=Array.from(((m=(f=i.current)==null?void 0:f.querySelector("tr"))==null?void 0:m.children)??[]),d=e.get(ee),h=((t==null?void 0:t())??0)+1;u.length===c?(d.call(pn.key,{pos:h,index:c-1}),d.call(Wc.key)):(d.call(pn.key,{pos:h,index:c}),d.call(hp.key)),d.call(pn.key,{pos:h,index:c})},selectCol:()=>{var f;if(!e)return;const[,c]=a.current,u=e.get(ee),d=((t==null?void 0:t())??0)+1;u.call(pn.key,{pos:d,index:c});const h=(f=o.current)==null?void 0:f.querySelector(".button-group");h&&(h.dataset.show=h.dataset.show==="true"?"false":"true")},selectRow:()=>{var f;if(!e)return;const[c]=a.current,u=e.get(ee),d=((t==null?void 0:t())??0)+1;u.call(fn.key,{pos:d,index:c});const h=(f=s.current)==null?void 0:f.querySelector(".button-group");h&&c>0&&(h.dataset.show=h.dataset.show==="true"?"false":"true")},deleteSelected:c=>{!e||!e.get(ge).editable||(c.preventDefault(),c.stopPropagation(),e.get(ee).call(_a.key),requestAnimationFrame(()=>{e.get(ge).focus()}))},onAlign:c=>u=>{!e||!e.get(ge).editable||(u.preventDefault(),u.stopPropagation(),e.get(ee).call(pp.key,c),requestAnimationFrame(()=>{e.get(ge).focus()}))}}}function OE(r,e){let t=0,n=null,i=null;const o=s=>{t=Date.now(),r(...s)};return(...s)=>{const a=Date.now(),l=e-(a-t);l<=0?(n&&(clearTimeout(n),n=null),o(s)):(i=s,n||(n=setTimeout(()=>{if(n=null,i){const c=i;i=null,o(c)}},l)))}}function RE(r,e){return OE(t=>{if(!(e!=null&&e.editable))return;const{contentWrapperRef:n,yLineHandleRef:i,xLineHandleRef:o,colHandleRef:s,rowHandleRef:a,hoverIndex:l,lineHoverIndex:c}=r,u=i.current;if(!u)return;const d=o.current;if(!d)return;const h=n.current;if(!h)return;const f=a.current;if(!f)return;const m=s.current;if(!m)return;const y=xE(t,e);if(!y)return;const x=pu(n,y);if(!x)return;const[b,S]=y,A=x.col.getBoundingClientRect(),D=Math.abs(t.clientX-A.left)<8,O=Math.abs(A.right-t.clientX)<8,L=Math.abs(t.clientY-A.top)<8,N=Math.abs(A.bottom-t.clientY)<8,$=D||O||L||N,K=f.querySelector(".button-group"),ne=m.querySelector(".button-group");if(K&&(K.dataset.show="false"),ne&&(ne.dataset.show="false"),$){const pe=h.getBoundingClientRect();f.dataset.show="false",m.dataset.show="false",d.dataset.displayType="tool",u.dataset.displayType="tool";const se=u.getBoundingClientRect().width,lt=d.getBoundingClientRect().height;D||O?(c.current[1]=D?S:S+1,qr(x.col,u,{placement:D?"left":"right",middleware:[Ki(D?-1*se:0)]}).then(({x:Re})=>{u.dataset.show="true",Object.assign(u.style,{height:`${pe.height}px`,left:`${Re}px`})}).catch(console.error)):u.dataset.show="false",y[0]!==0&&(L||N)?(c.current[0]=L?b:b+1,qr(x.row,d,{placement:L?"top":"bottom",middleware:[Ki(L?-1*lt:0)]}).then(({y:Re})=>{d.dataset.show="true",Object.assign(d.style,{width:`${pe.width}px`,top:`${Re}px`})}).catch(console.error)):d.dataset.show="false";return}c.current=[-1,-1],u.dataset.show="false",d.dataset.show="false",f.dataset.show="true",m.dataset.show="true",rm({refs:r,index:y}),tm({refs:r,index:y}),l.current=y},20)}function IE(r){return()=>{const{rowHandleRef:e,colHandleRef:t,yLineHandleRef:n,xLineHandleRef:i}=r;setTimeout(()=>{const o=e.current;if(!o)return;const s=t.current;if(!s)return;const a=n.current;if(!a)return;const l=i.current;l&&(o.dataset.show="false",s.dataset.show="false",a.dataset.show="false",l.dataset.show="false")},200)}}function zE(r,e){return{pointerMove:RE(r,e),pointerLeave:IE(r)}}function LE(){const{node:r,view:e,getPos:t,contentRef:n}=Es(),i=Tr(),o=$s(e),s=i.get($h.key),a=B.useRef(null),l=B.useRef(null),c=B.useRef(null),u=B.useRef(null),d=B.useRef(null),h=B.useRef(null),f=B.useRef(null),m=B.useRef([0,0]),y=B.useRef([-1,-1]),x=B.useRef(void 0),b={contentWrapperRef:a,tableWrapperRef:l,dragPreviewRef:c,yLineHandleRef:f,xLineHandleRef:h,colHandleRef:u,rowHandleRef:d,hoverIndex:m,lineHoverIndex:y,dragInfo:x},{onAddRow:S,onAddCol:A,selectCol:D,selectRow:O,deleteSelected:L,onAlign:N}=DE(b,i,t),$=se=>{a.current=se,n(se)},K=B.useRef(null);B.useEffect(()=>{const se=K.current;if(!se)return;const{pointerMove:lt,pointerLeave:Re}=zE(b,e),Ue=Bt=>lt(Bt),je=()=>Re();return se.addEventListener("pointermove",Ue),se.addEventListener("pointerleave",je),()=>{se.removeEventListener("pointermove",Ue),se.removeEventListener("pointerleave",je)}},[e]),B.useEffect(()=>{const se=u.current,lt=d.current;if(!se||!lt)return;const{dragCol:Re,dragRow:Ue,onDragOver:je,onDragEnd:Bt,onDrop:pr}=EE(b,i,t);return se.addEventListener("dragstart",Re),lt.addEventListener("dragstart",Ue),window.addEventListener("dragover",je),window.addEventListener("dragend",Bt),window.addEventListener("drop",pr),()=>{se.removeEventListener("dragstart",Re),lt.removeEventListener("dragstart",Ue),window.removeEventListener("dragover",je),window.removeEventListener("dragend",Bt),window.removeEventListener("drop",pr)}},[e]),B.useEffect(()=>{requestAnimationFrame(()=>{e.editable&&kE(b,e,r)})},[r,e]);const ne=se=>se.stopPropagation(),pe=se=>se.preventDefault();return z.jsxs("div",{ref:K,className:o?void 0:"readonly",onDragStart:pe,onDragOver:pe,onDragLeave:pe,children:[z.jsx(bE,{}),z.jsxs("div",{"data-show":"false",contentEditable:!1,draggable:!0,"data-role":"col-drag-handle",className:"handle cell-handle",onClick:D,onPointerDown:ne,onPointerMove:ne,ref:u,children:[z.jsx(ke,{icon:s.renderButton("col_drag_handle")}),z.jsxs("div",{className:"button-group","data-show":"false",onPointerMove:ne,children:[z.jsx("button",{type:"button","aria-label":"Align column left",onPointerDown:pe,onClick:N("left"),children:z.jsx(ke,{icon:s.renderButton("align_col_left")})}),z.jsx("button",{type:"button","aria-label":"Align column center",onPointerDown:pe,onClick:N("center"),children:z.jsx(ke,{icon:s.renderButton("align_col_center")})}),z.jsx("button",{type:"button","aria-label":"Align column right",onPointerDown:pe,onClick:N("right"),children:z.jsx(ke,{icon:s.renderButton("align_col_right")})}),z.jsx("button",{type:"button","aria-label":"Delete selected column",onPointerDown:pe,onClick:L,children:z.jsx(ke,{icon:s.renderButton("delete_col")})})]})]}),z.jsxs("div",{"data-show":"false",contentEditable:!1,draggable:!0,"data-role":"row-drag-handle",className:"handle cell-handle",onClick:O,onPointerDown:ne,onPointerMove:ne,ref:d,children:[z.jsx(ke,{icon:s.renderButton("row_drag_handle")}),z.jsx("div",{className:"button-group","data-show":"false",onPointerMove:ne,children:z.jsx("button",{type:"button","aria-label":"Delete selected row",onPointerDown:pe,onClick:L,children:z.jsx(ke,{icon:s.renderButton("delete_row")})})})]}),z.jsxs("div",{className:"table-wrapper",ref:l,children:[z.jsx("div",{"data-show":"false",className:"drag-preview","data-direction":"vertical",ref:c,children:z.jsx("table",{children:z.jsx("tbody",{})})}),z.jsx("div",{"data-show":"false",contentEditable:!1,"data-display-type":"tool","data-role":"x-line-drag-handle",className:"handle line-handle",onPointerMove:ne,ref:h,children:z.jsx("button",{type:"button","aria-label":"Add row",onClick:S,className:"add-button",children:z.jsx(ke,{icon:s.renderButton("add_row")})})}),z.jsx("div",{"data-show":"false",contentEditable:!1,"data-display-type":"tool","data-role":"y-line-drag-handle",className:"handle line-handle",onPointerMove:ne,ref:f,children:z.jsx("button",{type:"button","aria-label":"Add column",onClick:A,className:"add-button",children:z.jsx(ke,{icon:s.renderButton("add_col")})})}),z.jsx("table",{className:"children",ref:$})]})]})}function BE(r,e){const t=(i,o)=>{var f;if(!i.editable)return!1;const{state:s,dispatch:a}=i,l=i.posAtCoords({left:o.clientX,top:o.clientY});if(!l)return!1;const c=s.doc.resolve(l.inside),u=Fr(m=>m.type.name==="table_cell"||m.type.name==="table_header")(c);if(!u||s.selection instanceof Q&&((f=Fr(m=>m.type.name==="table_cell"||m.type.name==="table_header")(s.selection.$from))==null?void 0:f.node)===u.node)return!1;const{from:d}=u,h=re.create(s.doc,d+1);return s.selection.eq(h)?!1:(s.selection instanceof Ae?setTimeout(()=>{a(s.tr.setSelection(h).scrollIntoView())},20):requestAnimationFrame(()=>{a(s.tr.setSelection(h).scrollIntoView())}),!0)},n=Ha(Hr.node,i=>e({component:LE,as:()=>{const o=document.createElement("div");return o.className="milkdown-table-block",o},contentAs:"tbody",stopEvent:o=>{if(o.target instanceof Element&&o.target.closest("button, input, .milkdown-table-actions")||o.type==="drop"||o.type.startsWith("drag"))return!0;if(o.type==="mousedown"||o.type==="pointerdown"){if(o.target instanceof Element&&o.target.closest("button"))return!0;const s=o.target;if(s instanceof HTMLElement&&(s.closest("th")||s.closest("td")))return t(i.get(ge),o)}return!1}}));r.config(i=>{i.update($h.key,o=>({...o,renderButton:s=>{switch(s){case"add_row":return ph;case"add_col":return ph;case"delete_row":return mh;case"delete_col":return mh;case"align_col_left":return jC;case"align_col_center":return qC;case"align_col_right":return $C;case"col_drag_handle":return bC;case"row_drag_handle":return vC}}}))}).use($h).use(n)}function Nd(r){const e=r.dom.ownerDocument.getSelection();if(!r.editable||!e||e.isCollapsed)return;const{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}=e;if(!t||!i||!r.dom.contains(t)||!r.dom.contains(i))return;const s=r.posAtDOM(t,n),a=r.posAtDOM(i,o),l=Q.between(r.state.doc.resolve(s),r.state.doc.resolve(a));l.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(l))}function PE(){const r=new ly;return r.addGroup("formatting","Formatting").addItem("bold",{label:"Bold",icon:mC,active:e=>!!e.get(ee).call(Mo.key,Is.type(e)),onRun:e=>{e.get(ee).call(Hc.key)}}).addItem("italic",{label:"Italic",icon:NC,active:e=>!!e.get(ee).call(Mo.key,to.type(e)),onRun:e=>{e.get(ee).call(Fc.key)}}).addItem("strikethrough",{label:"Strikethrough",icon:HC,active:e=>!!e.get(ee).call(Mo.key,Bs.type(e)),onRun:e=>{e.get(ee).call($c.key)}}),r.addGroup("function","Function").addItem("code",{label:"Inline code",icon:o6,active:e=>!!e.get(ee).call(Mo.key,hn.type(e)),onRun:e=>{e.get(ee).call(_c.key)}}).addItem("link",{label:"Link",icon:EC,active:e=>!!e.get(ee).call(Mo.key,Cr.type(e)),onRun:e=>{e.get(ee).call(fy.key)}}),r.build()}function FE(){Zb();const r=Tr(),e=B.useMemo(()=>PE(),[]);return r.get(th).status!==R9.Created?null:z.jsx(z.Fragment,{children:e.map((t,n)=>z.jsxs(B.Fragment,{children:[n>0&&z.jsx("div",{className:"divider"}),t.items.map(i=>z.jsx("button",{type:"button","aria-label":i.label,title:i.label,"aria-pressed":i.active(r),className:_r("toolbar-item",i.active(r)&&"active"),onFocus:()=>Nd(r.get(ge)),onPointerDown:o=>{o.preventDefault(),Nd(r.get(ge))},onClick:()=>{var s;const o=r.get(ge);Nd(o),(s=i.onRun)==null||s.call(i,r)},children:z.jsx(ke,{icon:i.icon})},i.key))]},t.key))})}const w4=eu("CREPE_TOOLBAR");function HE(r,e){const{doc:t,selection:n}=r.state,{empty:i,from:o,to:s}=n,a=!t.textBetween(o,s).length&&n instanceof Q,l=!(n instanceof Q),c=r.dom.getRootNode(),u=e.contains(c.activeElement),d=!r.hasFocus()&&!u,h=!r.editable;return!(d||l||i||a||h)}function _E(r){let e,t;const n=()=>(t||(t=document.createElement("div"),t.className="milkdown-toolbar",t.dataset.show="false"),t);return r({component:FE,root:()=>n(),update:(i,o)=>{e||(e=new Qc({content:n(),debounce:20,offset:10,shouldShow:s=>HE(s,n())})),e.update(i,o)},destroy:()=>{e==null||e.destroy(),e=void 0,t=void 0}})}function qE(r,e){r.config(t=>{t.set(w4.key,{view:_E(e)})}).use(w4)}function $E({value:r,editable:e=YA,onChange:t,placeholder:n,nodeViewFactory:i,pluginViewFactory:o,ctxHolder:s,plugins:a}){const l=B.useRef(t);l.current=t;const c=B.useRef(a),u=B.useRef(r),d=B.useRef(r),h=B.useRef(n),f=B.useRef(e);J7(x=>{var S;const b=I9.make().config(A=>{A.set(K0,x),A.set($0,d.current),s.current=A,A.update(Sa,D=>({...D,editable:d4(()=>f.current)})),A.get(dh).markdownUpdated((D,O,L)=>{var N;O!==L&&(u.current=O,(N=l.current)==null||N.call(l,O))})}).use(SN).use(MN).use(Fk).use(Yk).use(Xk).use(MS).use(_3).use(NS).use(Y3);return NN(b),kN(b),vE(b,{text:h.current??"Type / for commands",mode:"block"}),pE(b,i),BN(b,i),xN(b,i),BE(b,i),qE(b,o),sN(b,o),dE(b,o),XN(b,o),(S=c.current)==null||S.forEach(A=>{A({editor:b,nodeViewFactory:i,pluginViewFactory:o})}),b});const[m,y]=X7();B.useEffect(()=>{if(m||r===u.current)return;const x=y();if(!x)return;u.current=r;let b=!1;return queueMicrotask(()=>{b||u.current!==r||x.action(B9(r))}),()=>{b=!0}},[r,m,y]),B.useEffect(()=>{if(f.current=e,m)return;const x=y();if(!x)return;let b=!1;return queueMicrotask(()=>{b||x.action(S=>{const A=S.get(ge);A.setProps({editable:d4(()=>f.current)}),A.dom.dispatchEvent(new Event("blintz:editable"))})}),()=>{b=!0}},[e,m,y])}function jE({value:r,editable:e,onChange:t,placeholder:n,className:i,theme:o="auto",plugins:s}){const a=B.useRef(null),l=B.useRef(null),[c,u]=B.useState("light");return B.useEffect(()=>{var m;const d=(m=window.matchMedia)==null?void 0:m.call(window,"(prefers-color-scheme: dark)"),h=()=>{var x;if(o!=="auto"){u(o);return}let y=(x=l.current)==null?void 0:x.parentElement;for(;y;){const b=y.getAttribute("data-theme");if(b==="light"||b==="dark"){u(b);return}if(y.classList.contains("dark")){u("dark");return}if(y.classList.contains("light")){u("light");return}y=y.parentElement}u(d!=null&&d.matches?"dark":"light")};h();const f=new MutationObserver(h);return f.observe(document.documentElement,{attributes:!0,subtree:!0,attributeFilter:["class","data-theme"]}),d==null||d.addEventListener("change",h),()=>{f.disconnect(),d==null||d.removeEventListener("change",h)}},[o]),z.jsx("div",{ref:l,className:_r("milkdown-editor-host",i),"data-blintz-theme":o==="auto"?c:o,children:z.jsx(GA,{value:a,children:z.jsx(Y7,{children:z.jsx(cw,{children:z.jsx(VE,{value:r,editable:e,onChange:t,placeholder:n,ctxHolder:a,plugins:s})})})})})}function VE({value:r,editable:e,onChange:t,placeholder:n,ctxHolder:i,plugins:o}){const s=Kb(),a=Qb();return $E({value:r,editable:e,onChange:t,placeholder:n,nodeViewFactory:s,pluginViewFactory:a,ctxHolder:i,plugins:o}),z.jsx(G7,{})}function YE({value:r,editable:e,onChange:t,className:n}){const i=Xy();return z.jsx("div",{"data-theme":i,className:"dorkos-markdown contents",children:z.jsx(jE,{value:r,theme:i,editable:e,onChange:t,className:Zy("desktop:select-text",n)})})}export{YE as BlintzCanvas};
1140
+ `)),f+=u.move(d),h(),f}function n(o,s,a){let l=o.value||"",c=1;for(e||c++;new RegExp("(^|[^$])"+"\\$".repeat(c)+"([^$]|$)").test(l);)c++;const u="$".repeat(c);/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^\$|\$$/.test(l))&&(l=" "+l+" ");let d=-1;for(;++d<a.unsafe.length;){const h=a.unsafe[d];if(!h.atBreak)continue;const f=a.compilePattern(h);let m;for(;m=f.exec(l);){let y=m.index;l.codePointAt(y)===10&&l.codePointAt(y-1)===13&&y--,l=l.slice(0,y)+" "+l.slice(m.index+1)}}return u+l+u}function i(){return"$"}}const HA={tokenize:_A,concrete:!0,name:"mathFlow"},u4={tokenize:qA,partial:!0};function _A(r,e,t){const n=this,i=n.events[n.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let s=0;return a;function a(S){return r.enter("mathFlow"),r.enter("mathFlowFence"),r.enter("mathFlowFenceSequence"),l(S)}function l(S){return S===36?(r.consume(S),s++,l):s<2?t(S):(r.exit("mathFlowFenceSequence"),p0(r,c,"whitespace")(S))}function c(S){return S===null||wr(S)?d(S):(r.enter("mathFlowFenceMeta"),r.enter("chunkString",{contentType:"string"}),u(S))}function u(S){return S===null||wr(S)?(r.exit("chunkString"),r.exit("mathFlowFenceMeta"),d(S)):S===36?t(S):(r.consume(S),u)}function d(S){return r.exit("mathFlowFence"),n.interrupt?e(S):r.attempt(u4,h,x)(S)}function h(S){return r.attempt({tokenize:b,partial:!0},x,f)(S)}function f(S){return(o?p0(r,m,"linePrefix",o+1):m)(S)}function m(S){return S===null?x(S):wr(S)?r.attempt(u4,h,x)(S):(r.enter("mathFlowValue"),y(S))}function y(S){return S===null||wr(S)?(r.exit("mathFlowValue"),m(S)):(r.consume(S),y)}function x(S){return r.exit("mathFlow"),e(S)}function b(S,A,D){let O=0;return p0(S,L,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function L(K){return S.enter("mathFlowFence"),S.enter("mathFlowFenceSequence"),N(K)}function N(K){return K===36?(O++,S.consume(K),N):O<s?D(K):(S.exit("mathFlowFenceSequence"),p0(S,j,"whitespace")(K))}function j(K){return K===null||wr(K)?(S.exit("mathFlowFence"),A(K)):D(K)}}}function qA(r,e,t){const n=this;return i;function i(s){return s===null?e(s):(r.enter("lineEnding"),r.consume(s),r.exit("lineEnding"),o)}function o(s){return n.parser.lazy[n.now().line]?t(s):e(s)}}function jA(r){let t=(r||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:$A,previous:VA,name:"mathText"};function n(i,o,s){let a=0,l,c;return u;function u(y){return i.enter("mathText"),i.enter("mathTextSequence"),d(y)}function d(y){return y===36?(i.consume(y),a++,d):a<2&&!t?s(y):(i.exit("mathTextSequence"),h(y))}function h(y){return y===null?s(y):y===36?(c=i.enter("mathTextSequence"),l=0,m(y)):y===32?(i.enter("space"),i.consume(y),i.exit("space"),h):wr(y)?(i.enter("lineEnding"),i.consume(y),i.exit("lineEnding"),h):(i.enter("mathTextData"),f(y))}function f(y){return y===null||y===32||y===36||wr(y)?(i.exit("mathTextData"),h(y)):(i.consume(y),f)}function m(y){return y===36?(i.consume(y),l++,m):l===a?(i.exit("mathTextSequence"),i.exit("mathText"),o(y)):(c.type="mathTextData",f(y))}}}function $A(r){let e=r.length-4,t=3,n,i;if((r[t][1].type==="lineEnding"||r[t][1].type==="space")&&(r[e][1].type==="lineEnding"||r[e][1].type==="space")){for(n=t;++n<e;)if(r[n][1].type==="mathTextData"){r[e][1].type="mathTextPadding",r[t][1].type="mathTextPadding",t+=2,e-=2;break}}for(n=t-1,e++;++n<=e;)i===void 0?n!==e&&r[n][1].type!=="lineEnding"&&(i=n):(n===e||r[n][1].type==="lineEnding")&&(r[i][1].type="mathTextData",n!==i+2&&(r[i][1].end=r[n-1][1].end,r.splice(i+2,n-i-2),e-=n-i-2,n=i+2),i=void 0);return r}function VA(r){return r!==36||this.events[this.events.length-1][1].type==="characterEscape"}function WA(r){return{flow:{36:HA},text:{36:jA(r)}}}const UA={};function KA(r){const e=this,t=r||UA,n=e.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(WA(t)),o.push(PA()),s.push(FA(t))}const oy=B.createContext(null),GA=oy.Provider;function Tr(){const r=B.useContext(oy);if(!r)throw new Error("useEditorCtx must be used within <MarkdownEditor>");if(!r.current)throw new Error("Milkdown ctx is not ready yet");return r.current}function js(r){return B.useSyncExternalStore(e=>(r.dom.addEventListener("blintz:editable",e),()=>r.dom.removeEventListener("blintz:editable",e)),()=>r.editable,()=>r.editable)}function _r(...r){return r.filter(Boolean).join(" ")}const YA=!0;function d4(r){return()=>r()}function sy(r){return r.$from.parent.type.name==="code_block"}function ay(r){var e,t;return((t=(e=r.$from.node(r.$from.depth-1))==null?void 0:e.type)==null?void 0:t.name)==="list_item"}function hu(r){return i6.sanitize(r)}function ke({icon:r,className:e,onPointerDown:t}){return z.jsx("span",{className:_r("milkdown-icon",e),onPointerDown:t,dangerouslySetInnerHTML:r?{__html:hu(r.trim())}:void 0})}const fu=ye({show:()=>{},hide:()=>{}},"crepeMenuAPICtx"),Gp=ye({onAdd:()=>{}},"crepeBlockHandleAPICtx"),Yp=ye(null,"crepeSlashStoreCtx");function JA(){const r=Tr(),e=B.useRef(null);return z.jsxs(z.Fragment,{children:[z.jsx("div",{ref:e,className:"operation-item",onPointerDown:t=>{var n;t.preventDefault(),t.stopPropagation(),(n=e.current)==null||n.classList.add("active")},onPointerUp:t=>{var n;t.preventDefault(),t.stopPropagation(),(n=e.current)==null||n.classList.remove("active"),r.get(Gp.key).onAdd()},children:z.jsx(ke,{icon:ph})}),z.jsx("div",{className:"operation-item",children:z.jsx(ke,{icon:xC})})]})}const Fh="image-block";function XA(r){return new Error(`Expected an HTMLElement, got ${String(r)}`)}const Hh=je("image-block",()=>({inline:!1,group:"block",selectable:!0,draggable:!0,isolating:!0,marks:"",atom:!0,priority:100,attrs:{src:{default:"",validate:"string"},caption:{default:"",validate:"string"},ratio:{default:1,validate:"number"}},parseDOM:[{tag:`img[data-type="${Fh}"]`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw XA(r);return{src:r.getAttribute("src")||"",caption:r.getAttribute("caption")||"",ratio:Number(r.getAttribute("ratio")??1)}}}],toDOM:r=>["img",{"data-type":Fh,...r.attrs}],parseMarkdown:{match:({type:r})=>r==="image-block",runner:(r,e,t)=>{const n=e.url,i=e.title;let o=Number(e.alt||1);(Number.isNaN(o)||o===0)&&(o=1),r.addNode(t,{src:n,caption:i,ratio:o})}},toMarkdown:{match:r=>r.type.name==="image-block",runner:(r,e)=>{r.openNode("paragraph"),r.addNode("image",void 0,void 0,{title:e.attrs.caption,url:e.attrs.src,alt:`${Number.parseFloat(e.attrs.ratio).toFixed(2)}`}),r.closeNode()}}}));var Li,zl;class ly{constructor(){P(this,Li,[]);We(this,"clear",()=>(I(this,Li,[]),this));P(this,zl,e=>{const t={group:e,addItem:(n,i)=>{const o={...i,key:n};return e.items.push(o),t},clear:()=>(e.items=[],t)};return t});We(this,"addGroup",(e,t)=>{const n={key:e,label:t,items:[]};return C(this,Li).push(n),C(this,zl).call(this,n)});We(this,"getGroup",e=>{const t=C(this,Li).find(n=>n.key===e);if(!t)throw new Error(`Group with key ${e} not found`);return C(this,zl).call(this,t)});We(this,"build",()=>C(this,Li))}}Li=new WeakMap,zl=new WeakMap;function h4(r){const e=new ly,t=e.addGroup("text","Text");t.addItem("text",{label:"Text",icon:VC,onRun:l=>{const c=l.get(ee),u=cr.type(l);c.call(Qt.key),c.call(J0.key,{nodeType:u})}});const n=[["h1",kC,1],["h2",MC,2],["h3",SC,3],["h4",CC,4],["h5",TC,5],["h6",AC,6]];for(const[l,c,u]of n)t.addItem(l,{label:`Heading ${u}`,icon:c,onRun:d=>{const h=d.get(ee),f=ii.type(d);h.call(Qt.key),h.call(J0.key,{nodeType:f,attrs:{level:u}})}});t.addItem("quote",{label:"Quote",icon:zC,onRun:l=>{const c=l.get(ee),u=zs.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),t.addItem("divider",{label:"Divider",icon:IC,onRun:l=>{const c=l.get(ee),u=Ls.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u})}});const i=e.addGroup("list","List");i.addItem("bullet-list",{label:"Bullet List",icon:RC,onRun:l=>{const c=l.get(ee),u=no.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),i.addItem("ordered-list",{label:"Ordered List",icon:DC,onRun:l=>{const c=l.get(ee),u=oi.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u})}}),i.addItem("task-list",{label:"Task List",icon:OC,onRun:l=>{const c=l.get(ee),u=fr.type(l);c.call(Qt.key),c.call(sa.key,{nodeType:u,attrs:{checked:!1}})}});const o=e.addGroup("advanced","Advanced");o.addItem("image",{label:"Image",icon:Dp,onRun:l=>{const c=l.get(ee),u=Hh.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u})}}),o.addItem("code",{label:"Code",icon:o6,onRun:l=>{const c=l.get(ee),u=$r.type(l);c.call(Qt.key),c.call(J0.key,{nodeType:u})}}),o.addItem("table",{label:"Table",icon:_C,onRun:l=>{const c=l.get(ee),u=l.get(ge);c.call(Qt.key);const{from:d}=u.state.selection;c.call(aa.key,{nodeType:lp(l,3,3)}),c.call(k3.key,{pos:d})}}),o.addItem("math",{label:"Math",icon:PC,onRun:l=>{const c=l.get(ee),u=$r.type(l);c.call(Qt.key),c.call(aa.key,{nodeType:u,attrs:{language:"LaTeX"}})}});let s=e.build();if(r){const l=r.toLowerCase();s=s.map(c=>({...c,items:c.items.filter(u=>u.label.toLowerCase().includes(l))})).filter(c=>c.items.length>0)}const a=s.flatMap(l=>l.items);return a.forEach((l,c)=>{Object.assign(l,{index:c})}),s.reduce((l,c)=>{const u=l+c.items.length;return Object.assign(c,{range:[l,u]}),u},0),{groups:s,size:a.length}}const ZA={show:!1,filter:""},QA={subscribe:()=>()=>{},getSnapshot:()=>ZA,set:()=>{}};function eN(){const r=Tr(),e=r.get(Yp.key)??QA,{show:t,filter:n}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),{groups:i,size:o}=B.useMemo(()=>h4(n),[n]),[s,a]=B.useState(0),l=B.useRef(null),c=B.useRef({x:-999,y:-999}),u=B.useRef(s);u.current=s;const d=B.useRef(i);d.current=i;const h=B.useRef(o);h.current=o;const f=B.useCallback(()=>r.get(fu.key).hide(),[r]),m=B.useCallback(D=>{const O=l.current,L=O==null?void 0:O.querySelector(`[data-index="${D}"]`),N=O==null?void 0:O.querySelector(".menu-groups");!L||!N||(N.scrollTop=L.offsetTop-N.offsetTop)},[]),y=B.useCallback((D,O)=>{const L=u.current,N=typeof D=="function"?D(L):D;O==null||O(N),a(N)},[]),x=B.useCallback(D=>{const O=e.getSnapshot().filter,L=h4(O).groups,N=O===n?D:0,j=L.flatMap(K=>K.items).at(N);j!=null&&j.onRun&&j.onRun(r),f()},[r,f,e,n]),b=B.useCallback(D=>{const O=h.current,L=d.current;if(D.key==="Escape"||D.key==="Enter"||D.key==="ArrowUp"||D.key==="ArrowDown"||D.key==="ArrowLeft"||D.key==="ArrowRight"){if(D.preventDefault(),D.stopPropagation(),D.key==="Escape"){f();return}if(D.key==="ArrowDown"){y(N=>N<O-1?N+1:N,m);return}if(D.key==="ArrowUp"){y(N=>N<=0?N:N-1,m);return}if(D.key==="ArrowLeft"){y(N=>{const j=L.find(ne=>ne.range[0]<=N&&ne.range[1]>N);if(!j)return N;const K=L[L.indexOf(j)-1];return K?K.range[1]-1:N},m);return}if(D.key==="ArrowRight"){y(N=>{const j=L.find(ne=>ne.range[0]<=N&&ne.range[1]>N);if(!j)return N;const K=L[L.indexOf(j)+1];return K?K.range[0]:N},m);return}D.key==="Enter"&&x(u.current)}},[f,y,x,m]);B.useEffect(()=>{if(t)return window.addEventListener("keydown",b,{capture:!0}),()=>window.removeEventListener("keydown",b,{capture:!0})},[t,b]),B.useEffect(()=>{o===0&&t?f():s>=o&&a(0)},[o,t,s,f]);const S=D=>{c.current={x:D.clientX,y:D.clientY}},A=D=>O=>{const L=c.current;O.clientX===L.x&&O.clientY===L.y||y(D)};return z.jsxs("div",{ref:l,onPointerDown:D=>D.preventDefault(),children:[z.jsx("nav",{className:"tab-group",children:z.jsx("ul",{children:i.map(D=>z.jsx("li",{onPointerDown:()=>y(D.range[0],m),className:s>=D.range[0]&&s<D.range[1]?"selected":"",children:D.label},D.key))})}),z.jsx("div",{className:"menu-groups",role:"listbox","aria-label":"Insert block",onPointerMove:S,children:i.map(D=>z.jsxs("div",{className:"menu-group",children:[z.jsx("h6",{children:D.label}),z.jsx("ul",{children:D.items.map(O=>z.jsxs("li",{"data-index":O.index,role:"option","aria-selected":s===O.index,"aria-label":O.label,className:s===O.index?"hover":"",onPointerEnter:A(O.index),onPointerDown:()=>{var L,N;(N=(L=l.current)==null?void 0:L.querySelector(`[data-index="${O.index}"]`))==null||N.classList.add("active")},onPointerUp:()=>{var L,N;(N=(L=l.current)==null?void 0:L.querySelector(`[data-index="${O.index}"]`))==null||N.classList.remove("active"),x(O.index)},children:[z.jsx(ke,{icon:O.icon}),z.jsx("span",{children:O.label})]},O.key))})]},D.key))})]})}const f4=new Set(["bullet_list","ordered_list"]),tN=Fe(()=>new Ce({key:new Me("MARKDOWN_EDITOR_ROBUST_BLOCK_DRAG"),view:r=>{const e=()=>{const t=r.dragging;if(!t||t.node)return;const{selection:n}=r.state;if(!(n instanceof re))return;let i=t.slice;const o=n.node;if(o.type.name==="list_item"){const s=n.$from.parent;if(f4.has(s.type.name)){const a=s.type.create(s.attrs,H.from(o));i=new Y(H.from(a),1,1)}}r.dragging={...t,slice:i,node:n}};return document.addEventListener("dragstart",e),{destroy:()=>document.removeEventListener("dragstart",e)}},appendTransaction:(r,e,t)=>{if(!r.some(o=>o.getMeta("uiEvent")==="drop"))return null;const n=t.tr;let i=!1;for(;;){let o=null;if(n.doc.descendants((s,a,l,c)=>{if(o!==null)return!1;if(!l||!f4.has(s.type.name))return!0;const u=c+1<l.childCount?l.child(c+1):null;if(u&&u.type===s.type){const d=a+s.nodeSize;if(Bl(n.doc,d))return o=d,!1}return!0}),o===null)break;n.join(o),i=!0}return i?n:null}}));function rN(){let r={show:!1,filter:""};const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>r,set:t=>{const n={...r,...t};n.show===r.show&&n.filter===r.filter||(r=n,e.forEach(i=>i()))}}}const cy=IS("CREPE_MENU");function nN(r,e){let t,n;const i=()=>(n||(n=document.createElement("div"),n.className="milkdown-block-handle",n.dataset.show="false"),n),o=()=>{const a=r.get(ge);if(!a.editable)return;a.hasFocus()||a.focus();const l=t==null?void 0:t.active;if(!l)return;const{state:c,dispatch:u}=a,d=l.$pos.pos+l.node.nodeSize;let h=c.tr.insert(d,cr.type(r).create());h=h.setSelection(Q.near(h.doc.resolve(d))),u(h.scrollIntoView()),t==null||t.hide(),r.get(fu.key).show(h.selection.from)};r.set(Gp.key,{onAdd:o}),r.set(Kc.key,{filterNodes:a=>!Fr(l=>["table","blockquote","math_inline"].includes(l.type.name))(a)});const s=e({component:JA,root:()=>i()});r.set(Jc.key,{view:a=>{const l=s(a);return t=new RS({ctx:r,content:i(),getOffset:()=>16,getPlacement:({active:c,blockDom:u})=>{if(c.node.type.name==="heading")return"left";let d=0;c.node.descendants(D=>{d+=D.childCount});const h=c.el,f=h.getBoundingClientRect(),m=u.getBoundingClientRect(),y=window.getComputedStyle(h),x=Number.parseInt(y.paddingTop,10)||0,b=Number.parseInt(y.paddingBottom,10)||0,S=f.height-x-b,A=m.height;return d>2||A<S?"left-start":"left"}}),t.update(),{update:(c,u)=>{var d;(d=l.update)==null||d.call(l,c,u),t==null||t.update()},destroy:()=>{var c;(c=l.destroy)==null||c.call(l),t==null||t.destroy(),t=void 0,n=void 0}}}})}function iN(r,e){const t=rN();r.set(Yp.key,t);let n,i,o=null;const s=()=>(i||(i=document.createElement("div"),i.className="milkdown-slash-menu",i.dataset.show="false"),i),a=d=>{if(!d.editable||sy(d.state.selection)||ay(d.state.selection))return!1;const h=n==null?void 0:n.getContent(d,f=>["paragraph","heading"].includes(f.type.name));if(h==null||!oN(d.state.selection))return!1;if(t.set({filter:h.startsWith("/")?h.slice(1):h}),typeof o=="number"){const f=d.state.doc.nodeSize-2,m=Math.min(o,f);return d.state.doc.resolve(m).node()!==d.state.doc.resolve(d.state.selection.from).node()?(o=null,!1):!0}return!!h.startsWith("/")},l=()=>{o=null,n==null||n.hide()},c=d=>{o=d,t.set({filter:""}),n==null||n.show()};r.set(fu.key,{show:c,hide:l});const u=e({component:eN,root:()=>s()});r.set(cy.key,{view:d=>{const h=u(d);return n=new zS({content:s(),debounce:20,shouldShow:a,offset:10}),n.onShow=()=>t.set({show:!0}),n.onHide=()=>t.set({show:!1}),n.update(d),{update:(f,m)=>{var x;const y=n==null?void 0:n.getContent(f,b=>["paragraph","heading"].includes(b.type.name));y!=null&&t.set({filter:y.startsWith("/")?y.slice(1):y}),(x=h.update)==null||x.call(h,f,m),n==null||n.update(f,m)},destroy:()=>{var f;(f=h.destroy)==null||f.call(h),n==null||n.destroy(),n=void 0,i=void 0,o=null}}}})}function oN(r){if(!(r instanceof Q))return!1;const{$head:e}=r;return e.parentOffset===e.parent.content.size}function sN(r,e){r.config(t=>nN(t,e)).config(t=>iN(t,e)).use(fu).use(Gp).use(Yp).use(Jc).use(cy).use(tN)}const aN=[ta.theme({"&":{color:"var(--crepe-color-on-surface)",backgroundColor:"var(--crepe-color-surface)"},".cm-content":{fontFamily:"var(--crepe-font-code)",caretColor:"var(--crepe-color-on-surface)"},".cm-scroller":{fontFamily:"var(--crepe-font-code)",lineHeight:"1.65",overflow:"auto"},".cm-gutters":{color:"var(--crepe-color-on-surface-variant)",backgroundColor:"var(--crepe-color-surface)",border:"none"},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:"var(--crepe-color-hover)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"var(--crepe-color-selected)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--crepe-color-on-surface)"},".cm-tooltip":{color:"var(--crepe-color-on-surface)",backgroundColor:"var(--crepe-color-surface-low)",borderColor:"var(--crepe-color-outline)"},".cm-searchMatch":{backgroundColor:"var(--crepe-color-secondary)",outline:"1px solid var(--crepe-color-primary)"}}),L4(k7.define([{tag:[rt.keyword,rt.modifier],color:"var(--blintz-syntax-keyword)"},{tag:[rt.string,rt.regexp],color:"var(--blintz-syntax-string)"},{tag:[rt.number,rt.bool,rt.null],color:"var(--blintz-syntax-number)"},{tag:rt.comment,color:"var(--blintz-syntax-comment)",fontStyle:"italic"},{tag:[rt.function(rt.variableName),rt.function(rt.propertyName)],color:"var(--blintz-syntax-function)"},{tag:[rt.typeName,rt.className,rt.tagName,rt.attributeName],color:"var(--blintz-syntax-type)"},{tag:[rt.operator,rt.punctuation],color:"var(--blintz-syntax-operator)"}]))];async function lN(r){try{return await navigator.clipboard.writeText(r)}catch{const e=document.createElement("textarea"),t=document.activeElement;e.value=r,e.setAttribute("readonly",""),e.style.contain="strict",e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="12pt";const n=document.getSelection(),i=n?n.rangeCount>0&&n.getRangeAt(0):null;document.body.appendChild(e),e.select(),e.selectionStart=0,e.selectionEnd=r.length,document.execCommand("copy"),document.body.removeChild(e),i&&(n.removeAllRanges(),n.addRange(i)),t&&t.focus()}}function cN({copyText:r,copyIcon:e,onCopy:t,text:n}){return z.jsxs("button",{type:"button",className:"copy-button",onClick:()=>{lN(n).then(()=>t(n)).catch(console.error)},children:[z.jsx(ke,{icon:e}),r]})}function uN({language:r,config:e,setLanguage:t,getAllLanguages:n,getReadOnly:i}){const o=B.useRef(null),s=B.useRef(null),a=B.useRef(null),[l,c]=B.useState(!1),[u,d]=B.useState("");B.useEffect(()=>{if(!l)return;d("");const m=o.current,y=s.current;if(!m||!y)return;qr(m,y,{placement:"bottom-start"}).then(({x:b,y:S})=>{Object.assign(y.style,{left:`${b}px`,top:`${S}px`})}).catch(console.error);const x=setTimeout(()=>{var b;return(b=a.current)==null?void 0:b.focus()},0);return()=>clearTimeout(x)},[l]),B.useEffect(()=>{if(!l)return;const m=y=>{var b,S;const x=y.target;(b=o.current)!=null&&b.contains(x)||(S=s.current)!=null&&S.contains(x)||c(!1)};return window.addEventListener("click",m),()=>window.removeEventListener("click",m)},[l]);const h=m=>{m.preventDefault(),m.stopPropagation(),!i()&&c(y=>!y)},f=B.useMemo(()=>{if(!l)return[];const m=n()??[],y=m.find(S=>S.name.toLowerCase()===r.toLowerCase()),x=u.toLowerCase(),b=m.filter(S=>(S.name.toLowerCase().includes(x)||S.alias.some(A=>A.toLowerCase().includes(x)))&&S!==y);return b.length===0?[]:y?[y,...b]:b},[l,u,r,n]);return z.jsxs(z.Fragment,{children:[z.jsxs("button",{type:"button",ref:o,className:"language-button","aria-label":"Code language","aria-expanded":l,disabled:i(),onClick:h,"data-expanded":String(l),children:[r||"Text",z.jsx("div",{className:"expand-icon",children:z.jsx(ke,{icon:e.expandIcon})})]}),z.jsx("div",{ref:s,className:"language-picker",children:l?z.jsxs("div",{className:"list-wrapper",children:[z.jsxs("div",{className:"search-box",children:[z.jsx("div",{className:"search-icon",children:z.jsx(ke,{icon:e.searchIcon})}),z.jsx("input",{ref:a,className:"search-input",placeholder:e.searchPlaceholder,"aria-label":e.searchPlaceholder,value:u,onChange:m=>d(m.target.value),onKeyDown:m=>{var y;m.key==="Escape"&&(c(!1),(y=o.current)==null||y.focus())}}),z.jsx("div",{className:_r("clear-icon",u.length===0&&"hidden"),onMouseDown:m=>{m.preventDefault(),d("")},children:z.jsx(ke,{icon:e.clearSearchIcon})})]}),z.jsx("ul",{className:"language-list",role:"listbox",onKeyDown:m=>{if(m.key==="Enter"){const y=document.activeElement;y instanceof HTMLElement&&y.dataset.language&&(t(y.dataset.language),c(!1))}},children:f.length?f.map(m=>{const y=m.name.toLowerCase()===r.toLowerCase();return z.jsx("li",{role:"option","aria-selected":y,tabIndex:0,className:"language-list-item","data-language":m.name,onClick:()=>{t(m.name),c(!1)},children:e.renderLanguage(m.name,y)},m.name)}):z.jsx("li",{className:"language-list-item no-result",children:e.noResultText})})]}):null})]})}const dN="http://www.w3.org/2000/svg";function hN(){const r=i6(),e={ADD_TAGS:["foreignObject"],ADD_ATTR:["xmlns"],HTML_INTEGRATION_POINTS:{foreignobject:!0}};return r.addHook("uponSanitizeElement",(t,n)=>{var i;if(n.tagName==="foreignobject"){const o=t.parentElement;(!o||o.namespaceURI!==dN)&&((i=t.parentNode)==null||i.removeChild(t))}}),t=>r.sanitize(t,e)}let p4;function fN(r){return p4??(p4=hN()),p4(r)}function pN({config:r,previewOnlyMode:e,preview:t}){const n=B.useRef(null);return B.useEffect(()=>{const i=n.current;if(i){for(;i.firstChild;)i.removeChild(i.firstChild);(typeof t=="string"||t instanceof Element)&&(i.innerHTML=fN(t))}},[t]),t?z.jsxs("div",{className:"preview-panel",children:[!e&&z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"preview-divider"}),z.jsx("div",{className:"preview-label",children:r.previewLabel})]}),z.jsx("div",{ref:n,className:"preview"})]}):null}const vc=new WeakMap;function mN(r,e){let t=vc.get(r);t||(t=new Set,vc.set(r,t)),t.add(e)}function gN(r,e){var t;(t=vc.get(r))==null||t.delete(e)}function m4(r,e){const t=vc.get(r);if(t)for(const n of t){const i=n.getPos();if(i==null)continue;const o=i+n.node.nodeSize;if(e>=i&&e<=o)return n}}class yN{constructor(e,t,n,i,o){We(this,"cm",null);We(this,"updating",!1);We(this,"languageName","");We(this,"languageConf",new Om);We(this,"readOnlyConf",new Om);We(this,"onTextChange",null);We(this,"node");We(this,"view");We(this,"getPos");We(this,"loader");We(this,"config");We(this,"forwardUpdate",e=>{if(!this.cm||this.updating||!this.cm.hasFocus)return;let t=(this.getPos()??0)+1;const{main:n}=e.state.selection,i=t+n.from,o=t+n.to,s=this.view.state.selection;if(e.docChanged||s.from!==i||s.to!==o){const a=this.view.state.tr;e.changes.iterChanges((l,c,u,d,h)=>{h.length?a.replaceWith(t+l,t+c,this.view.state.schema.text(h.toString())):a.delete(t+l,t+c),t+=d-u-(c-l)}),a.setSelection(Q.create(a.doc,i,o)),this.view.dispatch(a)}});We(this,"codeMirrorKeymap",()=>{const e=this.view;return[{key:"ArrowUp",run:()=>this.maybeEscape("line",-1)},{key:"ArrowLeft",run:()=>this.maybeEscape("char",-1)},{key:"ArrowDown",run:()=>this.maybeEscape("line",1)},{key:"ArrowRight",run:()=>this.maybeEscape("char",1)},{key:"Mod-Enter",run:()=>!e.editable||!g5(e.state,e.dispatch)?!1:(e.focus(),!0)},{key:"Mod-z",run:()=>e.editable&&wp(e.state,e.dispatch)},{key:"Shift-Mod-z",run:()=>e.editable&&hc(e.state,e.dispatch)},{key:"Mod-y",run:()=>e.editable&&hc(e.state,e.dispatch)},{key:"Backspace",run:()=>{if(!this.cm||!e.editable)return!1;const t=this.cm.state.selection.ranges;if(t.length>1)return!1;const n=t[0];if(n&&(!n.empty||n.anchor>0)||this.cm.state.doc.lines>=2)return!1;const i=this.view.state,o=this.getPos()??0,s=i.tr.replaceWith(o,o+this.node.nodeSize,i.schema.nodes.paragraph.createChecked({},this.node.content));return s.setSelection(Q.near(s.doc.resolve(o))),this.view.dispatch(s),this.view.focus(),!0}}]});We(this,"maybeEscape",(e,t)=>{if(!this.cm)return!1;const{state:n}=this.cm;let i=n.selection.main;if(!i.empty||(e==="line"&&(i=n.doc.lineAt(i.head)),t<0?i.from>0:i.to<n.doc.length))return!1;const o=(this.getPos()??0)+(t<0?0:this.node.nodeSize),s=Q.near(this.view.state.doc.resolve(o),t),a=this.view.state.tr.setSelection(s).scrollIntoView();return this.view.dispatch(a),this.view.focus(),!0});this.node=e,this.view=t,this.getPos=n,this.loader=i,this.config=o,mN(t,this)}init(e){return this.cm?this.cm:(this.cm=new ta({doc:this.node.textContent,root:this.view.root,extensions:[this.readOnlyConf.of([P0.readOnly.of(!this.view.editable),ta.editable.of(this.view.editable)]),z4(),Wh.of(this.codeMirrorKeymap()),this.languageConf.of([]),P0.changeFilter.of(()=>this.view.editable),...this.config.extensions,ta.updateListener.of(this.forwardUpdate)]}),e.appendChild(this.cm.dom),this.updateLanguage(),this.cm)}forceInit(){return this.cm?this.cm:this.init(document.createElement("div"))}updateLanguage(){if(!this.cm)return;const e=this.node.attrs.language??"";e!==this.languageName&&this.loader.load(e).then(t=>{this.cm&&(t?this.cm.dispatch({effects:this.languageConf.reconfigure(t)}):this.cm.dispatch({effects:this.languageConf.reconfigure([])}),this.languageName=e)}).catch(console.error)}setSelection(e,t){const n=this.forceInit();n.dom.isConnected&&(n.focus(),this.updating=!0,n.dispatch({selection:{anchor:e,head:t}}),this.updating=!1)}selectNode(){this.forceInit().focus()}update(e){if(e.type!==this.node.type)return!1;if(this.updating||(this.node=e,!this.cm))return!0;this.updateLanguage(),this.view.editable===this.cm.state.readOnly&&this.cm.dispatch({effects:this.readOnlyConf.reconfigure([P0.readOnly.of(!this.view.editable),ta.editable.of(this.view.editable)])});const t=vN(this.cm.state.doc.toString(),e.textContent);return t&&(this.updating=!0,this.cm.dispatch({changes:{from:t.from,to:t.to,insert:t.text},scrollIntoView:!0}),this.updating=!1),!0}destroy(){var e;gN(this.view,this),(e=this.cm)==null||e.destroy(),this.cm=null}}function vN(r,e){if(r===e)return null;let t=0,n=r.length,i=e.length;for(;t<n&&r.charCodeAt(t)===e.charCodeAt(t);)++t;for(;n>t&&i>t&&r.charCodeAt(n-1)===e.charCodeAt(i-1);)n--,i--;return{from:t,to:n,text:e.slice(t,i)}}const No={extensions:[],languages:[],expandIcon:"⬇",searchIcon:"🔍",clearSearchIcon:"⌫",searchPlaceholder:"Search language",noResultText:"No result",copyText:"Copy",copyIcon:"📋",onCopy:()=>{},renderLanguage:r=>r,renderPreview:()=>null,previewToggleButton:r=>r?"Edit":"Hide",previewLabel:"Preview",previewLoading:"Loading..."},bc=ye(No,"codeBlockConfigCtx");class bN{constructor(e){We(this,"map");We(this,"languages");this.languages=e,this.map={},e.forEach(t=>{t.alias.forEach(n=>{this.map[n]=t})})}getAll(){return this.languages.map(e=>({name:e.name,alias:e.alias}))}load(e){const t=this.map[e.toLowerCase()];return t?t.support?Promise.resolve(t.support):t.load():Promise.resolve(void 0)}}function wN(){const{node:r,view:e,getPos:t,setAttrs:n,selected:i}=Es(),o=Tr(),s=js(e),a=o.get(bc.key),l=B.useRef(null),c=B.useRef(null),u=B.useMemo(()=>new bN(a.languages),[a.languages]),d=r.attrs.language??"",h=r.textContent,[f,m]=B.useState(null),[y,x]=B.useState(a.previewOnlyByDefault??!e.editable);return B.useEffect(()=>{const b=l.current;if(!b)return;const S=new yN(r,e,t,u,a);c.current=S;const A=S.init(b);return A.dom.parentElement!==b&&b.appendChild(A.dom),()=>{S.destroy(),c.current=null}},[]),B.useEffect(()=>{const b=c.current;b&&(b.view=e,b.getPos=t,b.config=a,b.loader=u,b.update(r))}),B.useEffect(()=>{var S;const b=(S=l.current)==null?void 0:S.parentElement;b&&b.classList.toggle("selected",i)},[i]),B.useEffect(()=>{const b=a.renderPreview(d,h,S=>m(S));if(b){m(b);return}if(b===void 0){m(S=>S||a.previewLoading);return}m(null)},[d,h]),z.jsxs(z.Fragment,{children:[z.jsxs("div",{className:"tools",contentEditable:!1,children:[z.jsx(uN,{language:d,config:a,setLanguage:b=>{n({language:b})},getAllLanguages:()=>u.getAll(),getReadOnly:()=>!s}),z.jsxs("div",{className:"tools-button-group",children:[z.jsx(cN,{copyIcon:a.copyIcon,copyText:a.copyText,onCopy:a.onCopy??(()=>{}),text:h}),f?z.jsx("button",{type:"button",className:"preview-toggle-button",onClick:()=>x(b=>!b),children:z.jsx(ke,{icon:a.previewToggleButton(y)})}):null]})]}),z.jsx("div",{ref:l,className:_r("codemirror-host",f&&y&&"hidden")}),z.jsx(pN,{config:a,previewOnlyMode:y,preview:f})]})}function xN(r,e){const t=Ha($r.node,()=>e({component:wN,as:()=>{const n=document.createElement("div");return n.className="milkdown-code-block",n.contentEditable="false",n},stopEvent:()=>!0,selectNode:()=>{var o;const n=r.ctx.get(ge),i=n.state.selection;(o=m4(n,i.from))==null||o.selectNode()},setSelection:(n,i)=>{var a;const o=r.ctx.get(ge),s=o.state.selection;(a=m4(o,s.from))==null||a.setSelection(n,i)}}));r.config(n=>{const i=[Wh.of(B4.concat(S7)),UC,aN];n.update(bc.key,()=>({extensions:i,languages:C7,expandIcon:yC,searchIcon:LC,clearSearchIcon:WC,searchPlaceholder:"Search language",copyText:"Copy",copyIcon:s6,onCopy:()=>{},noResultText:"No result",renderLanguage:No.renderLanguage,renderPreview:No.renderPreview,previewToggleButton:o=>[o?a6:wC,o?"Edit":"Hide"].map(s=>s.trim()).join(" "),previewLabel:No.previewLabel,previewLoading:No.previewLoading,previewOnlyByDefault:No.previewOnlyByDefault}))}).use(bc).use(t)}function kN(r){r.config(e=>{e.update(Zc.key,()=>({class:"crepe-drop-cursor",width:4,color:!1}))}).use(cM).use(Fe(()=>uM()))}const SN=fk.filter(r=>r!==Ss.plugin&&r!==Ss.options),CN=new Set(["<br />","<br>","<br >","<br/>"]);function uy(r){if(!Array.isArray(r.children))return;const e=n=>n.type==="html"&&CN.has((n.value??"").trim()),t=["root","blockquote","listItem","list"].includes(r.type);r.children=r.children.filter(n=>{var i;return!(n.type==="paragraph"&&((i=n.children)!=null&&i.length)&&n.children.every(e))&&!(t&&e(n))}).map(n=>e(n)?{type:"break"}:n);for(const n of r.children)uy(n)}const MN=dr("markdownEditorStripEmptyLineBreaks",()=>()=>r=>{uy(r)}),TN=dr("remarkFrontmatter",()=>EM,"yaml"),B0="frontmatter",AN=je(B0,()=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,parseDOM:[{tag:`pre[data-type="${B0}"]`,preserveWhitespace:"full"}],toDOM:()=>["pre",{"data-type":B0,class:"milkdown-frontmatter"},["code",{spellcheck:"false"},0]],parseMarkdown:{match:r=>r.type==="yaml",runner:(r,e,t)=>{const n=e.value??"";r.openNode(t),n.length>0&&r.addText(n),r.closeNode()}},toMarkdown:{match:r=>r.type.name===B0,runner:(r,e)=>{r.addNode("yaml",void 0,e.textContent)}}}));function NN(r){r.use(TN).use(AN)}function dy({src:r,readonly:e,setLink:t,imageIcon:n,uploadButton:i,confirmButton:o,uploadPlaceholderText:s,className:a,onUpload:l,onImageLoadError:c}){const u=B.useId(),d=B.useRef(null),[h,f]=B.useState(!1),[m,y]=B.useState(r??""),[x,b]=B.useState(((r==null?void 0:r.length)??0)!==0),S=L=>{const N=L.target.value;b(N.length!==0),y(N)},A=L=>{var N;L.key==="Enter"&&t(((N=d.current)==null?void 0:N.value)??"")},D=()=>{var L;t(((L=d.current)==null?void 0:L.value)??"")},O=L=>{var j;const N=(j=L.target.files)==null?void 0:j[0];N&&l(N).then(K=>{K&&(t(K),b(!0))}).catch(K=>{console.error("An error occurred while uploading image"),console.error(K)})};return e?z.jsx("span",{className:"image-unavailable",children:"Image unavailable"}):z.jsxs("div",{className:_r("image-edit",a),children:[z.jsx(ke,{className:"image-icon",icon:n}),z.jsxs("div",{className:_r("link-importer",h&&"focus"),children:[z.jsx("input",{ref:d,"aria-label":"Image address",draggable:"true",onDragStart:L=>{L.preventDefault(),L.stopPropagation()},disabled:e,className:"link-input-area",value:m,onChange:S,onKeyDown:A,onFocus:()=>f(!0),onBlur:()=>f(!1)}),!x&&z.jsxs("div",{className:"placeholder",children:[z.jsx("input",{disabled:e,className:"hidden","aria-label":"Upload image",id:u,type:"file",accept:"image/*",onChange:O}),z.jsx("label",{className:"uploader",htmlFor:u,children:z.jsx(ke,{icon:i})}),z.jsx("span",{className:"text",onClick:()=>{var L;return(L=d.current)==null?void 0:L.focus()},children:s})]})]}),m&&z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"image-preview",children:z.jsx("img",{src:m,alt:"",onError:L=>Promise.resolve(c==null?void 0:c(L.nativeEvent)).catch(()=>{})})}),z.jsx("button",{type:"button","aria-label":"Insert image",className:"confirm",onClick:()=>D(),children:z.jsx(ke,{icon:o})})]})]})}function EN({src:r,caption:e,ratio:t,readonly:n,config:i,setAttr:o}){const s=B.useRef(null),a=B.useRef(0),[l,c]=B.useState(!!(e!=null&&e.length)),u=()=>{const b=s.current;if(!b)return;const S=b.closest(".milkdown-image-block");if(!S)return;let A=S.getBoundingClientRect().width;if(!A)return;i.maxWidth&&i.maxWidth<A&&(A=i.maxWidth);const D=b.naturalHeight,O=b.naturalWidth;let L=O<A?D:A*(D/O);i.maxHeight&&L>i.maxHeight&&(L=i.maxHeight);const N=(L*(t??1)).toFixed(2);b.dataset.origin=L.toFixed(2),b.dataset.height=N,b.style.height=`${N}px`,i.maxWidth&&(b.style.maxWidth=`${i.maxWidth}px`)},d=b=>{b.preventDefault(),b.stopPropagation(),!n&&c(S=>!S)},h=b=>{const S=b.target.value;a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{o("caption",S)},1e3)},f=b=>{const S=b.target.value;a.current&&(window.clearTimeout(a.current),a.current=0),o("caption",S)},m=B.useCallback(b=>{b.preventDefault();const S=s.current;if(!S)return;const A=S.getBoundingClientRect().top;let D=b.clientY-A;D<100&&(D=100),i.maxHeight&&D>i.maxHeight&&(D=i.maxHeight);const O=Number(D).toFixed(2);S.dataset.height=O,S.style.height=`${O}px`},[i.maxHeight]),y=B.useCallback(()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y);const b=s.current;if(!b)return;const S=Number(b.dataset.origin),A=Number(b.dataset.height),D=Number.parseFloat(Number(A/S).toFixed(2));Number.isNaN(D)||o("ratio",D)},[m,o]),x=b=>{n||(b.preventDefault(),b.stopPropagation(),window.addEventListener("pointermove",m),window.addEventListener("pointerup",y))};return B.useEffect(()=>()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y),a.current&&window.clearTimeout(a.current)},[m,y]),z.jsxs(z.Fragment,{children:[z.jsxs("div",{className:"image-wrapper",children:[!n&&z.jsx("div",{className:"operation",children:z.jsx("button",{type:"button","aria-label":"Toggle image caption","aria-pressed":l,className:"operation-item",onClick:d,children:z.jsx(ke,{icon:i.captionIcon})})}),z.jsx("img",{ref:s,"data-type":Fh,onLoad:u,src:r,alt:e,onError:b=>{var S;return Promise.resolve((S=i.onImageLoadError)==null?void 0:S.call(i,b.nativeEvent)).catch(()=>{})}}),!n&&z.jsx("div",{className:"image-resize-handle",onPointerDown:x})]}),n?e?z.jsx("div",{className:"caption-input",children:e}):null:l&&z.jsx("input",{"aria-label":"Image caption",draggable:"true",onDragStart:b=>{b.preventDefault(),b.stopPropagation()},className:"caption-input",placeholder:i==null?void 0:i.captionPlaceholderText,onChange:h,onBlur:f,defaultValue:e})]})}const DN={imageIcon:Dp,captionIcon:gC,uploadButton:"Upload file",confirmButton:Xc,uploadPlaceholderText:"or paste link",captionPlaceholderText:"Write Image Caption",onUpload:r=>Promise.resolve(URL.createObjectURL(r))},_h=ye(DN,"imageBlockConfigCtx"),ON={imageIcon:Dp,uploadButton:"Upload",confirmButton:Xc,uploadPlaceholderText:"or paste link",onUpload:r=>Promise.resolve(URL.createObjectURL(r))},hy=ye(ON,"inlineImageConfigCtx");function RN(){const{node:r,view:e,setAttrs:t,selected:n}=Es(),i=Tr().get(_h.key),{src:o,caption:s,ratio:a}=r.attrs,l=!js(e),[c,u]=B.useState(o);B.useEffect(()=>{const h=i.proxyDomURL;if(!h){u(o);return}const f=h(o);if(typeof f=="string"){u(f);return}let m=!1;return f.then(y=>{m||u(y)}).catch(console.error),()=>{m=!0}},[o,i.proxyDomURL]);const d=(h,f)=>{e.editable&&t({[h]:h==="src"?hu(f):f})};return o!=null&&o.length?z.jsx(EN,{src:c,caption:s,ratio:a,readonly:l,config:i,setAttr:d}):z.jsx(dy,{src:o,readonly:l,setLink:h=>d("src",h),imageIcon:i.imageIcon,uploadButton:i.uploadButton,confirmButton:i.confirmButton,uploadPlaceholderText:i.uploadPlaceholderText,onUpload:i.onUpload,onImageLoadError:i.onImageLoadError,className:n?"selected":void 0})}function IN(){const{node:r,view:e,setAttrs:t}=Es(),n=Tr().get(hy.key),{src:i,alt:o,title:s}=r.attrs,a=!js(e),[l,c]=B.useState(i);B.useEffect(()=>{const d=n.proxyDomURL;if(!d){c(i);return}const h=d(i);if(typeof h=="string"){c(h);return}let f=!1;return h.then(m=>{f||c(m)}).catch(console.error),()=>{f=!0}},[i,n.proxyDomURL]);const u=d=>{e.editable&&t({src:hu(d)})};return i!=null&&i.length?z.jsx("img",{className:"image-inline",src:l,alt:o,title:s}):z.jsx(dy,{src:i,readonly:a,setLink:u,imageIcon:n.imageIcon,uploadButton:n.uploadButton,confirmButton:n.confirmButton,uploadPlaceholderText:n.uploadPlaceholderText,onUpload:n.onUpload,className:"empty-image-inline"})}function zN(r){return Qi(r,"paragraph",(e,t,n)=>{var c,u;if(t==null||!n||((c=e.children)==null?void 0:c.length)!==1)return;const i=(u=e.children)==null?void 0:u[0];if(!i||i.type!=="image")return;const{url:o,alt:s,title:a}=i,l={type:"image-block",url:o,alt:s,title:a};n.children.splice(t,1,l)})}const LN=dr("remark-image-block",()=>()=>zN);function BN(r,e){const t=Ha(Hh.node,()=>e({component:RN,as:()=>{const i=document.createElement("div");return i.className="milkdown-image-block",i},stopEvent:i=>i.target instanceof HTMLInputElement})),n=Ha(ro.node,()=>e({component:IN,as:()=>{const i=document.createElement("span");return i.className="milkdown-image-inline",i},stopEvent:i=>i.target instanceof HTMLInputElement}));r.config(i=>{i.update(Oo.key,o=>({...o,uploader:async(s,a)=>{const l=a.nodes["image-block"]??a.nodes.image;if(!l)return[];const c=a.nodes["image-block"]?i.get(_h.key).onUpload:void 0,u=[];for(let d=0;d<s.length;d++){const h=s.item(d);h&&h.type.includes("image")&&u.push(h)}return await Promise.all(u.map(async d=>{const h=c?await c(d):URL.createObjectURL(d);return l.createAndFill({src:h})}))}}))}).use(_h).use(hy).use(Hh).use(LN).use(t).use(n)}const Jp=ye(null,"crepeLatexInlineEditStoreCtx"),PN={value:"",token:0,onConfirm:()=>{}},FN={subscribe:()=>()=>{},getSnapshot:()=>PN};function HN(){const r=Tr().get(Jp.key)??FN,{value:e,token:t,onConfirm:n}=B.useSyncExternalStore(r.subscribe,r.getSnapshot),[i,o]=B.useState(e);B.useEffect(()=>o(e),[t,e]);const s=()=>n(i);return z.jsxs("div",{className:"container",children:[z.jsx("input",{className:"latex-input","aria-label":"Math expression",placeholder:"Enter LaTeX...",value:i,onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&(a.preventDefault(),s())},onChange:a=>o(a.target.value)}),z.jsx("button",{type:"button",className:"button","aria-label":"Apply math expression",onPointerDown:a=>{a.preventDefault()},onClick:s,children:z.jsx(ke,{icon:Xc})})]})}const ua="math_inline",wc=je(ua,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${ua}"]`,getAttrs:r=>({value:r.dataset.value??""})}],toDOM:r=>{const e=r.attrs.value??"",t=document.createElement("span");return t.dataset.type=ua,t.dataset.value=e,iy.render(e,t,{throwOnError:!1}),t},parseMarkdown:{match:r=>r.type==="inlineMath",runner:(r,e,t)=>{r.addNode(t,{value:e.value})}},toMarkdown:{match:r=>r.type.name===ua,runner:(r,e)=>{r.addNode("inlineMath",void 0,e.attrs.value)}}})),_N=$r.extendSchema(r=>e=>{const t=r(e);return{...t,toMarkdown:{match:t.toMarkdown.match,runner:(n,i)=>{var o;if((i.attrs.language??"").toLowerCase()==="latex")n.addNode("math",void 0,((o=i.content.firstChild)==null?void 0:o.text)||"");else return t.toMarkdown.runner(n,i)}}}}),qN=le("ToggleLatex",r=>()=>(e,t)=>{const{hasNode:n,pos:i,target:o}=D5(e,wc.type(r)),{selection:s,doc:a,tr:l}=e;if(!n){const f=a.textBetween(s.from,s.to),m=l.replaceSelectionWith(wc.type(r).create({value:f}));return t&&t(m.setSelection(re.create(m.doc,s.from))),!0}const{from:c,to:u}=s;if(!o||i<0)return!1;let d=l.delete(i,i+1);const h=o.attrs.value;return d=d.insertText(h,i),t&&t(d.setSelection(Q.create(d.doc,c,u+h.length-1))),!0}),jN=mt(r=>Qw(/(?:\$)([^$]+)(?:\$)$/,wc.type(r),{getAttr:e=>({value:e[1]??""})})),$N=mt(r=>df(/^\$\$[\s\n]$/,$r.type(r),()=>({language:"LaTeX"}))),VN=dr("remarkMath",()=>KA);function WN(r){return Qi(r,"math",(e,t,n)=>{t==null||!n||n.children.splice(t,1,{type:"code",lang:"LaTeX",value:e.value??""})})}const UN=dr("remarkMathBlock",()=>()=>WN);function KN(r,e){return iy.renderToString(r,{...e,throwOnError:!1,displayMode:!0})}function GN(r){let e=r;const t=new Set;return{subscribe:n=>(t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,set:n=>{e=n,t.forEach(i=>i())}}}function YN(){return GN({value:"",token:0,onConfirm:()=>{}})}const g4=eu("CREPE_INLINE_LATEX");function JN(r,e){const t=YN();r.set(Jp.key,t);let n,i,o=0,s=-1;const a=()=>(i||(i=document.createElement("div"),i.className="milkdown-latex-inline-edit",i.dataset.show="false"),i),l=u=>d=>{const h=r.get(ge);h.dispatch(h.state.tr.setNodeAttribute(u,"value",d)),requestAnimationFrame(()=>h.focus())},c=u=>{if(!u.editable)return s=-1,!1;const{selection:d}=u.state;if(!(d instanceof re)||d.node.type.name!==ua)return s=-1,!1;const h=d.from;return h!==s&&(s=h,o+=1,t.set({value:d.node.attrs.value??"",token:o,onConfirm:l(h)})),!0};return e({component:HN,root:()=>a(),update:(u,d)=>{n||(n=new Qc({content:a(),debounce:0,offset:10,floatingUIOptions:{placement:"bottom"},shouldShow:c})),n.update(u,d)},destroy:()=>{n==null||n.destroy(),n=void 0,i=void 0,s=-1}})}function XN(r,e){r.config(t=>{t.update(bc.key,n=>({...n,renderPreview:(i,o,s)=>i.toLowerCase()==="latex"&&o.length>0?KN(o):n.renderPreview(i,o,s)})),t.set(g4.key,{view:JN(t,e)})}).use(VN).use(UN).use(wc).use(g4).use(jN).use($N).use(_N).use(qN).use(Jp)}const xc=ye({mode:"preview"},"crepeLinkTooltipStateCtx"),Ns=ye({addLink:()=>{},editLink:()=>{},removeLink:()=>{}},"crepeLinkTooltipAPICtx"),Xp=ye({linkIcon:s6,editButton:a6,removeButton:mh,confirmButton:Xc,inputPlaceholder:"Paste link...",onCopyLink:()=>{}},"crepeLinkTooltipConfigCtx"),Zp=ye(null,"crepeLinkPreviewStoreCtx"),Qp=ye(null,"crepeLinkEditStoreCtx"),ZN={src:"",token:0,onConfirm:()=>{},onCancel:()=>{}},QN={subscribe:()=>()=>{},getSnapshot:()=>ZN};function eE(){const r=Tr(),e=r.get(Qp.key)??QN,{src:t,token:n,onConfirm:i,onCancel:o}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),s=r.get(Xp.key),[a,l]=B.useState(t);B.useEffect(()=>l(t),[n,t]);const c=()=>i(a),u=d=>{d.stopPropagation(),d.key==="Enter"&&(d.preventDefault(),c()),d.key==="Escape"&&(d.preventDefault(),o())};return z.jsxs("div",{className:"link-edit",children:[z.jsx("input",{className:"input-area","aria-label":"Link address",placeholder:s.inputPlaceholder,value:a,onKeyDown:u,onChange:d=>l(d.target.value)}),a?z.jsx("button",{type:"button",className:"button confirm","aria-label":"Apply link",onPointerDown:d=>d.preventDefault(),onClick:c,children:z.jsx(ke,{icon:s.confirmButton})}):null]})}const tE={href:"",onEdit:()=>{},onRemove:()=>{}},rE={subscribe:()=>()=>{},getSnapshot:()=>tE};function nE(){const r=Tr(),e=r.get(Zp.key)??rE,{href:t,onEdit:n,onRemove:i}=B.useSyncExternalStore(e.subscribe,e.getSnapshot),o=r.get(Xp.key),s=c=>{c.preventDefault(),navigator.clipboard&&t&&navigator.clipboard.writeText(t).then(()=>o.onCopyLink(t)).catch(u=>console.error(u))},a=c=>{c.preventDefault(),c.stopPropagation(),n()},l=c=>{c.preventDefault(),c.stopPropagation(),i()};return z.jsxs("div",{className:"link-preview",children:[z.jsx("button",{type:"button",className:"button link-icon","aria-label":"Copy link",onPointerDown:c=>c.preventDefault(),onClick:s,children:z.jsx(ke,{icon:o.linkIcon})}),z.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"link-display",children:t}),z.jsx("button",{type:"button",className:"button link-edit-button","aria-label":"Edit link",onPointerDown:c=>c.preventDefault(),onClick:a,children:z.jsx(ke,{icon:o.editButton})}),z.jsx("button",{type:"button",className:"button link-remove-button","aria-label":"Remove link",onPointerDown:c=>c.preventDefault(),onClick:l,children:z.jsx(ke,{icon:o.removeButton})})]})}const fy=le("CrepeToggleLink",r=>()=>e=>{const{doc:t,selection:n}=e,i=Cr.type(r);return t.rangeHasMark(n.from,n.to,i)?(r.get(Ns.key).removeLink(n.from,n.to),!0):(r.get(Ns.key).addLink(n.from,n.to),!0)});function py(r){let e=r;const t=new Set;return{subscribe:n=>(t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,set:n=>{e=n,t.forEach(i=>i())}}}function iE(){return py({href:"",onEdit:()=>{},onRemove:()=>{}})}function oE(){return py({src:"",token:0,onConfirm:()=>{},onCancel:()=>{}})}const em=eu("CREPE_LINK_PREVIEW"),my=eu("CREPE_LINK_EDIT");function sE(r,e,t,n,i){let o={start:-1,end:-1};return t.nodesBetween(n,i,(s,a)=>{if(o.start>-1)return!1;o.start===-1&&r.isInSet(s.marks)&&e===s&&(o={start:a,end:a+Math.max(s.textContent.length,1)})}),o}function aE(r,e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return;const{pos:i}=n,o=e.state.doc.nodeAt(i);if(!o)return;const s=o.marks.find(a=>a.type===Cr.mark.type(r));if(!(!s||!em.pluginKey()))return{show:!0,pos:i,node:o,mark:s}}function lE(r,e){let t;return(...n)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...n),e)}}const y4=50;function cE(r,e){const t=iE();r.set(Zp.key,t);let n,i,o,s=!1;const a=()=>(i||(i=document.createElement("div"),i.className="milkdown-link-preview",i.dataset.show="false"),i),l=()=>{s=!0},c=()=>{s=!1},u=()=>{n==null||n.hide(),n==null||n.element.removeEventListener("mouseenter",l),n==null||n.element.removeEventListener("mouseleave",c)},d=()=>{s||u()},h=(b,S,A,D)=>{!n||!o||(t.set({href:b.attrs.href,onEdit:()=>r.get(Ns.key).editLink(b,S,A),onRemove:()=>{r.get(Ns.key).removeLink(S,A),u()}}),n.show({getBoundingClientRect:()=>D},o),n.element.addEventListener("mouseenter",l),n.element.addEventListener("mouseleave",c))},f=e({component:nE,root:()=>a()}),m=b=>{const S=f(b);return o=b,n=new Qc({content:a(),debounce:0,shouldShow:()=>!1}),n.update(b),{update:(A,D)=>{var O;o=A,(O=S.update)==null||O.call(S,A,D)},destroy:()=>{var A;u(),(A=S.destroy)==null||A.call(S),n==null||n.destroy(),n=void 0,i=void 0,o=void 0}}},y=lE((b,S)=>{if(!n||!b.hasFocus()||r.get(xc.key).mode==="edit")return;const A=aE(r,b,S);if(A){const D=b.state.doc.resolve(A.pos),O=sE(A.mark,A.node,b.state.doc,D.before(),D.after()),L=O.start,N=O.end;h(A.mark,L,N,Bc(b,L,N));return}d()},y4),x=()=>{setTimeout(()=>d(),y4)};return r.set(em.key,{props:{handleDOMEvents:{mousemove:y,mouseleave:x}},view:m}),{hide:u}}function uE(r,e,t){const n=oE();r.set(Qp.key,n);let i,o,s=0,a={from:-1,to:-1,mark:null};const l=()=>(o||(o=document.createElement("div"),o.className="milkdown-link-edit",o.dataset.show="false"),o),c=b=>{const S=b.target;S&&(l().contains(S)||h())},u=()=>document.addEventListener("pointerdown",c,!0),d=()=>document.removeEventListener("pointerdown",c,!0);function h(){d(),i==null||i.hide(),r.update(xc.key,b=>({...b,mode:"preview"})),a={from:-1,to:-1,mark:null}}const f=b=>{const S=r.get(ge),{from:A,to:D,mark:O}=a,L=Cr.type(r),N=hu(b);if(O&&O.attrs.href===N){h();return}const j=S.state.tr;if(O&&j.removeMark(A,D,O),A===D){if(!N){h();return}const K=L.create({href:N});j.insertText(N,A),j.addMark(A,A+N.length,K)}else j.addMark(A,D,L.create({href:N}));S.dispatch(j),h()},m=(b,S,A)=>{t(),s+=1,n.set({src:b,token:s,onConfirm:f,onCancel:h}),r.update(xc.key,O=>({...O,mode:"edit"}));const D=r.get(ge);D.dispatch(D.state.tr.setSelection(Q.create(D.state.doc,S,A))),i==null||i.show({getBoundingClientRect:()=>Bc(D,S,A)},D),u(),requestAnimationFrame(()=>{var O;(O=l().querySelector("input"))==null||O.focus()})};r.update(Ns.key,b=>({...b,addLink:(S,A)=>{a={from:S,to:A,mark:null},m("",S,A)},editLink:(S,A,D)=>{a={from:A,to:D,mark:S},m(S.attrs.href??"",A,D)},removeLink:(S,A)=>{const D=r.get(ge),O=D.state.tr;O.removeMark(S,A,Cr.type(r)),D.dispatch(O),h()}}));const y=e({component:eE,root:()=>l()}),x=b=>{const S=y(b);return i=new Qc({content:l(),debounce:0,shouldShow:()=>!1}),i.onHide=()=>{requestAnimationFrame(()=>b.dom.focus({preventScroll:!0}))},i.update(b),{update:(A,D)=>{var j;if((j=S.update)==null||j.call(S,A,D),a.from===-1&&a.to===-1)return;const{selection:O}=A.state;if(!(O instanceof Q))return;const{from:L,to:N}=O;L===a.from&&N===a.to||h()},destroy:()=>{var A;d(),(A=S.destroy)==null||A.call(S),i==null||i.destroy(),i=void 0,o=void 0}}};r.set(my.key,{view:x})}function dE(r,e){r.config(t=>{const n=cE(t,e);uE(t,e,n.hide)}).use(xc).use(Ns).use(Xp).use(Zp).use(Qp).use(em).use(my).use(fy)}function v4({label:r,listType:e,checked:t}){return t==null?e==="bullet"?'<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="2.5" /></svg>':r:t?BC:FC}function hE(){const{node:r,view:e,getPos:t,selected:n,contentRef:i}=Es(),{label:o,checked:s,listType:a}=r.attrs,l=!js(e),c=()=>{if(!e.editable)return;const d=t();d!=null&&e.dispatch(e.state.tr.setNodeAttribute(d,"checked",!s))},u=s==null?a==="bullet"?"bullet":"ordered":s?"checked":"unchecked";return z.jsxs("div",{className:_r("milkdown-list-item-content",n&&"ProseMirror-selectednode"),children:[s==null?z.jsx("span",{className:"label-wrapper",contentEditable:!1,"aria-hidden":"true",children:z.jsx(ke,{className:_r("label",u),icon:v4({label:o,listType:a,checked:s})})}):z.jsx("button",{type:"button",role:"checkbox","aria-checked":s,"aria-label":r.textContent||"Task",disabled:l,className:"label-wrapper task-checkbox",contentEditable:!1,onPointerDown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{d.stopPropagation(),c()},children:z.jsx(ke,{className:_r("label",u),icon:v4({label:o,listType:a,checked:s})})}),z.jsx("div",{className:"children",ref:i})]})}const fE=Fe(r=>new Ce({key:new Me("MARKDOWN_EDITOR_ORDERED_LIST_LABEL_SYNC"),appendTransaction:(e,t,n)=>{if(t.doc.eq(n.doc))return null;const i=oi.type(r),o=fr.type(r);let s=n.tr,a=!1;return n.doc.descendants((l,c)=>{if(l.type!==i)return;const u=l.attrs.order??1;l.forEach((d,h,f)=>{if(d.type!==o)return;const m=`${f+u}.`;d.attrs.label!==m&&(s=s.setNodeMarkup(c+1+h,void 0,{...d.attrs,label:m,listType:"ordered"}),a=!0)})}),a?s.setMeta("addToHistory",!1):null}}));function pE(r,e){const t=Ha(fr.node,()=>e({component:hE,as:()=>{const n=document.createElement("li");return n.className="milkdown-list-item-block",n},contentAs:"div",stopEvent:()=>!1}));r.use(t).use(fE)}function mE(r){var e;return r.childCount<=1&&!((e=r.firstChild)!=null&&e.content.size)}function gE(r,e){const{selection:t}=r;if(!t.empty)return null;const n=t.$anchor,i=n.parent;if(i.content.size>0||Fr(s=>s.type.name==="table")(n))return null;const o=n.before();return qe.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":e})}const qh=ye({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),yE=Fe(r=>new Ce({key:new Me("CREPE_PLACEHOLDER"),props:{decorations:e=>{let t=!0;try{t=r.get(ge).editable}catch{t=!0}if(!t)return null;const n=r.get(qh.key);if(n.mode==="doc"&&!mE(e.doc)||sy(e.selection)||ay(e.selection))return null;const i=gE(e,n.text??"Please enter...");return i?Se.create(e.doc,[i]):null}}}));function vE(r,e){r.config(t=>{e&&t.update(qh.key,n=>({...n,...e}))}).use(yE).use(qh)}function bE(){var x;const{node:r,view:e,getPos:t}=Es(),n=Tr(),i=js(e),[o,s]=B.useState(!1),[a,l]=B.useState({row:0,col:0}),c=B.useRef(null),u=B.useRef(null),d=B.useRef(null);B.useEffect(()=>{var S,A;if(!o)return;(A=(S=u.current)==null?void 0:S.querySelector("button:not(:disabled)"))==null||A.focus();const b=D=>{var O;D.target instanceof Node&&!((O=d.current)!=null&&O.contains(D.target))&&s(!1)};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[o]),B.useEffect(()=>{i||s(!1)},[i]);const h=()=>{if(!e.editable)return;const{$from:b}=e.state.selection,S=t();let A=0,D=0;if(S!=null&&b.pos>S&&b.pos<S+r.nodeSize){for(let O=0;O<=b.depth;O++)if(b.node(O).type.name==="table"){A=b.index(O),D=O<b.depth?b.index(O+1):0;break}}l({row:A,col:D}),s(!o)},f=b=>{if(!e.editable)return;const S=t();if(S==null)return;const A=n.get(ee),D=S+1;b==="add-row"||b==="delete-row"?(A.call(fn.key,{pos:D,index:a.row}),A.call(b==="add-row"?Uc.key:_a.key)):b==="add-col"||b==="delete-col"?(A.call(pn.key,{pos:D,index:a.col}),A.call(b==="add-col"?Wc.key:_a.key)):b==="row-up"||b==="row-down"?(A.call(fn.key,{pos:D,index:a.row}),A.call($c.key,{pos:D,from:a.row,to:a.row+(b==="row-up"?-1:1)})):(A.call(pn.key,{pos:D,index:a.col}),A.call(Vc.key,{pos:D,from:a.col,to:a.col+(b==="col-left"?-1:1)})),s(!1),e.focus()};if(!i)return null;const m=r.childCount,y=((x=r.firstChild)==null?void 0:x.childCount)??0;return z.jsxs("div",{className:"milkdown-table-actions",contentEditable:!1,ref:d,children:[z.jsx("button",{type:"button",ref:c,"aria-label":"Table actions","aria-haspopup":"menu","aria-expanded":o,onPointerDown:b=>b.preventDefault(),onClick:h,children:"•••"}),o&&z.jsxs("div",{className:"milkdown-table-actions-menu",role:"menu","aria-label":"Table actions",ref:u,onKeyDown:b=>{var S,A,D;if(b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),s(!1),(S=c.current)==null||S.focus()),b.key==="ArrowDown"||b.key==="ArrowUp"){b.preventDefault(),b.stopPropagation();const O=Array.from(((A=u.current)==null?void 0:A.querySelectorAll("button:not(:disabled)"))??[]),L=O.indexOf(document.activeElement);(D=O[(L+(b.key==="ArrowDown"?1:O.length-1))%O.length])==null||D.focus()}},children:[z.jsxs("div",{className:"milkdown-table-actions-context",children:["Row ",a.row+1," · Column ",a.col+1]}),z.jsx("button",{role:"menuitem",type:"button",onClick:()=>f("add-row"),children:"Add row below"}),z.jsx("button",{role:"menuitem",type:"button",onClick:()=>f("add-col"),children:"Add column right"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row<=1,onClick:()=>f("row-up"),children:"Move row up"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row===0||a.row>=m-1,onClick:()=>f("row-down"),children:"Move row down"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.col===0,onClick:()=>f("col-left"),children:"Move column left"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.col>=y-1,onClick:()=>f("col-right"),children:"Move column right"}),z.jsx("button",{role:"menuitem",type:"button",disabled:a.row===0,onClick:()=>f("delete-row"),children:"Delete row"}),z.jsx("button",{role:"menuitem",type:"button",disabled:y<=1,onClick:()=>f("delete-col"),children:"Delete column"})]})]})}const wE={renderButton:r=>{switch(r){case"add_row":return"+";case"add_col":return"+";case"delete_row":return"-";case"delete_col":return"-";case"align_col_left":return"left";case"align_col_center":return"center";case"align_col_right":return"right";case"col_drag_handle":return"=";case"row_drag_handle":return"="}}},jh=ye({...wE},"tableBlockConfigCtx");function $h(r,e){for(let t=0;t<r.childCount;t++)if(r.child(t)===e)return t;return-1}function xE(r,e){var t,n,i;if(e)try{const o=e.posAtCoords({left:r.clientX,top:r.clientY});if(!o)return;const s=o.inside;if(s==null||s<0)return;const a=e.state.doc.resolve(s),l=e.state.doc.nodeAt(s);if(!l)return;const c=["table_cell","table_header"],u=["table_row","table_header_row"],d=c.includes(l.type.name)?l:(t=Fr(y=>c.includes(y.type.name))(a))==null?void 0:t.node,h=(n=Fr(y=>u.includes(y.type.name))(a))==null?void 0:n.node,f=(i=Fr(y=>y.type.name==="table")(a))==null?void 0:i.node;if(!d||!h||!f)return;const m=$h(h,d);return[$h(f,h),m]}catch{return}}function pu(r,[e,t]){const n=r.current;if(!n)return;const i=n.querySelectorAll("tr"),o=i[e];if(!o)return;const s=i[0];if(!s)return;const a=s.children[t];if(!a)return;const l=o.children[t];if(l)return{row:o,col:l,headerCol:a}}function kE(r,e,t){if(!t||!e)return;const{selection:n}=e.state;if(!(n instanceof Ae))return;const{$from:i}=n,o=Rs(i);if(!(!o||o.node!==t)){if(n.isColSelection()){const{$head:s}=n,a=s.index(s.depth-1);tm({refs:r,index:[0,a],before:l=>{var c;(c=l.querySelector(".button-group"))==null||c.setAttribute("data-show","true")}});return}if(n.isRowSelection()){const{$head:s}=n,a=Fr(c=>c.type.name==="table_row"||c.type.name==="table_header_row")(s);if(!a)return;const l=$h(o.node,a.node);rm({refs:r,index:[l,0],before:c=>{var u;l>0&&((u=c.querySelector(".button-group"))==null||u.setAttribute("data-show","true"))}})}}}function tm({refs:r,index:e,before:t,after:n}){const{contentWrapperRef:i,colHandleRef:o,hoverIndex:s}=r,a=o.current;if(!a)return;s.current=e;const l=pu(i,e);if(!l)return;const{headerCol:c}=l;a.dataset.show="true",t&&t(a),qr(c,a,{placement:"top"}).then(({x:u,y:d})=>{Object.assign(a.style,{left:`${u}px`,top:`${d}px`}),n&&n(a)}).catch(console.error)}function rm({refs:r,index:e,before:t,after:n}){const{contentWrapperRef:i,rowHandleRef:o,hoverIndex:s}=r,a=o.current;if(!a)return;s.current=e;const l=pu(i,e);if(!l)return;const{row:c}=l;a.dataset.show="true",t&&t(a),qr(c,a,{placement:"left"}).then(({x:u,y:d})=>{Object.assign(a.style,{left:`${u}px`,top:`${d}px`}),n&&n(a)}).catch(console.error)}function SE(r,e){let t=0,n=null,i=null;const o=s=>{t=Date.now(),r(...s)};return(...s)=>{const a=Date.now(),l=e-(a-t);l<=0?(n&&(clearTimeout(n),n=null),o(s)):(i=s,n||(n=setTimeout(()=>{if(n=null,i){const c=i;i=null,o(c)}},l)))}}function gy(r){const{dragPreviewRef:e,tableWrapperRef:t,contentWrapperRef:n,yLineHandleRef:i,xLineHandleRef:o,colHandleRef:s,rowHandleRef:a}=r,l=e.current;if(!l)return;const c=t.current;if(!c)return;const u=n.current;if(!u)return;const d=u.querySelector("tbody");if(!d)return;const h=l.querySelector("tbody");if(!h)return;const f=i.current;if(!f)return;const m=o.current;if(!m)return;const y=s.current;if(!y)return;const x=a.current;if(x)return{preview:l,wrapper:c,content:u,contentRoot:d,previewRoot:h,yHandle:f,xHandle:m,colHandle:y,rowHandle:x}}function yy(r,e,t){const n=t==="x"?"left":"top",i=t==="x"?"right":"bottom",o=r.length-1,s=r.findIndex((l,c)=>{const u=l.getBoundingClientRect(),d=u[n],h=u[i];return d<=e&&e<=h||c===o&&e>h||c===0&&e<d}),a=r[s];return a?[a,s]:void 0}function CE(r,e){const t=r.querySelector("tr");if(!t)return;const n=Array.from(t.children);return yy(n,e,"x")}function ME(r,e){const t=Array.from(r.querySelectorAll("tr"));return yy(t,e,"y")}function vy(r){for(;r.firstChild;)r.removeChild(r.firstChild)}function by(r,e,t,n,i){const o=n.querySelector("tbody");if(!o)return;const{width:s,height:a}=o.getBoundingClientRect();if(r==="y"){const u=n.querySelectorAll("tr")[i];if(!u)return;t.appendChild(u.cloneNode(!0));const d=u.getBoundingClientRect().height;Object.assign(e.style,{width:`${s}px`,height:`${d}px`}),e.dataset.show="true";return}const l=n.querySelectorAll("tr");let c;Array.from(l).forEach(u=>{const d=u.children[i];if(!d)return;c===void 0&&(c=d.getBoundingClientRect().width);const h=d.parentElement;if(!h)return;const f=h.cloneNode(!1),m=d.cloneNode(!0);f.appendChild(m),t.appendChild(f)}),Object.assign(e.style,{width:`${c??0}px`,height:`${a}px`}),e.dataset.show="true"}function b4(r){var e;(e=r.querySelector(".button-group"))==null||e.setAttribute("data-show","false")}function wy(r,e,t,n){const{xHandle:i,yHandle:o,colHandle:s,rowHandle:a,preview:l}=t;i.dataset.displayType=r==="y"?"indicator":"none",o.dataset.displayType=r==="x"?"indicator":"none",r==="y"?(s.dataset.show="false",b4(a)):(a.dataset.show="false",b4(s));const{hoverIndex:c,dragInfo:u}=n,[d,h]=c.current;u.current={startCoords:[e.clientX,e.clientY],startIndex:r==="y"?d:h,endIndex:r==="y"?d:h,type:r==="y"?"row":"col"},l.dataset.direction=r==="y"?"vertical":"horizontal"}function xy(r,e,t,n){var o;if(!((o=t==null?void 0:t.get(ge))!=null&&o.editable))return;e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.effectAllowed="move");const i=gy(r);i&&requestAnimationFrame(()=>{n(i)})}function TE(r,e){return t=>{xy(r,t,e,n=>{wy("y",t,n,r);const{preview:i,content:o,previewRoot:s}=n;vy(s);const[a]=r.hoverIndex.current;by("y",i,s,o,a)})}}function AE(r,e){return t=>{xy(r,t,e,n=>{wy("x",t,n,r);const{preview:i,content:o,previewRoot:s}=n,[,a]=r.hoverIndex.current;vy(s),by("x",i,s,o,a)})}}function NE(r){return SE(e=>{const t=gy(r);if(!t)return;const{preview:n,content:i,contentRoot:o,xHandle:s,yHandle:a}=t,{dragInfo:l,hoverIndex:c}=r;if(n.dataset.show==="false")return;const u=pu(r.contentWrapperRef,c.current);if(!u||!o.querySelector("tr"))return;const d=l.current;if(!d)return;const h=o.offsetParent;if(!h)return;const f=h.offsetTop,m=h.offsetLeft;if(d.type==="col"){const y=u.col.getBoundingClientRect().width,{left:x,width:b}=o.getBoundingClientRect(),S=m-x,A=e.clientX+S-y/2,[D]=d.startCoords,O=D<e.clientX?"right":"left";n.style.top=`${f}px`;const L=A<x+S-20?x+S-20:A>x+b+S-y+20?x+b+S-y+20:A;n.style.left=`${L}px`;const N=CE(o,e.clientX);if(N){const[j,K]=N,ne=a.getBoundingClientRect().width,pe=i.getBoundingClientRect();d.endIndex=K,qr(j,a,{placement:O==="left"?"left":"right",middleware:[Ki(O==="left"?-1*ne:0)]}).then(({x:se})=>{a.dataset.show="true",Object.assign(a.style,{height:`${pe.height}px`,left:`${se}px`,top:`${f}px`})}).catch(console.error)}}else if(d.type==="row"){const y=u.row.getBoundingClientRect().height,{top:x,height:b}=o.getBoundingClientRect(),S=f-x,A=e.clientY+S-y/2,[,D]=d.startCoords,O=D<e.clientY?"down":"up",L=A<x+S-20?x+S-20:A>x+b+S-y+20?x+b+S-y+20:A;n.style.top=`${L}px`,n.style.left=`${m}px`;const N=ME(o,e.clientY);if(N){const[j,K]=N,ne=s.getBoundingClientRect().height,pe=i.getBoundingClientRect();d.endIndex=K,qr(j,s,{placement:O==="up"?"top":"bottom",middleware:[Ki(O==="up"?-1*ne:0)]}).then(({y:se})=>{s.dataset.show="true",Object.assign(s.style,{width:`${pe.width}px`,top:`${se}px`})}).catch(console.error)}}},20)}function EE(r,e,t){const{dragPreviewRef:n,yLineHandleRef:i,xLineHandleRef:o,dragInfo:s}=r,a=TE(r,e),l=AE(r,e),c=NE(r);return{dragCol:l,dragRow:a,onDragOver:c,onDragEnd:()=>{const u=n.current;if(!u||u.dataset.show==="false")return;const d=u.querySelector("tbody");for(;d!=null&&d.firstChild;)d.removeChild(d.firstChild);u.dataset.show="false",s.current=void 0},onDrop:()=>{const u=n.current;if(!u)return;const d=i.current;if(!d)return;const h=o.current;if(!h)return;const f=s.current;if(!f||!e||u.dataset.show==="false"||!r.colHandleRef.current||!r.rowHandleRef.current)return;d.dataset.show="false",h.dataset.show="false";const m=u.querySelector("tbody");for(;m!=null&&m.firstChild;)m.removeChild(m.firstChild);if(u.dataset.show="false",s.current=void 0,f.startIndex===f.endIndex||f.type==="row"&&(f.startIndex===0||f.endIndex===0))return;const y=e.get(ee),x={from:f.startIndex,to:f.endIndex,pos:((t==null?void 0:t())??0)+1};if(f.type==="col"){y.call(pn.key,{pos:x.pos,index:f.startIndex}),y.call(Vc.key,x);const b=[0,f.endIndex];tm({refs:r,index:b})}else{y.call(fn.key,{pos:x.pos,index:f.startIndex}),y.call($c.key,x);const b=[f.endIndex,0];rm({refs:r,index:b})}requestAnimationFrame(()=>{e.get(ge).focus()})}}}function DE(r,e,t){const{xLineHandleRef:n,contentWrapperRef:i,colHandleRef:o,rowHandleRef:s,hoverIndex:a,lineHoverIndex:l}=r;return{onAddRow:()=>{var m;if(!e)return;const c=n.current;if(!c)return;const[u]=l.current;if(u<0||!e.get(ge).editable)return;const d=Array.from(((m=i.current)==null?void 0:m.querySelectorAll("tr"))??[]),h=e.get(ee),f=((t==null?void 0:t())??0)+1;d.length===u?(h.call(fn.key,{pos:f,index:u-1}),h.call(Uc.key)):(h.call(fn.key,{pos:f,index:u}),h.call(fp.key)),h.call(fn.key,{pos:f,index:u}),c.dataset.show="false"},onAddCol:()=>{var f,m;if(!e||!n.current)return;const[,c]=l.current;if(c<0||!e.get(ge).editable)return;const u=Array.from(((m=(f=i.current)==null?void 0:f.querySelector("tr"))==null?void 0:m.children)??[]),d=e.get(ee),h=((t==null?void 0:t())??0)+1;u.length===c?(d.call(pn.key,{pos:h,index:c-1}),d.call(Wc.key)):(d.call(pn.key,{pos:h,index:c}),d.call(hp.key)),d.call(pn.key,{pos:h,index:c})},selectCol:()=>{var f;if(!e)return;const[,c]=a.current,u=e.get(ee),d=((t==null?void 0:t())??0)+1;u.call(pn.key,{pos:d,index:c});const h=(f=o.current)==null?void 0:f.querySelector(".button-group");h&&(h.dataset.show=h.dataset.show==="true"?"false":"true")},selectRow:()=>{var f;if(!e)return;const[c]=a.current,u=e.get(ee),d=((t==null?void 0:t())??0)+1;u.call(fn.key,{pos:d,index:c});const h=(f=s.current)==null?void 0:f.querySelector(".button-group");h&&c>0&&(h.dataset.show=h.dataset.show==="true"?"false":"true")},deleteSelected:c=>{!e||!e.get(ge).editable||(c.preventDefault(),c.stopPropagation(),e.get(ee).call(_a.key),requestAnimationFrame(()=>{e.get(ge).focus()}))},onAlign:c=>u=>{!e||!e.get(ge).editable||(u.preventDefault(),u.stopPropagation(),e.get(ee).call(pp.key,c),requestAnimationFrame(()=>{e.get(ge).focus()}))}}}function OE(r,e){let t=0,n=null,i=null;const o=s=>{t=Date.now(),r(...s)};return(...s)=>{const a=Date.now(),l=e-(a-t);l<=0?(n&&(clearTimeout(n),n=null),o(s)):(i=s,n||(n=setTimeout(()=>{if(n=null,i){const c=i;i=null,o(c)}},l)))}}function RE(r,e){return OE(t=>{if(!(e!=null&&e.editable))return;const{contentWrapperRef:n,yLineHandleRef:i,xLineHandleRef:o,colHandleRef:s,rowHandleRef:a,hoverIndex:l,lineHoverIndex:c}=r,u=i.current;if(!u)return;const d=o.current;if(!d)return;const h=n.current;if(!h)return;const f=a.current;if(!f)return;const m=s.current;if(!m)return;const y=xE(t,e);if(!y)return;const x=pu(n,y);if(!x)return;const[b,S]=y,A=x.col.getBoundingClientRect(),D=Math.abs(t.clientX-A.left)<8,O=Math.abs(A.right-t.clientX)<8,L=Math.abs(t.clientY-A.top)<8,N=Math.abs(A.bottom-t.clientY)<8,j=D||O||L||N,K=f.querySelector(".button-group"),ne=m.querySelector(".button-group");if(K&&(K.dataset.show="false"),ne&&(ne.dataset.show="false"),j){const pe=h.getBoundingClientRect();f.dataset.show="false",m.dataset.show="false",d.dataset.displayType="tool",u.dataset.displayType="tool";const se=u.getBoundingClientRect().width,lt=d.getBoundingClientRect().height;D||O?(c.current[1]=D?S:S+1,qr(x.col,u,{placement:D?"left":"right",middleware:[Ki(D?-1*se:0)]}).then(({x:Re})=>{u.dataset.show="true",Object.assign(u.style,{height:`${pe.height}px`,left:`${Re}px`})}).catch(console.error)):u.dataset.show="false",y[0]!==0&&(L||N)?(c.current[0]=L?b:b+1,qr(x.row,d,{placement:L?"top":"bottom",middleware:[Ki(L?-1*lt:0)]}).then(({y:Re})=>{d.dataset.show="true",Object.assign(d.style,{width:`${pe.width}px`,top:`${Re}px`})}).catch(console.error)):d.dataset.show="false";return}c.current=[-1,-1],u.dataset.show="false",d.dataset.show="false",f.dataset.show="true",m.dataset.show="true",rm({refs:r,index:y}),tm({refs:r,index:y}),l.current=y},20)}function IE(r){return()=>{const{rowHandleRef:e,colHandleRef:t,yLineHandleRef:n,xLineHandleRef:i}=r;setTimeout(()=>{const o=e.current;if(!o)return;const s=t.current;if(!s)return;const a=n.current;if(!a)return;const l=i.current;l&&(o.dataset.show="false",s.dataset.show="false",a.dataset.show="false",l.dataset.show="false")},200)}}function zE(r,e){return{pointerMove:RE(r,e),pointerLeave:IE(r)}}function LE(){const{node:r,view:e,getPos:t,contentRef:n}=Es(),i=Tr(),o=js(e),s=i.get(jh.key),a=B.useRef(null),l=B.useRef(null),c=B.useRef(null),u=B.useRef(null),d=B.useRef(null),h=B.useRef(null),f=B.useRef(null),m=B.useRef([0,0]),y=B.useRef([-1,-1]),x=B.useRef(void 0),b={contentWrapperRef:a,tableWrapperRef:l,dragPreviewRef:c,yLineHandleRef:f,xLineHandleRef:h,colHandleRef:u,rowHandleRef:d,hoverIndex:m,lineHoverIndex:y,dragInfo:x},{onAddRow:S,onAddCol:A,selectCol:D,selectRow:O,deleteSelected:L,onAlign:N}=DE(b,i,t),j=se=>{a.current=se,n(se)},K=B.useRef(null);B.useEffect(()=>{const se=K.current;if(!se)return;const{pointerMove:lt,pointerLeave:Re}=zE(b,e),Ue=Bt=>lt(Bt),$e=()=>Re();return se.addEventListener("pointermove",Ue),se.addEventListener("pointerleave",$e),()=>{se.removeEventListener("pointermove",Ue),se.removeEventListener("pointerleave",$e)}},[e]),B.useEffect(()=>{const se=u.current,lt=d.current;if(!se||!lt)return;const{dragCol:Re,dragRow:Ue,onDragOver:$e,onDragEnd:Bt,onDrop:pr}=EE(b,i,t);return se.addEventListener("dragstart",Re),lt.addEventListener("dragstart",Ue),window.addEventListener("dragover",$e),window.addEventListener("dragend",Bt),window.addEventListener("drop",pr),()=>{se.removeEventListener("dragstart",Re),lt.removeEventListener("dragstart",Ue),window.removeEventListener("dragover",$e),window.removeEventListener("dragend",Bt),window.removeEventListener("drop",pr)}},[e]),B.useEffect(()=>{requestAnimationFrame(()=>{e.editable&&kE(b,e,r)})},[r,e]);const ne=se=>se.stopPropagation(),pe=se=>se.preventDefault();return z.jsxs("div",{ref:K,className:o?void 0:"readonly",onDragStart:pe,onDragOver:pe,onDragLeave:pe,children:[z.jsx(bE,{}),z.jsxs("div",{"data-show":"false",contentEditable:!1,draggable:!0,"data-role":"col-drag-handle",className:"handle cell-handle",onClick:D,onPointerDown:ne,onPointerMove:ne,ref:u,children:[z.jsx(ke,{icon:s.renderButton("col_drag_handle")}),z.jsxs("div",{className:"button-group","data-show":"false",onPointerMove:ne,children:[z.jsx("button",{type:"button","aria-label":"Align column left",onPointerDown:pe,onClick:N("left"),children:z.jsx(ke,{icon:s.renderButton("align_col_left")})}),z.jsx("button",{type:"button","aria-label":"Align column center",onPointerDown:pe,onClick:N("center"),children:z.jsx(ke,{icon:s.renderButton("align_col_center")})}),z.jsx("button",{type:"button","aria-label":"Align column right",onPointerDown:pe,onClick:N("right"),children:z.jsx(ke,{icon:s.renderButton("align_col_right")})}),z.jsx("button",{type:"button","aria-label":"Delete selected column",onPointerDown:pe,onClick:L,children:z.jsx(ke,{icon:s.renderButton("delete_col")})})]})]}),z.jsxs("div",{"data-show":"false",contentEditable:!1,draggable:!0,"data-role":"row-drag-handle",className:"handle cell-handle",onClick:O,onPointerDown:ne,onPointerMove:ne,ref:d,children:[z.jsx(ke,{icon:s.renderButton("row_drag_handle")}),z.jsx("div",{className:"button-group","data-show":"false",onPointerMove:ne,children:z.jsx("button",{type:"button","aria-label":"Delete selected row",onPointerDown:pe,onClick:L,children:z.jsx(ke,{icon:s.renderButton("delete_row")})})})]}),z.jsxs("div",{className:"table-wrapper",ref:l,children:[z.jsx("div",{"data-show":"false",className:"drag-preview","data-direction":"vertical",ref:c,children:z.jsx("table",{children:z.jsx("tbody",{})})}),z.jsx("div",{"data-show":"false",contentEditable:!1,"data-display-type":"tool","data-role":"x-line-drag-handle",className:"handle line-handle",onPointerMove:ne,ref:h,children:z.jsx("button",{type:"button","aria-label":"Add row",onClick:S,className:"add-button",children:z.jsx(ke,{icon:s.renderButton("add_row")})})}),z.jsx("div",{"data-show":"false",contentEditable:!1,"data-display-type":"tool","data-role":"y-line-drag-handle",className:"handle line-handle",onPointerMove:ne,ref:f,children:z.jsx("button",{type:"button","aria-label":"Add column",onClick:A,className:"add-button",children:z.jsx(ke,{icon:s.renderButton("add_col")})})}),z.jsx("table",{className:"children",ref:j})]})]})}function BE(r,e){const t=(i,o)=>{var f;if(!i.editable)return!1;const{state:s,dispatch:a}=i,l=i.posAtCoords({left:o.clientX,top:o.clientY});if(!l)return!1;const c=s.doc.resolve(l.inside),u=Fr(m=>m.type.name==="table_cell"||m.type.name==="table_header")(c);if(!u||s.selection instanceof Q&&((f=Fr(m=>m.type.name==="table_cell"||m.type.name==="table_header")(s.selection.$from))==null?void 0:f.node)===u.node)return!1;const{from:d}=u,h=re.create(s.doc,d+1);return s.selection.eq(h)?!1:(s.selection instanceof Ae?setTimeout(()=>{a(s.tr.setSelection(h).scrollIntoView())},20):requestAnimationFrame(()=>{a(s.tr.setSelection(h).scrollIntoView())}),!0)},n=Ha(Hr.node,i=>e({component:LE,as:()=>{const o=document.createElement("div");return o.className="milkdown-table-block",o},contentAs:"tbody",stopEvent:o=>{if(o.target instanceof Element&&o.target.closest("button, input, .milkdown-table-actions")||o.type==="drop"||o.type.startsWith("drag"))return!0;if(o.type==="mousedown"||o.type==="pointerdown"){if(o.target instanceof Element&&o.target.closest("button"))return!0;const s=o.target;if(s instanceof HTMLElement&&(s.closest("th")||s.closest("td")))return t(i.get(ge),o)}return!1}}));r.config(i=>{i.update(jh.key,o=>({...o,renderButton:s=>{switch(s){case"add_row":return ph;case"add_col":return ph;case"delete_row":return mh;case"delete_col":return mh;case"align_col_left":return $C;case"align_col_center":return qC;case"align_col_right":return jC;case"col_drag_handle":return bC;case"row_drag_handle":return vC}}}))}).use(jh).use(n)}function Nd(r){const e=r.dom.ownerDocument.getSelection();if(!r.editable||!e||e.isCollapsed)return;const{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}=e;if(!t||!i||!r.dom.contains(t)||!r.dom.contains(i))return;const s=r.posAtDOM(t,n),a=r.posAtDOM(i,o),l=Q.between(r.state.doc.resolve(s),r.state.doc.resolve(a));l.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(l))}function PE(){const r=new ly;return r.addGroup("formatting","Formatting").addItem("bold",{label:"Bold",icon:mC,active:e=>!!e.get(ee).call(Mo.key,Is.type(e)),onRun:e=>{e.get(ee).call(Hc.key)}}).addItem("italic",{label:"Italic",icon:NC,active:e=>!!e.get(ee).call(Mo.key,to.type(e)),onRun:e=>{e.get(ee).call(Fc.key)}}).addItem("strikethrough",{label:"Strikethrough",icon:HC,active:e=>!!e.get(ee).call(Mo.key,Bs.type(e)),onRun:e=>{e.get(ee).call(jc.key)}}),r.addGroup("function","Function").addItem("code",{label:"Inline code",icon:o6,active:e=>!!e.get(ee).call(Mo.key,hn.type(e)),onRun:e=>{e.get(ee).call(_c.key)}}).addItem("link",{label:"Link",icon:EC,active:e=>!!e.get(ee).call(Mo.key,Cr.type(e)),onRun:e=>{e.get(ee).call(fy.key)}}),r.build()}function FE(){Zb();const r=Tr(),e=B.useMemo(()=>PE(),[]);return r.get(th).status!==R9.Created?null:z.jsx(z.Fragment,{children:e.map((t,n)=>z.jsxs(B.Fragment,{children:[n>0&&z.jsx("div",{className:"divider"}),t.items.map(i=>z.jsx("button",{type:"button","aria-label":i.label,title:i.label,"aria-pressed":i.active(r),className:_r("toolbar-item",i.active(r)&&"active"),onFocus:()=>Nd(r.get(ge)),onPointerDown:o=>{o.preventDefault(),Nd(r.get(ge))},onClick:()=>{var s;const o=r.get(ge);Nd(o),(s=i.onRun)==null||s.call(i,r)},children:z.jsx(ke,{icon:i.icon})},i.key))]},t.key))})}const w4=eu("CREPE_TOOLBAR");function HE(r,e){const{doc:t,selection:n}=r.state,{empty:i,from:o,to:s}=n,a=!t.textBetween(o,s).length&&n instanceof Q,l=!(n instanceof Q),c=r.dom.getRootNode(),u=e.contains(c.activeElement),d=!r.hasFocus()&&!u,h=!r.editable;return!(d||l||i||a||h)}function _E(r){let e,t;const n=()=>(t||(t=document.createElement("div"),t.className="milkdown-toolbar",t.dataset.show="false"),t);return r({component:FE,root:()=>n(),update:(i,o)=>{e||(e=new Qc({content:n(),debounce:20,offset:10,shouldShow:s=>HE(s,n())})),e.update(i,o)},destroy:()=>{e==null||e.destroy(),e=void 0,t=void 0}})}function qE(r,e){r.config(t=>{t.set(w4.key,{view:_E(e)})}).use(w4)}function jE({value:r,editable:e=YA,onChange:t,placeholder:n,nodeViewFactory:i,pluginViewFactory:o,ctxHolder:s,plugins:a}){const l=B.useRef(t);l.current=t;const c=B.useRef(a),u=B.useRef(r),d=B.useRef(r),h=B.useRef(n),f=B.useRef(e);J7(x=>{var S;const b=I9.make().config(A=>{A.set(K0,x),A.set(j0,d.current),s.current=A,A.update(Sa,D=>({...D,editable:d4(()=>f.current)})),A.get(dh).markdownUpdated((D,O,L)=>{var N;O!==L&&(u.current=O,(N=l.current)==null||N.call(l,O))})}).use(SN).use(MN).use(Fk).use(Yk).use(Xk).use(MS).use(_3).use(NS).use(Y3);return NN(b),kN(b),vE(b,{text:h.current??"Type / for commands",mode:"block"}),pE(b,i),BN(b,i),xN(b,i),BE(b,i),qE(b,o),sN(b,o),dE(b,o),XN(b,o),(S=c.current)==null||S.forEach(A=>{A({editor:b,nodeViewFactory:i,pluginViewFactory:o})}),b});const[m,y]=X7();B.useEffect(()=>{if(m||r===u.current)return;const x=y();if(!x)return;u.current=r;let b=!1;return queueMicrotask(()=>{b||u.current!==r||x.action(B9(r))}),()=>{b=!0}},[r,m,y]),B.useEffect(()=>{if(f.current=e,m)return;const x=y();if(!x)return;let b=!1;return queueMicrotask(()=>{b||x.action(S=>{const A=S.get(ge);A.setProps({editable:d4(()=>f.current)}),A.dom.dispatchEvent(new Event("blintz:editable"))})}),()=>{b=!0}},[e,m,y])}function $E({value:r,editable:e,onChange:t,placeholder:n,className:i,theme:o="auto",plugins:s}){const a=B.useRef(null),l=B.useRef(null),[c,u]=B.useState("light");return B.useEffect(()=>{var m;const d=(m=window.matchMedia)==null?void 0:m.call(window,"(prefers-color-scheme: dark)"),h=()=>{var x;if(o!=="auto"){u(o);return}let y=(x=l.current)==null?void 0:x.parentElement;for(;y;){const b=y.getAttribute("data-theme");if(b==="light"||b==="dark"){u(b);return}if(y.classList.contains("dark")){u("dark");return}if(y.classList.contains("light")){u("light");return}y=y.parentElement}u(d!=null&&d.matches?"dark":"light")};h();const f=new MutationObserver(h);return f.observe(document.documentElement,{attributes:!0,subtree:!0,attributeFilter:["class","data-theme"]}),d==null||d.addEventListener("change",h),()=>{f.disconnect(),d==null||d.removeEventListener("change",h)}},[o]),z.jsx("div",{ref:l,className:_r("milkdown-editor-host",i),"data-blintz-theme":o==="auto"?c:o,children:z.jsx(GA,{value:a,children:z.jsx(Y7,{children:z.jsx(cw,{children:z.jsx(VE,{value:r,editable:e,onChange:t,placeholder:n,ctxHolder:a,plugins:s})})})})})}function VE({value:r,editable:e,onChange:t,placeholder:n,ctxHolder:i,plugins:o}){const s=Kb(),a=Qb();return jE({value:r,editable:e,onChange:t,placeholder:n,nodeViewFactory:s,pluginViewFactory:a,ctxHolder:i,plugins:o}),z.jsx(G7,{})}function YE({value:r,editable:e,onChange:t,className:n}){const i=Xy();return z.jsx("div",{"data-theme":i,className:"dorkos-markdown contents",children:z.jsx($E,{value:r,theme:i,editable:e,onChange:t,className:Zy("desktop:select-text",n)})})}export{YE as BlintzCanvas};