md2x 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +12 -6
  2. package/dist/chunks/chunk-54X5GPSM.js +1552 -0
  3. package/dist/chunks/chunk-US45GBOT.js +415 -0
  4. package/dist/chunks/docx-exporter-7C6T4DFB.js +1 -0
  5. package/dist/core-worker.js +1764 -0
  6. package/dist/index.js +1 -1
  7. package/dist/md2x.js +5 -5
  8. package/dist/renderer/core-worker-browser.js +1775 -0
  9. package/dist/renderer/live-runtime-canvas.js +1 -1
  10. package/dist/renderer/live-runtime-dot.js +1 -1
  11. package/dist/renderer/live-runtime-html.js +1 -1
  12. package/dist/renderer/live-runtime-infographic.js +1 -1
  13. package/dist/renderer/live-runtime-md2x.js +4 -4
  14. package/dist/renderer/live-runtime-mermaid.js +1 -1
  15. package/dist/renderer/live-runtime-svg.js +1 -1
  16. package/dist/renderer/live-runtime-vega.js +1 -1
  17. package/dist/types/node/src/host/browser-renderer.d.ts +1 -175
  18. package/dist/types/node/src/host/core.d.ts +59 -0
  19. package/dist/types/node/src/host/index.d.ts +4 -49
  20. package/dist/types/node/src/host/node-exporter.d.ts +1 -90
  21. package/dist/types/node/src/host/node-platform.d.ts +1 -23
  22. package/dist/types/node/src/host/templates-data.d.ts +5 -0
  23. package/dist/types/node/src/host/themes-data.d.ts +2385 -0
  24. package/dist/types/node/src/host/types.d.ts +251 -0
  25. package/dist/types/node/src/index.d.ts +2 -3
  26. package/package.json +10 -2
  27. package/dist/chunks/chunk-2LPNL4GA.js +0 -1
  28. package/dist/chunks/chunk-3P5X57NT.js +0 -262
  29. package/dist/chunks/chunk-3VL755NO.js +0 -1
  30. package/dist/chunks/chunk-5DPTQTJJ.js +0 -1
  31. package/dist/chunks/chunk-AK6TXLWO.js +0 -1
  32. package/dist/chunks/chunk-CN4F5HOV.js +0 -5
  33. package/dist/chunks/chunk-CVKZIRZW.js +0 -5
  34. package/dist/chunks/chunk-DFROP2PD.js +0 -11
  35. package/dist/chunks/chunk-DJGIYXVP.js +0 -3
  36. package/dist/chunks/chunk-EFKQH5UR.js +0 -108
  37. package/dist/chunks/chunk-FXZD57XY.js +0 -532
  38. package/dist/chunks/chunk-IENSDROB.js +0 -1
  39. package/dist/chunks/chunk-LLCWR7UA.js +0 -1
  40. package/dist/chunks/chunk-MHCTK6WW.js +0 -1
  41. package/dist/chunks/chunk-NM6J3ND7.js +0 -1
  42. package/dist/chunks/chunk-PARPCLXM.js +0 -1
  43. package/dist/chunks/chunk-PUOHPY5L.js +0 -16
  44. package/dist/chunks/chunk-R65AQGTF.js +0 -1
  45. package/dist/chunks/chunk-R6G2575A.js +0 -3
  46. package/dist/chunks/chunk-TRGQPVRY.js +0 -2
  47. package/dist/chunks/chunk-URO5RPHJ.js +0 -9
  48. package/dist/chunks/chunk-YFL3W3OS.js +0 -1
  49. package/dist/chunks/chunk-Z4LVGK7Y.js +0 -1
  50. package/dist/chunks/docx-exporter-ZZ76JXFU.js +0 -1
  51. package/dist/chunks/rehype-highlight-Y4Q4RX67.js +0 -1
  52. package/dist/chunks/rehype-katex-FXTCTSUE.js +0 -1
  53. package/dist/chunks/rehype-stringify-4CQSSRDL.js +0 -1
  54. package/dist/chunks/remark-gfm-BUZ4SLP3.js +0 -1
  55. package/dist/chunks/remark-math-HEZQAPFK.js +0 -1
  56. package/dist/chunks/remark-parse-QC7TSXTK.js +0 -1
  57. package/dist/chunks/remark-rehype-C2LX643P.js +0 -1
  58. package/dist/chunks/remark-super-sub-EP2AQS54.js +0 -1
  59. package/dist/chunks/theme-manager-AZBU2SLL.js +0 -1
  60. package/dist/chunks/theme-to-css-GLV3WYDU.js +0 -85
  61. package/dist/chunks/unified-PU53JLVJ.js +0 -1
  62. package/dist/chunks/unist-util-visit-SBSD62C6.js +0 -1
  63. package/dist/templates/html/example.html +0 -35
  64. package/dist/templates/svelte/example.svelte +0 -18
  65. package/dist/templates/vue/PrinterComponent.vue +0 -875
  66. package/dist/templates/vue/example.vue +0 -17
  67. package/dist/templates/vue/mapLibre.vue +0 -371
  68. package/dist/themes/code-themes/business-contrast.json +0 -31
  69. package/dist/themes/code-themes/colorful.json +0 -32
  70. package/dist/themes/code-themes/cool-modern.json +0 -31
  71. package/dist/themes/code-themes/high-contrast.json +0 -31
  72. package/dist/themes/code-themes/light-clean.json +0 -31
  73. package/dist/themes/code-themes/warm-book.json +0 -31
  74. package/dist/themes/color-schemes/candy.json +0 -34
  75. package/dist/themes/color-schemes/cool.json +0 -34
  76. package/dist/themes/color-schemes/coral.json +0 -34
  77. package/dist/themes/color-schemes/dino.json +0 -34
  78. package/dist/themes/color-schemes/forest.json +0 -34
  79. package/dist/themes/color-schemes/garden.json +0 -34
  80. package/dist/themes/color-schemes/neutral.json +0 -34
  81. package/dist/themes/color-schemes/ocean.json +0 -34
  82. package/dist/themes/color-schemes/rainbow.json +0 -43
  83. package/dist/themes/color-schemes/sakura.json +0 -34
  84. package/dist/themes/color-schemes/sepia.json +0 -34
  85. package/dist/themes/color-schemes/space.json +0 -34
  86. package/dist/themes/color-schemes/starry.json +0 -34
  87. package/dist/themes/color-schemes/sunset.json +0 -34
  88. package/dist/themes/color-schemes/warm.json +0 -34
  89. package/dist/themes/font-config.json +0 -184
  90. package/dist/themes/layout-schemes/academic.json +0 -40
  91. package/dist/themes/layout-schemes/book.json +0 -40
  92. package/dist/themes/layout-schemes/document.json +0 -40
  93. package/dist/themes/layout-schemes/magazine.json +0 -40
  94. package/dist/themes/layout-schemes/student.json +0 -40
  95. package/dist/themes/layout-schemes/technical.json +0 -40
  96. package/dist/themes/presets/academic.json +0 -24
  97. package/dist/themes/presets/business.json +0 -22
  98. package/dist/themes/presets/candy.json +0 -23
  99. package/dist/themes/presets/century.json +0 -22
  100. package/dist/themes/presets/coral.json +0 -22
  101. package/dist/themes/presets/default.json +0 -22
  102. package/dist/themes/presets/dinosaur.json +0 -23
  103. package/dist/themes/presets/elegant.json +0 -22
  104. package/dist/themes/presets/forest.json +0 -22
  105. package/dist/themes/presets/garamond.json +0 -22
  106. package/dist/themes/presets/garden.json +0 -23
  107. package/dist/themes/presets/handwritten.json +0 -23
  108. package/dist/themes/presets/heiti.json +0 -22
  109. package/dist/themes/presets/magazine.json +0 -24
  110. package/dist/themes/presets/manuscript.json +0 -22
  111. package/dist/themes/presets/minimal.json +0 -22
  112. package/dist/themes/presets/mixed.json +0 -24
  113. package/dist/themes/presets/newspaper.json +0 -24
  114. package/dist/themes/presets/ocean.json +0 -22
  115. package/dist/themes/presets/palatino.json +0 -22
  116. package/dist/themes/presets/rainbow.json +0 -23
  117. package/dist/themes/presets/space.json +0 -23
  118. package/dist/themes/presets/starry.json +0 -23
  119. package/dist/themes/presets/sunset.json +0 -22
  120. package/dist/themes/presets/swiss.json +0 -22
  121. package/dist/themes/presets/technical.json +0 -22
  122. package/dist/themes/presets/typewriter.json +0 -23
  123. package/dist/themes/presets/verdana.json +0 -22
  124. package/dist/themes/presets/water.json +0 -22
  125. package/dist/themes/registry.json +0 -270
  126. package/dist/themes/table-styles/academic.json +0 -30
  127. package/dist/themes/table-styles/borderless.json +0 -26
  128. package/dist/themes/table-styles/compact.json +0 -24
  129. package/dist/themes/table-styles/grid.json +0 -22
  130. package/dist/themes/table-styles/high-contrast.json +0 -22
  131. package/dist/themes/table-styles/minimal-gray.json +0 -26
  132. package/dist/themes/table-styles/modern-tech.json +0 -34
  133. package/dist/themes/table-styles/professional.json +0 -34
  134. package/dist/themes/table-styles/zebra.json +0 -22
  135. package/dist/types/src/utils/theme-to-css.d.ts +0 -171
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var $e=Object.create;var Jt=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var He=(n,t)=>()=>(n&&(t=n(n=0)),t);var Mt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var je=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of We(t))!Ve.call(n,i)&&i!==e&&Jt(n,i,{get:()=>t[i],enumerable:!(r=ze(t,i))||r.enumerable});return n};var Ze=(n,t,e)=>(e=n!=null?$e(qe(n)):{},je(t||!n||!n.__esModule?Jt(e,"default",{value:n,enumerable:!0}):e,n));var ee=Mt(at=>{"use strict";k();at.byteLength=Qe;at.toByteArray=Je;at.fromByteArray=er;var O=[],_=[],Ye=typeof Uint8Array<"u"?Uint8Array:Array,kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(q=0,Kt=kt.length;q<Kt;++q)O[q]=kt[q],_[kt.charCodeAt(q)]=q;var q,Kt;_[45]=62;_[95]=63;function te(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function Qe(n){var t=te(n),e=t[0],r=t[1];return(e+r)*3/4-r}function Xe(n,t,e){return(t+e)*3/4-e}function Je(n){var t,e=te(n),r=e[0],i=e[1],o=new Ye(Xe(n,r,i)),s=0,a=i>0?r-4:r,h;for(h=0;h<a;h+=4)t=_[n.charCodeAt(h)]<<18|_[n.charCodeAt(h+1)]<<12|_[n.charCodeAt(h+2)]<<6|_[n.charCodeAt(h+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=_[n.charCodeAt(h)]<<2|_[n.charCodeAt(h+1)]>>4,o[s++]=t&255),i===1&&(t=_[n.charCodeAt(h)]<<10|_[n.charCodeAt(h+1)]<<4|_[n.charCodeAt(h+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Ke(n){return O[n>>18&63]+O[n>>12&63]+O[n>>6&63]+O[n&63]}function tr(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(Ke(r));return i.join("")}function er(n){for(var t,e=n.length,r=e%3,i=[],o=16383,s=0,a=e-r;s<a;s+=o)i.push(tr(n,s,s+o>a?a:s+o));return r===1?(t=n[e-1],i.push(O[t>>2]+O[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(O[t>>10]+O[t>>4&63]+O[t<<2&63]+"=")),i.join("")}});var re=Mt(Bt=>{k();Bt.read=function(n,t,e,r,i){var o,s,a=i*8-r-1,h=(1<<a)-1,l=h>>1,c=-7,u=e?i-1:0,p=e?-1:1,f=n[t+u];for(u+=p,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=o*256+n[t+u],u+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=s*256+n[t+u],u+=p,c-=8);if(o===0)o=1-l;else{if(o===h)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-l}return(f?-1:1)*s*Math.pow(2,o-r)};Bt.write=function(n,t,e,r,i,o){var s,a,h,l=o*8-i-1,c=(1<<l)-1,u=c>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,g=r?1:-1,m=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+u>=1?t+=p/h:t+=p*Math.pow(2,1-u),t*h>=2&&(s++,h/=2),s+u>=c?(a=0,s=c):s+u>=1?(a=(t*h-1)*Math.pow(2,i),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;n[e+f]=a&255,f+=g,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;n[e+f]=s&255,f+=g,s/=256,l-=8);n[e+f-g]|=m*128}});var xe=Mt(J=>{"use strict";k();var It=ee(),Q=re(),ne=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;J.Buffer=d;J.SlowBuffer=ar;J.INSPECT_MAX_BYTES=50;var ht=2147483647;J.kMaxLength=ht;d.TYPED_ARRAY_SUPPORT=rr();!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function rr(){try{let n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function G(n){if(n>ht)throw new RangeError('The value "'+n+'" is invalid for option "size"');let t=new Uint8Array(n);return Object.setPrototypeOf(t,d.prototype),t}function d(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Tt(n)}return ae(n,t,e)}d.poolSize=8192;function ae(n,t,e){if(typeof n=="string")return ir(n,t);if(ArrayBuffer.isView(n))return or(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(v(n,ArrayBuffer)||n&&v(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(v(n,SharedArrayBuffer)||n&&v(n.buffer,SharedArrayBuffer)))return At(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=n.valueOf&&n.valueOf();if(r!=null&&r!==n)return d.from(r,t,e);let i=sr(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return d.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}d.from=function(n,t,e){return ae(n,t,e)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function he(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function nr(n,t,e){return he(n),n<=0?G(n):t!==void 0?typeof e=="string"?G(n).fill(t,e):G(n).fill(t):G(n)}d.alloc=function(n,t,e){return nr(n,t,e)};function Tt(n){return he(n),G(n<0?0:Rt(n)|0)}d.allocUnsafe=function(n){return Tt(n)};d.allocUnsafeSlow=function(n){return Tt(n)};function ir(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!d.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=ue(n,t)|0,r=G(e),i=r.write(n,t);return i!==e&&(r=r.slice(0,i)),r}function St(n){let t=n.length<0?0:Rt(n.length)|0,e=G(t);for(let r=0;r<t;r+=1)e[r]=n[r]&255;return e}function or(n){if(v(n,Uint8Array)){let t=new Uint8Array(n);return At(t.buffer,t.byteOffset,t.byteLength)}return St(n)}function At(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let r;return t===void 0&&e===void 0?r=new Uint8Array(n):e===void 0?r=new Uint8Array(n,t):r=new Uint8Array(n,t,e),Object.setPrototypeOf(r,d.prototype),r}function sr(n){if(d.isBuffer(n)){let t=Rt(n.length)|0,e=G(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Pt(n.length)?G(0):St(n);if(n.type==="Buffer"&&Array.isArray(n.data))return St(n.data)}function Rt(n){if(n>=ht)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ht.toString(16)+" bytes");return n|0}function ar(n){return+n!=n&&(n=0),d.alloc(+n)}d.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==d.prototype};d.compare=function(t,e){if(v(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),v(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(t)||!d.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};d.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return d.alloc(0);let r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let i=d.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){let s=t[r];if(v(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function ue(n,t){if(d.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||v(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let e=n.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Ft(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return we(n).length;default:if(i)return r?-1:Ft(n).length;t=(""+t).toLowerCase(),i=!0}}d.byteLength=ue;function hr(n,t,e){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return wr(this,t,e);case"utf8":case"utf-8":return le(this,t,e);case"ascii":return mr(this,t,e);case"latin1":case"binary":return yr(this,t,e);case"base64":return dr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function V(n,t,e){let r=n[t];n[t]=n[e],n[e]=r}d.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)V(this,e,e+1);return this};d.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)V(this,e,e+3),V(this,e+1,e+2);return this};d.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)V(this,e,e+7),V(this,e+1,e+6),V(this,e+2,e+5),V(this,e+3,e+4);return this};d.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?le(this,0,t):hr.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(t){if(!d.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:d.compare(this,t)===0};d.prototype.inspect=function(){let t="",e=J.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ne&&(d.prototype[ne]=d.prototype.inspect);d.prototype.compare=function(t,e,r,i,o){if(v(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=r-e,h=Math.min(s,a),l=this.slice(i,o),c=t.slice(e,r);for(let u=0;u<h;++u)if(l[u]!==c[u]){s=l[u],a=c[u];break}return s<a?-1:a<s?1:0};function ce(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Pt(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:ie(n,t,e,r,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):ie(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function ie(n,t,e,r,i){let o=1,s=n.length,a=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,a/=2,e/=2}function h(c,u){return o===1?c[u]:c.readUInt16BE(u*o)}let l;if(i){let c=-1;for(l=e;l<s;l++)if(h(n,l)===h(t,c===-1?0:l-c)){if(c===-1&&(c=l),l-c+1===a)return c*o}else c!==-1&&(l-=l-c),c=-1}else for(e+a>s&&(e=s-a),l=e;l>=0;l--){let c=!0;for(let u=0;u<a;u++)if(h(n,l+u)!==h(t,u)){c=!1;break}if(c)return l}return-1}d.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};d.prototype.indexOf=function(t,e,r){return ce(this,t,e,r,!0)};d.prototype.lastIndexOf=function(t,e,r){return ce(this,t,e,r,!1)};function ur(n,t,e,r){e=Number(e)||0;let i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;let o=t.length;r>o/2&&(r=o/2);let s;for(s=0;s<r;++s){let a=parseInt(t.substr(s*2,2),16);if(Pt(a))return s;n[e+s]=a}return s}function cr(n,t,e,r){return ut(Ft(t,n.length-e),n,e,r)}function lr(n,t,e,r){return ut(kr(t),n,e,r)}function fr(n,t,e,r){return ut(we(t),n,e,r)}function pr(n,t,e,r){return ut(Br(t,n.length-e),n,e,r)}d.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return ur(this,t,e,r);case"utf8":case"utf-8":return cr(this,t,e,r);case"ascii":case"latin1":case"binary":return lr(this,t,e,r);case"base64":return fr(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pr(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dr(n,t,e){return t===0&&e===n.length?It.fromByteArray(n):It.fromByteArray(n.slice(t,e))}function le(n,t,e){e=Math.min(n.length,e);let r=[],i=t;for(;i<e;){let o=n[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=e){let h,l,c,u;switch(a){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(u=(o&31)<<6|h&63,u>127&&(s=u));break;case 3:h=n[i+1],l=n[i+2],(h&192)===128&&(l&192)===128&&(u=(o&15)<<12|(h&63)<<6|l&63,u>2047&&(u<55296||u>57343)&&(s=u));break;case 4:h=n[i+1],l=n[i+2],c=n[i+3],(h&192)===128&&(l&192)===128&&(c&192)===128&&(u=(o&15)<<18|(h&63)<<12|(l&63)<<6|c&63,u>65535&&u<1114112&&(s=u))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=a}return gr(r)}var oe=4096;function gr(n){let t=n.length;if(t<=oe)return String.fromCharCode.apply(String,n);let e="",r=0;for(;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=oe));return e}function mr(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function yr(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function wr(n,t,e){let r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);let i="";for(let o=t;o<e;++o)i+=Ir[n[o]];return i}function xr(n,t,e){let r=n.slice(t,e),i="";for(let o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}d.prototype.slice=function(t,e){let r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,d.prototype),i};function A(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]|this[t+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]<<8|this[t+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};d.prototype.readBigUInt64LE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+r*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};d.prototype.readIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=e,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};d.prototype.readInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};d.prototype.readInt16LE=function(t,e){t=t>>>0,e||A(t,2,this.length);let r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};d.prototype.readInt16BE=function(t,e){t=t>>>0,e||A(t,2,this.length);let r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};d.prototype.readInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};d.prototype.readInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};d.prototype.readBigInt64LE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});d.prototype.readBigInt64BE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r)});d.prototype.readFloatLE=function(t,e){return t=t>>>0,e||A(t,4,this.length),Q.read(this,t,!0,23,4)};d.prototype.readFloatBE=function(t,e){return t=t>>>0,e||A(t,4,this.length),Q.read(this,t,!1,23,4)};d.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||A(t,8,this.length),Q.read(this,t,!0,52,8)};d.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||A(t,8,this.length),Q.read(this,t,!1,52,8)};function F(n,t,e,r,i,o){if(!d.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let a=Math.pow(2,8*r)-1;F(this,t,e,r,a,0)}let o=1,s=0;for(this[e]=t&255;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let a=Math.pow(2,8*r)-1;F(this,t,e,r,a,0)}let o=r-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r};d.prototype.writeUint8=d.prototype.writeUInt8=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,1,255,0),this[e]=t&255,e+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function fe(n,t,e,r,i){ye(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,e}function pe(n,t,e,r,i){ye(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e+7]=o,o=o>>8,n[e+6]=o,o=o>>8,n[e+5]=o,o=o>>8,n[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e+3]=s,s=s>>8,n[e+2]=s,s=s>>8,n[e+1]=s,s=s>>8,n[e]=s,e+8}d.prototype.writeBigUInt64LE=$(function(t,e=0){return fe(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=$(function(t,e=0){return pe(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let h=Math.pow(2,8*r-1);F(this,t,e,r,h-1,-h)}let o=0,s=1,a=0;for(this[e]=t&255;++o<r&&(s*=256);)t<0&&a===0&&this[e+o-1]!==0&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r};d.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let h=Math.pow(2,8*r-1);F(this,t,e,r,h-1,-h)}let o=r-1,s=1,a=0;for(this[e+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[e+o+1]!==0&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r};d.prototype.writeInt8=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};d.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};d.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};d.prototype.writeBigInt64LE=$(function(t,e=0){return fe(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=$(function(t,e=0){return pe(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function de(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ge(n,t,e,r,i){return t=+t,e=e>>>0,i||de(n,t,e,4,34028234663852886e22,-34028234663852886e22),Q.write(n,t,e,r,23,4),e+4}d.prototype.writeFloatLE=function(t,e,r){return ge(this,t,e,!0,r)};d.prototype.writeFloatBE=function(t,e,r){return ge(this,t,e,!1,r)};function me(n,t,e,r,i){return t=+t,e=e>>>0,i||de(n,t,e,8,17976931348623157e292,-17976931348623157e292),Q.write(n,t,e,r,52,8),e+8}d.prototype.writeDoubleLE=function(t,e,r){return me(this,t,e,!0,r)};d.prototype.writeDoubleBE=function(t,e,r){return me(this,t,e,!1,r)};d.prototype.copy=function(t,e,r,i){if(!d.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);let o=i-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),o};d.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<r;++o)this[o]=t;else{let s=d.isBuffer(t)?t:d.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var Y={};function Ct(n,t,e){Y[n]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name}get code(){return n}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${n}]: ${this.message}`}}}Ct("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ct("ERR_INVALID_ARG_TYPE",function(n,t){return`The "${n}" argument must be of type number. Received type ${typeof t}`},TypeError);Ct("ERR_OUT_OF_RANGE",function(n,t,e){let r=`The value of "${n}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=se(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=se(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);function se(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function br(n,t,e){X(t,"offset"),(n[t]===void 0||n[t+e]===void 0)&&et(t,n.length-(e+1))}function ye(n,t,e,r,i,o){if(n>e||n<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${e}${s}`,new Y.ERR_OUT_OF_RANGE("value",a,n)}br(r,i,o)}function X(n,t){if(typeof n!="number")throw new Y.ERR_INVALID_ARG_TYPE(t,"number",n)}function et(n,t,e){throw Math.floor(n)!==n?(X(n,e),new Y.ERR_OUT_OF_RANGE(e||"offset","an integer",n)):t<0?new Y.ERR_BUFFER_OUT_OF_BOUNDS:new Y.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,n)}var Er=/[^+/0-9A-Za-z-_]/g;function Mr(n){if(n=n.split("=")[0],n=n.trim().replace(Er,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Ft(n,t){t=t||1/0;let e,r=n.length,i=null,o=[];for(let s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function kr(n){let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Br(n,t){let e,r,i,o=[];for(let s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function we(n){return It.toByteArray(Mr(n))}function ut(n,t,e,r){let i;for(i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function v(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Pt(n){return n!==n}var Ir=(function(){let n="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let r=e*16;for(let i=0;i<16;++i)t[r+i]=n[e]+n[i]}return t})();function $(n){return typeof BigInt>"u"?Sr:n}function Sr(){throw new Error("BigInt not supported")}});var be,k=He(()=>{"use strict";be=Ze(xe(),1);globalThis.Buffer=be.Buffer});k();k();k();k();var ct=class{constructor(t){this._initialized=!1;this.type=t}createContainer(){let t=document.createElement("div");return t.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),t.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(t),t}removeContainer(t){t&&t.parentNode&&t.parentNode.removeChild(t)}async initialize(t=null){this._initialized=!0}isInitialized(){return this._initialized}async render(t,e){throw new Error("render() must be implemented by subclass")}async mountToDom(t,e,r){let i=await this.render(t,e);if(!i||!i.base64){let s=document.createElement("div");return s.textContent=`Renderer returned empty result: ${this.type}`,r.appendChild(s),{root:s,cleanup:()=>{try{s.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,r.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(t){if(!t||typeof t=="string"&&t.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(t){return t}calculateCanvasScale(t){let r=t?.fontSize||12;return 14/16*(r/12)*4}async renderSvgToCanvas(t,e,r,i=null){return t=t.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,s)=>{let a=new Image;a.crossOrigin="Anonymous";let h=btoa(unescape(encodeURIComponent(t)));a.src=`data:image/svg+xml;base64,${h}`,a.onload=()=>{let l=document.createElement("canvas");l.width=e,l.height=r;let c=l.getContext("2d");i&&(c.font=`14px ${i}`),c.drawImage(a,0,0,e,r),o(l)},a.onerror=l=>{s(new Error("Failed to load SVG into image for rendering"))}})}};k();k();function _t(n,t,e){if(n&&n.length){let[r,i]=t,o=Math.PI/180*e,s=Math.cos(o),a=Math.sin(o);for(let h of n){let[l,c]=h;h[0]=(l-r)*s-(c-i)*a+r,h[1]=(l-r)*a+(c-i)*s+i}}}function Ar(n,t){return n[0]===t[0]&&n[1]===t[1]}function Fr(n,t,e,r=1){let i=e,o=Math.max(t,.1),s=n[0]&&n[0][0]&&typeof n[0][0]=="number"?[n]:n,a=[0,0];if(i)for(let l of s)_t(l,a,i);let h=(function(l,c,u){let p=[];for(let x of l){let b=[...x];Ar(b[0],b[b.length-1])||b.push([b[0][0],b[0][1]]),b.length>2&&p.push(b)}let f=[];c=Math.max(c,.1);let g=[];for(let x of p)for(let b=0;b<x.length-1;b++){let B=x[b],I=x[b+1];if(B[1]!==I[1]){let M=Math.min(B[1],I[1]);g.push({ymin:M,ymax:Math.max(B[1],I[1]),x:M===B[1]?B[0]:I[0],islope:(I[0]-B[0])/(I[1]-B[1])})}}if(g.sort(((x,b)=>x.ymin<b.ymin?-1:x.ymin>b.ymin?1:x.x<b.x?-1:x.x>b.x?1:x.ymax===b.ymax?0:(x.ymax-b.ymax)/Math.abs(x.ymax-b.ymax))),!g.length)return f;let m=[],y=g[0].ymin,w=0;for(;m.length||g.length;){if(g.length){let x=-1;for(let b=0;b<g.length&&!(g[b].ymin>y);b++)x=b;g.splice(0,x+1).forEach((b=>{m.push({s:y,edge:b})}))}if(m=m.filter((x=>!(x.edge.ymax<=y))),m.sort(((x,b)=>x.edge.x===b.edge.x?0:(x.edge.x-b.edge.x)/Math.abs(x.edge.x-b.edge.x))),(u!==1||w%c==0)&&m.length>1)for(let x=0;x<m.length;x+=2){let b=x+1;if(b>=m.length)break;let B=m[x].edge,I=m[b].edge;f.push([[Math.round(B.x),y],[Math.round(I.x),y]])}y+=u,m.forEach((x=>{x.edge.x=x.edge.x+u*x.edge.islope})),w++}return f})(s,o,r);if(i){for(let l of s)_t(l,a,-i);(function(l,c,u){let p=[];l.forEach((f=>p.push(...f))),_t(p,c,u)})(h,a,-i)}return h}function ot(n,t){var e;let r=t.hachureAngle+90,i=t.hachureGap;i<0&&(i=4*t.strokeWidth),i=Math.round(Math.max(i,.1));let o=1;return t.roughness>=1&&(((e=t.randomizer)===null||e===void 0?void 0:e.next())||Math.random())>.7&&(o=i),Fr(n,i,r,o||1)}var it=class{constructor(t){this.helper=t}fillPolygons(t,e){return this._fillPolygons(t,e)}_fillPolygons(t,e){let r=ot(t,e);return{type:"fillSketch",ops:this.renderLines(r,e)}}renderLines(t,e){let r=[];for(let i of t)r.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],e));return r}};function xt(n){let t=n[0],e=n[1];return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}var vt=class extends it{fillPolygons(t,e){let r=e.hachureGap;r<0&&(r=4*e.strokeWidth),r=Math.max(r,.1);let i=ot(t,Object.assign({},e,{hachureGap:r})),o=Math.PI/180*e.hachureAngle,s=[],a=.5*r*Math.cos(o),h=.5*r*Math.sin(o);for(let[l,c]of i)xt([l,c])&&s.push([[l[0]-a,l[1]+h],[...c]],[[l[0]+a,l[1]-h],[...c]]);return{type:"fillSketch",ops:this.renderLines(s,e)}}},Gt=class extends it{fillPolygons(t,e){let r=this._fillPolygons(t,e),i=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),o=this._fillPolygons(t,i);return r.ops=r.ops.concat(o.ops),r}},Nt=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=ot(t,e=Object.assign({},e,{hachureAngle:0}));return this.dotsOnLines(r,e)}dotsOnLines(t,e){let r=[],i=e.hachureGap;i<0&&(i=4*e.strokeWidth),i=Math.max(i,.1);let o=e.fillWeight;o<0&&(o=e.strokeWidth/2);let s=i/4;for(let a of t){let h=xt(a),l=h/i,c=Math.ceil(l)-1,u=h-c*i,p=(a[0][0]+a[1][0])/2-i/4,f=Math.min(a[0][1],a[1][1]);for(let g=0;g<c;g++){let m=f+u+g*i,y=p-s+2*Math.random()*s,w=m-s+2*Math.random()*s,x=this.helper.ellipse(y,w,o,o,e);r.push(...x.ops)}}return{type:"fillSketch",ops:r}}},$t=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=ot(t,e);return{type:"fillSketch",ops:this.dashedLine(r,e)}}dashedLine(t,e){let r=e.dashOffset<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashOffset,i=e.dashGap<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashGap,o=[];return t.forEach((s=>{let a=xt(s),h=Math.floor(a/(r+i)),l=(a+i-h*(r+i))/2,c=s[0],u=s[1];c[0]>u[0]&&(c=s[1],u=s[0]);let p=Math.atan((u[1]-c[1])/(u[0]-c[0]));for(let f=0;f<h;f++){let g=f*(r+i),m=g+r,y=[c[0]+g*Math.cos(p)+l*Math.cos(p),c[1]+g*Math.sin(p)+l*Math.sin(p)],w=[c[0]+m*Math.cos(p)+l*Math.cos(p),c[1]+m*Math.sin(p)+l*Math.sin(p)];o.push(...this.helper.doubleLineOps(y[0],y[1],w[0],w[1],e))}})),o}},zt=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=e.hachureGap<0?4*e.strokeWidth:e.hachureGap,i=e.zigzagOffset<0?r:e.zigzagOffset,o=ot(t,e=Object.assign({},e,{hachureGap:r+i}));return{type:"fillSketch",ops:this.zigzagLines(o,i,e)}}zigzagLines(t,e,r){let i=[];return t.forEach((o=>{let s=xt(o),a=Math.round(s/(2*e)),h=o[0],l=o[1];h[0]>l[0]&&(h=o[1],l=o[0]);let c=Math.atan((l[1]-h[1])/(l[0]-h[0]));for(let u=0;u<a;u++){let p=2*u*e,f=2*(u+1)*e,g=Math.sqrt(2*Math.pow(e,2)),m=[h[0]+p*Math.cos(c),h[1]+p*Math.sin(c)],y=[h[0]+f*Math.cos(c),h[1]+f*Math.sin(c)],w=[m[0]+g*Math.cos(c+Math.PI/4),m[1]+g*Math.sin(c+Math.PI/4)];i.push(...this.helper.doubleLineOps(m[0],m[1],w[0],w[1],r),...this.helper.doubleLineOps(w[0],w[1],y[0],y[1],r))}})),i}},T={},Wt=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},Tr=0,Ut=1,Ee=2,lt={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Lt(n,t){return n.type===t}function Yt(n){let t=[],e=(function(s){let a=new Array;for(;s!=="";)if(s.match(/^([ \t\r\n,]+)/))s=s.substr(RegExp.$1.length);else if(s.match(/^([aAcChHlLmMqQsStTvVzZ])/))a[a.length]={type:Tr,text:RegExp.$1},s=s.substr(RegExp.$1.length);else{if(!s.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];a[a.length]={type:Ut,text:`${parseFloat(RegExp.$1)}`},s=s.substr(RegExp.$1.length)}return a[a.length]={type:Ee,text:""},a})(n),r="BOD",i=0,o=e[i];for(;!Lt(o,Ee);){let s=0,a=[];if(r==="BOD"){if(o.text!=="M"&&o.text!=="m")return Yt("M0,0"+n);i++,s=lt[o.text],r=o.text}else Lt(o,Ut)?s=lt[r]:(i++,s=lt[o.text],r=o.text);if(!(i+s<e.length))throw new Error("Path data ended short");for(let h=i;h<i+s;h++){let l=e[h];if(!Lt(l,Ut))throw new Error("Param not a number: "+r+","+l.text);a[a.length]=+l.text}if(typeof lt[r]!="number")throw new Error("Bad segment: "+r);{let h={key:r,data:a};t.push(h),i+=s,o=e[i],r==="M"&&(r="L"),r==="m"&&(r="l")}}return t}function Te(n){let t=0,e=0,r=0,i=0,o=[];for(let{key:s,data:a}of n)switch(s){case"M":o.push({key:"M",data:[...a]}),[t,e]=a,[r,i]=a;break;case"m":t+=a[0],e+=a[1],o.push({key:"M",data:[t,e]}),r=t,i=e;break;case"L":o.push({key:"L",data:[...a]}),[t,e]=a;break;case"l":t+=a[0],e+=a[1],o.push({key:"L",data:[t,e]});break;case"C":o.push({key:"C",data:[...a]}),t=a[4],e=a[5];break;case"c":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"C",data:h}),t=h[4],e=h[5];break}case"Q":o.push({key:"Q",data:[...a]}),t=a[2],e=a[3];break;case"q":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"Q",data:h}),t=h[2],e=h[3];break}case"A":o.push({key:"A",data:[...a]}),t=a[5],e=a[6];break;case"a":t+=a[5],e+=a[6],o.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],t,e]});break;case"H":o.push({key:"H",data:[...a]}),t=a[0];break;case"h":t+=a[0],o.push({key:"H",data:[t]});break;case"V":o.push({key:"V",data:[...a]}),e=a[0];break;case"v":e+=a[0],o.push({key:"V",data:[e]});break;case"S":o.push({key:"S",data:[...a]}),t=a[2],e=a[3];break;case"s":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"S",data:h}),t=h[2],e=h[3];break}case"T":o.push({key:"T",data:[...a]}),t=a[0],e=a[1];break;case"t":t+=a[0],e+=a[1],o.push({key:"T",data:[t,e]});break;case"Z":case"z":o.push({key:"Z",data:[]}),t=r,e=i}return o}function Re(n){let t=[],e="",r=0,i=0,o=0,s=0,a=0,h=0;for(let{key:l,data:c}of n){switch(l){case"M":t.push({key:"M",data:[...c]}),[r,i]=c,[o,s]=c;break;case"C":t.push({key:"C",data:[...c]}),r=c[4],i=c[5],a=c[2],h=c[3];break;case"L":t.push({key:"L",data:[...c]}),[r,i]=c;break;case"H":r=c[0],t.push({key:"L",data:[r,i]});break;case"V":i=c[0],t.push({key:"L",data:[r,i]});break;case"S":{let u=0,p=0;e==="C"||e==="S"?(u=r+(r-a),p=i+(i-h)):(u=r,p=i),t.push({key:"C",data:[u,p,...c]}),a=c[0],h=c[1],r=c[2],i=c[3];break}case"T":{let[u,p]=c,f=0,g=0;e==="Q"||e==="T"?(f=r+(r-a),g=i+(i-h)):(f=r,g=i);let m=r+2*(f-r)/3,y=i+2*(g-i)/3,w=u+2*(f-u)/3,x=p+2*(g-p)/3;t.push({key:"C",data:[m,y,w,x,u,p]}),a=f,h=g,r=u,i=p;break}case"Q":{let[u,p,f,g]=c,m=r+2*(u-r)/3,y=i+2*(p-i)/3,w=f+2*(u-f)/3,x=g+2*(p-g)/3;t.push({key:"C",data:[m,y,w,x,f,g]}),a=u,h=p,r=f,i=g;break}case"A":{let u=Math.abs(c[0]),p=Math.abs(c[1]),f=c[2],g=c[3],m=c[4],y=c[5],w=c[6];u===0||p===0?(t.push({key:"C",data:[r,i,y,w,y,w]}),r=y,i=w):(r!==y||i!==w)&&(Ce(r,i,y,w,u,p,f,g,m).forEach((function(x){t.push({key:"C",data:x})})),r=y,i=w);break}case"Z":t.push({key:"Z",data:[]}),r=o,i=s}e=l}return t}function rt(n,t,e){return[n*Math.cos(e)-t*Math.sin(e),n*Math.sin(e)+t*Math.cos(e)]}function Ce(n,t,e,r,i,o,s,a,h,l){let c=(u=s,Math.PI*u/180);var u;let p=[],f=0,g=0,m=0,y=0;if(l)[f,g,m,y]=l;else{[n,t]=rt(n,t,-c),[e,r]=rt(e,r,-c);let P=(n-e)/2,S=(t-r)/2,D=P*P/(i*i)+S*S/(o*o);D>1&&(D=Math.sqrt(D),i*=D,o*=D);let j=i*i,Z=o*o,Ge=j*Z-j*S*S-Z*P*P,Ne=j*S*S+Z*P*P,Xt=(a===h?-1:1)*Math.sqrt(Math.abs(Ge/Ne));m=Xt*i*S/o+(n+e)/2,y=Xt*-o*P/i+(t+r)/2,f=Math.asin(parseFloat(((t-y)/o).toFixed(9))),g=Math.asin(parseFloat(((r-y)/o).toFixed(9))),n<m&&(f=Math.PI-f),e<m&&(g=Math.PI-g),f<0&&(f=2*Math.PI+f),g<0&&(g=2*Math.PI+g),h&&f>g&&(f-=2*Math.PI),!h&&g>f&&(g-=2*Math.PI)}let w=g-f;if(Math.abs(w)>120*Math.PI/180){let P=g,S=e,D=r;g=h&&g>f?f+120*Math.PI/180*1:f+120*Math.PI/180*-1,p=Ce(e=m+i*Math.cos(g),r=y+o*Math.sin(g),S,D,i,o,s,0,h,[g,P,m,y])}w=g-f;let x=Math.cos(f),b=Math.sin(f),B=Math.cos(g),I=Math.sin(g),M=Math.tan(w/4),C=4/3*i*M,L=4/3*o*M,st=[n,t],U=[n+C*b,t-L*x],W=[e+C*I,r-L*B],Qt=[e,r];if(U[0]=2*st[0]-U[0],U[1]=2*st[1]-U[1],l)return[U,W,Qt].concat(p);{p=[U,W,Qt].concat(p);let P=[];for(let S=0;S<p.length;S+=3){let D=rt(p[S][0],p[S][1],c),j=rt(p[S+1][0],p[S+1][1],c),Z=rt(p[S+2][0],p[S+2][1],c);P.push([D[0],D[1],j[0],j[1],Z[0],Z[1]])}return P}}var Rr={randOffset:function(n,t){return E(n,t)},randOffsetWithRange:function(n,t,e){return mt(n,t,e)},ellipse:function(n,t,e,r,i){let o=_e(e,r,i);return qt(n,t,i,o).opset},doubleLineOps:function(n,t,e,r,i){return z(n,t,e,r,i,!0)}};function Pe(n,t,e,r,i){return{type:"path",ops:z(n,t,e,r,i)}}function dt(n,t,e){let r=(n||[]).length;if(r>2){let i=[];for(let o=0;o<r-1;o++)i.push(...z(n[o][0],n[o][1],n[o+1][0],n[o+1][1],e));return t&&i.push(...z(n[r-1][0],n[r-1][1],n[0][0],n[0][1],e)),{type:"path",ops:i}}return r===2?Pe(n[0][0],n[0][1],n[1][0],n[1][1],e):{type:"path",ops:[]}}function Cr(n,t,e,r,i){return(function(o,s){return dt(o,!0,s)})([[n,t],[n+e,t],[n+e,t+r],[n,t+r]],i)}function Me(n,t){if(n.length){let e=typeof n[0][0]=="number"?[n]:n,r=ft(e[0],1*(1+.2*t.roughness),t),i=t.disableMultiStroke?[]:ft(e[0],1.5*(1+.22*t.roughness),Ie(t));for(let o=1;o<e.length;o++){let s=e[o];if(s.length){let a=ft(s,1*(1+.2*t.roughness),t),h=t.disableMultiStroke?[]:ft(s,1.5*(1+.22*t.roughness),Ie(t));for(let l of a)l.op!=="move"&&r.push(l);for(let l of h)l.op!=="move"&&i.push(l)}}return{type:"path",ops:r.concat(i)}}return{type:"path",ops:[]}}function _e(n,t,e){let r=Math.sqrt(2*Math.PI*Math.sqrt((Math.pow(n/2,2)+Math.pow(t/2,2))/2)),i=Math.ceil(Math.max(e.curveStepCount,e.curveStepCount/Math.sqrt(200)*r)),o=2*Math.PI/i,s=Math.abs(n/2),a=Math.abs(t/2),h=1-e.curveFitting;return s+=E(s*h,e),a+=E(a*h,e),{increment:o,rx:s,ry:a}}function qt(n,t,e,r){let[i,o]=Se(r.increment,n,t,r.rx,r.ry,1,r.increment*mt(.1,mt(.4,1,e),e),e),s=yt(i,null,e);if(!e.disableMultiStroke&&e.roughness!==0){let[a]=Se(r.increment,n,t,r.rx,r.ry,1.5,0,e),h=yt(a,null,e);s=s.concat(h)}return{estimatedPoints:o,opset:{type:"path",ops:s}}}function ke(n,t,e,r,i,o,s,a,h){let l=n,c=t,u=Math.abs(e/2),p=Math.abs(r/2);u+=E(.01*u,h),p+=E(.01*p,h);let f=i,g=o;for(;f<0;)f+=2*Math.PI,g+=2*Math.PI;g-f>2*Math.PI&&(f=0,g=2*Math.PI);let m=2*Math.PI/h.curveStepCount,y=Math.min(m/2,(g-f)/2),w=Ae(y,l,c,u,p,f,g,1,h);if(!h.disableMultiStroke){let x=Ae(y,l,c,u,p,f,g,1.5,h);w.push(...x)}return s&&(a?w.push(...z(l,c,l+u*Math.cos(f),c+p*Math.sin(f),h),...z(l,c,l+u*Math.cos(g),c+p*Math.sin(g),h)):w.push({op:"lineTo",data:[l,c]},{op:"lineTo",data:[l+u*Math.cos(f),c+p*Math.sin(f)]})),{type:"path",ops:w}}function Be(n,t){let e=Re(Te(Yt(n))),r=[],i=[0,0],o=[0,0];for(let{key:s,data:a}of e)switch(s){case"M":o=[a[0],a[1]],i=[a[0],a[1]];break;case"L":r.push(...z(o[0],o[1],a[0],a[1],t)),o=[a[0],a[1]];break;case"C":{let[h,l,c,u,p,f]=a;r.push(...Pr(h,l,c,u,p,f,o,t)),o=[p,f];break}case"Z":r.push(...z(o[0],o[1],i[0],i[1],t)),o=[i[0],i[1]]}return{type:"path",ops:r}}function Dt(n,t){let e=[];for(let r of n)if(r.length){let i=t.maxRandomnessOffset||0,o=r.length;if(o>2){e.push({op:"move",data:[r[0][0]+E(i,t),r[0][1]+E(i,t)]});for(let s=1;s<o;s++)e.push({op:"lineTo",data:[r[s][0]+E(i,t),r[s][1]+E(i,t)]})}}return{type:"fillPath",ops:e}}function K(n,t){return(function(e,r){let i=e.fillStyle||"hachure";if(!T[i])switch(i){case"zigzag":T[i]||(T[i]=new vt(r));break;case"cross-hatch":T[i]||(T[i]=new Gt(r));break;case"dots":T[i]||(T[i]=new Nt(r));break;case"dashed":T[i]||(T[i]=new $t(r));break;case"zigzag-line":T[i]||(T[i]=new zt(r));break;default:i="hachure",T[i]||(T[i]=new it(r))}return T[i]})(t,Rr).fillPolygons(n,t)}function Ie(n){let t=Object.assign({},n);return t.randomizer=void 0,n.seed&&(t.seed=n.seed+1),t}function Ue(n){return n.randomizer||(n.randomizer=new Wt(n.seed||0)),n.randomizer.next()}function mt(n,t,e,r=1){return e.roughness*r*(Ue(e)*(t-n)+n)}function E(n,t,e=1){return mt(-n,n,t,e)}function z(n,t,e,r,i,o=!1){let s=o?i.disableMultiStrokeFill:i.disableMultiStroke,a=Vt(n,t,e,r,i,!0,!1);if(s)return a;let h=Vt(n,t,e,r,i,!0,!0);return a.concat(h)}function Vt(n,t,e,r,i,o,s){let a=Math.pow(n-e,2)+Math.pow(t-r,2),h=Math.sqrt(a),l=1;l=h<200?1:h>500?.4:-.0016668*h+1.233334;let c=i.maxRandomnessOffset||0;c*c*100>a&&(c=h/10);let u=c/2,p=.2+.2*Ue(i),f=i.bowing*i.maxRandomnessOffset*(r-t)/200,g=i.bowing*i.maxRandomnessOffset*(n-e)/200;f=E(f,i,l),g=E(g,i,l);let m=[],y=()=>E(u,i,l),w=()=>E(c,i,l),x=i.preserveVertices;return o&&(s?m.push({op:"move",data:[n+(x?0:y()),t+(x?0:y())]}):m.push({op:"move",data:[n+(x?0:E(c,i,l)),t+(x?0:E(c,i,l))]})),s?m.push({op:"bcurveTo",data:[f+n+(e-n)*p+y(),g+t+(r-t)*p+y(),f+n+2*(e-n)*p+y(),g+t+2*(r-t)*p+y(),e+(x?0:y()),r+(x?0:y())]}):m.push({op:"bcurveTo",data:[f+n+(e-n)*p+w(),g+t+(r-t)*p+w(),f+n+2*(e-n)*p+w(),g+t+2*(r-t)*p+w(),e+(x?0:w()),r+(x?0:w())]}),m}function ft(n,t,e){if(!n.length)return[];let r=[];r.push([n[0][0]+E(t,e),n[0][1]+E(t,e)]),r.push([n[0][0]+E(t,e),n[0][1]+E(t,e)]);for(let i=1;i<n.length;i++)r.push([n[i][0]+E(t,e),n[i][1]+E(t,e)]),i===n.length-1&&r.push([n[i][0]+E(t,e),n[i][1]+E(t,e)]);return yt(r,null,e)}function yt(n,t,e){let r=n.length,i=[];if(r>3){let o=[],s=1-e.curveTightness;i.push({op:"move",data:[n[1][0],n[1][1]]});for(let a=1;a+2<r;a++){let h=n[a];o[0]=[h[0],h[1]],o[1]=[h[0]+(s*n[a+1][0]-s*n[a-1][0])/6,h[1]+(s*n[a+1][1]-s*n[a-1][1])/6],o[2]=[n[a+1][0]+(s*n[a][0]-s*n[a+2][0])/6,n[a+1][1]+(s*n[a][1]-s*n[a+2][1])/6],o[3]=[n[a+1][0],n[a+1][1]],i.push({op:"bcurveTo",data:[o[1][0],o[1][1],o[2][0],o[2][1],o[3][0],o[3][1]]})}if(t&&t.length===2){let a=e.maxRandomnessOffset;i.push({op:"lineTo",data:[t[0]+E(a,e),t[1]+E(a,e)]})}}else r===3?(i.push({op:"move",data:[n[1][0],n[1][1]]}),i.push({op:"bcurveTo",data:[n[1][0],n[1][1],n[2][0],n[2][1],n[2][0],n[2][1]]})):r===2&&i.push(...Vt(n[0][0],n[0][1],n[1][0],n[1][1],e,!0,!0));return i}function Se(n,t,e,r,i,o,s,a){let h=[],l=[];if(a.roughness===0){n/=4,l.push([t+r*Math.cos(-n),e+i*Math.sin(-n)]);for(let c=0;c<=2*Math.PI;c+=n){let u=[t+r*Math.cos(c),e+i*Math.sin(c)];h.push(u),l.push(u)}l.push([t+r*Math.cos(0),e+i*Math.sin(0)]),l.push([t+r*Math.cos(n),e+i*Math.sin(n)])}else{let c=E(.5,a)-Math.PI/2;l.push([E(o,a)+t+.9*r*Math.cos(c-n),E(o,a)+e+.9*i*Math.sin(c-n)]);let u=2*Math.PI+c-.01;for(let p=c;p<u;p+=n){let f=[E(o,a)+t+r*Math.cos(p),E(o,a)+e+i*Math.sin(p)];h.push(f),l.push(f)}l.push([E(o,a)+t+r*Math.cos(c+2*Math.PI+.5*s),E(o,a)+e+i*Math.sin(c+2*Math.PI+.5*s)]),l.push([E(o,a)+t+.98*r*Math.cos(c+s),E(o,a)+e+.98*i*Math.sin(c+s)]),l.push([E(o,a)+t+.9*r*Math.cos(c+.5*s),E(o,a)+e+.9*i*Math.sin(c+.5*s)])}return[l,h]}function Ae(n,t,e,r,i,o,s,a,h){let l=o+E(.1,h),c=[];c.push([E(a,h)+t+.9*r*Math.cos(l-n),E(a,h)+e+.9*i*Math.sin(l-n)]);for(let u=l;u<=s;u+=n)c.push([E(a,h)+t+r*Math.cos(u),E(a,h)+e+i*Math.sin(u)]);return c.push([t+r*Math.cos(s),e+i*Math.sin(s)]),c.push([t+r*Math.cos(s),e+i*Math.sin(s)]),yt(c,null,h)}function Pr(n,t,e,r,i,o,s,a){let h=[],l=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3],c=[0,0],u=a.disableMultiStroke?1:2,p=a.preserveVertices;for(let f=0;f<u;f++)f===0?h.push({op:"move",data:[s[0],s[1]]}):h.push({op:"move",data:[s[0]+(p?0:E(l[0],a)),s[1]+(p?0:E(l[0],a))]}),c=p?[i,o]:[i+E(l[f],a),o+E(l[f],a)],h.push({op:"bcurveTo",data:[n+E(l[f],a),t+E(l[f],a),e+E(l[f],a),r+E(l[f],a),c[0],c[1]]});return h}function nt(n){return[...n]}function Fe(n,t=0){let e=n.length;if(e<3)throw new Error("A curve must have at least three points.");let r=[];if(e===3)r.push(nt(n[0]),nt(n[1]),nt(n[2]),nt(n[2]));else{let i=[];i.push(n[0],n[0]);for(let a=1;a<n.length;a++)i.push(n[a]),a===n.length-1&&i.push(n[a]);let o=[],s=1-t;r.push(nt(i[0]));for(let a=1;a+2<i.length;a++){let h=i[a];o[0]=[h[0],h[1]],o[1]=[h[0]+(s*i[a+1][0]-s*i[a-1][0])/6,h[1]+(s*i[a+1][1]-s*i[a-1][1])/6],o[2]=[i[a+1][0]+(s*i[a][0]-s*i[a+2][0])/6,i[a+1][1]+(s*i[a][1]-s*i[a+2][1])/6],o[3]=[i[a+1][0],i[a+1][1]],r.push(o[1],o[2],o[3])}}return r}function gt(n,t){return Math.pow(n[0]-t[0],2)+Math.pow(n[1]-t[1],2)}function _r(n,t,e){let r=gt(t,e);if(r===0)return gt(n,t);let i=((n[0]-t[0])*(e[0]-t[0])+(n[1]-t[1])*(e[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),gt(n,H(t,e,i))}function H(n,t,e){return[n[0]+(t[0]-n[0])*e,n[1]+(t[1]-n[1])*e]}function Ht(n,t,e,r){let i=r||[];if((function(a,h){let l=a[h+0],c=a[h+1],u=a[h+2],p=a[h+3],f=3*c[0]-2*l[0]-p[0];f*=f;let g=3*c[1]-2*l[1]-p[1];g*=g;let m=3*u[0]-2*p[0]-l[0];m*=m;let y=3*u[1]-2*p[1]-l[1];return y*=y,f<m&&(f=m),g<y&&(g=y),f+g})(n,t)<e){let a=n[t+0];i.length?(o=i[i.length-1],s=a,Math.sqrt(gt(o,s))>1&&i.push(a)):i.push(a),i.push(n[t+3])}else{let h=n[t+0],l=n[t+1],c=n[t+2],u=n[t+3],p=H(h,l,.5),f=H(l,c,.5),g=H(c,u,.5),m=H(p,f,.5),y=H(f,g,.5),w=H(m,y,.5);Ht([h,p,m,w],0,e,i),Ht([w,y,g,u],0,e,i)}var o,s;return i}function Ur(n,t){return wt(n,0,n.length,t)}function wt(n,t,e,r,i){let o=i||[],s=n[t],a=n[e-1],h=0,l=1;for(let c=t+1;c<e-1;++c){let u=_r(n[c],s,a);u>h&&(h=u,l=c)}return Math.sqrt(h)>r?(wt(n,t,l+1,r,o),wt(n,l,e,r,o)):(o.length||o.push(s),o.push(a)),o}function Ot(n,t=.15,e){let r=[],i=(n.length-1)/3;for(let o=0;o<i;o++)Ht(n,3*o,t,r);return e&&e>0?wt(r,0,r.length,e):r}var R="none",tt=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,e,r){return{shape:t,sets:e||[],options:r||this.defaultOptions}}line(t,e,r,i,o){let s=this._o(o);return this._d("line",[Pe(t,e,r,i,s)],s)}rectangle(t,e,r,i,o){let s=this._o(o),a=[],h=Cr(t,e,r,i,s);if(s.fill){let l=[[t,e],[t+r,e],[t+r,e+i],[t,e+i]];s.fillStyle==="solid"?a.push(Dt([l],s)):a.push(K([l],s))}return s.stroke!==R&&a.push(h),this._d("rectangle",a,s)}ellipse(t,e,r,i,o){let s=this._o(o),a=[],h=_e(r,i,s),l=qt(t,e,s,h);if(s.fill)if(s.fillStyle==="solid"){let c=qt(t,e,s,h).opset;c.type="fillPath",a.push(c)}else a.push(K([l.estimatedPoints],s));return s.stroke!==R&&a.push(l.opset),this._d("ellipse",a,s)}circle(t,e,r,i){let o=this.ellipse(t,e,r,r,i);return o.shape="circle",o}linearPath(t,e){let r=this._o(e);return this._d("linearPath",[dt(t,!1,r)],r)}arc(t,e,r,i,o,s,a=!1,h){let l=this._o(h),c=[],u=ke(t,e,r,i,o,s,a,!0,l);if(a&&l.fill)if(l.fillStyle==="solid"){let p=Object.assign({},l);p.disableMultiStroke=!0;let f=ke(t,e,r,i,o,s,!0,!1,p);f.type="fillPath",c.push(f)}else c.push((function(p,f,g,m,y,w,x){let b=p,B=f,I=Math.abs(g/2),M=Math.abs(m/2);I+=E(.01*I,x),M+=E(.01*M,x);let C=y,L=w;for(;C<0;)C+=2*Math.PI,L+=2*Math.PI;L-C>2*Math.PI&&(C=0,L=2*Math.PI);let st=(L-C)/x.curveStepCount,U=[];for(let W=C;W<=L;W+=st)U.push([b+I*Math.cos(W),B+M*Math.sin(W)]);return U.push([b+I*Math.cos(L),B+M*Math.sin(L)]),U.push([b,B]),K([U],x)})(t,e,r,i,o,s,l));return l.stroke!==R&&c.push(u),this._d("arc",c,l)}curve(t,e){let r=this._o(e),i=[],o=Me(t,r);if(r.fill&&r.fill!==R)if(r.fillStyle==="solid"){let s=Me(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(s.ops)})}else{let s=[],a=t;if(a.length){let h=typeof a[0][0]=="number"?[a]:a;for(let l of h)l.length<3?s.push(...l):l.length===3?s.push(...Ot(Fe([l[0],l[0],l[1],l[2]]),10,(1+r.roughness)/2)):s.push(...Ot(Fe(l),10,(1+r.roughness)/2))}s.length&&i.push(K([s],r))}return r.stroke!==R&&i.push(o),this._d("curve",i,r)}polygon(t,e){let r=this._o(e),i=[],o=dt(t,!0,r);return r.fill&&(r.fillStyle==="solid"?i.push(Dt([t],r)):i.push(K([t],r))),r.stroke!==R&&i.push(o),this._d("polygon",i,r)}path(t,e){let r=this._o(e),i=[];if(!t)return this._d("path",i,r);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let o=r.fill&&r.fill!=="transparent"&&r.fill!==R,s=r.stroke!==R,a=!!(r.simplification&&r.simplification<1),h=(function(c,u,p){let f=Re(Te(Yt(c))),g=[],m=[],y=[0,0],w=[],x=()=>{w.length>=4&&m.push(...Ot(w,u)),w=[]},b=()=>{x(),m.length&&(g.push(m),m=[])};for(let{key:I,data:M}of f)switch(I){case"M":b(),y=[M[0],M[1]],m.push(y);break;case"L":x(),m.push([M[0],M[1]]);break;case"C":if(!w.length){let C=m.length?m[m.length-1]:y;w.push([C[0],C[1]])}w.push([M[0],M[1]]),w.push([M[2],M[3]]),w.push([M[4],M[5]]);break;case"Z":x(),m.push([y[0],y[1]])}if(b(),!p)return g;let B=[];for(let I of g){let M=Ur(I,p);M.length&&B.push(M)}return B})(t,1,a?4-4*(r.simplification||1):(1+r.roughness)/2),l=Be(t,r);if(o)if(r.fillStyle==="solid")if(h.length===1){let c=Be(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(c.ops)})}else i.push(Dt(h,r));else i.push(K(h,r));return s&&(a?h.forEach((c=>{i.push(dt(c,!1,r))})):i.push(l)),this._d("path",i,r)}opsToPath(t,e){let r="";for(let i of t.ops){let o=typeof e=="number"&&e>=0?i.data.map((s=>+s.toFixed(e))):i.data;switch(i.op){case"move":r+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":r+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":r+=`L${o[0]} ${o[1]} `}}return r.trim()}toPaths(t){let e=t.sets||[],r=t.options||this.defaultOptions,i=[];for(let o of e){let s=null;switch(o.type){case"path":s={d:this.opsToPath(o),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:R};break;case"fillPath":s={d:this.opsToPath(o),stroke:R,strokeWidth:0,fill:r.fill||R};break;case"fillSketch":s=this.fillSketch(o,r)}s&&i.push(s)}return i}fillSketch(t,e){let r=e.fillWeight;return r<0&&(r=e.strokeWidth/2),{d:this.opsToPath(t),stroke:e.fill||R,strokeWidth:r,fill:R}}_mergedShape(t){return t.filter(((e,r)=>r===0||e.op!=="move"))}},jt=class{constructor(t,e){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new tt(e)}draw(t){let e=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.ctx,o=t.options.fixedDecimalPlaceDigits;for(let s of e)switch(s.type){case"path":i.save(),i.strokeStyle=r.stroke==="none"?"transparent":r.stroke,i.lineWidth=r.strokeWidth,r.strokeLineDash&&i.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(i.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(i,s,o),i.restore();break;case"fillPath":{i.save(),i.fillStyle=r.fill||"";let a=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(i,s,o,a),i.restore();break}case"fillSketch":this.fillSketch(i,s,r)}}fillSketch(t,e,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2),t.save(),r.fillLineDash&&t.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(t.lineDashOffset=r.fillLineDashOffset),t.strokeStyle=r.fill||"",t.lineWidth=i,this._drawToContext(t,e,r.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,e,r,i="nonzero"){t.beginPath();for(let o of e.ops){let s=typeof r=="number"&&r>=0?o.data.map((a=>+a.toFixed(r))):o.data;switch(o.op){case"move":t.moveTo(s[0],s[1]);break;case"bcurveTo":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"lineTo":t.lineTo(s[0],s[1])}}e.type==="fillPath"?t.fill(i):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,e,r,i,o){let s=this.gen.line(t,e,r,i,o);return this.draw(s),s}rectangle(t,e,r,i,o){let s=this.gen.rectangle(t,e,r,i,o);return this.draw(s),s}ellipse(t,e,r,i,o){let s=this.gen.ellipse(t,e,r,i,o);return this.draw(s),s}circle(t,e,r,i){let o=this.gen.circle(t,e,r,i);return this.draw(o),o}linearPath(t,e){let r=this.gen.linearPath(t,e);return this.draw(r),r}polygon(t,e){let r=this.gen.polygon(t,e);return this.draw(r),r}arc(t,e,r,i,o,s,a=!1,h){let l=this.gen.arc(t,e,r,i,o,s,a,h);return this.draw(l),l}curve(t,e){let r=this.gen.curve(t,e);return this.draw(r),r}path(t,e){let r=this.gen.path(t,e);return this.draw(r),r}},pt="http://www.w3.org/2000/svg",Zt=class{constructor(t,e){this.svg=t,this.gen=new tt(e)}draw(t){let e=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.svg.ownerDocument||window.document,o=i.createElementNS(pt,"g"),s=t.options.fixedDecimalPlaceDigits;for(let a of e){let h=null;switch(a.type){case"path":h=i.createElementNS(pt,"path"),h.setAttribute("d",this.opsToPath(a,s)),h.setAttribute("stroke",r.stroke),h.setAttribute("stroke-width",r.strokeWidth+""),h.setAttribute("fill","none"),r.strokeLineDash&&h.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&h.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break;case"fillPath":h=i.createElementNS(pt,"path"),h.setAttribute("d",this.opsToPath(a,s)),h.setAttribute("stroke","none"),h.setAttribute("stroke-width","0"),h.setAttribute("fill",r.fill||""),t.shape!=="curve"&&t.shape!=="polygon"||h.setAttribute("fill-rule","evenodd");break;case"fillSketch":h=this.fillSketch(i,a,r)}h&&o.appendChild(h)}return o}fillSketch(t,e,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2);let o=t.createElementNS(pt,"path");return o.setAttribute("d",this.opsToPath(e,r.fixedDecimalPlaceDigits)),o.setAttribute("stroke",r.fill||""),o.setAttribute("stroke-width",i+""),o.setAttribute("fill","none"),r.fillLineDash&&o.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&o.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),o}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,e){return this.gen.opsToPath(t,e)}line(t,e,r,i,o){let s=this.gen.line(t,e,r,i,o);return this.draw(s)}rectangle(t,e,r,i,o){let s=this.gen.rectangle(t,e,r,i,o);return this.draw(s)}ellipse(t,e,r,i,o){let s=this.gen.ellipse(t,e,r,i,o);return this.draw(s)}circle(t,e,r,i){let o=this.gen.circle(t,e,r,i);return this.draw(o)}linearPath(t,e){let r=this.gen.linearPath(t,e);return this.draw(r)}polygon(t,e){let r=this.gen.polygon(t,e);return this.draw(r)}arc(t,e,r,i,o,s,a=!1,h){let l=this.gen.arc(t,e,r,i,o,s,a,h);return this.draw(l)}curve(t,e){let r=this.gen.curve(t,e);return this.draw(r)}path(t,e){let r=this.gen.path(t,e);return this.draw(r)}},Le={canvas:(n,t)=>new jt(n,t),svg:(n,t)=>new Zt(n,t),generator:n=>new tt(n),newSeed:()=>tt.newSeed()};var Lr={roughness:.5,bowing:.5,fillStyle:"hachure",fillWeight:.5,hachureGap:4,defaultBorderColor:"#333"};function De(n,t={}){let e={...Lr,...t},r={roughness:e.roughness,bowing:e.bowing},i=document.createElement("div");i.style.cssText="position: absolute; left: -9999px; top: -9999px;",i.innerHTML=n,document.body.appendChild(i);let o=i.querySelector("svg");if(!o)return document.body.removeChild(i),n;let s=Le.svg(o),a=u=>{let p=u.getAttribute("stroke");if(p&&p!=="none")return p;let f=window.getComputedStyle(u).stroke;return f&&f!=="none"&&f!==""?f:null},h=u=>{let p=u.getAttribute("fill");if(p&&p!=="none")return p;let f=window.getComputedStyle(u).fill;return f&&f!=="none"&&f!==""?f:null},l=u=>{u.setAttribute("stroke","none"),u.style.stroke="none"},c=u=>{let p=u.parentElement;for(;p;){let f=p.tagName.toLowerCase();if(f==="defs"||f==="marker")return!0;p=p.parentElement}return!1};return o.querySelectorAll("rect").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("x")||"0"),m=parseFloat(u.getAttribute("y")||"0"),y=parseFloat(u.getAttribute("width")||"0"),w=parseFloat(u.getAttribute("height")||"0");if(y<=0||w<=0)return;let x=p||e.defaultBorderColor,b=s.rectangle(g,m,y,w,{...r,stroke:x,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(b,u),u.remove()}),o.querySelectorAll("circle").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("cx")||"0"),m=parseFloat(u.getAttribute("cy")||"0"),y=parseFloat(u.getAttribute("r")||"0");if(y<=0)return;let w=p||e.defaultBorderColor,x=s.circle(g,m,y*2,{...r,stroke:w,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(x,u),u.remove()}),o.querySelectorAll("ellipse").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("cx")||"0"),m=parseFloat(u.getAttribute("cy")||"0"),y=parseFloat(u.getAttribute("rx")||"0"),w=parseFloat(u.getAttribute("ry")||"0");if(y<=0||w<=0)return;let x=p||e.defaultBorderColor,b=s.ellipse(g,m,y*2,w*2,{...r,stroke:x,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(b,u),u.remove()}),o.querySelectorAll("polygon").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let m=(u.getAttribute("points")||"").trim().split(/\s+/).map(x=>{let[b,B]=x.split(",").map(Number);return[b,B]});if(m.length<3)return;let y=p||e.defaultBorderColor,w=s.polygon(m,{...r,stroke:y,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(w,u),u.remove()}),o.querySelectorAll("line").forEach(u=>{if(c(u))return;let p=a(u);if(!p)return;let f=parseFloat(u.getAttribute("x1")||"0"),g=parseFloat(u.getAttribute("y1")||"0"),m=parseFloat(u.getAttribute("x2")||"0"),y=parseFloat(u.getAttribute("y2")||"0"),w=s.line(f,g,m,y,{...r,stroke:p}),x=u.getAttribute("marker-end"),b=u.getAttribute("marker-start");x||b?(l(u),u.parentNode?.insertBefore(w,u)):u.parentNode?.replaceChild(w,u)}),o.querySelectorAll("path").forEach(u=>{if(c(u))return;let p=a(u),f=h(u),g=u.getAttribute("d");if(!p||!g||f&&f!=="rgb(0, 0, 0)")return;let m=s.path(g,{...r,stroke:p,fill:"none"}),y=u.getAttribute("marker-end"),w=u.getAttribute("marker-start");y||w?(l(u),u.parentNode?.insertBefore(m,u)):u.parentNode?.replaceChild(m,u)}),document.body.removeChild(i),new XMLSerializer().serializeToString(o)}function Oe(){let n=window.mermaid;if(!n)throw new Error("Mermaid library not loaded. Ensure lib-mermaid.js is loaded before render-worker.js");return n}var bt=class extends ct{constructor(){super("mermaid");this.roughOptions={roughness:.5,bowing:.5}}async initialize(e=null){this.applyThemeConfig(e),this._initialized=!0}applyThemeConfig(e=null){let r=e?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",i=e?.diagramStyle==="handDrawn";Oe().initialize({startOnLoad:!1,securityLevel:"loose",look:i?"handDrawn":"classic",themeVariables:{fontFamily:r,background:"transparent"},flowchart:{htmlLabels:!0,curve:"basis"}})}isSequenceDiagram(e){return e.trim().toLowerCase().startsWith("sequencediagram")}preprocessCode(e){return e.replace(/\\n/g,"<br>")}applyRoughEffectToSvg(e,r){return r?.diagramStyle==="handDrawn"?De(e,this.roughOptions):e}async render(e,r){this._initialized||await this.initialize(r),this.validateInput(e),e=this.preprocessCode(e),this.applyThemeConfig(r);let i=this.createContainer();i.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let o="mermaid-diagram-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),{svg:s}=await Oe().render(o,e);if(!s||s.length<100)throw new Error("Generated SVG is too small or empty");if(!s.includes("<svg")||!s.includes("</svg>"))throw new Error("Generated content is not valid SVG");i.innerHTML=s;let a=i.querySelector("svg");if(!a)throw new Error("SVG element not found in rendered content");i.offsetHeight,a.getBoundingClientRect(),await new Promise(w=>setTimeout(w,100)),document.fonts&&document.fonts.ready&&await document.fonts.ready,i.offsetHeight,a.getBoundingClientRect(),await new Promise(w=>setTimeout(w,50));let h=a.getAttribute("viewBox"),l,c;if(h){let w=h.split(/\s+/);l=Math.ceil(parseFloat(w[2])),c=Math.ceil(parseFloat(w[3]))}else l=Math.ceil(parseFloat(a.getAttribute("width")||"800")),c=Math.ceil(parseFloat(a.getAttribute("height")||"600"));let u=r?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",p=this.calculateCanvasScale(r),f=this.isSequenceDiagram(e)?this.applyRoughEffectToSvg(s,r):s,g=await this.renderSvgToCanvas(f,l*p,c*p,u),y=g.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,"");return this.removeContainer(i),{base64:y,width:g.width,height:g.height,format:"png"}}};function Dr(){let n=window.mermaid;if(!n)throw new Error("Mermaid library not loaded.");return n}var Et=class extends bt{async mountToDom(t,e,r){if(this._initialized||await this.initialize(e),typeof t!="string")throw new Error("Mermaid input must be a string");let i=t;this.validateInput(i);let o=this.preprocessCode(i);this.applyThemeConfig(e);let s="mermaid-diagram-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),{svg:a}=await Dr().render(s,o),h=this.isSequenceDiagram(o)?this.applyRoughEffectToSvg(a,e):a;r.innerHTML=h;let c=r.querySelector("svg")||r,u=(async()=>{try{document.fonts?.ready&&await document.fonts.ready}catch{}try{typeof globalThis.requestAnimationFrame=="function"&&(await new Promise(p=>globalThis.requestAnimationFrame(()=>p())),await new Promise(p=>globalThis.requestAnimationFrame(()=>p())))}catch{}})();return{root:c,cleanup:()=>{try{r.innerHTML=""}catch{}},done:u}}};k();function Or(){return globalThis}function vr(){let n=Or();return n.__md2x_renderer_registry__||(n.__md2x_renderer_registry__=new Map),n.__md2x_renderer_registry__}function ve(n){vr().set(n.type,n)}ve(new Et);})();
1
+ "use strict";(()=>{var $e=Object.create;var Jt=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var He=(n,t)=>()=>(n&&(t=n(n=0)),t);var Mt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var je=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of We(t))!Ve.call(n,i)&&i!==e&&Jt(n,i,{get:()=>t[i],enumerable:!(r=ze(t,i))||r.enumerable});return n};var Ze=(n,t,e)=>(e=n!=null?$e(qe(n)):{},je(t||!n||!n.__esModule?Jt(e,"default",{value:n,enumerable:!0}):e,n));var ee=Mt(at=>{"use strict";k();at.byteLength=Qe;at.toByteArray=Je;at.fromByteArray=er;var O=[],_=[],Ye=typeof Uint8Array<"u"?Uint8Array:Array,kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(q=0,Kt=kt.length;q<Kt;++q)O[q]=kt[q],_[kt.charCodeAt(q)]=q;var q,Kt;_[45]=62;_[95]=63;function te(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function Qe(n){var t=te(n),e=t[0],r=t[1];return(e+r)*3/4-r}function Xe(n,t,e){return(t+e)*3/4-e}function Je(n){var t,e=te(n),r=e[0],i=e[1],o=new Ye(Xe(n,r,i)),s=0,a=i>0?r-4:r,h;for(h=0;h<a;h+=4)t=_[n.charCodeAt(h)]<<18|_[n.charCodeAt(h+1)]<<12|_[n.charCodeAt(h+2)]<<6|_[n.charCodeAt(h+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=_[n.charCodeAt(h)]<<2|_[n.charCodeAt(h+1)]>>4,o[s++]=t&255),i===1&&(t=_[n.charCodeAt(h)]<<10|_[n.charCodeAt(h+1)]<<4|_[n.charCodeAt(h+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Ke(n){return O[n>>18&63]+O[n>>12&63]+O[n>>6&63]+O[n&63]}function tr(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(Ke(r));return i.join("")}function er(n){for(var t,e=n.length,r=e%3,i=[],o=16383,s=0,a=e-r;s<a;s+=o)i.push(tr(n,s,s+o>a?a:s+o));return r===1?(t=n[e-1],i.push(O[t>>2]+O[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(O[t>>10]+O[t>>4&63]+O[t<<2&63]+"=")),i.join("")}});var re=Mt(Bt=>{k();Bt.read=function(n,t,e,r,i){var o,s,a=i*8-r-1,h=(1<<a)-1,l=h>>1,c=-7,u=e?i-1:0,p=e?-1:1,f=n[t+u];for(u+=p,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=o*256+n[t+u],u+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=s*256+n[t+u],u+=p,c-=8);if(o===0)o=1-l;else{if(o===h)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-l}return(f?-1:1)*s*Math.pow(2,o-r)};Bt.write=function(n,t,e,r,i,o){var s,a,h,l=o*8-i-1,c=(1<<l)-1,u=c>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,g=r?1:-1,m=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+u>=1?t+=p/h:t+=p*Math.pow(2,1-u),t*h>=2&&(s++,h/=2),s+u>=c?(a=0,s=c):s+u>=1?(a=(t*h-1)*Math.pow(2,i),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;n[e+f]=a&255,f+=g,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;n[e+f]=s&255,f+=g,s/=256,l-=8);n[e+f-g]|=m*128}});var xe=Mt(J=>{"use strict";k();var St=ee(),Q=re(),ne=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;J.Buffer=d;J.SlowBuffer=ar;J.INSPECT_MAX_BYTES=50;var ht=2147483647;J.kMaxLength=ht;d.TYPED_ARRAY_SUPPORT=rr();!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function rr(){try{let n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function G(n){if(n>ht)throw new RangeError('The value "'+n+'" is invalid for option "size"');let t=new Uint8Array(n);return Object.setPrototypeOf(t,d.prototype),t}function d(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Tt(n)}return ae(n,t,e)}d.poolSize=8192;function ae(n,t,e){if(typeof n=="string")return ir(n,t);if(ArrayBuffer.isView(n))return or(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(v(n,ArrayBuffer)||n&&v(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(v(n,SharedArrayBuffer)||n&&v(n.buffer,SharedArrayBuffer)))return At(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=n.valueOf&&n.valueOf();if(r!=null&&r!==n)return d.from(r,t,e);let i=sr(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return d.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}d.from=function(n,t,e){return ae(n,t,e)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function he(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function nr(n,t,e){return he(n),n<=0?G(n):t!==void 0?typeof e=="string"?G(n).fill(t,e):G(n).fill(t):G(n)}d.alloc=function(n,t,e){return nr(n,t,e)};function Tt(n){return he(n),G(n<0?0:Rt(n)|0)}d.allocUnsafe=function(n){return Tt(n)};d.allocUnsafeSlow=function(n){return Tt(n)};function ir(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!d.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=ue(n,t)|0,r=G(e),i=r.write(n,t);return i!==e&&(r=r.slice(0,i)),r}function It(n){let t=n.length<0?0:Rt(n.length)|0,e=G(t);for(let r=0;r<t;r+=1)e[r]=n[r]&255;return e}function or(n){if(v(n,Uint8Array)){let t=new Uint8Array(n);return At(t.buffer,t.byteOffset,t.byteLength)}return It(n)}function At(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let r;return t===void 0&&e===void 0?r=new Uint8Array(n):e===void 0?r=new Uint8Array(n,t):r=new Uint8Array(n,t,e),Object.setPrototypeOf(r,d.prototype),r}function sr(n){if(d.isBuffer(n)){let t=Rt(n.length)|0,e=G(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Pt(n.length)?G(0):It(n);if(n.type==="Buffer"&&Array.isArray(n.data))return It(n.data)}function Rt(n){if(n>=ht)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ht.toString(16)+" bytes");return n|0}function ar(n){return+n!=n&&(n=0),d.alloc(+n)}d.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==d.prototype};d.compare=function(t,e){if(v(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),v(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(t)||!d.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};d.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return d.alloc(0);let r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let i=d.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){let s=t[r];if(v(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function ue(n,t){if(d.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||v(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let e=n.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Ft(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return we(n).length;default:if(i)return r?-1:Ft(n).length;t=(""+t).toLowerCase(),i=!0}}d.byteLength=ue;function hr(n,t,e){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return wr(this,t,e);case"utf8":case"utf-8":return le(this,t,e);case"ascii":return mr(this,t,e);case"latin1":case"binary":return yr(this,t,e);case"base64":return dr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function V(n,t,e){let r=n[t];n[t]=n[e],n[e]=r}d.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)V(this,e,e+1);return this};d.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)V(this,e,e+3),V(this,e+1,e+2);return this};d.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)V(this,e,e+7),V(this,e+1,e+6),V(this,e+2,e+5),V(this,e+3,e+4);return this};d.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?le(this,0,t):hr.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(t){if(!d.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:d.compare(this,t)===0};d.prototype.inspect=function(){let t="",e=J.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ne&&(d.prototype[ne]=d.prototype.inspect);d.prototype.compare=function(t,e,r,i,o){if(v(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=r-e,h=Math.min(s,a),l=this.slice(i,o),c=t.slice(e,r);for(let u=0;u<h;++u)if(l[u]!==c[u]){s=l[u],a=c[u];break}return s<a?-1:a<s?1:0};function ce(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Pt(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:ie(n,t,e,r,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):ie(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function ie(n,t,e,r,i){let o=1,s=n.length,a=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,a/=2,e/=2}function h(c,u){return o===1?c[u]:c.readUInt16BE(u*o)}let l;if(i){let c=-1;for(l=e;l<s;l++)if(h(n,l)===h(t,c===-1?0:l-c)){if(c===-1&&(c=l),l-c+1===a)return c*o}else c!==-1&&(l-=l-c),c=-1}else for(e+a>s&&(e=s-a),l=e;l>=0;l--){let c=!0;for(let u=0;u<a;u++)if(h(n,l+u)!==h(t,u)){c=!1;break}if(c)return l}return-1}d.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};d.prototype.indexOf=function(t,e,r){return ce(this,t,e,r,!0)};d.prototype.lastIndexOf=function(t,e,r){return ce(this,t,e,r,!1)};function ur(n,t,e,r){e=Number(e)||0;let i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;let o=t.length;r>o/2&&(r=o/2);let s;for(s=0;s<r;++s){let a=parseInt(t.substr(s*2,2),16);if(Pt(a))return s;n[e+s]=a}return s}function cr(n,t,e,r){return ut(Ft(t,n.length-e),n,e,r)}function lr(n,t,e,r){return ut(kr(t),n,e,r)}function fr(n,t,e,r){return ut(we(t),n,e,r)}function pr(n,t,e,r){return ut(Br(t,n.length-e),n,e,r)}d.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return ur(this,t,e,r);case"utf8":case"utf-8":return cr(this,t,e,r);case"ascii":case"latin1":case"binary":return lr(this,t,e,r);case"base64":return fr(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pr(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dr(n,t,e){return t===0&&e===n.length?St.fromByteArray(n):St.fromByteArray(n.slice(t,e))}function le(n,t,e){e=Math.min(n.length,e);let r=[],i=t;for(;i<e;){let o=n[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=e){let h,l,c,u;switch(a){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(u=(o&31)<<6|h&63,u>127&&(s=u));break;case 3:h=n[i+1],l=n[i+2],(h&192)===128&&(l&192)===128&&(u=(o&15)<<12|(h&63)<<6|l&63,u>2047&&(u<55296||u>57343)&&(s=u));break;case 4:h=n[i+1],l=n[i+2],c=n[i+3],(h&192)===128&&(l&192)===128&&(c&192)===128&&(u=(o&15)<<18|(h&63)<<12|(l&63)<<6|c&63,u>65535&&u<1114112&&(s=u))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=a}return gr(r)}var oe=4096;function gr(n){let t=n.length;if(t<=oe)return String.fromCharCode.apply(String,n);let e="",r=0;for(;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=oe));return e}function mr(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function yr(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function wr(n,t,e){let r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);let i="";for(let o=t;o<e;++o)i+=Sr[n[o]];return i}function xr(n,t,e){let r=n.slice(t,e),i="";for(let o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}d.prototype.slice=function(t,e){let r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,d.prototype),i};function A(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]|this[t+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]<<8|this[t+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};d.prototype.readBigUInt64LE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+r*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};d.prototype.readIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||A(t,e,this.length);let i=e,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};d.prototype.readInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};d.prototype.readInt16LE=function(t,e){t=t>>>0,e||A(t,2,this.length);let r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};d.prototype.readInt16BE=function(t,e){t=t>>>0,e||A(t,2,this.length);let r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};d.prototype.readInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};d.prototype.readInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};d.prototype.readBigInt64LE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});d.prototype.readBigInt64BE=$(function(t){t=t>>>0,X(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&et(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r)});d.prototype.readFloatLE=function(t,e){return t=t>>>0,e||A(t,4,this.length),Q.read(this,t,!0,23,4)};d.prototype.readFloatBE=function(t,e){return t=t>>>0,e||A(t,4,this.length),Q.read(this,t,!1,23,4)};d.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||A(t,8,this.length),Q.read(this,t,!0,52,8)};d.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||A(t,8,this.length),Q.read(this,t,!1,52,8)};function F(n,t,e,r,i,o){if(!d.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let a=Math.pow(2,8*r)-1;F(this,t,e,r,a,0)}let o=1,s=0;for(this[e]=t&255;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let a=Math.pow(2,8*r)-1;F(this,t,e,r,a,0)}let o=r-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r};d.prototype.writeUint8=d.prototype.writeUInt8=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,1,255,0),this[e]=t&255,e+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function fe(n,t,e,r,i){ye(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,e}function pe(n,t,e,r,i){ye(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e+7]=o,o=o>>8,n[e+6]=o,o=o>>8,n[e+5]=o,o=o>>8,n[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e+3]=s,s=s>>8,n[e+2]=s,s=s>>8,n[e+1]=s,s=s>>8,n[e]=s,e+8}d.prototype.writeBigUInt64LE=$(function(t,e=0){return fe(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=$(function(t,e=0){return pe(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let h=Math.pow(2,8*r-1);F(this,t,e,r,h-1,-h)}let o=0,s=1,a=0;for(this[e]=t&255;++o<r&&(s*=256);)t<0&&a===0&&this[e+o-1]!==0&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r};d.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let h=Math.pow(2,8*r-1);F(this,t,e,r,h-1,-h)}let o=r-1,s=1,a=0;for(this[e+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[e+o+1]!==0&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r};d.prototype.writeInt8=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};d.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};d.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};d.prototype.writeBigInt64LE=$(function(t,e=0){return fe(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=$(function(t,e=0){return pe(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function de(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ge(n,t,e,r,i){return t=+t,e=e>>>0,i||de(n,t,e,4,34028234663852886e22,-34028234663852886e22),Q.write(n,t,e,r,23,4),e+4}d.prototype.writeFloatLE=function(t,e,r){return ge(this,t,e,!0,r)};d.prototype.writeFloatBE=function(t,e,r){return ge(this,t,e,!1,r)};function me(n,t,e,r,i){return t=+t,e=e>>>0,i||de(n,t,e,8,17976931348623157e292,-17976931348623157e292),Q.write(n,t,e,r,52,8),e+8}d.prototype.writeDoubleLE=function(t,e,r){return me(this,t,e,!0,r)};d.prototype.writeDoubleBE=function(t,e,r){return me(this,t,e,!1,r)};d.prototype.copy=function(t,e,r,i){if(!d.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);let o=i-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),o};d.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<r;++o)this[o]=t;else{let s=d.isBuffer(t)?t:d.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var Y={};function Ct(n,t,e){Y[n]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name}get code(){return n}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${n}]: ${this.message}`}}}Ct("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ct("ERR_INVALID_ARG_TYPE",function(n,t){return`The "${n}" argument must be of type number. Received type ${typeof t}`},TypeError);Ct("ERR_OUT_OF_RANGE",function(n,t,e){let r=`The value of "${n}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=se(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=se(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);function se(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function br(n,t,e){X(t,"offset"),(n[t]===void 0||n[t+e]===void 0)&&et(t,n.length-(e+1))}function ye(n,t,e,r,i,o){if(n>e||n<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${e}${s}`,new Y.ERR_OUT_OF_RANGE("value",a,n)}br(r,i,o)}function X(n,t){if(typeof n!="number")throw new Y.ERR_INVALID_ARG_TYPE(t,"number",n)}function et(n,t,e){throw Math.floor(n)!==n?(X(n,e),new Y.ERR_OUT_OF_RANGE(e||"offset","an integer",n)):t<0?new Y.ERR_BUFFER_OUT_OF_BOUNDS:new Y.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,n)}var Er=/[^+/0-9A-Za-z-_]/g;function Mr(n){if(n=n.split("=")[0],n=n.trim().replace(Er,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Ft(n,t){t=t||1/0;let e,r=n.length,i=null,o=[];for(let s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function kr(n){let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Br(n,t){let e,r,i,o=[];for(let s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function we(n){return St.toByteArray(Mr(n))}function ut(n,t,e,r){let i;for(i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function v(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Pt(n){return n!==n}var Sr=(function(){let n="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let r=e*16;for(let i=0;i<16;++i)t[r+i]=n[e]+n[i]}return t})();function $(n){return typeof BigInt>"u"?Ir:n}function Ir(){throw new Error("BigInt not supported")}});var be,k=He(()=>{"use strict";be=Ze(xe(),1);globalThis.Buffer=be.Buffer});k();k();k();k();var ct=class{constructor(t){this._initialized=!1;this.type=t}createContainer(){let t=document.createElement("div");return t.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),t.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(t),t}removeContainer(t){t&&t.parentNode&&t.parentNode.removeChild(t)}async initialize(t=null){this._initialized=!0}isInitialized(){return this._initialized}async render(t,e){throw new Error("render() must be implemented by subclass")}async mountToDom(t,e,r){let i=await this.render(t,e);if(!i||!i.base64){let s=document.createElement("div");return s.textContent=`Renderer returned empty result: ${this.type}`,r.appendChild(s),{root:s,cleanup:()=>{try{s.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,r.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(t){if(!t||typeof t=="string"&&t.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(t){return t}calculateCanvasScale(t){return(t?.fontSize||12)/12*4}async renderSvgToCanvas(t,e,r,i=null){return t=t.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,s)=>{let a=new Image;a.crossOrigin="Anonymous";let h=btoa(unescape(encodeURIComponent(t)));a.src=`data:image/svg+xml;base64,${h}`,a.onload=()=>{let l=document.createElement("canvas");l.width=e,l.height=r;let c=l.getContext("2d");i&&(c.font=`14px ${i}`),c.drawImage(a,0,0,e,r),o(l)},a.onerror=l=>{s(new Error("Failed to load SVG into image for rendering"))}})}};k();k();function _t(n,t,e){if(n&&n.length){let[r,i]=t,o=Math.PI/180*e,s=Math.cos(o),a=Math.sin(o);for(let h of n){let[l,c]=h;h[0]=(l-r)*s-(c-i)*a+r,h[1]=(l-r)*a+(c-i)*s+i}}}function Ar(n,t){return n[0]===t[0]&&n[1]===t[1]}function Fr(n,t,e,r=1){let i=e,o=Math.max(t,.1),s=n[0]&&n[0][0]&&typeof n[0][0]=="number"?[n]:n,a=[0,0];if(i)for(let l of s)_t(l,a,i);let h=(function(l,c,u){let p=[];for(let x of l){let b=[...x];Ar(b[0],b[b.length-1])||b.push([b[0][0],b[0][1]]),b.length>2&&p.push(b)}let f=[];c=Math.max(c,.1);let g=[];for(let x of p)for(let b=0;b<x.length-1;b++){let B=x[b],S=x[b+1];if(B[1]!==S[1]){let M=Math.min(B[1],S[1]);g.push({ymin:M,ymax:Math.max(B[1],S[1]),x:M===B[1]?B[0]:S[0],islope:(S[0]-B[0])/(S[1]-B[1])})}}if(g.sort(((x,b)=>x.ymin<b.ymin?-1:x.ymin>b.ymin?1:x.x<b.x?-1:x.x>b.x?1:x.ymax===b.ymax?0:(x.ymax-b.ymax)/Math.abs(x.ymax-b.ymax))),!g.length)return f;let m=[],y=g[0].ymin,w=0;for(;m.length||g.length;){if(g.length){let x=-1;for(let b=0;b<g.length&&!(g[b].ymin>y);b++)x=b;g.splice(0,x+1).forEach((b=>{m.push({s:y,edge:b})}))}if(m=m.filter((x=>!(x.edge.ymax<=y))),m.sort(((x,b)=>x.edge.x===b.edge.x?0:(x.edge.x-b.edge.x)/Math.abs(x.edge.x-b.edge.x))),(u!==1||w%c==0)&&m.length>1)for(let x=0;x<m.length;x+=2){let b=x+1;if(b>=m.length)break;let B=m[x].edge,S=m[b].edge;f.push([[Math.round(B.x),y],[Math.round(S.x),y]])}y+=u,m.forEach((x=>{x.edge.x=x.edge.x+u*x.edge.islope})),w++}return f})(s,o,r);if(i){for(let l of s)_t(l,a,-i);(function(l,c,u){let p=[];l.forEach((f=>p.push(...f))),_t(p,c,u)})(h,a,-i)}return h}function ot(n,t){var e;let r=t.hachureAngle+90,i=t.hachureGap;i<0&&(i=4*t.strokeWidth),i=Math.round(Math.max(i,.1));let o=1;return t.roughness>=1&&(((e=t.randomizer)===null||e===void 0?void 0:e.next())||Math.random())>.7&&(o=i),Fr(n,i,r,o||1)}var it=class{constructor(t){this.helper=t}fillPolygons(t,e){return this._fillPolygons(t,e)}_fillPolygons(t,e){let r=ot(t,e);return{type:"fillSketch",ops:this.renderLines(r,e)}}renderLines(t,e){let r=[];for(let i of t)r.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],e));return r}};function xt(n){let t=n[0],e=n[1];return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}var vt=class extends it{fillPolygons(t,e){let r=e.hachureGap;r<0&&(r=4*e.strokeWidth),r=Math.max(r,.1);let i=ot(t,Object.assign({},e,{hachureGap:r})),o=Math.PI/180*e.hachureAngle,s=[],a=.5*r*Math.cos(o),h=.5*r*Math.sin(o);for(let[l,c]of i)xt([l,c])&&s.push([[l[0]-a,l[1]+h],[...c]],[[l[0]+a,l[1]-h],[...c]]);return{type:"fillSketch",ops:this.renderLines(s,e)}}},Gt=class extends it{fillPolygons(t,e){let r=this._fillPolygons(t,e),i=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),o=this._fillPolygons(t,i);return r.ops=r.ops.concat(o.ops),r}},Nt=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=ot(t,e=Object.assign({},e,{hachureAngle:0}));return this.dotsOnLines(r,e)}dotsOnLines(t,e){let r=[],i=e.hachureGap;i<0&&(i=4*e.strokeWidth),i=Math.max(i,.1);let o=e.fillWeight;o<0&&(o=e.strokeWidth/2);let s=i/4;for(let a of t){let h=xt(a),l=h/i,c=Math.ceil(l)-1,u=h-c*i,p=(a[0][0]+a[1][0])/2-i/4,f=Math.min(a[0][1],a[1][1]);for(let g=0;g<c;g++){let m=f+u+g*i,y=p-s+2*Math.random()*s,w=m-s+2*Math.random()*s,x=this.helper.ellipse(y,w,o,o,e);r.push(...x.ops)}}return{type:"fillSketch",ops:r}}},$t=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=ot(t,e);return{type:"fillSketch",ops:this.dashedLine(r,e)}}dashedLine(t,e){let r=e.dashOffset<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashOffset,i=e.dashGap<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashGap,o=[];return t.forEach((s=>{let a=xt(s),h=Math.floor(a/(r+i)),l=(a+i-h*(r+i))/2,c=s[0],u=s[1];c[0]>u[0]&&(c=s[1],u=s[0]);let p=Math.atan((u[1]-c[1])/(u[0]-c[0]));for(let f=0;f<h;f++){let g=f*(r+i),m=g+r,y=[c[0]+g*Math.cos(p)+l*Math.cos(p),c[1]+g*Math.sin(p)+l*Math.sin(p)],w=[c[0]+m*Math.cos(p)+l*Math.cos(p),c[1]+m*Math.sin(p)+l*Math.sin(p)];o.push(...this.helper.doubleLineOps(y[0],y[1],w[0],w[1],e))}})),o}},zt=class{constructor(t){this.helper=t}fillPolygons(t,e){let r=e.hachureGap<0?4*e.strokeWidth:e.hachureGap,i=e.zigzagOffset<0?r:e.zigzagOffset,o=ot(t,e=Object.assign({},e,{hachureGap:r+i}));return{type:"fillSketch",ops:this.zigzagLines(o,i,e)}}zigzagLines(t,e,r){let i=[];return t.forEach((o=>{let s=xt(o),a=Math.round(s/(2*e)),h=o[0],l=o[1];h[0]>l[0]&&(h=o[1],l=o[0]);let c=Math.atan((l[1]-h[1])/(l[0]-h[0]));for(let u=0;u<a;u++){let p=2*u*e,f=2*(u+1)*e,g=Math.sqrt(2*Math.pow(e,2)),m=[h[0]+p*Math.cos(c),h[1]+p*Math.sin(c)],y=[h[0]+f*Math.cos(c),h[1]+f*Math.sin(c)],w=[m[0]+g*Math.cos(c+Math.PI/4),m[1]+g*Math.sin(c+Math.PI/4)];i.push(...this.helper.doubleLineOps(m[0],m[1],w[0],w[1],r),...this.helper.doubleLineOps(w[0],w[1],y[0],y[1],r))}})),i}},T={},Wt=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},Tr=0,Ut=1,Ee=2,lt={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Lt(n,t){return n.type===t}function Yt(n){let t=[],e=(function(s){let a=new Array;for(;s!=="";)if(s.match(/^([ \t\r\n,]+)/))s=s.substr(RegExp.$1.length);else if(s.match(/^([aAcChHlLmMqQsStTvVzZ])/))a[a.length]={type:Tr,text:RegExp.$1},s=s.substr(RegExp.$1.length);else{if(!s.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];a[a.length]={type:Ut,text:`${parseFloat(RegExp.$1)}`},s=s.substr(RegExp.$1.length)}return a[a.length]={type:Ee,text:""},a})(n),r="BOD",i=0,o=e[i];for(;!Lt(o,Ee);){let s=0,a=[];if(r==="BOD"){if(o.text!=="M"&&o.text!=="m")return Yt("M0,0"+n);i++,s=lt[o.text],r=o.text}else Lt(o,Ut)?s=lt[r]:(i++,s=lt[o.text],r=o.text);if(!(i+s<e.length))throw new Error("Path data ended short");for(let h=i;h<i+s;h++){let l=e[h];if(!Lt(l,Ut))throw new Error("Param not a number: "+r+","+l.text);a[a.length]=+l.text}if(typeof lt[r]!="number")throw new Error("Bad segment: "+r);{let h={key:r,data:a};t.push(h),i+=s,o=e[i],r==="M"&&(r="L"),r==="m"&&(r="l")}}return t}function Te(n){let t=0,e=0,r=0,i=0,o=[];for(let{key:s,data:a}of n)switch(s){case"M":o.push({key:"M",data:[...a]}),[t,e]=a,[r,i]=a;break;case"m":t+=a[0],e+=a[1],o.push({key:"M",data:[t,e]}),r=t,i=e;break;case"L":o.push({key:"L",data:[...a]}),[t,e]=a;break;case"l":t+=a[0],e+=a[1],o.push({key:"L",data:[t,e]});break;case"C":o.push({key:"C",data:[...a]}),t=a[4],e=a[5];break;case"c":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"C",data:h}),t=h[4],e=h[5];break}case"Q":o.push({key:"Q",data:[...a]}),t=a[2],e=a[3];break;case"q":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"Q",data:h}),t=h[2],e=h[3];break}case"A":o.push({key:"A",data:[...a]}),t=a[5],e=a[6];break;case"a":t+=a[5],e+=a[6],o.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],t,e]});break;case"H":o.push({key:"H",data:[...a]}),t=a[0];break;case"h":t+=a[0],o.push({key:"H",data:[t]});break;case"V":o.push({key:"V",data:[...a]}),e=a[0];break;case"v":e+=a[0],o.push({key:"V",data:[e]});break;case"S":o.push({key:"S",data:[...a]}),t=a[2],e=a[3];break;case"s":{let h=a.map(((l,c)=>c%2?l+e:l+t));o.push({key:"S",data:h}),t=h[2],e=h[3];break}case"T":o.push({key:"T",data:[...a]}),t=a[0],e=a[1];break;case"t":t+=a[0],e+=a[1],o.push({key:"T",data:[t,e]});break;case"Z":case"z":o.push({key:"Z",data:[]}),t=r,e=i}return o}function Re(n){let t=[],e="",r=0,i=0,o=0,s=0,a=0,h=0;for(let{key:l,data:c}of n){switch(l){case"M":t.push({key:"M",data:[...c]}),[r,i]=c,[o,s]=c;break;case"C":t.push({key:"C",data:[...c]}),r=c[4],i=c[5],a=c[2],h=c[3];break;case"L":t.push({key:"L",data:[...c]}),[r,i]=c;break;case"H":r=c[0],t.push({key:"L",data:[r,i]});break;case"V":i=c[0],t.push({key:"L",data:[r,i]});break;case"S":{let u=0,p=0;e==="C"||e==="S"?(u=r+(r-a),p=i+(i-h)):(u=r,p=i),t.push({key:"C",data:[u,p,...c]}),a=c[0],h=c[1],r=c[2],i=c[3];break}case"T":{let[u,p]=c,f=0,g=0;e==="Q"||e==="T"?(f=r+(r-a),g=i+(i-h)):(f=r,g=i);let m=r+2*(f-r)/3,y=i+2*(g-i)/3,w=u+2*(f-u)/3,x=p+2*(g-p)/3;t.push({key:"C",data:[m,y,w,x,u,p]}),a=f,h=g,r=u,i=p;break}case"Q":{let[u,p,f,g]=c,m=r+2*(u-r)/3,y=i+2*(p-i)/3,w=f+2*(u-f)/3,x=g+2*(p-g)/3;t.push({key:"C",data:[m,y,w,x,f,g]}),a=u,h=p,r=f,i=g;break}case"A":{let u=Math.abs(c[0]),p=Math.abs(c[1]),f=c[2],g=c[3],m=c[4],y=c[5],w=c[6];u===0||p===0?(t.push({key:"C",data:[r,i,y,w,y,w]}),r=y,i=w):(r!==y||i!==w)&&(Ce(r,i,y,w,u,p,f,g,m).forEach((function(x){t.push({key:"C",data:x})})),r=y,i=w);break}case"Z":t.push({key:"Z",data:[]}),r=o,i=s}e=l}return t}function rt(n,t,e){return[n*Math.cos(e)-t*Math.sin(e),n*Math.sin(e)+t*Math.cos(e)]}function Ce(n,t,e,r,i,o,s,a,h,l){let c=(u=s,Math.PI*u/180);var u;let p=[],f=0,g=0,m=0,y=0;if(l)[f,g,m,y]=l;else{[n,t]=rt(n,t,-c),[e,r]=rt(e,r,-c);let P=(n-e)/2,I=(t-r)/2,D=P*P/(i*i)+I*I/(o*o);D>1&&(D=Math.sqrt(D),i*=D,o*=D);let j=i*i,Z=o*o,Ge=j*Z-j*I*I-Z*P*P,Ne=j*I*I+Z*P*P,Xt=(a===h?-1:1)*Math.sqrt(Math.abs(Ge/Ne));m=Xt*i*I/o+(n+e)/2,y=Xt*-o*P/i+(t+r)/2,f=Math.asin(parseFloat(((t-y)/o).toFixed(9))),g=Math.asin(parseFloat(((r-y)/o).toFixed(9))),n<m&&(f=Math.PI-f),e<m&&(g=Math.PI-g),f<0&&(f=2*Math.PI+f),g<0&&(g=2*Math.PI+g),h&&f>g&&(f-=2*Math.PI),!h&&g>f&&(g-=2*Math.PI)}let w=g-f;if(Math.abs(w)>120*Math.PI/180){let P=g,I=e,D=r;g=h&&g>f?f+120*Math.PI/180*1:f+120*Math.PI/180*-1,p=Ce(e=m+i*Math.cos(g),r=y+o*Math.sin(g),I,D,i,o,s,0,h,[g,P,m,y])}w=g-f;let x=Math.cos(f),b=Math.sin(f),B=Math.cos(g),S=Math.sin(g),M=Math.tan(w/4),C=4/3*i*M,L=4/3*o*M,st=[n,t],U=[n+C*b,t-L*x],W=[e+C*S,r-L*B],Qt=[e,r];if(U[0]=2*st[0]-U[0],U[1]=2*st[1]-U[1],l)return[U,W,Qt].concat(p);{p=[U,W,Qt].concat(p);let P=[];for(let I=0;I<p.length;I+=3){let D=rt(p[I][0],p[I][1],c),j=rt(p[I+1][0],p[I+1][1],c),Z=rt(p[I+2][0],p[I+2][1],c);P.push([D[0],D[1],j[0],j[1],Z[0],Z[1]])}return P}}var Rr={randOffset:function(n,t){return E(n,t)},randOffsetWithRange:function(n,t,e){return mt(n,t,e)},ellipse:function(n,t,e,r,i){let o=_e(e,r,i);return qt(n,t,i,o).opset},doubleLineOps:function(n,t,e,r,i){return z(n,t,e,r,i,!0)}};function Pe(n,t,e,r,i){return{type:"path",ops:z(n,t,e,r,i)}}function dt(n,t,e){let r=(n||[]).length;if(r>2){let i=[];for(let o=0;o<r-1;o++)i.push(...z(n[o][0],n[o][1],n[o+1][0],n[o+1][1],e));return t&&i.push(...z(n[r-1][0],n[r-1][1],n[0][0],n[0][1],e)),{type:"path",ops:i}}return r===2?Pe(n[0][0],n[0][1],n[1][0],n[1][1],e):{type:"path",ops:[]}}function Cr(n,t,e,r,i){return(function(o,s){return dt(o,!0,s)})([[n,t],[n+e,t],[n+e,t+r],[n,t+r]],i)}function Me(n,t){if(n.length){let e=typeof n[0][0]=="number"?[n]:n,r=ft(e[0],1*(1+.2*t.roughness),t),i=t.disableMultiStroke?[]:ft(e[0],1.5*(1+.22*t.roughness),Se(t));for(let o=1;o<e.length;o++){let s=e[o];if(s.length){let a=ft(s,1*(1+.2*t.roughness),t),h=t.disableMultiStroke?[]:ft(s,1.5*(1+.22*t.roughness),Se(t));for(let l of a)l.op!=="move"&&r.push(l);for(let l of h)l.op!=="move"&&i.push(l)}}return{type:"path",ops:r.concat(i)}}return{type:"path",ops:[]}}function _e(n,t,e){let r=Math.sqrt(2*Math.PI*Math.sqrt((Math.pow(n/2,2)+Math.pow(t/2,2))/2)),i=Math.ceil(Math.max(e.curveStepCount,e.curveStepCount/Math.sqrt(200)*r)),o=2*Math.PI/i,s=Math.abs(n/2),a=Math.abs(t/2),h=1-e.curveFitting;return s+=E(s*h,e),a+=E(a*h,e),{increment:o,rx:s,ry:a}}function qt(n,t,e,r){let[i,o]=Ie(r.increment,n,t,r.rx,r.ry,1,r.increment*mt(.1,mt(.4,1,e),e),e),s=yt(i,null,e);if(!e.disableMultiStroke&&e.roughness!==0){let[a]=Ie(r.increment,n,t,r.rx,r.ry,1.5,0,e),h=yt(a,null,e);s=s.concat(h)}return{estimatedPoints:o,opset:{type:"path",ops:s}}}function ke(n,t,e,r,i,o,s,a,h){let l=n,c=t,u=Math.abs(e/2),p=Math.abs(r/2);u+=E(.01*u,h),p+=E(.01*p,h);let f=i,g=o;for(;f<0;)f+=2*Math.PI,g+=2*Math.PI;g-f>2*Math.PI&&(f=0,g=2*Math.PI);let m=2*Math.PI/h.curveStepCount,y=Math.min(m/2,(g-f)/2),w=Ae(y,l,c,u,p,f,g,1,h);if(!h.disableMultiStroke){let x=Ae(y,l,c,u,p,f,g,1.5,h);w.push(...x)}return s&&(a?w.push(...z(l,c,l+u*Math.cos(f),c+p*Math.sin(f),h),...z(l,c,l+u*Math.cos(g),c+p*Math.sin(g),h)):w.push({op:"lineTo",data:[l,c]},{op:"lineTo",data:[l+u*Math.cos(f),c+p*Math.sin(f)]})),{type:"path",ops:w}}function Be(n,t){let e=Re(Te(Yt(n))),r=[],i=[0,0],o=[0,0];for(let{key:s,data:a}of e)switch(s){case"M":o=[a[0],a[1]],i=[a[0],a[1]];break;case"L":r.push(...z(o[0],o[1],a[0],a[1],t)),o=[a[0],a[1]];break;case"C":{let[h,l,c,u,p,f]=a;r.push(...Pr(h,l,c,u,p,f,o,t)),o=[p,f];break}case"Z":r.push(...z(o[0],o[1],i[0],i[1],t)),o=[i[0],i[1]]}return{type:"path",ops:r}}function Dt(n,t){let e=[];for(let r of n)if(r.length){let i=t.maxRandomnessOffset||0,o=r.length;if(o>2){e.push({op:"move",data:[r[0][0]+E(i,t),r[0][1]+E(i,t)]});for(let s=1;s<o;s++)e.push({op:"lineTo",data:[r[s][0]+E(i,t),r[s][1]+E(i,t)]})}}return{type:"fillPath",ops:e}}function K(n,t){return(function(e,r){let i=e.fillStyle||"hachure";if(!T[i])switch(i){case"zigzag":T[i]||(T[i]=new vt(r));break;case"cross-hatch":T[i]||(T[i]=new Gt(r));break;case"dots":T[i]||(T[i]=new Nt(r));break;case"dashed":T[i]||(T[i]=new $t(r));break;case"zigzag-line":T[i]||(T[i]=new zt(r));break;default:i="hachure",T[i]||(T[i]=new it(r))}return T[i]})(t,Rr).fillPolygons(n,t)}function Se(n){let t=Object.assign({},n);return t.randomizer=void 0,n.seed&&(t.seed=n.seed+1),t}function Ue(n){return n.randomizer||(n.randomizer=new Wt(n.seed||0)),n.randomizer.next()}function mt(n,t,e,r=1){return e.roughness*r*(Ue(e)*(t-n)+n)}function E(n,t,e=1){return mt(-n,n,t,e)}function z(n,t,e,r,i,o=!1){let s=o?i.disableMultiStrokeFill:i.disableMultiStroke,a=Vt(n,t,e,r,i,!0,!1);if(s)return a;let h=Vt(n,t,e,r,i,!0,!0);return a.concat(h)}function Vt(n,t,e,r,i,o,s){let a=Math.pow(n-e,2)+Math.pow(t-r,2),h=Math.sqrt(a),l=1;l=h<200?1:h>500?.4:-.0016668*h+1.233334;let c=i.maxRandomnessOffset||0;c*c*100>a&&(c=h/10);let u=c/2,p=.2+.2*Ue(i),f=i.bowing*i.maxRandomnessOffset*(r-t)/200,g=i.bowing*i.maxRandomnessOffset*(n-e)/200;f=E(f,i,l),g=E(g,i,l);let m=[],y=()=>E(u,i,l),w=()=>E(c,i,l),x=i.preserveVertices;return o&&(s?m.push({op:"move",data:[n+(x?0:y()),t+(x?0:y())]}):m.push({op:"move",data:[n+(x?0:E(c,i,l)),t+(x?0:E(c,i,l))]})),s?m.push({op:"bcurveTo",data:[f+n+(e-n)*p+y(),g+t+(r-t)*p+y(),f+n+2*(e-n)*p+y(),g+t+2*(r-t)*p+y(),e+(x?0:y()),r+(x?0:y())]}):m.push({op:"bcurveTo",data:[f+n+(e-n)*p+w(),g+t+(r-t)*p+w(),f+n+2*(e-n)*p+w(),g+t+2*(r-t)*p+w(),e+(x?0:w()),r+(x?0:w())]}),m}function ft(n,t,e){if(!n.length)return[];let r=[];r.push([n[0][0]+E(t,e),n[0][1]+E(t,e)]),r.push([n[0][0]+E(t,e),n[0][1]+E(t,e)]);for(let i=1;i<n.length;i++)r.push([n[i][0]+E(t,e),n[i][1]+E(t,e)]),i===n.length-1&&r.push([n[i][0]+E(t,e),n[i][1]+E(t,e)]);return yt(r,null,e)}function yt(n,t,e){let r=n.length,i=[];if(r>3){let o=[],s=1-e.curveTightness;i.push({op:"move",data:[n[1][0],n[1][1]]});for(let a=1;a+2<r;a++){let h=n[a];o[0]=[h[0],h[1]],o[1]=[h[0]+(s*n[a+1][0]-s*n[a-1][0])/6,h[1]+(s*n[a+1][1]-s*n[a-1][1])/6],o[2]=[n[a+1][0]+(s*n[a][0]-s*n[a+2][0])/6,n[a+1][1]+(s*n[a][1]-s*n[a+2][1])/6],o[3]=[n[a+1][0],n[a+1][1]],i.push({op:"bcurveTo",data:[o[1][0],o[1][1],o[2][0],o[2][1],o[3][0],o[3][1]]})}if(t&&t.length===2){let a=e.maxRandomnessOffset;i.push({op:"lineTo",data:[t[0]+E(a,e),t[1]+E(a,e)]})}}else r===3?(i.push({op:"move",data:[n[1][0],n[1][1]]}),i.push({op:"bcurveTo",data:[n[1][0],n[1][1],n[2][0],n[2][1],n[2][0],n[2][1]]})):r===2&&i.push(...Vt(n[0][0],n[0][1],n[1][0],n[1][1],e,!0,!0));return i}function Ie(n,t,e,r,i,o,s,a){let h=[],l=[];if(a.roughness===0){n/=4,l.push([t+r*Math.cos(-n),e+i*Math.sin(-n)]);for(let c=0;c<=2*Math.PI;c+=n){let u=[t+r*Math.cos(c),e+i*Math.sin(c)];h.push(u),l.push(u)}l.push([t+r*Math.cos(0),e+i*Math.sin(0)]),l.push([t+r*Math.cos(n),e+i*Math.sin(n)])}else{let c=E(.5,a)-Math.PI/2;l.push([E(o,a)+t+.9*r*Math.cos(c-n),E(o,a)+e+.9*i*Math.sin(c-n)]);let u=2*Math.PI+c-.01;for(let p=c;p<u;p+=n){let f=[E(o,a)+t+r*Math.cos(p),E(o,a)+e+i*Math.sin(p)];h.push(f),l.push(f)}l.push([E(o,a)+t+r*Math.cos(c+2*Math.PI+.5*s),E(o,a)+e+i*Math.sin(c+2*Math.PI+.5*s)]),l.push([E(o,a)+t+.98*r*Math.cos(c+s),E(o,a)+e+.98*i*Math.sin(c+s)]),l.push([E(o,a)+t+.9*r*Math.cos(c+.5*s),E(o,a)+e+.9*i*Math.sin(c+.5*s)])}return[l,h]}function Ae(n,t,e,r,i,o,s,a,h){let l=o+E(.1,h),c=[];c.push([E(a,h)+t+.9*r*Math.cos(l-n),E(a,h)+e+.9*i*Math.sin(l-n)]);for(let u=l;u<=s;u+=n)c.push([E(a,h)+t+r*Math.cos(u),E(a,h)+e+i*Math.sin(u)]);return c.push([t+r*Math.cos(s),e+i*Math.sin(s)]),c.push([t+r*Math.cos(s),e+i*Math.sin(s)]),yt(c,null,h)}function Pr(n,t,e,r,i,o,s,a){let h=[],l=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3],c=[0,0],u=a.disableMultiStroke?1:2,p=a.preserveVertices;for(let f=0;f<u;f++)f===0?h.push({op:"move",data:[s[0],s[1]]}):h.push({op:"move",data:[s[0]+(p?0:E(l[0],a)),s[1]+(p?0:E(l[0],a))]}),c=p?[i,o]:[i+E(l[f],a),o+E(l[f],a)],h.push({op:"bcurveTo",data:[n+E(l[f],a),t+E(l[f],a),e+E(l[f],a),r+E(l[f],a),c[0],c[1]]});return h}function nt(n){return[...n]}function Fe(n,t=0){let e=n.length;if(e<3)throw new Error("A curve must have at least three points.");let r=[];if(e===3)r.push(nt(n[0]),nt(n[1]),nt(n[2]),nt(n[2]));else{let i=[];i.push(n[0],n[0]);for(let a=1;a<n.length;a++)i.push(n[a]),a===n.length-1&&i.push(n[a]);let o=[],s=1-t;r.push(nt(i[0]));for(let a=1;a+2<i.length;a++){let h=i[a];o[0]=[h[0],h[1]],o[1]=[h[0]+(s*i[a+1][0]-s*i[a-1][0])/6,h[1]+(s*i[a+1][1]-s*i[a-1][1])/6],o[2]=[i[a+1][0]+(s*i[a][0]-s*i[a+2][0])/6,i[a+1][1]+(s*i[a][1]-s*i[a+2][1])/6],o[3]=[i[a+1][0],i[a+1][1]],r.push(o[1],o[2],o[3])}}return r}function gt(n,t){return Math.pow(n[0]-t[0],2)+Math.pow(n[1]-t[1],2)}function _r(n,t,e){let r=gt(t,e);if(r===0)return gt(n,t);let i=((n[0]-t[0])*(e[0]-t[0])+(n[1]-t[1])*(e[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),gt(n,H(t,e,i))}function H(n,t,e){return[n[0]+(t[0]-n[0])*e,n[1]+(t[1]-n[1])*e]}function Ht(n,t,e,r){let i=r||[];if((function(a,h){let l=a[h+0],c=a[h+1],u=a[h+2],p=a[h+3],f=3*c[0]-2*l[0]-p[0];f*=f;let g=3*c[1]-2*l[1]-p[1];g*=g;let m=3*u[0]-2*p[0]-l[0];m*=m;let y=3*u[1]-2*p[1]-l[1];return y*=y,f<m&&(f=m),g<y&&(g=y),f+g})(n,t)<e){let a=n[t+0];i.length?(o=i[i.length-1],s=a,Math.sqrt(gt(o,s))>1&&i.push(a)):i.push(a),i.push(n[t+3])}else{let h=n[t+0],l=n[t+1],c=n[t+2],u=n[t+3],p=H(h,l,.5),f=H(l,c,.5),g=H(c,u,.5),m=H(p,f,.5),y=H(f,g,.5),w=H(m,y,.5);Ht([h,p,m,w],0,e,i),Ht([w,y,g,u],0,e,i)}var o,s;return i}function Ur(n,t){return wt(n,0,n.length,t)}function wt(n,t,e,r,i){let o=i||[],s=n[t],a=n[e-1],h=0,l=1;for(let c=t+1;c<e-1;++c){let u=_r(n[c],s,a);u>h&&(h=u,l=c)}return Math.sqrt(h)>r?(wt(n,t,l+1,r,o),wt(n,l,e,r,o)):(o.length||o.push(s),o.push(a)),o}function Ot(n,t=.15,e){let r=[],i=(n.length-1)/3;for(let o=0;o<i;o++)Ht(n,3*o,t,r);return e&&e>0?wt(r,0,r.length,e):r}var R="none",tt=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,e,r){return{shape:t,sets:e||[],options:r||this.defaultOptions}}line(t,e,r,i,o){let s=this._o(o);return this._d("line",[Pe(t,e,r,i,s)],s)}rectangle(t,e,r,i,o){let s=this._o(o),a=[],h=Cr(t,e,r,i,s);if(s.fill){let l=[[t,e],[t+r,e],[t+r,e+i],[t,e+i]];s.fillStyle==="solid"?a.push(Dt([l],s)):a.push(K([l],s))}return s.stroke!==R&&a.push(h),this._d("rectangle",a,s)}ellipse(t,e,r,i,o){let s=this._o(o),a=[],h=_e(r,i,s),l=qt(t,e,s,h);if(s.fill)if(s.fillStyle==="solid"){let c=qt(t,e,s,h).opset;c.type="fillPath",a.push(c)}else a.push(K([l.estimatedPoints],s));return s.stroke!==R&&a.push(l.opset),this._d("ellipse",a,s)}circle(t,e,r,i){let o=this.ellipse(t,e,r,r,i);return o.shape="circle",o}linearPath(t,e){let r=this._o(e);return this._d("linearPath",[dt(t,!1,r)],r)}arc(t,e,r,i,o,s,a=!1,h){let l=this._o(h),c=[],u=ke(t,e,r,i,o,s,a,!0,l);if(a&&l.fill)if(l.fillStyle==="solid"){let p=Object.assign({},l);p.disableMultiStroke=!0;let f=ke(t,e,r,i,o,s,!0,!1,p);f.type="fillPath",c.push(f)}else c.push((function(p,f,g,m,y,w,x){let b=p,B=f,S=Math.abs(g/2),M=Math.abs(m/2);S+=E(.01*S,x),M+=E(.01*M,x);let C=y,L=w;for(;C<0;)C+=2*Math.PI,L+=2*Math.PI;L-C>2*Math.PI&&(C=0,L=2*Math.PI);let st=(L-C)/x.curveStepCount,U=[];for(let W=C;W<=L;W+=st)U.push([b+S*Math.cos(W),B+M*Math.sin(W)]);return U.push([b+S*Math.cos(L),B+M*Math.sin(L)]),U.push([b,B]),K([U],x)})(t,e,r,i,o,s,l));return l.stroke!==R&&c.push(u),this._d("arc",c,l)}curve(t,e){let r=this._o(e),i=[],o=Me(t,r);if(r.fill&&r.fill!==R)if(r.fillStyle==="solid"){let s=Me(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(s.ops)})}else{let s=[],a=t;if(a.length){let h=typeof a[0][0]=="number"?[a]:a;for(let l of h)l.length<3?s.push(...l):l.length===3?s.push(...Ot(Fe([l[0],l[0],l[1],l[2]]),10,(1+r.roughness)/2)):s.push(...Ot(Fe(l),10,(1+r.roughness)/2))}s.length&&i.push(K([s],r))}return r.stroke!==R&&i.push(o),this._d("curve",i,r)}polygon(t,e){let r=this._o(e),i=[],o=dt(t,!0,r);return r.fill&&(r.fillStyle==="solid"?i.push(Dt([t],r)):i.push(K([t],r))),r.stroke!==R&&i.push(o),this._d("polygon",i,r)}path(t,e){let r=this._o(e),i=[];if(!t)return this._d("path",i,r);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let o=r.fill&&r.fill!=="transparent"&&r.fill!==R,s=r.stroke!==R,a=!!(r.simplification&&r.simplification<1),h=(function(c,u,p){let f=Re(Te(Yt(c))),g=[],m=[],y=[0,0],w=[],x=()=>{w.length>=4&&m.push(...Ot(w,u)),w=[]},b=()=>{x(),m.length&&(g.push(m),m=[])};for(let{key:S,data:M}of f)switch(S){case"M":b(),y=[M[0],M[1]],m.push(y);break;case"L":x(),m.push([M[0],M[1]]);break;case"C":if(!w.length){let C=m.length?m[m.length-1]:y;w.push([C[0],C[1]])}w.push([M[0],M[1]]),w.push([M[2],M[3]]),w.push([M[4],M[5]]);break;case"Z":x(),m.push([y[0],y[1]])}if(b(),!p)return g;let B=[];for(let S of g){let M=Ur(S,p);M.length&&B.push(M)}return B})(t,1,a?4-4*(r.simplification||1):(1+r.roughness)/2),l=Be(t,r);if(o)if(r.fillStyle==="solid")if(h.length===1){let c=Be(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(c.ops)})}else i.push(Dt(h,r));else i.push(K(h,r));return s&&(a?h.forEach((c=>{i.push(dt(c,!1,r))})):i.push(l)),this._d("path",i,r)}opsToPath(t,e){let r="";for(let i of t.ops){let o=typeof e=="number"&&e>=0?i.data.map((s=>+s.toFixed(e))):i.data;switch(i.op){case"move":r+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":r+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":r+=`L${o[0]} ${o[1]} `}}return r.trim()}toPaths(t){let e=t.sets||[],r=t.options||this.defaultOptions,i=[];for(let o of e){let s=null;switch(o.type){case"path":s={d:this.opsToPath(o),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:R};break;case"fillPath":s={d:this.opsToPath(o),stroke:R,strokeWidth:0,fill:r.fill||R};break;case"fillSketch":s=this.fillSketch(o,r)}s&&i.push(s)}return i}fillSketch(t,e){let r=e.fillWeight;return r<0&&(r=e.strokeWidth/2),{d:this.opsToPath(t),stroke:e.fill||R,strokeWidth:r,fill:R}}_mergedShape(t){return t.filter(((e,r)=>r===0||e.op!=="move"))}},jt=class{constructor(t,e){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new tt(e)}draw(t){let e=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.ctx,o=t.options.fixedDecimalPlaceDigits;for(let s of e)switch(s.type){case"path":i.save(),i.strokeStyle=r.stroke==="none"?"transparent":r.stroke,i.lineWidth=r.strokeWidth,r.strokeLineDash&&i.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(i.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(i,s,o),i.restore();break;case"fillPath":{i.save(),i.fillStyle=r.fill||"";let a=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(i,s,o,a),i.restore();break}case"fillSketch":this.fillSketch(i,s,r)}}fillSketch(t,e,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2),t.save(),r.fillLineDash&&t.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(t.lineDashOffset=r.fillLineDashOffset),t.strokeStyle=r.fill||"",t.lineWidth=i,this._drawToContext(t,e,r.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,e,r,i="nonzero"){t.beginPath();for(let o of e.ops){let s=typeof r=="number"&&r>=0?o.data.map((a=>+a.toFixed(r))):o.data;switch(o.op){case"move":t.moveTo(s[0],s[1]);break;case"bcurveTo":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"lineTo":t.lineTo(s[0],s[1])}}e.type==="fillPath"?t.fill(i):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,e,r,i,o){let s=this.gen.line(t,e,r,i,o);return this.draw(s),s}rectangle(t,e,r,i,o){let s=this.gen.rectangle(t,e,r,i,o);return this.draw(s),s}ellipse(t,e,r,i,o){let s=this.gen.ellipse(t,e,r,i,o);return this.draw(s),s}circle(t,e,r,i){let o=this.gen.circle(t,e,r,i);return this.draw(o),o}linearPath(t,e){let r=this.gen.linearPath(t,e);return this.draw(r),r}polygon(t,e){let r=this.gen.polygon(t,e);return this.draw(r),r}arc(t,e,r,i,o,s,a=!1,h){let l=this.gen.arc(t,e,r,i,o,s,a,h);return this.draw(l),l}curve(t,e){let r=this.gen.curve(t,e);return this.draw(r),r}path(t,e){let r=this.gen.path(t,e);return this.draw(r),r}},pt="http://www.w3.org/2000/svg",Zt=class{constructor(t,e){this.svg=t,this.gen=new tt(e)}draw(t){let e=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.svg.ownerDocument||window.document,o=i.createElementNS(pt,"g"),s=t.options.fixedDecimalPlaceDigits;for(let a of e){let h=null;switch(a.type){case"path":h=i.createElementNS(pt,"path"),h.setAttribute("d",this.opsToPath(a,s)),h.setAttribute("stroke",r.stroke),h.setAttribute("stroke-width",r.strokeWidth+""),h.setAttribute("fill","none"),r.strokeLineDash&&h.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&h.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break;case"fillPath":h=i.createElementNS(pt,"path"),h.setAttribute("d",this.opsToPath(a,s)),h.setAttribute("stroke","none"),h.setAttribute("stroke-width","0"),h.setAttribute("fill",r.fill||""),t.shape!=="curve"&&t.shape!=="polygon"||h.setAttribute("fill-rule","evenodd");break;case"fillSketch":h=this.fillSketch(i,a,r)}h&&o.appendChild(h)}return o}fillSketch(t,e,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2);let o=t.createElementNS(pt,"path");return o.setAttribute("d",this.opsToPath(e,r.fixedDecimalPlaceDigits)),o.setAttribute("stroke",r.fill||""),o.setAttribute("stroke-width",i+""),o.setAttribute("fill","none"),r.fillLineDash&&o.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&o.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),o}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,e){return this.gen.opsToPath(t,e)}line(t,e,r,i,o){let s=this.gen.line(t,e,r,i,o);return this.draw(s)}rectangle(t,e,r,i,o){let s=this.gen.rectangle(t,e,r,i,o);return this.draw(s)}ellipse(t,e,r,i,o){let s=this.gen.ellipse(t,e,r,i,o);return this.draw(s)}circle(t,e,r,i){let o=this.gen.circle(t,e,r,i);return this.draw(o)}linearPath(t,e){let r=this.gen.linearPath(t,e);return this.draw(r)}polygon(t,e){let r=this.gen.polygon(t,e);return this.draw(r)}arc(t,e,r,i,o,s,a=!1,h){let l=this.gen.arc(t,e,r,i,o,s,a,h);return this.draw(l)}curve(t,e){let r=this.gen.curve(t,e);return this.draw(r)}path(t,e){let r=this.gen.path(t,e);return this.draw(r)}},Le={canvas:(n,t)=>new jt(n,t),svg:(n,t)=>new Zt(n,t),generator:n=>new tt(n),newSeed:()=>tt.newSeed()};var Lr={roughness:.5,bowing:.5,fillStyle:"hachure",fillWeight:.5,hachureGap:4,defaultBorderColor:"#333"};function De(n,t={}){let e={...Lr,...t},r={roughness:e.roughness,bowing:e.bowing},i=document.createElement("div");i.style.cssText="position: absolute; left: -9999px; top: -9999px;",i.innerHTML=n,document.body.appendChild(i);let o=i.querySelector("svg");if(!o)return document.body.removeChild(i),n;let s=Le.svg(o),a=u=>{let p=u.getAttribute("stroke");if(p&&p!=="none")return p;let f=window.getComputedStyle(u).stroke;return f&&f!=="none"&&f!==""?f:null},h=u=>{let p=u.getAttribute("fill");if(p&&p!=="none")return p;let f=window.getComputedStyle(u).fill;return f&&f!=="none"&&f!==""?f:null},l=u=>{u.setAttribute("stroke","none"),u.style.stroke="none"},c=u=>{let p=u.parentElement;for(;p;){let f=p.tagName.toLowerCase();if(f==="defs"||f==="marker")return!0;p=p.parentElement}return!1};return o.querySelectorAll("rect").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("x")||"0"),m=parseFloat(u.getAttribute("y")||"0"),y=parseFloat(u.getAttribute("width")||"0"),w=parseFloat(u.getAttribute("height")||"0");if(y<=0||w<=0)return;let x=p||e.defaultBorderColor,b=s.rectangle(g,m,y,w,{...r,stroke:x,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(b,u),u.remove()}),o.querySelectorAll("circle").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("cx")||"0"),m=parseFloat(u.getAttribute("cy")||"0"),y=parseFloat(u.getAttribute("r")||"0");if(y<=0)return;let w=p||e.defaultBorderColor,x=s.circle(g,m,y*2,{...r,stroke:w,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(x,u),u.remove()}),o.querySelectorAll("ellipse").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let g=parseFloat(u.getAttribute("cx")||"0"),m=parseFloat(u.getAttribute("cy")||"0"),y=parseFloat(u.getAttribute("rx")||"0"),w=parseFloat(u.getAttribute("ry")||"0");if(y<=0||w<=0)return;let x=p||e.defaultBorderColor,b=s.ellipse(g,m,y*2,w*2,{...r,stroke:x,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(b,u),u.remove()}),o.querySelectorAll("polygon").forEach(u=>{if(c(u))return;let p=a(u),f=h(u);if(!p&&!f)return;let m=(u.getAttribute("points")||"").trim().split(/\s+/).map(x=>{let[b,B]=x.split(",").map(Number);return[b,B]});if(m.length<3)return;let y=p||e.defaultBorderColor,w=s.polygon(m,{...r,stroke:y,fill:f||"none",fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureGap:e.hachureGap});u.parentNode?.insertBefore(w,u),u.remove()}),o.querySelectorAll("line").forEach(u=>{if(c(u))return;let p=a(u);if(!p)return;let f=parseFloat(u.getAttribute("x1")||"0"),g=parseFloat(u.getAttribute("y1")||"0"),m=parseFloat(u.getAttribute("x2")||"0"),y=parseFloat(u.getAttribute("y2")||"0"),w=s.line(f,g,m,y,{...r,stroke:p}),x=u.getAttribute("marker-end"),b=u.getAttribute("marker-start");x||b?(l(u),u.parentNode?.insertBefore(w,u)):u.parentNode?.replaceChild(w,u)}),o.querySelectorAll("path").forEach(u=>{if(c(u))return;let p=a(u),f=h(u),g=u.getAttribute("d");if(!p||!g||f&&f!=="rgb(0, 0, 0)")return;let m=s.path(g,{...r,stroke:p,fill:"none"}),y=u.getAttribute("marker-end"),w=u.getAttribute("marker-start");y||w?(l(u),u.parentNode?.insertBefore(m,u)):u.parentNode?.replaceChild(m,u)}),document.body.removeChild(i),new XMLSerializer().serializeToString(o)}function Oe(){let n=window.mermaid;if(!n)throw new Error("Mermaid library not loaded. Ensure lib-mermaid.js is loaded before render-worker.js");return n}var bt=class extends ct{constructor(){super("mermaid");this.roughOptions={roughness:.5,bowing:.5}}async initialize(e=null){this.applyThemeConfig(e),this._initialized=!0}applyThemeConfig(e=null){let r=e?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",i=e?.diagramStyle==="handDrawn";Oe().initialize({startOnLoad:!1,securityLevel:"loose",look:i?"handDrawn":"classic",themeVariables:{fontFamily:r,background:"transparent"},flowchart:{htmlLabels:!0,curve:"basis"}})}isSequenceDiagram(e){return e.trim().toLowerCase().startsWith("sequencediagram")}preprocessCode(e){return e.replace(/\\n/g,"<br>")}applyRoughEffectToSvg(e,r){return r?.diagramStyle==="handDrawn"?De(e,this.roughOptions):e}async render(e,r){this._initialized||await this.initialize(r),this.validateInput(e),e=this.preprocessCode(e),this.applyThemeConfig(r);let i=this.createContainer();i.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let o="mermaid-diagram-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),{svg:s}=await Oe().render(o,e);if(!s||s.length<100)throw new Error("Generated SVG is too small or empty");if(!s.includes("<svg")||!s.includes("</svg>"))throw new Error("Generated content is not valid SVG");i.innerHTML=s;let a=i.querySelector("svg");if(!a)throw new Error("SVG element not found in rendered content");i.offsetHeight,a.getBoundingClientRect(),await new Promise(w=>setTimeout(w,100)),document.fonts&&document.fonts.ready&&await document.fonts.ready,i.offsetHeight,a.getBoundingClientRect(),await new Promise(w=>setTimeout(w,50));let h=a.getAttribute("viewBox"),l,c;if(h){let w=h.split(/\s+/);l=Math.ceil(parseFloat(w[2])),c=Math.ceil(parseFloat(w[3]))}else l=Math.ceil(parseFloat(a.getAttribute("width")||"800")),c=Math.ceil(parseFloat(a.getAttribute("height")||"600"));let u=r?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",p=this.calculateCanvasScale(r),f=this.isSequenceDiagram(e)?this.applyRoughEffectToSvg(s,r):s,g=await this.renderSvgToCanvas(f,l*p,c*p,u),y=g.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,"");return this.removeContainer(i),{base64:y,width:g.width,height:g.height,format:"png"}}};function Dr(){let n=window.mermaid;if(!n)throw new Error("Mermaid library not loaded.");return n}var Et=class extends bt{async mountToDom(t,e,r){if(this._initialized||await this.initialize(e),typeof t!="string")throw new Error("Mermaid input must be a string");let i=t;this.validateInput(i);let o=this.preprocessCode(i);this.applyThemeConfig(e);let s="mermaid-diagram-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),{svg:a}=await Dr().render(s,o),h=this.isSequenceDiagram(o)?this.applyRoughEffectToSvg(a,e):a;r.innerHTML=h;let c=r.querySelector("svg")||r,u=(async()=>{try{document.fonts?.ready&&await document.fonts.ready}catch{}try{typeof globalThis.requestAnimationFrame=="function"&&(await new Promise(p=>globalThis.requestAnimationFrame(()=>p())),await new Promise(p=>globalThis.requestAnimationFrame(()=>p())))}catch{}})();return{root:c,cleanup:()=>{try{r.innerHTML=""}catch{}},done:u}}};k();function Or(){return globalThis}function vr(){let n=Or();return n.__md2x_renderer_registry__||(n.__md2x_renderer_registry__=new Map),n.__md2x_renderer_registry__}function ve(n){vr().set(n.type,n)}ve(new Et);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js:
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var Br=Object.create;var J=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Fr=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var Ur=(e,r)=>()=>(e&&(r=e(e=0)),r);var P=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Rr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ir(r))!Ar.call(e,i)&&i!==t&&J(e,i,{get:()=>r[i],enumerable:!(n=Er(r,i))||n.enumerable});return e};var Tr=(e,r,t)=>(t=e!=null?Br(Fr(e)):{},Rr(r||!e||!e.__esModule?J(t,"default",{value:e,enumerable:!0}):t,e));var Q=P(S=>{"use strict";y();S.byteLength=br;S.toByteArray=Sr;S.fromByteArray=Dr;var m=[],x=[],Cr=typeof Uint8Array<"u"?Uint8Array:Array,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(F=0,K=O.length;F<K;++F)m[F]=O[F],x[O.charCodeAt(F)]=F;var F,K;x[45]=62;x[95]=63;function Z(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function br(e){var r=Z(e),t=r[0],n=r[1];return(t+n)*3/4-n}function _r(e,r,t){return(r+t)*3/4-t}function Sr(e){var r,t=Z(e),n=t[0],i=t[1],o=new Cr(_r(e,n,i)),u=0,c=i>0?n-4:n,h;for(h=0;h<c;h+=4)r=x[e.charCodeAt(h)]<<18|x[e.charCodeAt(h+1)]<<12|x[e.charCodeAt(h+2)]<<6|x[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return i===2&&(r=x[e.charCodeAt(h)]<<2|x[e.charCodeAt(h+1)]>>4,o[u++]=r&255),i===1&&(r=x[e.charCodeAt(h)]<<10|x[e.charCodeAt(h+1)]<<4|x[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Mr(e){return m[e>>18&63]+m[e>>12&63]+m[e>>6&63]+m[e&63]}function Lr(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Mr(n));return i.join("")}function Dr(e){for(var r,t=e.length,n=t%3,i=[],o=16383,u=0,c=t-n;u<c;u+=o)i.push(Lr(e,u,u+o>c?c:u+o));return n===1?(r=e[t-1],i.push(m[r>>2]+m[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(m[r>>10]+m[r>>4&63]+m[r<<2&63]+"=")),i.join("")}});var v=P(G=>{y();G.read=function(e,r,t,n,i){var o,u,c=i*8-n-1,h=(1<<c)-1,a=h>>1,f=-7,p=t?i-1:0,I=t?-1:1,d=e[r+p];for(p+=I,o=d&(1<<-f)-1,d>>=-f,f+=c;f>0;o=o*256+e[r+p],p+=I,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=n;f>0;u=u*256+e[r+p],p+=I,f-=8);if(o===0)o=1-a;else{if(o===h)return u?NaN:(d?-1:1)*(1/0);u=u+Math.pow(2,n),o=o-a}return(d?-1:1)*u*Math.pow(2,o-n)};G.write=function(e,r,t,n,i,o){var u,c,h,a=o*8-i-1,f=(1<<a)-1,p=f>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,$=n?1:-1,gr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,u=f):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+p>=1?r+=I/h:r+=I*Math.pow(2,1-p),r*h>=2&&(u++,h/=2),u+p>=f?(c=0,u=f):u+p>=1?(c=(r*h-1)*Math.pow(2,i),u=u+p):(c=r*Math.pow(2,p-1)*Math.pow(2,i),u=0));i>=8;e[t+d]=c&255,d+=$,c/=256,i-=8);for(u=u<<i|c,a+=i;a>0;e[t+d]=u&255,d+=$,u/=256,a-=8);e[t+d-$]|=gr*128}});var dr=P(b=>{"use strict";y();var H=Q(),T=v(),rr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;b.Buffer=s;b.SlowBuffer=Gr;b.INSPECT_MAX_BYTES=50;var M=2147483647;b.kMaxLength=M;s.TYPED_ARRAY_SUPPORT=Nr();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Nr(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function B(e){if(e>M)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,s.prototype),r}function s(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return V(e)}return ir(e,r,t)}s.poolSize=8192;function ir(e,r,t){if(typeof e=="string")return $r(e,r);if(ArrayBuffer.isView(e))return Pr(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(g(e,ArrayBuffer)||e&&g(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(g(e,SharedArrayBuffer)||e&&g(e.buffer,SharedArrayBuffer)))return j(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return s.from(n,r,t);let i=Or(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,r,t){return ir(e,r,t)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function or(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function kr(e,r,t){return or(e),e<=0?B(e):r!==void 0?typeof t=="string"?B(e).fill(r,t):B(e).fill(r):B(e)}s.alloc=function(e,r,t){return kr(e,r,t)};function V(e){return or(e),B(e<0?0:W(e)|0)}s.allocUnsafe=function(e){return V(e)};s.allocUnsafeSlow=function(e){return V(e)};function $r(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=ur(e,r)|0,n=B(t),i=n.write(e,r);return i!==t&&(n=n.slice(0,i)),n}function z(e){let r=e.length<0?0:W(e.length)|0,t=B(r);for(let n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Pr(e){if(g(e,Uint8Array)){let r=new Uint8Array(e);return j(r.buffer,r.byteOffset,r.byteLength)}return z(e)}function j(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(e):t===void 0?n=new Uint8Array(e,r):n=new Uint8Array(e,r,t),Object.setPrototypeOf(n,s.prototype),n}function Or(e){if(s.isBuffer(e)){let r=W(e.length)|0,t=B(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||X(e.length)?B(0):z(e);if(e.type==="Buffer"&&Array.isArray(e.data))return z(e.data)}function W(e){if(e>=M)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M.toString(16)+" bytes");return e|0}function Gr(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype};s.compare=function(r,t){if(g(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),g(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(r)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,i=t.length;for(let o=0,u=Math.min(n,i);o<u;++o)if(r[o]!==t[o]){n=r[o],i=t[o];break}return n<i?-1:i<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;let i=s.allocUnsafe(t),o=0;for(n=0;n<r.length;++n){let u=r[n];if(g(u,Uint8Array))o+u.length>i.length?(s.isBuffer(u)||(u=s.from(u)),u.copy(i,o)):Uint8Array.prototype.set.call(i,u,o);else if(s.isBuffer(u))u.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return i};function ur(e,r){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||g(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return wr(e).length;default:if(i)return n?-1:q(e).length;r=(""+r).toLowerCase(),i=!0}}s.byteLength=ur;function Hr(e,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Zr(this,r,t);case"utf8":case"utf-8":return cr(this,r,t);case"ascii":return Jr(this,r,t);case"latin1":case"binary":return Kr(this,r,t);case"base64":return Yr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function A(e,r,t){let n=e[r];e[r]=e[t],e[t]=n}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)A(this,t,t+1);return this};s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)A(this,t,t+3),A(this,t+1,t+2);return this};s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)A(this,t,t+7),A(this,t+1,t+6),A(this,t+2,t+5),A(this,t+3,t+4);return this};s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?cr(this,0,r):Hr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.inspect=function(){let r="",t=b.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};rr&&(s.prototype[rr]=s.prototype.inspect);s.prototype.compare=function(r,t,n,i,o){if(g(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>r.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===r)return 0;let u=o-i,c=n-t,h=Math.min(u,c),a=this.slice(i,o),f=r.slice(t,n);for(let p=0;p<h;++p)if(a[p]!==f[p]){u=a[p],c=f[p];break}return u<c?-1:c<u?1:0};function sr(e,r,t,n,i){if(e.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,X(t)&&(t=i?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(i)return-1;t=e.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),s.isBuffer(r))return r.length===0?-1:tr(e,r,t,n,i);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):tr(e,[r],t,n,i);throw new TypeError("val must be string, number or Buffer")}function tr(e,r,t,n,i){let o=1,u=e.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,c/=2,t/=2}function h(f,p){return o===1?f[p]:f.readUInt16BE(p*o)}let a;if(i){let f=-1;for(a=t;a<u;a++)if(h(e,a)===h(r,f===-1?0:a-f)){if(f===-1&&(f=a),a-f+1===c)return f*o}else f!==-1&&(a-=a-f),f=-1}else for(t+c>u&&(t=u-c),a=t;a>=0;a--){let f=!0;for(let p=0;p<c;p++)if(h(e,a+p)!==h(r,p)){f=!1;break}if(f)return a}return-1}s.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1};s.prototype.indexOf=function(r,t,n){return sr(this,r,t,n,!0)};s.prototype.lastIndexOf=function(r,t,n){return sr(this,r,t,n,!1)};function zr(e,r,t,n){t=Number(t)||0;let i=e.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=r.length;n>o/2&&(n=o/2);let u;for(u=0;u<n;++u){let c=parseInt(r.substr(u*2,2),16);if(X(c))return u;e[t+u]=c}return u}function jr(e,r,t,n){return L(q(r,e.length-t),e,t,n)}function qr(e,r,t,n){return L(et(r),e,t,n)}function Vr(e,r,t,n){return L(wr(r),e,t,n)}function Wr(e,r,t,n){return L(nt(r,e.length-t),e,t,n)}s.prototype.write=function(r,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let u=!1;for(;;)switch(i){case"hex":return zr(this,r,t,n);case"utf8":case"utf-8":return jr(this,r,t,n);case"ascii":case"latin1":case"binary":return qr(this,r,t,n);case"base64":return Vr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,r,t,n);default:if(u)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),u=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yr(e,r,t){return r===0&&t===e.length?H.fromByteArray(e):H.fromByteArray(e.slice(r,t))}function cr(e,r,t){t=Math.min(e.length,t);let n=[],i=r;for(;i<t;){let o=e[i],u=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let h,a,f,p;switch(c){case 1:o<128&&(u=o);break;case 2:h=e[i+1],(h&192)===128&&(p=(o&31)<<6|h&63,p>127&&(u=p));break;case 3:h=e[i+1],a=e[i+2],(h&192)===128&&(a&192)===128&&(p=(o&15)<<12|(h&63)<<6|a&63,p>2047&&(p<55296||p>57343)&&(u=p));break;case 4:h=e[i+1],a=e[i+2],f=e[i+3],(h&192)===128&&(a&192)===128&&(f&192)===128&&(p=(o&15)<<18|(h&63)<<12|(a&63)<<6|f&63,p>65535&&p<1114112&&(u=p))}}u===null?(u=65533,c=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u),i+=c}return Xr(n)}var er=4096;function Xr(e){let r=e.length;if(r<=er)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.slice(n,n+=er));return t}function Jr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]&127);return n}function Kr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]);return n}function Zr(e,r,t){let n=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=r;o<t;++o)i+=it[e[o]];return i}function Qr(e,r,t){let n=e.slice(r,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(r,t){let n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);let i=this.subarray(r,t);return Object.setPrototypeOf(i,s.prototype),i};function l(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r],o=1,u=0;for(;++u<t&&(o*=256);)i+=this[r+u]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r+--t],o=1;for(;t>0&&(o*=256);)i+=this[r+--t]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(r,t){return r=r>>>0,t||l(r,1,this.length),this[r]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||l(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||l(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||l(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readBigUInt64LE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r],o=1,u=0;for(;++u<t&&(o*=256);)i+=this[r+u]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};s.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=t,o=1,u=this[r+--i];for(;i>0&&(o*=256);)u+=this[r+--i]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};s.prototype.readInt8=function(r,t){return r=r>>>0,t||l(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,t){r=r>>>0,t||l(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,t){r=r>>>0,t||l(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readBigInt64LE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});s.prototype.readBigInt64BE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(i)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)});s.prototype.readFloatLE=function(r,t){return r=r>>>0,t||l(r,4,this.length),T.read(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,t){return r=r>>>0,t||l(r,4,this.length),T.read(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||l(r,8,this.length),T.read(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||l(r,8,this.length),T.read(this,r,!1,52,8)};function w(e,r,t,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(t+n>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;w(this,r,t,n,c,0)}let o=1,u=0;for(this[t]=r&255;++u<n&&(o*=256);)this[t+u]=r/o&255;return t+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;w(this,r,t,n,c,0)}let o=n-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,1,255,0),this[t]=r&255,t+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function hr(e,r,t,n,i){yr(r,n,i,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function fr(e,r,t,n,i){yr(r,n,i,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}s.prototype.writeBigUInt64LE=E(function(r,t=0){return hr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=E(function(r,t=0){return fr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let h=Math.pow(2,8*n-1);w(this,r,t,n,h-1,-h)}let o=0,u=1,c=0;for(this[t]=r&255;++o<n&&(u*=256);)r<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+n};s.prototype.writeIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let h=Math.pow(2,8*n-1);w(this,r,t,n,h-1,-h)}let o=n-1,u=1,c=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+n};s.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};s.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};s.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};s.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};s.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};s.prototype.writeBigInt64LE=E(function(r,t=0){return hr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=E(function(r,t=0){return fr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function pr(e,r,t,n,i,o){if(t+n>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ar(e,r,t,n,i){return r=+r,t=t>>>0,i||pr(e,r,t,4,34028234663852886e22,-34028234663852886e22),T.write(e,r,t,n,23,4),t+4}s.prototype.writeFloatLE=function(r,t,n){return ar(this,r,t,!0,n)};s.prototype.writeFloatBE=function(r,t,n){return ar(this,r,t,!1,n)};function lr(e,r,t,n,i){return r=+r,t=t>>>0,i||pr(e,r,t,8,17976931348623157e292,-17976931348623157e292),T.write(e,r,t,n,52,8),t+8}s.prototype.writeDoubleLE=function(r,t,n){return lr(this,r,t,!0,n)};s.prototype.writeDoubleBE=function(r,t,n){return lr(this,r,t,!1,n)};s.prototype.copy=function(r,t,n,i){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=r.length&&(t=r.length),t||(t=0),i>0&&i<n&&(i=n),i===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-t<i-n&&(i=r.length-t+n);let o=i-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(r,this.subarray(n,i),t),o};s.prototype.fill=function(r,t,n,i){if(typeof r=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(r.length===1){let u=r.charCodeAt(0);(i==="utf8"&&u<128||i==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<n;++o)this[o]=r;else{let u=s.isBuffer(r)?r:s.from(r,i),c=u.length;if(c===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=u[o%c]}return this};var R={};function Y(e,r,t){R[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Y("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);Y("ERR_OUT_OF_RANGE",function(e,r,t){let n=`The value of "${e}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=nr(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=nr(i)),i+="n"),n+=` It must be ${r}. Received ${i}`,n},RangeError);function nr(e){let r="",t=e.length,n=e[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function vr(e,r,t){C(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&_(r,e.length-(t+1))}function yr(e,r,t,n,i,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",c;throw o>3?r===0||r===BigInt(0)?c=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:c=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:c=`>= ${r}${u} and <= ${t}${u}`,new R.ERR_OUT_OF_RANGE("value",c,e)}vr(n,i,o)}function C(e,r){if(typeof e!="number")throw new R.ERR_INVALID_ARG_TYPE(r,"number",e)}function _(e,r,t){throw Math.floor(e)!==e?(C(e,t),new R.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var rt=/[^+/0-9A-Za-z-_]/g;function tt(e){if(e=e.split("=")[0],e=e.trim().replace(rt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function q(e,r){r=r||1/0;let t,n=e.length,i=null,o=[];for(let u=0;u<n;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!i){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function et(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function nt(e,r){let t,n,i,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function wr(e){return H.toByteArray(tt(e))}function L(e,r,t,n){let i;for(i=0;i<n&&!(i+t>=r.length||i>=e.length);++i)r[i+t]=e[i];return i}function g(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function X(e){return e!==e}var it=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)r[n+i]=e[t]+e[i]}return r})();function E(e){return typeof BigInt>"u"?ot:e}function ot(){throw new Error("BigInt not supported")}});var xr,y=Ur(()=>{"use strict";xr=Tr(dr(),1);globalThis.Buffer=xr.Buffer});y();y();y();y();var D=class{constructor(r){this._initialized=!1;this.type=r}createContainer(){let r=document.createElement("div");return r.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),r.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(r),r}removeContainer(r){r&&r.parentNode&&r.parentNode.removeChild(r)}async initialize(r=null){this._initialized=!0}isInitialized(){return this._initialized}async render(r,t){throw new Error("render() must be implemented by subclass")}async mountToDom(r,t,n){let i=await this.render(r,t);if(!i||!i.base64){let u=document.createElement("div");return u.textContent=`Renderer returned empty result: ${this.type}`,n.appendChild(u),{root:u,cleanup:()=>{try{u.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,n.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(r){if(!r||typeof r=="string"&&r.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(r){return r}calculateCanvasScale(r){let n=r?.fontSize||12;return 14/16*(n/12)*4}async renderSvgToCanvas(r,t,n,i=null){return r=r.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,u)=>{let c=new Image;c.crossOrigin="Anonymous";let h=btoa(unescape(encodeURIComponent(r)));c.src=`data:image/svg+xml;base64,${h}`,c.onload=()=>{let a=document.createElement("canvas");a.width=t,a.height=n;let f=a.getContext("2d");i&&(f.font=`14px ${i}`),f.drawImage(c,0,0,t,n),o(a)},c.onerror=a=>{u(new Error("Failed to load SVG into image for rendering"))}})}};var N=class extends D{constructor(){super("svg")}validateInput(r){if(!r||typeof r!="string")throw new Error("SVG input must be a non-empty string");if(!r.includes("<svg"))throw new Error("Invalid SVG: missing <svg> tag");return!0}async render(r,t){this.validateInput(r);let o=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!o)throw new Error("No SVG element found in input");let u=o.getAttribute("viewBox"),c,h;if(u){let d=u.split(/\s+/);c=Math.ceil(parseFloat(d[2])),h=Math.ceil(parseFloat(d[3]))}else c=Math.ceil(parseFloat(o.getAttribute("width")||"800")),h=Math.ceil(parseFloat(o.getAttribute("height")||"600"));let a=this.calculateCanvasScale(t),f=await this.renderSvgToCanvas(r,c*a,h*a);return{base64:f.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,""),width:f.width,height:f.height,format:"png"}}};var k=class extends N{async mountToDom(r,t,n){if(typeof r!="string")throw new Error("SVG input must be a string");let i=r;return this.validateInput(i),n.innerHTML=i,{root:n.querySelector("svg")||n,cleanup:()=>{try{n.innerHTML=""}catch{}}}}};y();function ut(){return globalThis}function st(){let e=ut();return e.__md2x_renderer_registry__||(e.__md2x_renderer_registry__=new Map),e.__md2x_renderer_registry__}function mr(e){st().set(e.type,e)}mr(new k);})();
1
+ "use strict";(()=>{var Br=Object.create;var J=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Fr=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var Ur=(e,r)=>()=>(e&&(r=e(e=0)),r);var P=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Rr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ir(r))!Ar.call(e,i)&&i!==t&&J(e,i,{get:()=>r[i],enumerable:!(n=Er(r,i))||n.enumerable});return e};var Tr=(e,r,t)=>(t=e!=null?Br(Fr(e)):{},Rr(r||!e||!e.__esModule?J(t,"default",{value:e,enumerable:!0}):t,e));var Q=P(S=>{"use strict";y();S.byteLength=br;S.toByteArray=Sr;S.fromByteArray=Dr;var x=[],m=[],Cr=typeof Uint8Array<"u"?Uint8Array:Array,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(F=0,K=O.length;F<K;++F)x[F]=O[F],m[O.charCodeAt(F)]=F;var F,K;m[45]=62;m[95]=63;function Z(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function br(e){var r=Z(e),t=r[0],n=r[1];return(t+n)*3/4-n}function _r(e,r,t){return(r+t)*3/4-t}function Sr(e){var r,t=Z(e),n=t[0],i=t[1],o=new Cr(_r(e,n,i)),u=0,c=i>0?n-4:n,h;for(h=0;h<c;h+=4)r=m[e.charCodeAt(h)]<<18|m[e.charCodeAt(h+1)]<<12|m[e.charCodeAt(h+2)]<<6|m[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return i===2&&(r=m[e.charCodeAt(h)]<<2|m[e.charCodeAt(h+1)]>>4,o[u++]=r&255),i===1&&(r=m[e.charCodeAt(h)]<<10|m[e.charCodeAt(h+1)]<<4|m[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Mr(e){return x[e>>18&63]+x[e>>12&63]+x[e>>6&63]+x[e&63]}function Lr(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Mr(n));return i.join("")}function Dr(e){for(var r,t=e.length,n=t%3,i=[],o=16383,u=0,c=t-n;u<c;u+=o)i.push(Lr(e,u,u+o>c?c:u+o));return n===1?(r=e[t-1],i.push(x[r>>2]+x[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(x[r>>10]+x[r>>4&63]+x[r<<2&63]+"=")),i.join("")}});var v=P(G=>{y();G.read=function(e,r,t,n,i){var o,u,c=i*8-n-1,h=(1<<c)-1,a=h>>1,f=-7,p=t?i-1:0,I=t?-1:1,d=e[r+p];for(p+=I,o=d&(1<<-f)-1,d>>=-f,f+=c;f>0;o=o*256+e[r+p],p+=I,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=n;f>0;u=u*256+e[r+p],p+=I,f-=8);if(o===0)o=1-a;else{if(o===h)return u?NaN:(d?-1:1)*(1/0);u=u+Math.pow(2,n),o=o-a}return(d?-1:1)*u*Math.pow(2,o-n)};G.write=function(e,r,t,n,i,o){var u,c,h,a=o*8-i-1,f=(1<<a)-1,p=f>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,$=n?1:-1,gr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,u=f):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+p>=1?r+=I/h:r+=I*Math.pow(2,1-p),r*h>=2&&(u++,h/=2),u+p>=f?(c=0,u=f):u+p>=1?(c=(r*h-1)*Math.pow(2,i),u=u+p):(c=r*Math.pow(2,p-1)*Math.pow(2,i),u=0));i>=8;e[t+d]=c&255,d+=$,c/=256,i-=8);for(u=u<<i|c,a+=i;a>0;e[t+d]=u&255,d+=$,u/=256,a-=8);e[t+d-$]|=gr*128}});var dr=P(b=>{"use strict";y();var z=Q(),T=v(),rr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;b.Buffer=s;b.SlowBuffer=Gr;b.INSPECT_MAX_BYTES=50;var M=2147483647;b.kMaxLength=M;s.TYPED_ARRAY_SUPPORT=Nr();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Nr(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function B(e){if(e>M)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,s.prototype),r}function s(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return V(e)}return ir(e,r,t)}s.poolSize=8192;function ir(e,r,t){if(typeof e=="string")return $r(e,r);if(ArrayBuffer.isView(e))return Pr(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(g(e,ArrayBuffer)||e&&g(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(g(e,SharedArrayBuffer)||e&&g(e.buffer,SharedArrayBuffer)))return j(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return s.from(n,r,t);let i=Or(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,r,t){return ir(e,r,t)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function or(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function kr(e,r,t){return or(e),e<=0?B(e):r!==void 0?typeof t=="string"?B(e).fill(r,t):B(e).fill(r):B(e)}s.alloc=function(e,r,t){return kr(e,r,t)};function V(e){return or(e),B(e<0?0:W(e)|0)}s.allocUnsafe=function(e){return V(e)};s.allocUnsafeSlow=function(e){return V(e)};function $r(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=ur(e,r)|0,n=B(t),i=n.write(e,r);return i!==t&&(n=n.slice(0,i)),n}function H(e){let r=e.length<0?0:W(e.length)|0,t=B(r);for(let n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Pr(e){if(g(e,Uint8Array)){let r=new Uint8Array(e);return j(r.buffer,r.byteOffset,r.byteLength)}return H(e)}function j(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(e):t===void 0?n=new Uint8Array(e,r):n=new Uint8Array(e,r,t),Object.setPrototypeOf(n,s.prototype),n}function Or(e){if(s.isBuffer(e)){let r=W(e.length)|0,t=B(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||X(e.length)?B(0):H(e);if(e.type==="Buffer"&&Array.isArray(e.data))return H(e.data)}function W(e){if(e>=M)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M.toString(16)+" bytes");return e|0}function Gr(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype};s.compare=function(r,t){if(g(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),g(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(r)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,i=t.length;for(let o=0,u=Math.min(n,i);o<u;++o)if(r[o]!==t[o]){n=r[o],i=t[o];break}return n<i?-1:i<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;let i=s.allocUnsafe(t),o=0;for(n=0;n<r.length;++n){let u=r[n];if(g(u,Uint8Array))o+u.length>i.length?(s.isBuffer(u)||(u=s.from(u)),u.copy(i,o)):Uint8Array.prototype.set.call(i,u,o);else if(s.isBuffer(u))u.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return i};function ur(e,r){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||g(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return wr(e).length;default:if(i)return n?-1:q(e).length;r=(""+r).toLowerCase(),i=!0}}s.byteLength=ur;function zr(e,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Zr(this,r,t);case"utf8":case"utf-8":return cr(this,r,t);case"ascii":return Jr(this,r,t);case"latin1":case"binary":return Kr(this,r,t);case"base64":return Yr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function A(e,r,t){let n=e[r];e[r]=e[t],e[t]=n}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)A(this,t,t+1);return this};s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)A(this,t,t+3),A(this,t+1,t+2);return this};s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)A(this,t,t+7),A(this,t+1,t+6),A(this,t+2,t+5),A(this,t+3,t+4);return this};s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?cr(this,0,r):zr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.inspect=function(){let r="",t=b.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};rr&&(s.prototype[rr]=s.prototype.inspect);s.prototype.compare=function(r,t,n,i,o){if(g(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>r.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===r)return 0;let u=o-i,c=n-t,h=Math.min(u,c),a=this.slice(i,o),f=r.slice(t,n);for(let p=0;p<h;++p)if(a[p]!==f[p]){u=a[p],c=f[p];break}return u<c?-1:c<u?1:0};function sr(e,r,t,n,i){if(e.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,X(t)&&(t=i?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(i)return-1;t=e.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),s.isBuffer(r))return r.length===0?-1:tr(e,r,t,n,i);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):tr(e,[r],t,n,i);throw new TypeError("val must be string, number or Buffer")}function tr(e,r,t,n,i){let o=1,u=e.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,c/=2,t/=2}function h(f,p){return o===1?f[p]:f.readUInt16BE(p*o)}let a;if(i){let f=-1;for(a=t;a<u;a++)if(h(e,a)===h(r,f===-1?0:a-f)){if(f===-1&&(f=a),a-f+1===c)return f*o}else f!==-1&&(a-=a-f),f=-1}else for(t+c>u&&(t=u-c),a=t;a>=0;a--){let f=!0;for(let p=0;p<c;p++)if(h(e,a+p)!==h(r,p)){f=!1;break}if(f)return a}return-1}s.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1};s.prototype.indexOf=function(r,t,n){return sr(this,r,t,n,!0)};s.prototype.lastIndexOf=function(r,t,n){return sr(this,r,t,n,!1)};function Hr(e,r,t,n){t=Number(t)||0;let i=e.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=r.length;n>o/2&&(n=o/2);let u;for(u=0;u<n;++u){let c=parseInt(r.substr(u*2,2),16);if(X(c))return u;e[t+u]=c}return u}function jr(e,r,t,n){return L(q(r,e.length-t),e,t,n)}function qr(e,r,t,n){return L(et(r),e,t,n)}function Vr(e,r,t,n){return L(wr(r),e,t,n)}function Wr(e,r,t,n){return L(nt(r,e.length-t),e,t,n)}s.prototype.write=function(r,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let u=!1;for(;;)switch(i){case"hex":return Hr(this,r,t,n);case"utf8":case"utf-8":return jr(this,r,t,n);case"ascii":case"latin1":case"binary":return qr(this,r,t,n);case"base64":return Vr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,r,t,n);default:if(u)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),u=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yr(e,r,t){return r===0&&t===e.length?z.fromByteArray(e):z.fromByteArray(e.slice(r,t))}function cr(e,r,t){t=Math.min(e.length,t);let n=[],i=r;for(;i<t;){let o=e[i],u=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let h,a,f,p;switch(c){case 1:o<128&&(u=o);break;case 2:h=e[i+1],(h&192)===128&&(p=(o&31)<<6|h&63,p>127&&(u=p));break;case 3:h=e[i+1],a=e[i+2],(h&192)===128&&(a&192)===128&&(p=(o&15)<<12|(h&63)<<6|a&63,p>2047&&(p<55296||p>57343)&&(u=p));break;case 4:h=e[i+1],a=e[i+2],f=e[i+3],(h&192)===128&&(a&192)===128&&(f&192)===128&&(p=(o&15)<<18|(h&63)<<12|(a&63)<<6|f&63,p>65535&&p<1114112&&(u=p))}}u===null?(u=65533,c=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u),i+=c}return Xr(n)}var er=4096;function Xr(e){let r=e.length;if(r<=er)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.slice(n,n+=er));return t}function Jr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]&127);return n}function Kr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]);return n}function Zr(e,r,t){let n=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=r;o<t;++o)i+=it[e[o]];return i}function Qr(e,r,t){let n=e.slice(r,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(r,t){let n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);let i=this.subarray(r,t);return Object.setPrototypeOf(i,s.prototype),i};function l(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r],o=1,u=0;for(;++u<t&&(o*=256);)i+=this[r+u]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r+--t],o=1;for(;t>0&&(o*=256);)i+=this[r+--t]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(r,t){return r=r>>>0,t||l(r,1,this.length),this[r]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||l(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||l(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||l(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readBigUInt64LE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=this[r],o=1,u=0;for(;++u<t&&(o*=256);)i+=this[r+u]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};s.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||l(r,t,this.length);let i=t,o=1,u=this[r+--i];for(;i>0&&(o*=256);)u+=this[r+--i]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};s.prototype.readInt8=function(r,t){return r=r>>>0,t||l(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,t){r=r>>>0,t||l(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,t){r=r>>>0,t||l(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,t){return r=r>>>0,t||l(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readBigInt64LE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});s.prototype.readBigInt64BE=E(function(r){r=r>>>0,C(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_(r,this.length-8);let i=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(i)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)});s.prototype.readFloatLE=function(r,t){return r=r>>>0,t||l(r,4,this.length),T.read(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,t){return r=r>>>0,t||l(r,4,this.length),T.read(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||l(r,8,this.length),T.read(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||l(r,8,this.length),T.read(this,r,!1,52,8)};function w(e,r,t,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(t+n>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;w(this,r,t,n,c,0)}let o=1,u=0;for(this[t]=r&255;++u<n&&(o*=256);)this[t+u]=r/o&255;return t+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;w(this,r,t,n,c,0)}let o=n-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,1,255,0),this[t]=r&255,t+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function hr(e,r,t,n,i){yr(r,n,i,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function fr(e,r,t,n,i){yr(r,n,i,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}s.prototype.writeBigUInt64LE=E(function(r,t=0){return hr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=E(function(r,t=0){return fr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let h=Math.pow(2,8*n-1);w(this,r,t,n,h-1,-h)}let o=0,u=1,c=0;for(this[t]=r&255;++o<n&&(u*=256);)r<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+n};s.prototype.writeIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let h=Math.pow(2,8*n-1);w(this,r,t,n,h-1,-h)}let o=n-1,u=1,c=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+n};s.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};s.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};s.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};s.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};s.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||w(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};s.prototype.writeBigInt64LE=E(function(r,t=0){return hr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=E(function(r,t=0){return fr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function pr(e,r,t,n,i,o){if(t+n>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ar(e,r,t,n,i){return r=+r,t=t>>>0,i||pr(e,r,t,4,34028234663852886e22,-34028234663852886e22),T.write(e,r,t,n,23,4),t+4}s.prototype.writeFloatLE=function(r,t,n){return ar(this,r,t,!0,n)};s.prototype.writeFloatBE=function(r,t,n){return ar(this,r,t,!1,n)};function lr(e,r,t,n,i){return r=+r,t=t>>>0,i||pr(e,r,t,8,17976931348623157e292,-17976931348623157e292),T.write(e,r,t,n,52,8),t+8}s.prototype.writeDoubleLE=function(r,t,n){return lr(this,r,t,!0,n)};s.prototype.writeDoubleBE=function(r,t,n){return lr(this,r,t,!1,n)};s.prototype.copy=function(r,t,n,i){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=r.length&&(t=r.length),t||(t=0),i>0&&i<n&&(i=n),i===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-t<i-n&&(i=r.length-t+n);let o=i-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(r,this.subarray(n,i),t),o};s.prototype.fill=function(r,t,n,i){if(typeof r=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(r.length===1){let u=r.charCodeAt(0);(i==="utf8"&&u<128||i==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<n;++o)this[o]=r;else{let u=s.isBuffer(r)?r:s.from(r,i),c=u.length;if(c===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=u[o%c]}return this};var R={};function Y(e,r,t){R[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Y("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);Y("ERR_OUT_OF_RANGE",function(e,r,t){let n=`The value of "${e}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=nr(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=nr(i)),i+="n"),n+=` It must be ${r}. Received ${i}`,n},RangeError);function nr(e){let r="",t=e.length,n=e[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function vr(e,r,t){C(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&_(r,e.length-(t+1))}function yr(e,r,t,n,i,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",c;throw o>3?r===0||r===BigInt(0)?c=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:c=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:c=`>= ${r}${u} and <= ${t}${u}`,new R.ERR_OUT_OF_RANGE("value",c,e)}vr(n,i,o)}function C(e,r){if(typeof e!="number")throw new R.ERR_INVALID_ARG_TYPE(r,"number",e)}function _(e,r,t){throw Math.floor(e)!==e?(C(e,t),new R.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var rt=/[^+/0-9A-Za-z-_]/g;function tt(e){if(e=e.split("=")[0],e=e.trim().replace(rt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function q(e,r){r=r||1/0;let t,n=e.length,i=null,o=[];for(let u=0;u<n;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!i){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function et(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function nt(e,r){let t,n,i,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function wr(e){return z.toByteArray(tt(e))}function L(e,r,t,n){let i;for(i=0;i<n&&!(i+t>=r.length||i>=e.length);++i)r[i+t]=e[i];return i}function g(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function X(e){return e!==e}var it=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)r[n+i]=e[t]+e[i]}return r})();function E(e){return typeof BigInt>"u"?ot:e}function ot(){throw new Error("BigInt not supported")}});var mr,y=Ur(()=>{"use strict";mr=Tr(dr(),1);globalThis.Buffer=mr.Buffer});y();y();y();y();var D=class{constructor(r){this._initialized=!1;this.type=r}createContainer(){let r=document.createElement("div");return r.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),r.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(r),r}removeContainer(r){r&&r.parentNode&&r.parentNode.removeChild(r)}async initialize(r=null){this._initialized=!0}isInitialized(){return this._initialized}async render(r,t){throw new Error("render() must be implemented by subclass")}async mountToDom(r,t,n){let i=await this.render(r,t);if(!i||!i.base64){let u=document.createElement("div");return u.textContent=`Renderer returned empty result: ${this.type}`,n.appendChild(u),{root:u,cleanup:()=>{try{u.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,n.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(r){if(!r||typeof r=="string"&&r.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(r){return r}calculateCanvasScale(r){return(r?.fontSize||12)/12*4}async renderSvgToCanvas(r,t,n,i=null){return r=r.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,u)=>{let c=new Image;c.crossOrigin="Anonymous";let h=btoa(unescape(encodeURIComponent(r)));c.src=`data:image/svg+xml;base64,${h}`,c.onload=()=>{let a=document.createElement("canvas");a.width=t,a.height=n;let f=a.getContext("2d");i&&(f.font=`14px ${i}`),f.drawImage(c,0,0,t,n),o(a)},c.onerror=a=>{u(new Error("Failed to load SVG into image for rendering"))}})}};var N=class extends D{constructor(){super("svg")}validateInput(r){if(!r||typeof r!="string")throw new Error("SVG input must be a non-empty string");if(!r.includes("<svg"))throw new Error("Invalid SVG: missing <svg> tag");return!0}async render(r,t){this.validateInput(r);let o=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!o)throw new Error("No SVG element found in input");let u=o.getAttribute("viewBox"),c,h;if(u){let d=u.split(/\s+/);c=Math.ceil(parseFloat(d[2])),h=Math.ceil(parseFloat(d[3]))}else c=Math.ceil(parseFloat(o.getAttribute("width")||"800")),h=Math.ceil(parseFloat(o.getAttribute("height")||"600"));let a=this.calculateCanvasScale(t),f=await this.renderSvgToCanvas(r,c*a,h*a);return{base64:f.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,""),width:f.width,height:f.height,format:"png"}}};var k=class extends N{async mountToDom(r,t,n){if(typeof r!="string")throw new Error("SVG input must be a string");let i=r;return this.validateInput(i),n.innerHTML=i,{root:n.querySelector("svg")||n,cleanup:()=>{try{n.innerHTML=""}catch{}}}}};y();function ut(){return globalThis}function st(){let e=ut();return e.__md2x_renderer_registry__||(e.__md2x_renderer_registry__=new Map),e.__md2x_renderer_registry__}function xr(e){st().set(e.type,e)}xr(new k);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js:
@@ -190,7 +190,7 @@ ${s}`)}return l})(e,"",0)}var wk={};Sn(wk,{Bounds:()=>ft,CanvasHandler:()=>Ka,Ca
190
190
  <circle r="2" cy="8" cx="2"></circle>
191
191
  <circle r="2" cy="8" cx="8"></circle>
192
192
  <circle r="2" cy="8" cx="14"></circle>
193
- </svg>`,yme="chart-wrapper";function xme(e){return typeof e=="function"}function a9(e,t,n,r){let i=`<html><head>${t}</head><body><pre><code class="json">`,o=`</code></pre>${n}</body></html>`,a=window.open("");a.document.write(i+e+o),a.document.title=`${lm[r]} JSON Source`}function bme(e,t,n){if(e.$schema){let r=tR(e.$schema);n&&n!==r.library&&t.warn(`The given visualization spec is written in ${lm[r.library]}, but mode argument sets ${lm[n]??n}.`);let i=r.library;return h9(Qx[i],`^${r.version.slice(1)}`)||t.warn(`The input spec uses ${lm[i]} ${r.version}, but the current version of ${lm[i]} is v${Qx[i]}.`),i}return"mark"in e||"encoding"in e||"layer"in e||"hconcat"in e||"vconcat"in e||"facet"in e||"repeat"in e?"vega-lite":"marks"in e||"signals"in e||"scales"in e||"axes"in e?"vega":n??"vega"}function m9(e){return!!(e&&"load"in e)}function s9(e){return m9(e)?e:mo.loader(e)}function vme(e){let t=e.usermeta?.embedOptions??{};return Z(t.defaultStyle)&&(t.defaultStyle=!1),t}async function eb(e,t,n={}){let r,i;Z(t)?(i=s9(n.loader),r=JSON.parse(await i.load(t))):r=t;let o=vme(r),a=o.loader;(!i||a)&&(i=s9(n.loader??a));let s=await u9(o,i),u=await u9(n,i),l={...p9(u,s),config:bo(u.config??{},s.config??{})};return await Eme(e,r,l,i)}async function u9(e,t){let n=Z(e.config)?JSON.parse(await t.load(e.config)):e.config??{},r=Z(e.patch)?JSON.parse(await t.load(e.patch)):e.patch;return{...e,...r?{patch:r}:{},...n?{config:n}:{}}}function wme(e){let t=e.getRootNode?e.getRootNode():document;return t instanceof ShadowRoot?{root:t,rootContainer:t}:{root:document,rootContainer:document.head??document.body}}async function Eme(e,t,n={},r){let i=n.theme?bo(uR[n.theme],n.config??{}):n.config,o=Gr(n.actions)?n.actions:p9({},hme,n.actions??{}),a={...pme,...n.i18n},s=n.renderer??"svg",u=n.logger??Ns(mo.Warn);n.logLevel!==void 0&&u.level(n.logLevel);let l=n.downloadFileName??"visualization",c=typeof e=="string"?document.querySelector(e):e;if(!c)throw new Error(`${e} does not exist`);if(n.defaultStyle!==!1){let E="vega-embed-style",{root:_,rootContainer:S}=wme(c);if(!_.getElementById(E)){let k=document.createElement("style");k.id=E,k.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?lme.toString():n.defaultStyle,S.appendChild(k)}}let f=bme(t,u,n.mode),d=mme[f](t,u,i);if(f==="vega-lite"&&d.$schema){let E=tR(d.$schema);h9(Qx.vega,`^${E.version.slice(1)}`)||u.warn(`The compiled spec uses Vega ${E.version}, but current version is v${Qx.vega}.`)}c.classList.add("vega-embed"),o&&c.classList.add("has-actions"),c.innerHTML="";let h=c;if(o){let E=document.createElement("div");E.classList.add(yme),c.appendChild(E),h=E}let p=n.patch;if(p&&(d=p instanceof Function?p(d):Jx(d,p,!0,!1).newDocument),n.formatLocale&&mo.formatLocale(n.formatLocale),n.timeFormatLocale&&mo.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(let E in n.expressionFunctions){let _=n.expressionFunctions[E];"fn"in _?mo.expressionFunction(E,_.fn,_.visitor):_ instanceof Function&&mo.expressionFunction(E,_)}let{ast:m}=n,g=mo.parse(d,f==="vega-lite"?{}:i,{ast:m}),y=new(n.viewClass||mo.View)(g,{loader:r,logger:u,renderer:s,...m?{expr:mo.expressionInterpreter??n.expr??Gc}:{}});if(y.addSignalListener("autosize",(E,_)=>{let{type:S}=_;S=="fit-x"?(h.classList.add("fit-x"),h.classList.remove("fit-y")):S=="fit-y"?(h.classList.remove("fit-x"),h.classList.add("fit-y")):S=="fit"?h.classList.add("fit-x","fit-y"):h.classList.remove("fit-x","fit-y")}),n.tooltip!==!1){let{loader:E,tooltip:_}=n,S=E&&!m9(E)?E?.baseURL:void 0,k=xme(_)?_:new Yx({baseURL:S,..._===!0?{}:_}).call;y.tooltip(k)}let{hover:b}=n;if(b===void 0&&(b=f==="vega"),b){let{hoverSet:E,updateSet:_}=typeof b=="boolean"?{}:b;y.hover(E,_)}n&&(n.width!=null&&y.width(n.width),n.height!=null&&y.height(n.height),n.padding!=null&&y.padding(n.padding)),await y.initialize(h,n.bind).runAsync();let v;if(o!==!1){let E=c;if(n.defaultStyle!==!1||n.forceActionsMenu){let S=document.createElement("details");S.title=a.CLICK_TO_VIEW_ACTIONS,c.append(S),E=S;let k=document.createElement("summary");k.innerHTML=gme,S.append(k),v=C=>{S.contains(C.target)||S.removeAttribute("open")},document.addEventListener("click",v)}let _=document.createElement("div");if(E.append(_),_.classList.add("vega-actions"),o===!0||o.export!==!1){for(let S of["svg","png"])if(o===!0||o.export===!0||o.export[S]){let k=a[`${S.toUpperCase()}_ACTION`],C=document.createElement("a"),M=Q(n.scaleFactor)?n.scaleFactor[S]:n.scaleFactor;C.text=k,C.href="#",C.target="_blank",C.download=`${l}.${S}`,C.addEventListener("mousedown",async function(R){R.preventDefault();let P=await y.toImageURL(S,M);this.href=P}),_.append(C)}}if(o===!0||o.source!==!1){let S=document.createElement("a");S.text=a.SOURCE_ACTION,S.href="#",S.addEventListener("click",function(k){a9(Af(t),n.sourceHeader??"",n.sourceFooter??"",f),k.preventDefault()}),_.append(S)}if(f==="vega-lite"&&(o===!0||o.compiled!==!1)){let S=document.createElement("a");S.text=a.COMPILED_ACTION,S.href="#",S.addEventListener("click",function(k){a9(Af(d),n.sourceHeader??"",n.sourceFooter??"","vega"),k.preventDefault()}),_.append(S)}if(o===!0||o.editor!==!1){let S=n.editorUrl??"https://vega.github.io/editor/",k=document.createElement("a");k.text=a.EDITOR_ACTION,k.href="#",k.addEventListener("click",function(C){ume(window,S,{config:i,mode:p?"vega":f,renderer:s,spec:Af(p?d:t)}),C.preventDefault()}),_.append(k)}}function w(){v&&document.removeEventListener("click",v),y.finalize()}return{view:y,spec:t,vgSpec:d,finalize:w,embedOptions:n}}x();x();var tb=class{constructor(t){this._initialized=!1;this.type=t}createContainer(){let t=document.createElement("div");return t.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),t.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(t),t}removeContainer(t){t&&t.parentNode&&t.parentNode.removeChild(t)}async initialize(t=null){this._initialized=!0}isInitialized(){return this._initialized}async render(t,n){throw new Error("render() must be implemented by subclass")}async mountToDom(t,n,r){let i=await this.render(t,n);if(!i||!i.base64){let a=document.createElement("div");return a.textContent=`Renderer returned empty result: ${this.type}`,r.appendChild(a),{root:a,cleanup:()=>{try{a.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,r.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(t){if(!t||typeof t=="string"&&t.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(t){return t}calculateCanvasScale(t){let r=t?.fontSize||12;return 14/16*(r/12)*4}async renderSvgToCanvas(t,n,r,i=null){return t=t.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,a)=>{let s=new Image;s.crossOrigin="Anonymous";let u=btoa(unescape(encodeURIComponent(t)));s.src=`data:image/svg+xml;base64,${u}`,s.onload=()=>{let l=document.createElement("canvas");l.width=n,l.height=r;let c=l.getContext("2d");i&&(c.font=`14px ${i}`),c.drawImage(s,0,0,n,r),o(l)},s.onerror=l=>{a(new Error("Failed to load SVG into image for rendering"))}})}};var nb=class extends tb{constructor(t="vega-lite"){super(t),this.mode=t}validateInput(t){if(!t)throw new Error(`Empty ${this.mode} specification provided`);return!0}preprocessInput(t){let n;if(typeof t=="string")try{n=JSON.parse(t)}catch(r){throw new Error(`Invalid JSON in ${this.mode} specification: ${r.message}`)}else n=t;if(!n||typeof n!="object")throw new Error(`Invalid ${this.mode} specification: must be an object`);return this.mode==="vega-lite"&&this.disableAutoSortRecursive(n),n}disableAutoSortRecursive(t){!t||typeof t!="object"||(t.encoding&&this.disableAutoSort(t.encoding),Array.isArray(t.layer)&&t.layer.forEach(n=>this.disableAutoSortRecursive(n)),["hconcat","vconcat","concat"].forEach(n=>{let r=t[n];Array.isArray(r)&&r.forEach(i=>this.disableAutoSortRecursive(i))}),t.facet&&(t.facet.encoding&&this.disableAutoSort(t.facet.encoding),t.spec&&this.disableAutoSortRecursive(t.spec)),t.repeat&&t.spec&&this.disableAutoSortRecursive(t.spec))}disableAutoSort(t){if(!(!t||typeof t!="object"))for(let n in t){let r=t[n];r&&typeof r=="object"&&!Array.isArray(r)&&(Object.prototype.hasOwnProperty.call(r,"sort")||(r.sort=null))}}async render(t,n){this._initialized||await this.initialize(n),this.validateInput(t);let r=this.preprocessInput(t),i=n?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",o=this.createContainer();o.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let a={mode:this.mode,actions:!1,renderer:"canvas",ast:!0,expr:Gc,config:{background:null,font:i,view:{stroke:null},axis:{labelFontSize:11,titleFontSize:12},legend:{labelFontSize:11,titleFontSize:12},mark:{tooltip:!0}}},s=await eb(o,r,a),u=this.calculateCanvasScale(n),l=await s.view.toCanvas(u);if(!l||l.width===0||l.height===0)throw new Error("Generated canvas is empty or invalid");let f=l.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,"");return this.removeContainer(o),{base64:f,width:l.width,height:l.height,format:"png"}}};var dm=class extends nb{async mountToDom(t,n,r){this._initialized||await this.initialize(n),this.validateInput(t);let i=this.preprocessInput(t),o=n?.fontFamily||"'SimSun', 'Times New Roman', Times, serif";r.innerHTML="";let a=document.createElement("div");a.style.cssText="display: inline-block; background: transparent; padding: 0; margin: 0;",r.appendChild(a);let u={mode:this.type==="vega"?"vega":"vega-lite",actions:!1,renderer:"svg",ast:!0,expr:Gc,config:{background:null,font:o,view:{stroke:null},axis:{labelFontSize:11,titleFontSize:12},legend:{labelFontSize:11,titleFontSize:12},mark:{tooltip:!0}}},l=await eb(a,i,u),c=(async()=>{try{l?.view?.runAsync&&await l.view.runAsync()}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}})();return{root:a,cleanup:()=>{try{l?.view?.finalize?.()}catch{}try{a.remove()}catch{}},done:c}}};x();function Sme(){return globalThis}function _me(){let e=Sme();return e.__md2x_renderer_registry__||(e.__md2x_renderer_registry__=new Map),e.__md2x_renderer_registry__}function PR(e){_me().set(e.type,e)}PR(new dm("vega-lite"));PR(new dm("vega"));})();
193
+ </svg>`,yme="chart-wrapper";function xme(e){return typeof e=="function"}function a9(e,t,n,r){let i=`<html><head>${t}</head><body><pre><code class="json">`,o=`</code></pre>${n}</body></html>`,a=window.open("");a.document.write(i+e+o),a.document.title=`${lm[r]} JSON Source`}function bme(e,t,n){if(e.$schema){let r=tR(e.$schema);n&&n!==r.library&&t.warn(`The given visualization spec is written in ${lm[r.library]}, but mode argument sets ${lm[n]??n}.`);let i=r.library;return h9(Qx[i],`^${r.version.slice(1)}`)||t.warn(`The input spec uses ${lm[i]} ${r.version}, but the current version of ${lm[i]} is v${Qx[i]}.`),i}return"mark"in e||"encoding"in e||"layer"in e||"hconcat"in e||"vconcat"in e||"facet"in e||"repeat"in e?"vega-lite":"marks"in e||"signals"in e||"scales"in e||"axes"in e?"vega":n??"vega"}function m9(e){return!!(e&&"load"in e)}function s9(e){return m9(e)?e:mo.loader(e)}function vme(e){let t=e.usermeta?.embedOptions??{};return Z(t.defaultStyle)&&(t.defaultStyle=!1),t}async function eb(e,t,n={}){let r,i;Z(t)?(i=s9(n.loader),r=JSON.parse(await i.load(t))):r=t;let o=vme(r),a=o.loader;(!i||a)&&(i=s9(n.loader??a));let s=await u9(o,i),u=await u9(n,i),l={...p9(u,s),config:bo(u.config??{},s.config??{})};return await Eme(e,r,l,i)}async function u9(e,t){let n=Z(e.config)?JSON.parse(await t.load(e.config)):e.config??{},r=Z(e.patch)?JSON.parse(await t.load(e.patch)):e.patch;return{...e,...r?{patch:r}:{},...n?{config:n}:{}}}function wme(e){let t=e.getRootNode?e.getRootNode():document;return t instanceof ShadowRoot?{root:t,rootContainer:t}:{root:document,rootContainer:document.head??document.body}}async function Eme(e,t,n={},r){let i=n.theme?bo(uR[n.theme],n.config??{}):n.config,o=Gr(n.actions)?n.actions:p9({},hme,n.actions??{}),a={...pme,...n.i18n},s=n.renderer??"svg",u=n.logger??Ns(mo.Warn);n.logLevel!==void 0&&u.level(n.logLevel);let l=n.downloadFileName??"visualization",c=typeof e=="string"?document.querySelector(e):e;if(!c)throw new Error(`${e} does not exist`);if(n.defaultStyle!==!1){let E="vega-embed-style",{root:_,rootContainer:S}=wme(c);if(!_.getElementById(E)){let k=document.createElement("style");k.id=E,k.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?lme.toString():n.defaultStyle,S.appendChild(k)}}let f=bme(t,u,n.mode),d=mme[f](t,u,i);if(f==="vega-lite"&&d.$schema){let E=tR(d.$schema);h9(Qx.vega,`^${E.version.slice(1)}`)||u.warn(`The compiled spec uses Vega ${E.version}, but current version is v${Qx.vega}.`)}c.classList.add("vega-embed"),o&&c.classList.add("has-actions"),c.innerHTML="";let h=c;if(o){let E=document.createElement("div");E.classList.add(yme),c.appendChild(E),h=E}let p=n.patch;if(p&&(d=p instanceof Function?p(d):Jx(d,p,!0,!1).newDocument),n.formatLocale&&mo.formatLocale(n.formatLocale),n.timeFormatLocale&&mo.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(let E in n.expressionFunctions){let _=n.expressionFunctions[E];"fn"in _?mo.expressionFunction(E,_.fn,_.visitor):_ instanceof Function&&mo.expressionFunction(E,_)}let{ast:m}=n,g=mo.parse(d,f==="vega-lite"?{}:i,{ast:m}),y=new(n.viewClass||mo.View)(g,{loader:r,logger:u,renderer:s,...m?{expr:mo.expressionInterpreter??n.expr??Gc}:{}});if(y.addSignalListener("autosize",(E,_)=>{let{type:S}=_;S=="fit-x"?(h.classList.add("fit-x"),h.classList.remove("fit-y")):S=="fit-y"?(h.classList.remove("fit-x"),h.classList.add("fit-y")):S=="fit"?h.classList.add("fit-x","fit-y"):h.classList.remove("fit-x","fit-y")}),n.tooltip!==!1){let{loader:E,tooltip:_}=n,S=E&&!m9(E)?E?.baseURL:void 0,k=xme(_)?_:new Yx({baseURL:S,..._===!0?{}:_}).call;y.tooltip(k)}let{hover:b}=n;if(b===void 0&&(b=f==="vega"),b){let{hoverSet:E,updateSet:_}=typeof b=="boolean"?{}:b;y.hover(E,_)}n&&(n.width!=null&&y.width(n.width),n.height!=null&&y.height(n.height),n.padding!=null&&y.padding(n.padding)),await y.initialize(h,n.bind).runAsync();let v;if(o!==!1){let E=c;if(n.defaultStyle!==!1||n.forceActionsMenu){let S=document.createElement("details");S.title=a.CLICK_TO_VIEW_ACTIONS,c.append(S),E=S;let k=document.createElement("summary");k.innerHTML=gme,S.append(k),v=C=>{S.contains(C.target)||S.removeAttribute("open")},document.addEventListener("click",v)}let _=document.createElement("div");if(E.append(_),_.classList.add("vega-actions"),o===!0||o.export!==!1){for(let S of["svg","png"])if(o===!0||o.export===!0||o.export[S]){let k=a[`${S.toUpperCase()}_ACTION`],C=document.createElement("a"),M=Q(n.scaleFactor)?n.scaleFactor[S]:n.scaleFactor;C.text=k,C.href="#",C.target="_blank",C.download=`${l}.${S}`,C.addEventListener("mousedown",async function(R){R.preventDefault();let P=await y.toImageURL(S,M);this.href=P}),_.append(C)}}if(o===!0||o.source!==!1){let S=document.createElement("a");S.text=a.SOURCE_ACTION,S.href="#",S.addEventListener("click",function(k){a9(Af(t),n.sourceHeader??"",n.sourceFooter??"",f),k.preventDefault()}),_.append(S)}if(f==="vega-lite"&&(o===!0||o.compiled!==!1)){let S=document.createElement("a");S.text=a.COMPILED_ACTION,S.href="#",S.addEventListener("click",function(k){a9(Af(d),n.sourceHeader??"",n.sourceFooter??"","vega"),k.preventDefault()}),_.append(S)}if(o===!0||o.editor!==!1){let S=n.editorUrl??"https://vega.github.io/editor/",k=document.createElement("a");k.text=a.EDITOR_ACTION,k.href="#",k.addEventListener("click",function(C){ume(window,S,{config:i,mode:p?"vega":f,renderer:s,spec:Af(p?d:t)}),C.preventDefault()}),_.append(k)}}function w(){v&&document.removeEventListener("click",v),y.finalize()}return{view:y,spec:t,vgSpec:d,finalize:w,embedOptions:n}}x();x();var tb=class{constructor(t){this._initialized=!1;this.type=t}createContainer(){let t=document.createElement("div");return t.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),t.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(t),t}removeContainer(t){t&&t.parentNode&&t.parentNode.removeChild(t)}async initialize(t=null){this._initialized=!0}isInitialized(){return this._initialized}async render(t,n){throw new Error("render() must be implemented by subclass")}async mountToDom(t,n,r){let i=await this.render(t,n);if(!i||!i.base64){let a=document.createElement("div");return a.textContent=`Renderer returned empty result: ${this.type}`,r.appendChild(a),{root:a,cleanup:()=>{try{a.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,r.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(t){if(!t||typeof t=="string"&&t.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(t){return t}calculateCanvasScale(t){return(t?.fontSize||12)/12*4}async renderSvgToCanvas(t,n,r,i=null){return t=t.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,a)=>{let s=new Image;s.crossOrigin="Anonymous";let u=btoa(unescape(encodeURIComponent(t)));s.src=`data:image/svg+xml;base64,${u}`,s.onload=()=>{let l=document.createElement("canvas");l.width=n,l.height=r;let c=l.getContext("2d");i&&(c.font=`14px ${i}`),c.drawImage(s,0,0,n,r),o(l)},s.onerror=l=>{a(new Error("Failed to load SVG into image for rendering"))}})}};var nb=class extends tb{constructor(t="vega-lite"){super(t),this.mode=t}validateInput(t){if(!t)throw new Error(`Empty ${this.mode} specification provided`);return!0}preprocessInput(t){let n;if(typeof t=="string")try{n=JSON.parse(t)}catch(r){throw new Error(`Invalid JSON in ${this.mode} specification: ${r.message}`)}else n=t;if(!n||typeof n!="object")throw new Error(`Invalid ${this.mode} specification: must be an object`);return this.mode==="vega-lite"&&this.disableAutoSortRecursive(n),n}disableAutoSortRecursive(t){!t||typeof t!="object"||(t.encoding&&this.disableAutoSort(t.encoding),Array.isArray(t.layer)&&t.layer.forEach(n=>this.disableAutoSortRecursive(n)),["hconcat","vconcat","concat"].forEach(n=>{let r=t[n];Array.isArray(r)&&r.forEach(i=>this.disableAutoSortRecursive(i))}),t.facet&&(t.facet.encoding&&this.disableAutoSort(t.facet.encoding),t.spec&&this.disableAutoSortRecursive(t.spec)),t.repeat&&t.spec&&this.disableAutoSortRecursive(t.spec))}disableAutoSort(t){if(!(!t||typeof t!="object"))for(let n in t){let r=t[n];r&&typeof r=="object"&&!Array.isArray(r)&&(Object.prototype.hasOwnProperty.call(r,"sort")||(r.sort=null))}}async render(t,n){this._initialized||await this.initialize(n),this.validateInput(t);let r=this.preprocessInput(t),i=n?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",o=this.createContainer();o.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let a={mode:this.mode,actions:!1,renderer:"canvas",ast:!0,expr:Gc,config:{background:null,font:i,view:{stroke:null},axis:{labelFontSize:11,titleFontSize:12},legend:{labelFontSize:11,titleFontSize:12},mark:{tooltip:!0}}},s=await eb(o,r,a),u=this.calculateCanvasScale(n),l=await s.view.toCanvas(u);if(!l||l.width===0||l.height===0)throw new Error("Generated canvas is empty or invalid");let f=l.toDataURL("image/png",1).replace(/^data:image\/png;base64,/,"");return this.removeContainer(o),{base64:f,width:l.width,height:l.height,format:"png"}}};var dm=class extends nb{async mountToDom(t,n,r){this._initialized||await this.initialize(n),this.validateInput(t);let i=this.preprocessInput(t),o=n?.fontFamily||"'SimSun', 'Times New Roman', Times, serif";r.innerHTML="";let a=document.createElement("div");a.style.cssText="display: inline-block; background: transparent; padding: 0; margin: 0;",r.appendChild(a);let u={mode:this.type==="vega"?"vega":"vega-lite",actions:!1,renderer:"svg",ast:!0,expr:Gc,config:{background:null,font:o,view:{stroke:null},axis:{labelFontSize:11,titleFontSize:12},legend:{labelFontSize:11,titleFontSize:12},mark:{tooltip:!0}}},l=await eb(a,i,u),c=(async()=>{try{l?.view?.runAsync&&await l.view.runAsync()}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}})();return{root:a,cleanup:()=>{try{l?.view?.finalize?.()}catch{}try{a.remove()}catch{}},done:c}}};x();function Sme(){return globalThis}function _me(){let e=Sme();return e.__md2x_renderer_registry__||(e.__md2x_renderer_registry__=new Map),e.__md2x_renderer_registry__}function PR(e){_me().set(e.type,e)}PR(new dm("vega-lite"));PR(new dm("vega"));})();
194
194
  /*! Bundled license information:
195
195
 
196
196
  ieee754/index.js: