@pacem/pacem-foundation 2.0.0-abel → 2.0.0-babbage
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.
- package/dist/browser/pacem-foundation.js +13 -6
- package/dist/browser/pacem-foundation.js.map +1 -1
- package/dist/browser/pacem-foundation.min.js +2 -2
- package/dist/bundle/pacem-foundation.min.mjs +2 -2
- package/dist/bundle/pacem-foundation.mjs +13 -6
- package/dist/bundle/pacem-foundation.mjs.map +2 -2
- package/dist/docs/pacem-foundation.json +144 -1
- package/dist/esm/array-extensions.js +1 -1
- package/dist/esm/arrays.js +1 -1
- package/dist/esm/blobs.js +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/colors.js +1 -1
- package/dist/esm/dates.js +1 -1
- package/dist/esm/deepmerger.js +1 -1
- package/dist/esm/geom.js +1 -1
- package/dist/esm/history-svc.js +1 -1
- package/dist/esm/imaging.js +13 -6
- package/dist/esm/index-compile-markdown.js +1 -1
- package/dist/esm/index-compile.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index-root.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keygenerator.js +1 -1
- package/dist/esm/matrix2d.js +1 -1
- package/dist/esm/null-checker.js +1 -1
- package/dist/esm/number-extensions.js +1 -1
- package/dist/esm/numbers.js +1 -1
- package/dist/esm/rect.js +1 -1
- package/dist/esm/strings.js +1 -1
- package/package.json +1 -1
- package/typings/index.d.ts +14 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-foundation v2.0.0-
|
|
2
|
+
* @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
!function(){"use strict";Number.prototype.isCloseTo=function(t,e=14){const r=Number(`1e-${e}`);return this>t-r&&this<t+r},Number.prototype.roundoff=function(t=14){return parseFloat(this.toFixed(t))},Number.prototype.clamp=function(t,e){let r=this;return null==t||isNaN(t)||(r=Math.max(r,t)),null==e||isNaN(e)||(r=Math.min(r,e)),r},Number.prototype.toBase62=function(){for(var t=this,e="";0!=t;){e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(t%62)+e,t=Math.floor(t/62)}return e},Number.prototype.toBase36=function(){return this.toString(36)};const t=/^\/Date\([\d]+\)\/$/i;class Dates{static parse(e){let r;return"string"==typeof e?(r=t.test(e)?parseInt(e.substring(6)):Date.parse(e),new Date(r)):"number"==typeof e?new Date(e):e}static isLeapYear(t){return t%4==0&&t%100!=0||t%400==0}static daysInMonth(t,e){return[31,Dates.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),n=new Date(t),s=n.getMonth()+e,i=0;for(;s<0;)s+=12,i--;return n.setDate(1),n.setMonth(s%12),n.setFullYear(n.getFullYear()+i+Math.floor(s/12)),n.setDate(Math.min(r,Dates.daysInMonth(n.getFullYear(),n.getMonth()))),n}static addDays(t,e){return new Date(t.valueOf()+864e5*e)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}}class NullChecker{static isNull(t){return null==t}static isEmpty(t){try{return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||"object"==typeof t&&0===Object.keys(t).length&&!Dates.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch(t){return!1}}static isNullOrEmpty(t){return NullChecker.isNull(t)||NullChecker.isEmpty(t)}}function e(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)&&(t.constructor===Object||void 0===t.constructor)}function r(t,n){const s=t;for(const t of Object.keys(n)){const i=n[t],a=s[t];e(i)?s[t]=r(e(a)?a:{},i):Array.isArray(i)?s[t]=i.slice():s[t]=i}return s}Array.prototype.distinct=function(){return Array.from(new Set(this))},Array.prototype.union=function(t){const e=NullChecker.isNullOrEmpty(this),r=NullChecker.isNullOrEmpty(t);return e&&r?[]:r?this.slice():e?t.slice():this.concat(t).distinct()},Array.prototype.moveWithin=function(t,e){const r="Index must be greater or equal than 0 and less or equal than the length of the array.";var n=this;if(t<0||t>n.length)throw new Error(r);if(e<0||e>n.length)throw new Error(r);n.splice(e,0,Array.prototype.splice.apply(n,[t,1])[0])},Array.prototype.equalsContent=function(t){if(null==t||this.length!==t.length)return!1;for(let e=0;e<this.length;e++)if(this[e]!==t[e])return!1;return!0},Array.prototype.cloneFrom=function(t){if(null==t)throw"Cannot clone array from null object.";const e=t.length;var r=this.length!==t.length;for(let n=0;n<e;n++){const e=t[n];this.length>n?this[n]!==e&&(this[n]=e,r=!0):(Array.prototype.push.apply(this,[e]),r=!0)}r&&this.splice(e)};class DeepMerger{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},r(e,t)}}class Blobs{static blobToDataURL(t){return new Promise((e,r)=>{const n=new FileReader;n.onload=t=>{e(t.target.result)},n.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length;const r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){const r=Blobs._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){const e=t.indexOf(",");if(-1===e)return Blobs.base64ToBlob(t);{const r=t.substring(e+1),n=t.substring(0,e).match(/:(.*?);/)[1];return Blobs.base64ToBlob(r,{type:n})}}static async blobToText(t,e){const r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",n,s=63){let i=r.toLowerCase();const a=()=>`${e};charset=${i}`;switch(i){case"utf-8":{const e=(new TextEncoder).encode(t),r=n?[new Uint8Array([239,187,191]),e]:[e];return new Blob(r,{type:a()})}case"utf-16":i="utf-16le",n??=!0;case"utf-16le":case"utf-16be":{const e="utf-16be"!==i,r=n?1:0,s=new ArrayBuffer(2*(t.length+r)),o=new DataView(s);n&&o.setUint16(0,65279,e);for(let n=0;n<t.length;n++)o.setUint16(2*(n+r),t.charCodeAt(n),e);return new Blob([s],{type:a()})}case"ascii":case"iso-8859-1":case"latin1":{const e="ascii"===i?127:255,n=new Uint8Array(t.length),o=s>0;for(let i=0;i<t.length;i++){const a=t.charCodeAt(i);if(a>e){if(!o)throw new Error(`Character "${t[i]}" cannot be encoded in ${r}.`);n[i]=s}else n[i]=a}return new Blob([n],{type:a()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}}const n=(t,e)=>{const r=t.match(e);return r?r[2]:null};const s=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,i=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,a=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,o=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,c=/^#[a-f0-9]{6}$/,l=/^#[a-f0-9]{3}$/;function u(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"r"in t&&"g"in t&&"b"in t&&"number"==typeof t.r&&"number"==typeof t.b&&"number"==typeof t.g&&(t.a??=1,t.r>=0&&t.r<=1&&t.g>=0&&t.g<=1&&t.b>=0&&t.b<=1&&t.a>=0&&t.a<=1)}function h(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&"number"==typeof t.h&&"number"==typeof t.s&&"number"==typeof t.l&&(t.a??=1,t.h>=0&&t.h<=360&&t.s>=0&&t.s<=1&&t.l>=0&&t.l<=1&&t.a>=0&&t.a<=1)}const p={adjustRgbChannel:t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),adjustRgbChannelInv:t=>t<=.00304?12.92*t:1.055*(Math.pow(t,1/2.4)-.055),adjustRgb:t=>({r:p.adjustRgbChannel(t.r),g:p.adjustRgbChannel(t.g),b:p.adjustRgbChannel(t.b),a:t.a}),adjustRgbInv:t=>({r:p.adjustRgbChannelInv(t.r),g:p.adjustRgbChannelInv(t.g),b:p.adjustRgbChannelInv(t.b),a:t.a}),X:t=>.4125*t.r+.3576*t.g+.1804*t.b,Y:t=>.2126*t.r+.7152*t.g+.0722*t.b,Z:t=>.0193*t.r+.1191*t.g+.9503*t.b,relativeLuminance:t=>{const e=p.adjustRgb(t);return p.Y(e)},rgbToCieXYZ:t=>{const e=p.adjustRgb(t);return{x:p.X(e),y:p.Y(e),z:p.Z(e),a:t.a}},cieXYZToRgb:t=>{const e=3.241*t.x-1.5374*t.y-.4986*t.z,r=-.9692*t.x+1.876*t.y+.0416*t.z,n=.0556*t.x-.204*t.y+1.057*t.z;return p.adjustRgbInv({r:e,g:r,b:n,a:t.a})},contrastRatio:(t,e)=>{const r=p.relativeLuminance(t)+.05,n=p.relativeLuminance(e)+.05;return r>n?r/n:n/r}};function d(t){return t.toString(16).padStart(2,"0")}class Colors{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){const e=t=>Math.min(1,Math.max(0,t));return null==t[3]&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),a.test(t)){let e=a.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(o.test(t)){let e=o.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(c.test(t)){let e=c.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(l.test(t)){let e=l.exec(t)[0],r=e.substr(1,1),n=e.substr(2,1),s=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+n+n),parseInt("0x"+s+s),1]))}if(s.test(t)){let e=s.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3])};return this.rgb(r)}if(i.test(t)){let e=i.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3]),a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){const e=function(t){const e=t.r,r=t.g,n=t.b;return(.5*(Math.max(e,r,n)+Math.min(e,r,n))).clamp(0,1)}(t),r=function(t,e){const r=t.r,n=t.g,s=t.b,i=Math.max(r,n,s),a=Math.min(r,n,s);return(0===e||1===e?0:(i-a)/(1-Math.abs(2*e-1))).clamp(0,1)}(t,e),n=function(t){const e=t.r,r=t.g,n=t.b,s=Math.max(e,r,n),i=Math.min(e,r,n);let a=0;return s!==i&&(a=s===e?((r-n)/(s-i)*60+360)%360:s===r?((n-e)/(s-i)*60+120)%360:((e-r)/(s-i)*60+240)%360),a.clamp(0,360)}(t);return{h:n,s:r,l:e,a:t.a}}static cieXYZ(t){return h(t)&&(t=this.rgb(t)),p.rgbToCieXYZ(t)}static rgb(t){if(!h(t)){const e=p.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}{const e=t.h,r=t.s,n=t.l,s=e/60,i=(1-Math.abs(2*n-1))*r,a=i*(1-Math.abs(s%2-1)),o=n-i/2,c=(e,r,n)=>this._clampRGB([e+o,r+o,n+o,t.a]);if(s<=1)return c(i,a,0);if(s<=2)return c(a,i,0);if(s<=3)return c(0,i,a);if(s<=4)return c(0,a,i);if(s<=5)return c(a,0,i);if(s<=6)return c(i,0,a)}}static stringify(t,e=1){if(h(t)){e??=1,t.a??=1;const r="number"==typeof e?e:1;return`hsla(${t.h.roundoff(r)},${(100*t.s).roundoff(r)}%,${(100*t.l).roundoff(r)}%,${t.a.roundoff()})`}if(u(t)){e??=!0,t.a??=1;const r="boolean"==typeof e?e:!!e,n=Math.round(255*t.r),s=Math.round(255*t.g),i=Math.round(255*t.b),a=t.a.roundoff();return 1===a?r?("#"+d(n)+d(s)+d(i)).toUpperCase():`rgb(${n},${s},${i})`:`rgba(${n},${s},${i},${a})`}}static contrastRatio(t,e){return h(t)&&(t=this.rgb(t)),h(e)&&(e=this.rgb(e)),p.contrastRatio(t,e)}static luminance(t){return h(t)&&(t=Colors.rgb(t)),p.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(u(t)){const r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(u(t)){const r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,n){r??=.5,n??=r;const s=(r+n).roundoff(),i=(r/s).roundoff(),a=(n/s).roundoff(),o=u(t),c=h(t),l=t=>u(t)||h(t)?Colors.cieXYZ(t):t;t=l(t),e=l(e);const p={x:(t.x*i+e.x*a).roundoff(),y:(t.y*i+e.y*a).roundoff(),z:(t.z*i+e.z*a).roundoff(),a:(t.a*i+e.a*a).roundoff()};return o?Colors.rgb(p):c?Colors.hsl(Colors.rgb(p)):p}}const g=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function f(t){const e=[];let r=t.match(g);return r&&r.length>0&&r.forEach(t=>e.push(parseFloat(t))),e}class Angle{static isAngle(t){return"object"==typeof t&&"vertex"in t&&Point.isPoint(t.vertex)&&"start"in t&&Point.isPoint(t.start)&&"end"in t&&Point.isPoint(t.end)}static value(t){if(NullChecker.isNullOrEmpty(t)||!Angle.isAngle(t))return Number.NaN;const{vertex:e,start:r,end:n}=t;return Angle.angleBetween(e,r,n)}static angleBetween(t,e,r){const n=e.x-t.x,s=e.y-t.y,i=r.x-t.x,a=r.y-t.y,o=n*i+s*a,c=n*a-s*i;return-Math.atan2(c,o)}}class Size{static parse(t){let e=f(t);if(e&&2===e.length)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return"object"==typeof t&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}}class Point{static parse(t){let e=f(t);if(e&&2===e.length)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return"object"==typeof t&&"x"in t&&"number"==typeof t.x&&"y"in t&&"number"==typeof t.y}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}}class Matrix2D{static isIdentity(t){return 1===t.a&&1===t.d&&0===t.b&&0===t.f&&0===t.c&&0===t.e}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){const r=Math.cos(e),n=Math.sin(e);return Matrix2D.multiply(t,{a:r,b:n,c:-n,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?"number"==typeof e?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:"number"==typeof e?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){const e=this.det(t);if(0===e)return null;const r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){const r=Math.sqrt(t.a*t.a+t.c*t.c),n=Math.sqrt(t.b*t.b+t.d*t.d),s=0!=r?t.a/r:0,i=0!=r?t.c/r:0,a=Math.atan2(i,s),{x:o,y:c}=e;return{scaleX:r,scaleY:n,rotation:a,translation:{x:t.e-o*(r*s-1)+c*r*i,y:t.f-c*(n*s-1)-o*n*i}}}static fromTransform([t,e,r],[n,s,i]){const a=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(a)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");const o=1/a;return{a:o*(n.x*(e.y-r.y)+s.x*(r.y-t.y)+i.x*(t.y-e.y)),b:o*(n.y*(e.y-r.y)+s.y*(r.y-t.y)+i.y*(t.y-e.y)),c:o*(n.x*(r.x-e.x)+s.x*(t.x-r.x)+i.x*(e.x-t.x)),d:o*(n.y*(r.x-e.x)+s.y*(t.x-r.x)+i.y*(e.x-t.x)),e:o*(n.x*(e.x*r.y-r.x*e.y)+s.x*(r.x*t.y-t.x*r.y)+i.x*(t.x*e.y-e.x*t.y)),f:o*(n.y*(e.x*r.y-r.x*e.y)+s.y*(r.x*t.y-t.x*r.y)+i.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}}class Rect{static parse(t){let e=f(t);if(e&&4===e.length)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return Point.isPoint(t)&&Size.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,n){let s=1;s=t.width/t.height>=e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _cover(t,e,r,n){let s=1;s=t.width/t.height<e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _align(t,e,r,n){let s=0,i=0;switch(r){case"left":s=e.x-t.x;break;case"right":s=e.x+e.width-t.width-t.x;break;default:s=e.x+.5*e.width-.5*t.width-t.x}switch(n){case"top":i=e.y-t.y;break;case"bottom":i=e.y+e.height-t.height-t.y;break;default:i=e.y+.5*e.height-.5*t.height-t.y}return{x:s,y:i}}static findTransform(t,e,r="stretch",n="center",s="middle"){switch(r){case"contain":return this._contain(t,e,n,s);case"cover":return this._cover(t,e,n,s);default:return this._stretch(t,e)}}static intersect(...t){const e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var n=r[0],s=1;s<r.length;s++){const t=r[s],i=Math.max(t.x,n.x),a=Math.max(t.y,n.y),o=Math.min(t.x+t.width,n.x+n.width)-i,c=Math.min(t.y+t.height,n.y+n.height)-a;if(o<0||c<=0)return e;n={x:i,y:a,width:o,height:c}}return n}static expand(t,...e){const r=Array.from(e||[]);let n=t.x,s=t.y,i=n,a=s;Rect.isRect(t)&&(i+=t.width,a+=t.height);for(let t of r)n=Math.min(t.x,n),s=Math.min(t.y,s),i=Math.max(t.x,i),a=Math.max(t.y,a);return{x:n,y:s,width:i-n,height:a-s}}}const y={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"};class Imaging{static async loadImage(t){const e=await fetch(t);if(!e.ok)return null;return await e.blob()}static async resizeImage(t,e,r,n){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");"string"==typeof t&&(t=await Imaging.loadImage(t));const s=await self.createImageBitmap(t),i=s.width,a=s.height,o=new OffscreenCanvas(i,a),c=o.getContext("2d");c.imageSmoothingEnabled=c.mozImageSmoothingEnabled=c.oImageSmoothingEnabled=c.webkitImageSmoothingEnabled=!0;const{quality:l,type:u,mode:h,align:p,valign:d,background:g}=Object.assign({},y,n??{}),f={width:i,height:a,x:0,y:0},m={x:0,y:0,width:e,height:r},w=Rect.findTransform(f,m,h,p,d);o.width=e,o.height=r,g&&(c.fillStyle=g,c.fillRect(0,0,o.width,o.height)),c.setTransform(w),c.drawImage(s,0,0);return await o.convertToBlob({quality:l,type:u})}}class Keys{static#t;static uniqueId(){let t=Keys.#t||Date.now();return Keys.#t=++t}static uniqueCode(){return Keys.uniqueId().toBase62()}static randomString(t){let e="";do{e+=(62*Math.random()).toBase62()}while(e.length<t);return e}}function m(t,e){const r=t.length,n=e.length,s=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let i=1;i<=r;i++)for(let r=1;r<=n;r++)t[i-1]===e[r-1]?s[i][r]=s[i-1][r-1]+1:s[i][r]=Math.max(s[i-1][r],s[i][r-1]);return s}function w(t,e,r,n=""){const s=t.length,i=e.length,a=[];let o=s,c=i,l=null;const u=()=>{l&&(a.push(l),l=null)};for(;o>0||c>0;){var h=null;let s=null;o>0&&c>0&&t[o-1]===e[c-1]?(h="=",s=t[o-1],o--,c--):c>0&&(0===o||r[o][c-1]>=r[o-1][c])?(h="+",s=e[c-1],c--):o>0&&(0===c||r[o-1][c]>r[o][c-1])&&(h="-",s=t[o-1],o--),h&&null!==s?l&&l.type===h?l.value=s+(l.value?n:"")+l.value:(u(),l={type:h,value:s}):u()}return u(),a.reverse()}class LexerClass{tokenize(t,e){const r=[];for(;t;){const n=t.length;for(let n of e){const e=n.exec(t,this),s=e?.length;if(s>0){Array.prototype.push.apply(r,e);const n=e[s-1];t=t.substr((n.index||0)+n.raw.length);break}}if(t.length>=n)throw new Error(`Cannot parse\n"${t}"\n using the provided grammar.`)}return r}}let x=class Parser{constructor(t=new LexerClass){this._lexer=t}parse(t,e,r){const n=this._lexer.tokenize(t,e);return r.render(n)}};var b;!function(t){t.Text="text",t.Space="space",t.Newline="newline",t.Comment="comment",t.DocComment="doc-comment",t.Keyword="keyword",t.Identifier="identifier",t.String="string",t.Regex="regex",t.Number="number",t.Bracket="bracket",t.Punctuation="punctuation",t.Operator="operator",t.Preprocessor="preprocessor",t.Tag="tag",t.TagName="tagname",t.Attribute="attribute",t.Entity="entity"}(b||(b={}));const k=new Map;function _(t){return(t??"").trim().toLowerCase()}class Syntaxes{static register(t){if(null==t)return;const e=[t.name].concat(t.aliases??[]);for(let r of e){const e=_(r);k.set(e,t)}}static get(t){const e=_(t);return k.get(e)??null}static names(){const t=k.keys();return Array.from(t)}}const S=[b.Identifier],$=[b.Space,b.Newline,b.Comment,b.DocComment];function C(t){return null!=t.combined}const v=new WeakMap;function T(t){return"include"in t}function A(t){return null==t||0===t.length?null:new Set(t)}function N(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=t[e].concat(n)}return r}function R(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=n.concat(t[e])}return r}function E(t,e=0){const r=t.lexical??{states:{}},n={start:r.start,states:r.states??{},keywords:r.keywords??{},keywordSources:r.keywordSources,keywordExceptAfter:r.keywordExceptAfter,insignificant:r.insignificant},s=t.extends?Syntaxes.get(t.extends):null;if(null==s||s===t||e>=16)return n;const i=E(s,e+1);return{start:n.start??i.start,states:N(n.states,i.states),keywords:R(n.keywords,i.keywords),keywordSources:n.keywordSources??i.keywordSources,keywordExceptAfter:n.keywordExceptAfter??i.keywordExceptAfter,insignificant:n.insignificant??i.insignificant}}function L(t,e,r){const n=t[e]??[];if(r.has(e))return[];r.add(e);const s=[];for(let e of n){if(!T(e)){s.push(e);continue}const n=L(t,e.include,r);Array.prototype.push.apply(s,n)}return r.delete(e),s}function M(t){const e=Array.isArray(t.type)?t.type:null,r=Array.isArray(t.type)?t.type[0]:t.type,n=function(t){const e=t.split(""),r=new Set(e);return Array.from(r).join("")}((t.flags??"").replace(/[yd]/g,"")),s=n+"y"+(e?"d":""),i=new RegExp(t.match,s),a=t.until?new RegExp(t.until,"y"):null,o=!0===t.pop?1:"number"==typeof t.pop?t.pop:0;var c;return{regex:i,type:r,groupTypes:e,when:null==(c=t.when)?null:{previousTypes:A(c.previousTypes),previousNotTypes:A(c.previousNotTypes),previousTexts:A(c.previousTexts),previousNotTexts:A(c.previousNotTexts)},pop:o,until:a,source:t.match,flags:n,next:t.next??null,push:t.push??null,embed:t.embed??null,hasTransition:o>0||!!t.next||!!t.push||!!t.embed}}function I(t){const e=new Map;for(let r in t)for(let n of t[r])e.set(n,r);return e}const z=/\\[1-9]|\\k<|\(\?<(?![=!])/;function B(t,e){return new RegExp(t+"|",e).exec("").length-1}function O(t){return null==t.when&&!z.test(t.source)&&(e=t.source,r=t.flags,!new RegExp("^(?:"+e+")$",r).test(""));var e,r}function F(t){const e=[];let r=[];const n=()=>{if(r.length>0){const t=function(t){if(1===t.length)return{rule:t[0],combined:null};const e=[];let r=1;for(let n of t)e.push(r),r+=1+B(n.source,n.flags);const n=t.map(t=>"("+t.source+")").join("|");return{rule:null,combined:new RegExp(n,t[0].flags+"y"),rules:t,groupIndices:e}}(r);e.push(t)}r=[]};for(let s of t)O(s)?(r.length>0&&r[0].flags!==s.flags&&n(),r.push(s)):(n(),e.push({rule:s,combined:null}));return n(),e}function j(t){const e=v.get(t);if(null!=e)return e;const r=E(t),n=new Map;for(let t in r.states){const e=new Set,s=F(L(r.states,t,e).map(M));n.set(t,s)}const s={name:t.name,start:r.start??"root",states:n,keywords:I(r.keywords),keywordSources:new Set(r.keywordSources??S),keywordExceptAfter:new Set(r.keywordExceptAfter??[]),insignificant:new Set(r.insignificant??$)};return v.set(t,s),s}class ScanRun{constructor(t,e){this._source=t,this._tokens=[],this._position=0,this._emitted=0,this._line=1,this._column=1,this._previous=null,this._emptyTransitions=0,this._stack=[{syntax:e,state:e.start,until:null}]}run(){const t=this._source.length;for(;this._position<t;)this._step();return this._flushText(),this._tokens}get _top(){const t=this._stack;return t[t.length-1]}_step(){const t=this._top;if(this._popOnUntil(t))return;const e=this._findRule(t);if(null==e)return void this._position++;this._flushText(),this._emitMatch(e,t.syntax),this._transition(e.rule,t.syntax);const r=e.match[0].length;this._position+=r,r>0&&(this._emptyTransitions=0)}_popOnUntil(t){const e=t.until;return!(null==e||this._stack.length<=1)&&(e.lastIndex=this._position,!!e.test(this._source)&&(this._flushText(),this._stack.pop(),!0))}_findRule(t){const e=t.syntax.states.get(t.state)??[];for(let t of e){const e=C(t)?this._tryCombined(t):this._trySingle(t.rule);if(null!=e)return e}return null}_trySingle(t){const e=this._tryRule(t);return null==e?null:{rule:t,match:e}}_tryCombined(t){const e=t.combined;e.lastIndex=this._position;const r=e.exec(this._source);if(null==r)return null;const n=t.groupIndices;for(let e=0;e<n.length;e++){if(void 0===r[n[e]])continue;const s=t.rules[e];return this._trySingle(s)}return null}_tryRule(t){if(null!=t.when&&!function(t,e){const r=e?.type??null,n=e?.raw??null;return!(null!=t.previousTypes&&!t.previousTypes.has(r)||null!=t.previousNotTypes&&t.previousNotTypes.has(r)||null!=t.previousTexts&&!t.previousTexts.has(n)||null!=t.previousNotTexts&&t.previousNotTexts.has(n))}(t.when,this._previous))return null;const e=t.regex;e.lastIndex=this._position;const r=e.exec(this._source);return null==r?null:r[0].length>0?r:!t.hasTransition||this._emptyTransitions>=64?null:(this._emptyTransitions++,r)}_emitMatch({rule:t,match:e},r){const n=e[0];null!=t.groupTypes?this._emitGroups(t,e,r):this._append(t.type,n,r)}_emitGroups(t,e,r){const n=e.indices,s=e.index,i=s+e[0].length,a=t.groupTypes;let o=s;for(let t=1;t<e.length;t++){const e=n[t];if(null==e||e[0]<o||e[1]===e[0])continue;if(e[0]>o){const t=this._source.slice(o,e[0]);this._append(b.Text,t,r)}const s=this._source.slice(e[0],e[1]),i=a[t-1]??a[a.length-1];this._append(i,s,r),o=e[1]}if(o<i){const t=this._source.slice(o,i);this._append(b.Text,t,r)}}_transition(t,e){const r=this._stack;for(let e=0;e<t.pop&&r.length>1;e++)r.pop();if(null!=t.next&&(this._top.state=t.next),null!=t.push&&r.push({syntax:e,state:t.push,until:null}),null==t.embed)return;const n=function(t){const e=Syntaxes.get(t);return null==e?null:j(e)}(t.embed);null!=n&&r.push({syntax:n,state:n.start,until:t.until})}_flushText(){if(this._emitted>=this._position)return;const t=this._source.slice(this._emitted,this._position),e=this._top.syntax;this._append(b.Text,t,e)}_resolveType(t,e,r){if(!r.keywordSources.has(t))return t;const n=this._previous?.raw;return r.keywordExceptAfter.has(n)?t:r.keywords.get(e)??t}_append(t,e,r){const n=this._resolveType(t,e,r),s={type:n,raw:e,text:e,index:this._emitted,line:this._line,column:this._column,depth:this._stack.length-1,syntax:r.name};this._tokens.push(s),this._advance(e),r.insignificant.has(n)||(this._previous=s)}_advance(t){this._emitted+=t.length;const e=t.lastIndexOf("\n");if(e<0)this._column+=t.length;else{for(let r=0;r<=e;r++)10===t.charCodeAt(r)&&this._line++;this._column=t.length-e}}}const D={name:b.Text,lexical:{states:{}}};class Scanner{tokenize(t,e){const r=t??"",n=j(("string"==typeof e?Syntaxes.get(e):e)??D);return new ScanRun(r,n).run()}}const U=Object.freeze({keyword:"code-keyword",preprocessor:"code-keyword",string:"code-string",regex:"code-string",number:"code-number",comment:"code-comment","doc-comment":"code-comment",tag:"code-tag",tagname:"code-tagname",attribute:"code-attribute"}),H={"&":"&","<":"<",">":">",'"':"""};class HighlightRenderer{constructor(t=U){this._classes=t}render(t){let e="";for(let r of t??[])e+=this._renderToken(r);return e}_renderToken(t){const e=(t.raw??"").replace(/[&<>"]/g,t=>H[t]);const r=this._classes[t.type];return null==r?e:`<span class="${r}">${e}</span>`}}function P(t){return(t??"").replace(/</g,"<")}function q(t){return(t??"").replace(/&(?!(?:#\d+|#x[\da-fA-F]+|\w+);)/g,"&").replace(/"/g,""").replace(/</g,"<")}function Q(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));return e.split(/(?<!\\)\|/).map(t=>t.trim().replace(/\\\|/g,"|"))}function X(t){const e=t.startsWith(":"),r=t.endsWith(":");return e&&r?"center":r?"right":e?"left":null}function Y(t){return/^ */.exec(t)[0].length}const Z=new Scanner;function G(t){return t?.index||void 0}function W(t){return t?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function K(t,e,r){const n=e.exec(t);return n&&n.length?r(n):null}const J=/(<!--)([\s\S]*?)(-->|$)/,V=/^ {0,3}(={3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,}|(?:\*[ \t]*){3,})(\r?\n|$)/,tt=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,et=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,rt=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,nt=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,st=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,it=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,at=/^( {0,3}([-+]|\*(?=[ \t])).*(\r?\n|$))((?!(?: ?\d+[.\)]|\r?\n\S)).*(\r?\n|$))*/,ot=/^( {0,3}(\d+[.\)]).*(\r?\n|$))((?!(?: {0,2}(?:[-+]|\*[ \t])|\r?\n\S)).*(\r?\n|$))*/,ct=/^( *)([-+*]|\d+[.\)])([ \t]+|$)/,lt=/^\[([ xX])\][ \t]+/,ut=/^(?! {4,})(?=[ \t]*\S)(.+(\n(?![ \t]*(?:\n|$))(?! {0,3}```)(?! {0,3}([-+]|\*[ \t]|\d+[.\)]))(?! {0,3}#{1,6}[ \t])(?! {4,})(?! {0,3}>).+)*)/,ht=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,pt=/(?<!\\)!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,dt=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,gt=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,ft=/(\*\*?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1|(?<![A-Za-z0-9])(__?)((?!\3\s?)(?:(?!\3)[\S\s])*[^\s])\3(?![A-Za-z0-9])/,yt=/(~~?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,mt=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,wt=/^\s+/,xt=/^(?:[ \t]*\r?\n)+|^\s+/,bt=/(?: {2,}|\\)\r?\n/,kt=/^[^\r\n]+/,_t=/\\(<|[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/,St={"<":"<","<":"<","&":"&"},$t=/(?:<|<)((?:https?|ftp|mailto):[^\s<>]+|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)>/,Ct=/(?<![\w\/\\(\[<"'=;&@])(?:https?:\/\/|www\.)[^\s<>]*[^\s<>.,:;"'!?)\]*_~]/,vt=/\[\^([^\]\s]+)\]/,Tt=/^ {0,3}\[\^([^\]\s]+)\]: *([^\r\n]*(?:\r?\n {2,}[^\r\n]+)*)(\r?\n|$)+/,At=/^ {0,3}(\|?[^\r\n]*\|[^\r\n]*)\r?\n {0,3}(\|? *:?-+:? *(?:\| *:?-+:? *)*\|?) *(?:\r?\n|$)((?:(?! {0,3}(?:\r?\n|$))[^\r\n]*\|[^\r\n]*(?:\r?\n|$))*)/;var Nt,Rt;function Et(t=[]){const e={[Rt.Comment]:{exec:(t,e)=>K(t,J,r=>{const n=G(r),s=[{type:Nt.Html,index:n,raw:r[0],text:r[2]}];if(n>0){const r=t.substr(0,n),i=e.tokenize(r,y);Array.prototype.unshift.apply(s,i)}return s})},[Rt.Reference]:{exec:t=>K(t,ht,t=>{const e=G(t),r=t[0],n=r,s="!"===t[1],i=t[2],a=t[3],o=t[4];return[{type:Nt.Reference,index:e,raw:r,text:n,id:i,image:s,url:a,title:o}]})},[Rt.FootnoteDefinition]:{exec:(t,e)=>K(t,Tt,t=>{const r=t[0],n=W(t[1]),s=t[2].replace(/\r?\n {2,}/g," ");return[{type:Nt.FootnoteDefinition,index:G(t),raw:r,text:s,id:n,tokens:e.tokenize(s,l)}]})}},r=[],n=[],s={};for(let e of t){let t,i="inline";switch("type"in e?(i=e.type,t=e.rule):t=e,i){case"block":r.push(t);break;case"code":if("lang"in e){const r=e.lang.toLowerCase();(s[r]=s[r]||[]).push(t)}break;default:const i={exec:(e,r)=>{const n=t.exec(e,r);return o(e,n,r),n}};n.push(i)}}const i={[Rt.Text]:{exec:t=>K(t,kt,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.Text}]})},[Rt.Space]:{exec:t=>K(t,wt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},a={[Rt.ImageOrLink]:{exec:(t,e)=>c(t,pt,e,t=>{const r=G(t),n=t[0],s="!"===n.charAt(0),i=t[1],a=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\[/.test(t)&&/\]$/.test(t)))return/^\(/.test(t)&&/\)$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2]),o=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\(/.test(t)&&/\)$/.test(t)))return/^\[/.test(t)&&/\]$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2])??i,c=W(o),{url:u,title:h}=function(t){if(NullChecker.isNullOrEmpty(t))return{url:t};const e=t.trim(),r=/^(\S*)\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\))\s*$/.exec(e);if(null==r)return{url:e};const n=r[2]??r[3]??r[4];return{url:r[1],title:n}}(a),p=e.tokenize(i,l);return s?[{index:r,type:u?Nt.Image:Nt.ImageLike,raw:n,text:i,src:u,title:h,ref:c,tokens:p}]:[{index:r,type:u?Nt.Link:Nt.LinkLike,raw:n,text:i,href:u,title:h,ref:c,tokens:p}]})},[Rt.Escape]:{exec:(t,e)=>c(t,_t,e,t=>{const e=St[t[1]]??t[1];return[{index:G(t),raw:t[0],text:e,type:Nt.Text}]})},[Rt.AutoLink]:{exec:(t,e)=>c(t,$t,e,t=>{const e=t[1],r=!/^[a-z]+:/i.test(e)?"mailto:"+e:e;return[{index:G(t),raw:t[0],text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.BareUrl]:{exec:(t,e)=>c(t,Ct,e,t=>{const e=t[0],r=/^www\./i.test(e)?"http://"+e:e;return[{index:G(t),raw:e,text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.FootnoteReference]:{exec:(t,e)=>c(t,vt,e,t=>{const e=W(t[1]);return[{index:G(t),raw:t[0],text:t[1],id:e,type:Nt.FootnoteReference}]})},[Rt.Code]:{exec:(t,e)=>c(t,gt,e,t=>{const e=P(t[1]);return[{type:Nt.Code,raw:t[0],text:e,index:G(t)}]})},[Rt.EmphasizedLink]:{exec:(t,e)=>c(t,dt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=t[1].length>1?Nt.Bold:Nt.Italic,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Emphasize]:{exec:(t,e)=>c(t,ft,e,t=>{const r=t[1]??t[3],n=t[2]??t[4];if(NullChecker.isNullOrEmpty(n))return null;const s=r.length>1?Nt.Bold:Nt.Italic;return[{index:G(t),type:s,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.StrikeThrough]:{exec:(t,e)=>c(t,yt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.StrikeThrough,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Quote]:{exec:(t,e)=>c(t,mt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.Quote,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.LineBreak]:{exec:(t,e)=>c(t,bt,e,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.LineBreak}]})}},o=(t,e,r)=>{const n=e?.length>0&&e[0].index;if(n>0){const s=t.substr(0,n),i=r.tokenize(s,l)||[];Array.prototype.unshift.apply(e,i)}},c=(t,e,r,n)=>{const s=K(t,e,r=>{if(e!=gt){const e=gt.exec(t);if(e&&e.length&&e.index<r.index)return null}return n(r)});return o(t,s,r),s},l=[a[Rt.FootnoteReference],a[Rt.EmphasizedLink],a[Rt.ImageOrLink],a[Rt.Escape],a[Rt.AutoLink],a[Rt.Emphasize],a[Rt.StrikeThrough],a[Rt.Quote],a[Rt.Code],a[Rt.LineBreak],a[Rt.BareUrl]];Array.prototype.push.apply(l,n),l.push(i[Rt.Text],i[Rt.Space]);const u=t=>{const e=[i[Rt.Text],i[Rt.Space]],r=t?.toLowerCase()||"";return r&&r in s&&Array.prototype.unshift.apply(e,s[r]),e},h={[Rt.Paragraph]:{exec:(t,e)=>K(t,ut,t=>{const r=t[0],n=r.replace(/^[ \t]+/gm,"");return 0===n.trim().length?null:[{type:Nt.Paragraph,raw:r,text:n,tokens:e.tokenize(n,l)}]})},[Rt.Space]:{exec:t=>K(t,xt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},p=(t,e)=>{const r=function(t){const e=t.replace(/\t/g," ").split(/\r?\n/),r=[];for(let t of e){const e=r[r.length-1],n=ct.exec(t);if(null!=n&&(null==e||n[1].length<e.indent)){const e=n[0].length,s=t.slice(e);r.push({indent:e,lines:[s]});continue}if(null==e)continue;const s=Math.min(e.indent,Y(t)),i=t.slice(s);e.lines.push(i)}return r.map(t=>t.lines.join("\n").replace(/\s+$/,""))}(t);return r.filter(t=>!NullChecker.isNullOrEmpty(t)).map(t=>{const r=lt.exec(t),n=r?t.slice(r[0].length):t,s=((t,e)=>{if(!/^ {0,3}(`{3,}|$|>|[-+*]\s|\d+[.\)]|#{1,6}\s|\|)/m.test(t))return e.tokenize(t,l);const r=e.tokenize(t,f),n=r[0];if(/\n[ \t]*\n/.test(t)||n?.type!==Nt.Paragraph)return r;const s=n.tokens??[],i=r.slice(1);return s.concat(i)})(n,e);if(null==r)return{type:Nt.ListItem,raw:t,text:n,tokens:s};const i=" "!==r[1];return{type:Nt.ListItem,raw:t,text:n,tokens:s,task:!0,checked:i}})},d=(t,e,r,n)=>{const s=e.map((e,s)=>{const i=t[s]??"",a=n.tokenize(i,l);return{type:Nt.TableCell,raw:i,text:i,header:r,align:e,tokens:a}}),i=t.join(" | ");return{type:Nt.TableRow,raw:i,text:i,header:r,tokens:s}},g={[Rt.HorizontalRule]:{exec:(t,e)=>K(t,V,t=>{const e=t[0],r=e;return[{type:Nt.HorizontalRule,raw:e,text:r}]})},[Rt.Heading]:{exec:(t,e)=>K(t,tt,t=>{const r=t[2].replace(/[ \t]+#+[ \t]*$/,"");return[{type:Nt.Heading,raw:t[0],text:r,level:t[1].length,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading1]:{exec:(t,e)=>K(t,et,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:1,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading2]:{exec:(t,e)=>K(t,rt,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:2,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.CodeBlock]:{exec:(t,e)=>K(t,nt,t=>{const r=t[0],n=r.replace(/^ {4}/gm,"").replace(/\s+$/,""),s=P(n);return 0===n.length?null:[{type:Nt.CodeBlock,raw:r,text:s,tokens:e.tokenize(s,u(""))}]})},[Rt.Fences]:{exec:(t,e)=>K(t,st,t=>{const r=(t[1]??"").trim().split(/\s+/)[0].toLowerCase(),n=r in s?null:Syntaxes.get(r);if(null==n){const n=P(t[2]);return[{type:Nt.CodeBlock,raw:t[0],text:n,lang:r,tokens:e.tokenize(n,u(r))}]}const i=function(t){return(t??"").replace(/</g,"<")}(t[2]),a=Z.tokenize(i,n);return[{type:Nt.CodeBlock,raw:t[0],text:i,lang:r,syntax:n.name,highlighted:!0,tokens:a}]})},[Rt.BlockQuote]:{exec:(t,e)=>K(t,it,t=>{const r=t[0],n=r.replace(/^ {0,3}> ?/gm,"");return[{type:Nt.BlockQuote,raw:r,text:n,tokens:e.tokenize(n,f)}]})},[Rt.OrderedList]:{exec:(t,e)=>K(t,ot,t=>{const r=t[0],n=/\d+/.exec(r),s=parseInt(n[0]),i=p(r,e);return[{type:Nt.OrderedList,start:s,raw:r,text:r,tokens:i}]})},[Rt.UnorderedList]:{exec:(t,e)=>K(t,at,t=>{const r=t[0],n=p(r,e);return[{type:Nt.UnorderedList,raw:r,text:r,tokens:n}]})},[Rt.Table]:{exec:(t,e)=>K(t,At,t=>{const r=Q(t[1]),n=Q(t[2]);if(r.length!==n.length)return null;const s=n.map(X),i=t[3].split(/\r?\n/).filter(t=>t.trim().length>0),a=d(r,s,!0,e),o=i.map(t=>{const r=Q(t);return d(r,s,!1,e)}),c=[a].concat(o);return[{type:Nt.Table,raw:t[0],text:t[0],align:s,tokens:c}]})}},f=Object.values(g);Array.prototype.push.apply(f,r),f.push(h[Rt.Paragraph],h[Rt.Space]);const y=[e[Rt.Comment],e[Rt.FootnoteDefinition],e[Rt.Reference]].concat(f);return y}!function(t){t.Html="html",t.Text="text",t.Paragraph="paragraph",t.BlockQuote="blockquote",t.Space="space",t.Heading="heading",t.Bold="bold",t.Italic="italic",t.CodeBlock="codeblock",t.Code="code",t.Image="img",t.ImageLike="imglike",t.Link="link",t.LinkLike="linklike",t.LineBreak="br",t.StrikeThrough="strike",t.Quote="quote",t.HorizontalRule="hr",t.OrderedList="ol",t.UnorderedList="ul",t.ListItem="listitem",t.Reference="ref",t.Table="table",t.TableRow="tr",t.TableCell="td",t.FootnoteReference="fnref",t.FootnoteDefinition="fndef"}(Nt||(Nt={})),function(t){t[t.Comment=0]="Comment",t[t.Reference=1]="Reference",t[t.HorizontalRule=2]="HorizontalRule",t[t.Heading=3]="Heading",t[t.Heading1=4]="Heading1",t[t.Heading2=5]="Heading2",t[t.CodeBlock=6]="CodeBlock",t[t.Fences=7]="Fences",t[t.BlockQuote=8]="BlockQuote",t[t.OrderedList=9]="OrderedList",t[t.UnorderedList=10]="UnorderedList",t[t.Paragraph=11]="Paragraph",t[t.EmphasizedLink=12]="EmphasizedLink",t[t.ImageOrLink=13]="ImageOrLink",t[t.Emphasize=14]="Emphasize",t[t.StrikeThrough=15]="StrikeThrough",t[t.Quote=16]="Quote",t[t.Code=17]="Code",t[t.LineBreak=18]="LineBreak",t[t.FootnoteDefinition=19]="FootnoteDefinition",t[t.Table=20]="Table",t[t.Escape=21]="Escape",t[t.AutoLink=22]="AutoLink",t[t.FootnoteReference=23]="FootnoteReference",t[t.BareUrl=24]="BareUrl",t[t.Text=254]="Text",t[t.Space=255]="Space"}(Rt||(Rt={}));const Lt="\0",Mt=/[ \r\n]*\0+[ \r\n]*/g;function It(t){if(NullChecker.isNullOrEmpty(t))return"";return` title="${q(t)}"`}function zt(t){return null==t?"":` style="text-align: ${t}"`}class HtmlRenderer{constructor(t=(t,e)=>t?.text||""){this._extraItemRender=t,this.#e=[],this.#r=new Map,this.#n=[],this.#s=new HighlightRenderer,this._renderContent=t=>{const e=t.tokens;return NullChecker.isNullOrEmpty(e)?t.text:this._render(e)}}#e;#r;#n;#s;_collectDefinitions(t){for(let e of t??[])e?.type===Nt.Reference&&this.#e.push(e),e?.type!==Nt.FootnoteDefinition||this.#r.has(e.id)||this.#r.set(e.id,e),this._collectDefinitions(e?.tokens)}_findReference(t,e){if(NullChecker.isNullOrEmpty(t))return;const r=t.toLowerCase();return this.#e.find(t=>!0===t.image===e&&t.id?.toLowerCase()===r)}_renderCodeBlock(t){const e=Lt,r=t.lang;if(!0!==t.highlighted){return`<pre>${e}<code${r?' class="'+r+'"':""}>${this._renderContent(t)}</code>${e}</pre>${e}`}const n=[r,"code-highlighted"];"markup"===t.syntax&&n.push("code-markup");return`<pre>${e}<code class="${q(n.join(" "))}">${this.#s.render(t.tokens)}</code>${e}</pre>${e}`}_renderImage(t){let e=t.src,r=t.title;if(!e){const n=this._findReference(t.ref,!0);e=n?.url,r=n?.title}if(!e){return`![${this._renderContent(t)}]`}const n=It(r);return`<img src="${e}" alt="${t.text}"${n} />`}_renderLink(t){let e=t.href,r=t.title;if(!e){const n=this._findReference(t.ref,!1);e=n?.url,r=n?.title}const n=this._renderContent(t);if(!e)return`[${n}]`;return`<a href="${e}"${It(r)}>${n}</a>`}_renderListItem(t){const e=Lt,r=this._renderContent(t);if(!0!==t.task)return`\t<li>${r}</li>${e}`;return`\t<li class="task-list-item"><input type="checkbox" disabled${!0===t.checked?" checked":""} /> ${r}</li>${e}`}_renderTableRow(t){const e=Lt;let r="";for(let e of t.tokens??[]){const t=!0===e.header?"th":"td";r+=`<${t}${zt(e.align)}>${this._renderContent(e)}</${t}>`}return`<tr>${r}</tr>${e}`}_renderTable(t){const e=Lt,r=t.tokens??[],n=r.filter(t=>!0===t.header),s=r.filter(t=>!0!==t.header);let i=`<table>${e}<thead>${e}${n.map(t=>this._renderTableRow(t)).join("")}</thead>${e}`;if(s.length>0){i+=`<tbody>${e}${s.map(t=>this._renderTableRow(t)).join("")}</tbody>${e}`}return i+`</table>${e}`}_renderFootnoteReference(t){const e=t.id;if(!this.#r.has(e))return`[^${t.text}]`;const r=this.#n,n=!r.includes(e);n&&r.push(e);return`<sup class="footnote-ref"><a href="#fn-${e}"${n?` id="fnref-${e}"`:""}>${r.indexOf(e)+1}</a></sup>`}_renderFootnotes(){const t=this.#n;if(0===t.length)return"";const e=Lt;let r="";for(let n=0;n<t.length;n++){const s=t[n],i=this.#r.get(s);r+=`<li id="fn-${s}">${this._renderContent(i)} <a href="#fnref-${s}" class="footnote-backref">↩</a></li>${e}`}return`<section class="footnotes">${e}<ol>${e}${r}</ol>${e}</section>${e}`}_rendeItem(t,e){const r=this._renderContent,n=Lt;switch(t?.type){case Nt.Reference:case Nt.FootnoteDefinition:return"";case Nt.Html:return t.raw;case Nt.BlockQuote:return`<blockquote>\n${r(t)}</blockquote>${n}`;case Nt.Bold:return`<b>${r(t)}</b>`;case Nt.CodeBlock:return this._renderCodeBlock(t);case Nt.Code:return`<code>${r(t)}</code>`;case Nt.HorizontalRule:return`<hr />${n}`;case Nt.Heading:const e=t.level;return`<h${e} id="${t.ref}">${r(t)}</h${e}>${n}`;case Nt.Image:case Nt.ImageLike:return this._renderImage(t);case Nt.Italic:return`<i>${r(t)}</i>`;case Nt.StrikeThrough:return`<s>${r(t)}</s>`;case Nt.Quote:return`<q>${r(t)}</q>`;case Nt.LineBreak:return"<br />\0";case Nt.OrderedList:return`<ol start="${t.start}">\n${r(t)}</ol>${n}`;case Nt.UnorderedList:return`<ul>\n${r(t)}</ul>${n}`;case Nt.ListItem:return this._renderListItem(t);case Nt.Link:case Nt.LinkLike:return this._renderLink(t);case Nt.Table:return this._renderTable(t);case Nt.FootnoteReference:return this._renderFootnoteReference(t);case Nt.Paragraph:return`<p>${r(t)}</p>${n}`;case Nt.Text:case Nt.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let r of t||[])e+=this._rendeItem(r,t);return e}render(t){this.#e=[],this.#r.clear(),this.#n=[],this._collectDefinitions(t);const e=this._render(t),r=this._renderFootnotes();return n=e+r,n?.replace(Mt,"\n").trim();var n}}class TokenRenderer{_render(t){return NullChecker.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(t=>!NullChecker.isNullOrEmpty(t)).map(this._render).join(",")+"]"}}var Bt=Object.freeze({__proto__:null,Parser:class Parser extends x{toHtml(t,e,r){const n=new HtmlRenderer(r);return NullChecker.isNullOrEmpty(e)?this.parse(t,n):this.parse(t,Et(e),n)}tokenize(t,e){const r=this.parse(t,Et(e),new TokenRenderer);return JSON.parse(r)}parse(t,e=Et(),r=new HtmlRenderer){const n=(t??"").replace(/\r\n?/g,"\n");if((s=e)&&"object"==typeof s&&"function"==typeof s.render){const t=Et();return super.parse(n,t,e)}var s;return super.parse(n,e,r)}}});const Ot={name:"javascript",aliases:["js","mjs","cjs","jsx","typescript","ts","tsx","script","ecmascript"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n
]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:"`",type:"string",push:"template"},{match:String.raw`"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\[\s\S]|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\[\r\n])+/[a-z]*`,type:"regex",when:{previousNotTypes:["identifier","number","string","regex"],previousNotTexts:[")","]","}","this","super","null","undefined","true","false","++","--"]}},{match:String.raw`0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d[\d_]*)?n?`,type:"number"},{match:String.raw`#?[A-Za-z_$ -][\w$ -]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.(?!\d)|\.\.\.|[;,.]`,type:"punctuation"},{match:String.raw`>>>=|<<=|>>=|>>>|\*\*=|&&=|\|\|=|\?\?=|===|!==|=>|\*\*|\+\+|--|<<|>>|&&|\|\||\?\?|[-+*/%&|^<>!=]=?|[~?:@]`,type:"operator"}],template:[{match:"`",type:"string",pop:!0},{match:String.raw`\$\{`,type:"punctuation",push:"templateExpression"},{match:String.raw`(?:\\[\s\S]|\$(?!\{)|[^\\`+"`"+String.raw`$])+`,type:"string"}],templateExpression:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","import","in","instanceof","let","new","null","of","return","set","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield","abstract","accessor","any","as","asserts","bigint","boolean","declare","implements","infer","interface","is","keyof","module","namespace","never","number","object","override","package","private","protected","public","readonly","satisfies","string","symbol","type","unique","unknown"]},keywordExceptAfter:[".","?."]}},Ft={previousNotTexts:[".","?."]},jt={name:"pacem-binding",aliases:["pacem","binding"],extends:"javascript",lexical:{states:{root:[{match:String.raw`:host(?=\.)`,type:"binding-host",when:Ft},{match:String.raw`::[A-Za-z_$][\w$]*`,type:"binding-host-property"},{match:String.raw`\^+item(?![\w$])`,type:"binding-item"},{match:String.raw`\^+index(?![\w$])`,type:"binding-index"},{match:String.raw`#[A-Za-z_][\w]*`,type:"binding-element",when:Ft},{match:String.raw`\$?this(?![\w$])`,type:"binding-this",when:Ft}]}}},Dt={match:String.raw`\r\n|[\r\n]`,type:"newline"},Ut=[Dt,{match:String.raw`[ \t\f]+`,type:"space"},{match:'"',type:"string",push:"doubleQuoted"},{match:"'",type:"string",push:"singleQuoted"},{match:String.raw`[^\s=/>"']+`,type:"attribute"},{match:"=",type:"operator"},{match:"/",type:"punctuation"}],Ht=[{match:String.raw`\{\{`,type:"punctuation",embed:"pacem-binding",until:String.raw`\}\}`},{match:String.raw`\}\}`,type:"punctuation"}],Pt={name:"markup",aliases:["html","htm","xml","xhtml","svg"],lexical:{start:"root",states:{root:[{match:String.raw`<!--[\s\S]*?(?:-->|$)`,type:"comment"},{match:String.raw`<![^>]*>?`,type:"tag"},{match:String.raw`(<\/)([\w:.-]+)(\s*>?)`,type:["tag","tagname","tag"]},{match:String.raw`(<)(script)(?![\w:.-])`,flags:"i",type:["tag","tagname"],push:"scriptTag"},{match:String.raw`(<)([\w:.-]+)`,type:["tag","tagname"],push:"tag"},{match:String.raw`&(?:#\d+|#[xX][\da-fA-F]+|\w+);`,type:"entity"},Dt,{match:String.raw`[^<&\r\n]+`,type:"text"}],tag:[{match:String.raw`/?>`,type:"tag",pop:!0},{include:"attributes"}],scriptTag:[{match:"/>",type:"tag",pop:!0},{match:">",type:"tag",pop:!0,embed:"javascript",until:String.raw`<\/script`},{include:"attributes"}],attributes:Ut,doubleQuoted:[{match:'"',type:"string",pop:!0},...Ht,{match:String.raw`(?:[^"{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}],singleQuoted:[{match:"'",type:"string",pop:!0},...Ht,{match:String.raw`(?:[^'{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}]},insignificant:["space","newline","comment","text"]}},qt={name:"csharp",aliases:["cs","c#","c-sharp","dotnet"],lexical:{start:"root",states:{root:[{match:String.raw`///[^\r\n]*`,type:"doc-comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*[a-z]+[^\r\n]*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v\u00A0\uFEFF]+`,type:"space"},{match:String.raw`\$*("{3,})[\s\S]*?\1`,type:"string"},{match:String.raw`\$@"|@\$"`,type:"string",push:"interpolatedVerbatim"},{match:String.raw`\$"`,type:"string",push:"interpolated"},{match:String.raw`@"(?:[^"]|"")*"?`,type:"string"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F_]+[uUlL]*|0[bB][01_]+[uUlL]*|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?[fFdDmMuUlL]*`,type:"number"},{match:String.raw`@?[A-Za-z_\u00A0-\uFFFF][\w\u00A0-\uFFFF]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.|::|[;,.]`,type:"punctuation"},{match:String.raw`\?\?=|<<=|>>>=|>>=|>>>|=>|==|!=|<=|>=|&&|\|\||\?\?|\+\+|--|->|<<|[-+*/%&|^<>!=]=?|[~?:]`,type:"operator"}],interpolated:[{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`(?:\\.|[^"\\{}\r\n])+`,type:"string"}],interpolatedVerbatim:[{match:'""',type:"string"},{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`[^"{}]+`,type:"string"}],interpolation:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["abstract","add","alias","and","args","as","ascending","async","await","base","bool","break","by","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","do","double","dynamic","else","enum","equals","event","explicit","extern","false","file","finally","fixed","float","for","foreach","from","get","global","goto","group","if","implicit","in","init","int","interface","internal","into","is","join","let","lock","long","managed","nameof","namespace","new","nint","not","notnull","nuint","null","object","on","operator","or","orderby","out","override","params","partial","private","protected","public","readonly","record","ref","remove","required","return","sbyte","scoped","sealed","select","set","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unmanaged","unsafe","ushort","using","value","var","virtual","void","volatile","when","where","while","with","yield"]},keywordExceptAfter:[".","?."]}},Qt={name:"c",aliases:["cpp","c++","cc","cxx","h","hpp","hxx","objc"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)|///[^\r\n]*`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*\w+(?:\\\r?\n|[^\r\n])*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v]+`,type:"space"},{match:String.raw`(?:u8|u|U|L)?R"([^()\\\s]{0,16})\([\s\S]*?\)\1"`,type:"string"},{match:String.raw`(?:u8|u|U|L)?"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`(?:u8|u|U|L)?'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F']+[uUlL]*|0[bB][01']+[uUlL]*|(?:\d[\d']*\.?[\d']*|\.\d[\d']*)(?:[eEpP][+-]?\d+)?[fFlLuU]*`,type:"number"},{match:String.raw`[A-Za-z_][\w]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`::|\.\.\.|->\*?|\.\*?|[;,]`,type:"punctuation"},{match:String.raw`<=>|<<=|>>=|<<|>>|\+\+|--|&&|\|\||[-+*/%&|^<>!=]=?|[~?:#]`,type:"operator"}]},keywords:{keyword:["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","bool","true","false","NULL","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","and","and_eq","asm","bitand","bitor","catch","char8_t","char16_t","char32_t","class","co_await","co_return","co_yield","compl","concept","consteval","constexpr","constinit","const_cast","decltype","delete","dynamic_cast","explicit","export","final","friend","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reinterpret_cast","requires","static_assert","static_cast","template","this","thread_local","throw","try","typeid","typename","using","virtual","wchar_t","xor","xor_eq"]},keywordExceptAfter:[".","->","::"]}},Xt={name:"json",aliases:["jsonc","json5","webmanifest"],lexical:{start:"root",states:{root:[{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:String.raw`(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')(?=\s*:)`,type:"attribute"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?|'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`-?(?:0[xX][\da-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)|-?Infinity|NaN`,type:"number"},{match:String.raw`[A-Za-z_$][\w$]*`,type:"identifier"},{match:String.raw`[\[\]{}]`,type:"bracket"},{match:String.raw`[:,]`,type:"punctuation"}]},keywords:{keyword:["true","false","null"]}}},Yt={javascript:Ot,"pacem-binding":jt,markup:Pt,csharp:qt,c:Qt,json:Xt};for(let t in Yt){const e=Yt[t];Syntaxes.register(e)}var Zt=Object.freeze({__proto__:null,CSharpSyntax:qt,CSyntax:Qt,DefaultHighlightClasses:U,HighlightRenderer:HighlightRenderer,JavaScriptSyntax:Ot,JsonSyntax:Xt,Markdown:Bt,MarkupSyntax:Pt,PacemBindingSyntax:jt,Parser:x,Scanner:Scanner,get SyntaxTokenType(){return b},Syntaxes:Syntaxes}),Gt=Object.freeze({__proto__:null,Angle:Angle,Arrays:class Arrays{static range(t,e,r=2){let n=t;NullChecker.isNull(e)&&(e=r=t,t=1);const s=(e-t)/(r-1),i=[];if(s>0)for(;i.length<r;)i.push(n.roundoff()),n+=s;return i}static chunkify(t,e){if(NullChecker.isNullOrEmpty(t))return[];if(e<=0||e%1!=0)throw new Error("Provide a positive integer number.");const r=Math.ceil(t.length/e);return Array.from({length:r},(r,n)=>{const s=n*e,i=s+e;return t.slice(s,i)})}},Blobs:Blobs,Colors:Colors,Compile:Zt,Dates:Dates,DeepMerger:DeepMerger,HistoryService:class HistoryService{constructor(t,e){this.#i=t,this.#a=e}#o=[];#c=[];#a;#i;get current(){return this.#i}get canUndo(){return this.#o.length>0}get canRedo(){return this.#c.length>0}set maxlength(t){this.#a=t}undo(){if(this.canUndo){const t=this.#o,e=this.#c,r=this.#i;e.unshift(r),this.#i=t.pop()}}redo(){if(this.canRedo){const t=this.#o,e=this.#c,r=this.#i;t.push(r),this.#i=e.shift()}}push(t){this.#c.splice(0),this.#o.push(this.#i),this.#i=t;const e=this.#a,r=this.#o;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#c.splice(0),this.#o.splice(0)}},Imaging:Imaging,Keys:Keys,Matrix2D:Matrix2D,NullChecker:NullChecker,Numbers:class Numbers{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){const n=t.toString(),s=parseInt(n,e);return n.endsWith(s.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}},Point:Point,Rect:Rect,Size:Size,Strings:class Strings{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){const r=Array.from(e);let n=t;for(let t=0;t<r.length;t++){const e=new RegExp("(^|[^\\{])\\{"+t+"\\}($|[^\\}])","g");n=n.replaceAll(e,(e,...n)=>e.replace("{"+t+"}",r[t]))}const s=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(n);if(!NullChecker.isNullOrEmpty(s))throw new Error(`Missing argument at index ${s[2]}.`);return n}static diff(t,e,r="char"){switch(r){case"line":return function(t,e){const r=/\r?\n/,n=t.split(r),s=e.split(r);return w(n,s,m(n,s),"\n")}(t,e);case"word":return function(t,e){const r=/(\S+|\s+)/g,n=t.match(r)||[],s=e.match(r)||[];return w(n,s,m(n,s),"")}(t,e);default:return function(t,e){const r=t.split(""),n=e.split("");return w(r,n,m(r,n),"")}(t,e)}}static async hash(t,e="SHA-256"){const r=await crypto.subtle.digest(e,(new TextEncoder).encode(t));return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}},detect:function(t=navigator.userAgent){let e="unknown",r=null;switch(/ucbrowser/i.test(t)?e="UCBrowser":/edg/i.test(t)?e="Edge":/googlebot/i.test(t)?e="GoogleBot":/chromium/i.test(t)?e="Chromium":/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t)?e="Firefox":/; msie|trident/i.test(t)&&!/ucbrowser/i.test(t)?e="IE":/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t)?e="Chrome":/safari/i.test(t)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(t)?e="Safari":/opr|opera/i.test(t)&&(e="Opera"),e){case"UCBrowser":r=n(t,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":r=n(t,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":r=n(t,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":r=n(t,/(chromium)\/([\d\.]+)/i);break;case"Firefox":r=n(t,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":r=n(t,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":r=n(t,/(safari)\/([\d\.]+)/i);break;case"Opera":r=n(t,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{const e=n(t,/(trident)\/([\d\.]+)/i);r=e?`${parseFloat(e)+4}`:"7.0";break}default:r="0.0.0.0"}return{name:e,version:r}},parseAsNumericalArray:f});DeepMerger.merge(Gt)}();
|
|
6
|
+
!function(){"use strict";Number.prototype.isCloseTo=function(t,e=14){const r=Number(`1e-${e}`);return this>t-r&&this<t+r},Number.prototype.roundoff=function(t=14){return parseFloat(this.toFixed(t))},Number.prototype.clamp=function(t,e){let r=this;return null==t||isNaN(t)||(r=Math.max(r,t)),null==e||isNaN(e)||(r=Math.min(r,e)),r},Number.prototype.toBase62=function(){for(var t=this,e="";0!=t;){e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(t%62)+e,t=Math.floor(t/62)}return e},Number.prototype.toBase36=function(){return this.toString(36)};const t=/^\/Date\([\d]+\)\/$/i;class Dates{static parse(e){let r;return"string"==typeof e?(r=t.test(e)?parseInt(e.substring(6)):Date.parse(e),new Date(r)):"number"==typeof e?new Date(e):e}static isLeapYear(t){return t%4==0&&t%100!=0||t%400==0}static daysInMonth(t,e){return[31,Dates.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),n=new Date(t),s=n.getMonth()+e,i=0;for(;s<0;)s+=12,i--;return n.setDate(1),n.setMonth(s%12),n.setFullYear(n.getFullYear()+i+Math.floor(s/12)),n.setDate(Math.min(r,Dates.daysInMonth(n.getFullYear(),n.getMonth()))),n}static addDays(t,e){return new Date(t.valueOf()+864e5*e)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}}class NullChecker{static isNull(t){return null==t}static isEmpty(t){try{return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||"object"==typeof t&&0===Object.keys(t).length&&!Dates.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch(t){return!1}}static isNullOrEmpty(t){return NullChecker.isNull(t)||NullChecker.isEmpty(t)}}function e(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)&&(t.constructor===Object||void 0===t.constructor)}function r(t,n){const s=t;for(const t of Object.keys(n)){const i=n[t],a=s[t];e(i)?s[t]=r(e(a)?a:{},i):Array.isArray(i)?s[t]=i.slice():s[t]=i}return s}Array.prototype.distinct=function(){return Array.from(new Set(this))},Array.prototype.union=function(t){const e=NullChecker.isNullOrEmpty(this),r=NullChecker.isNullOrEmpty(t);return e&&r?[]:r?this.slice():e?t.slice():this.concat(t).distinct()},Array.prototype.moveWithin=function(t,e){const r="Index must be greater or equal than 0 and less or equal than the length of the array.";var n=this;if(t<0||t>n.length)throw new Error(r);if(e<0||e>n.length)throw new Error(r);n.splice(e,0,Array.prototype.splice.apply(n,[t,1])[0])},Array.prototype.equalsContent=function(t){if(null==t||this.length!==t.length)return!1;for(let e=0;e<this.length;e++)if(this[e]!==t[e])return!1;return!0},Array.prototype.cloneFrom=function(t){if(null==t)throw"Cannot clone array from null object.";const e=t.length;var r=this.length!==t.length;for(let n=0;n<e;n++){const e=t[n];this.length>n?this[n]!==e&&(this[n]=e,r=!0):(Array.prototype.push.apply(this,[e]),r=!0)}r&&this.splice(e)};class DeepMerger{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},r(e,t)}}class Blobs{static blobToDataURL(t){return new Promise((e,r)=>{const n=new FileReader;n.onload=t=>{e(t.target.result)},n.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length;const r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){const r=Blobs._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){const e=t.indexOf(",");if(-1===e)return Blobs.base64ToBlob(t);{const r=t.substring(e+1),n=t.substring(0,e).match(/:(.*?);/)[1];return Blobs.base64ToBlob(r,{type:n})}}static async blobToText(t,e){const r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",n,s=63){let i=r.toLowerCase();const a=()=>`${e};charset=${i}`;switch(i){case"utf-8":{const e=(new TextEncoder).encode(t),r=n?[new Uint8Array([239,187,191]),e]:[e];return new Blob(r,{type:a()})}case"utf-16":i="utf-16le",n??=!0;case"utf-16le":case"utf-16be":{const e="utf-16be"!==i,r=n?1:0,s=new ArrayBuffer(2*(t.length+r)),o=new DataView(s);n&&o.setUint16(0,65279,e);for(let n=0;n<t.length;n++)o.setUint16(2*(n+r),t.charCodeAt(n),e);return new Blob([s],{type:a()})}case"ascii":case"iso-8859-1":case"latin1":{const e="ascii"===i?127:255,n=new Uint8Array(t.length),o=s>0;for(let i=0;i<t.length;i++){const a=t.charCodeAt(i);if(a>e){if(!o)throw new Error(`Character "${t[i]}" cannot be encoded in ${r}.`);n[i]=s}else n[i]=a}return new Blob([n],{type:a()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}}const n=(t,e)=>{const r=t.match(e);return r?r[2]:null};const s=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,i=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,a=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,o=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,c=/^#[a-f0-9]{6}$/,l=/^#[a-f0-9]{3}$/;function u(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"r"in t&&"g"in t&&"b"in t&&"number"==typeof t.r&&"number"==typeof t.b&&"number"==typeof t.g&&(t.a??=1,t.r>=0&&t.r<=1&&t.g>=0&&t.g<=1&&t.b>=0&&t.b<=1&&t.a>=0&&t.a<=1)}function h(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&"number"==typeof t.h&&"number"==typeof t.s&&"number"==typeof t.l&&(t.a??=1,t.h>=0&&t.h<=360&&t.s>=0&&t.s<=1&&t.l>=0&&t.l<=1&&t.a>=0&&t.a<=1)}const p={adjustRgbChannel:t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),adjustRgbChannelInv:t=>t<=.00304?12.92*t:1.055*(Math.pow(t,1/2.4)-.055),adjustRgb:t=>({r:p.adjustRgbChannel(t.r),g:p.adjustRgbChannel(t.g),b:p.adjustRgbChannel(t.b),a:t.a}),adjustRgbInv:t=>({r:p.adjustRgbChannelInv(t.r),g:p.adjustRgbChannelInv(t.g),b:p.adjustRgbChannelInv(t.b),a:t.a}),X:t=>.4125*t.r+.3576*t.g+.1804*t.b,Y:t=>.2126*t.r+.7152*t.g+.0722*t.b,Z:t=>.0193*t.r+.1191*t.g+.9503*t.b,relativeLuminance:t=>{const e=p.adjustRgb(t);return p.Y(e)},rgbToCieXYZ:t=>{const e=p.adjustRgb(t);return{x:p.X(e),y:p.Y(e),z:p.Z(e),a:t.a}},cieXYZToRgb:t=>{const e=3.241*t.x-1.5374*t.y-.4986*t.z,r=-.9692*t.x+1.876*t.y+.0416*t.z,n=.0556*t.x-.204*t.y+1.057*t.z;return p.adjustRgbInv({r:e,g:r,b:n,a:t.a})},contrastRatio:(t,e)=>{const r=p.relativeLuminance(t)+.05,n=p.relativeLuminance(e)+.05;return r>n?r/n:n/r}};function d(t){return t.toString(16).padStart(2,"0")}class Colors{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){const e=t=>Math.min(1,Math.max(0,t));return null==t[3]&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),a.test(t)){let e=a.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(o.test(t)){let e=o.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(c.test(t)){let e=c.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(l.test(t)){let e=l.exec(t)[0],r=e.substr(1,1),n=e.substr(2,1),s=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+n+n),parseInt("0x"+s+s),1]))}if(s.test(t)){let e=s.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3])};return this.rgb(r)}if(i.test(t)){let e=i.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3]),a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){const e=function(t){const e=t.r,r=t.g,n=t.b;return(.5*(Math.max(e,r,n)+Math.min(e,r,n))).clamp(0,1)}(t),r=function(t,e){const r=t.r,n=t.g,s=t.b,i=Math.max(r,n,s),a=Math.min(r,n,s);return(0===e||1===e?0:(i-a)/(1-Math.abs(2*e-1))).clamp(0,1)}(t,e),n=function(t){const e=t.r,r=t.g,n=t.b,s=Math.max(e,r,n),i=Math.min(e,r,n);let a=0;return s!==i&&(a=s===e?((r-n)/(s-i)*60+360)%360:s===r?((n-e)/(s-i)*60+120)%360:((e-r)/(s-i)*60+240)%360),a.clamp(0,360)}(t);return{h:n,s:r,l:e,a:t.a}}static cieXYZ(t){return h(t)&&(t=this.rgb(t)),p.rgbToCieXYZ(t)}static rgb(t){if(!h(t)){const e=p.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}{const e=t.h,r=t.s,n=t.l,s=e/60,i=(1-Math.abs(2*n-1))*r,a=i*(1-Math.abs(s%2-1)),o=n-i/2,c=(e,r,n)=>this._clampRGB([e+o,r+o,n+o,t.a]);if(s<=1)return c(i,a,0);if(s<=2)return c(a,i,0);if(s<=3)return c(0,i,a);if(s<=4)return c(0,a,i);if(s<=5)return c(a,0,i);if(s<=6)return c(i,0,a)}}static stringify(t,e=1){if(h(t)){e??=1,t.a??=1;const r="number"==typeof e?e:1;return`hsla(${t.h.roundoff(r)},${(100*t.s).roundoff(r)}%,${(100*t.l).roundoff(r)}%,${t.a.roundoff()})`}if(u(t)){e??=!0,t.a??=1;const r="boolean"==typeof e?e:!!e,n=Math.round(255*t.r),s=Math.round(255*t.g),i=Math.round(255*t.b),a=t.a.roundoff();return 1===a?r?("#"+d(n)+d(s)+d(i)).toUpperCase():`rgb(${n},${s},${i})`:`rgba(${n},${s},${i},${a})`}}static contrastRatio(t,e){return h(t)&&(t=this.rgb(t)),h(e)&&(e=this.rgb(e)),p.contrastRatio(t,e)}static luminance(t){return h(t)&&(t=Colors.rgb(t)),p.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(u(t)){const r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(u(t)){const r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,n){r??=.5,n??=r;const s=(r+n).roundoff(),i=(r/s).roundoff(),a=(n/s).roundoff(),o=u(t),c=h(t),l=t=>u(t)||h(t)?Colors.cieXYZ(t):t;t=l(t),e=l(e);const p={x:(t.x*i+e.x*a).roundoff(),y:(t.y*i+e.y*a).roundoff(),z:(t.z*i+e.z*a).roundoff(),a:(t.a*i+e.a*a).roundoff()};return o?Colors.rgb(p):c?Colors.hsl(Colors.rgb(p)):p}}const g=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function f(t){const e=[];let r=t.match(g);return r&&r.length>0&&r.forEach(t=>e.push(parseFloat(t))),e}class Angle{static isAngle(t){return"object"==typeof t&&"vertex"in t&&Point.isPoint(t.vertex)&&"start"in t&&Point.isPoint(t.start)&&"end"in t&&Point.isPoint(t.end)}static value(t){if(NullChecker.isNullOrEmpty(t)||!Angle.isAngle(t))return Number.NaN;const{vertex:e,start:r,end:n}=t;return Angle.angleBetween(e,r,n)}static angleBetween(t,e,r){const n=e.x-t.x,s=e.y-t.y,i=r.x-t.x,a=r.y-t.y,o=n*i+s*a,c=n*a-s*i;return-Math.atan2(c,o)}}class Size{static parse(t){let e=f(t);if(e&&2===e.length)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return"object"==typeof t&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}}class Point{static parse(t){let e=f(t);if(e&&2===e.length)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return"object"==typeof t&&"x"in t&&"number"==typeof t.x&&"y"in t&&"number"==typeof t.y}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}}class Matrix2D{static isIdentity(t){return 1===t.a&&1===t.d&&0===t.b&&0===t.f&&0===t.c&&0===t.e}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){const r=Math.cos(e),n=Math.sin(e);return Matrix2D.multiply(t,{a:r,b:n,c:-n,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?"number"==typeof e?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:"number"==typeof e?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){const e=this.det(t);if(0===e)return null;const r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){const r=Math.sqrt(t.a*t.a+t.c*t.c),n=Math.sqrt(t.b*t.b+t.d*t.d),s=0!=r?t.a/r:0,i=0!=r?t.c/r:0,a=Math.atan2(i,s),{x:o,y:c}=e;return{scaleX:r,scaleY:n,rotation:a,translation:{x:t.e-o*(r*s-1)+c*r*i,y:t.f-c*(n*s-1)-o*n*i}}}static fromTransform([t,e,r],[n,s,i]){const a=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(a)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");const o=1/a;return{a:o*(n.x*(e.y-r.y)+s.x*(r.y-t.y)+i.x*(t.y-e.y)),b:o*(n.y*(e.y-r.y)+s.y*(r.y-t.y)+i.y*(t.y-e.y)),c:o*(n.x*(r.x-e.x)+s.x*(t.x-r.x)+i.x*(e.x-t.x)),d:o*(n.y*(r.x-e.x)+s.y*(t.x-r.x)+i.y*(e.x-t.x)),e:o*(n.x*(e.x*r.y-r.x*e.y)+s.x*(r.x*t.y-t.x*r.y)+i.x*(t.x*e.y-e.x*t.y)),f:o*(n.y*(e.x*r.y-r.x*e.y)+s.y*(r.x*t.y-t.x*r.y)+i.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}}class Rect{static parse(t){let e=f(t);if(e&&4===e.length)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return Point.isPoint(t)&&Size.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,n){let s=1;s=t.width/t.height>=e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _cover(t,e,r,n){let s=1;s=t.width/t.height<e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _align(t,e,r,n){let s=0,i=0;switch(r){case"left":s=e.x-t.x;break;case"right":s=e.x+e.width-t.width-t.x;break;default:s=e.x+.5*e.width-.5*t.width-t.x}switch(n){case"top":i=e.y-t.y;break;case"bottom":i=e.y+e.height-t.height-t.y;break;default:i=e.y+.5*e.height-.5*t.height-t.y}return{x:s,y:i}}static findTransform(t,e,r="stretch",n="center",s="middle"){switch(r){case"contain":return this._contain(t,e,n,s);case"cover":return this._cover(t,e,n,s);default:return this._stretch(t,e)}}static intersect(...t){const e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var n=r[0],s=1;s<r.length;s++){const t=r[s],i=Math.max(t.x,n.x),a=Math.max(t.y,n.y),o=Math.min(t.x+t.width,n.x+n.width)-i,c=Math.min(t.y+t.height,n.y+n.height)-a;if(o<0||c<=0)return e;n={x:i,y:a,width:o,height:c}}return n}static expand(t,...e){const r=Array.from(e||[]);let n=t.x,s=t.y,i=n,a=s;Rect.isRect(t)&&(i+=t.width,a+=t.height);for(let t of r)n=Math.min(t.x,n),s=Math.min(t.y,s),i=Math.max(t.x,i),a=Math.max(t.y,a);return{x:n,y:s,width:i-n,height:a-s}}}const y={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"};class Imaging{static async loadImage(t){const e=await fetch(t);if(!e.ok)return null;return await e.blob()}static async resizeImage(t,e,r,n){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");const s=await Imaging._toDrawable(t),i=s.width||e,a=s.height||r,o=new OffscreenCanvas(i,a),c=o.getContext("2d");c.imageSmoothingEnabled=c.mozImageSmoothingEnabled=c.oImageSmoothingEnabled=c.webkitImageSmoothingEnabled=!0;const{quality:l,type:u,mode:h,align:p,valign:d,background:g}=Object.assign({},y,n??{}),f={width:i,height:a,x:0,y:0},m={x:0,y:0,width:e,height:r},w=Rect.findTransform(f,m,h,p,d);o.width=e,o.height=r,g&&(c.fillStyle=g,c.fillRect(0,0,o.width,o.height)),c.setTransform(w),c.drawImage(s,0,0);return await o.convertToBlob({quality:l,type:u})}static async _toDrawable(t){return"string"==typeof t&&(t=await Imaging.loadImage(t)),t instanceof Blob?await self.createImageBitmap(t):t}}class Keys{static#t;static uniqueId(){let t=Keys.#t||Date.now();return Keys.#t=++t}static uniqueCode(){return Keys.uniqueId().toBase62()}static randomString(t){let e="";do{e+=(62*Math.random()).toBase62()}while(e.length<t);return e}}function m(t,e){const r=t.length,n=e.length,s=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let i=1;i<=r;i++)for(let r=1;r<=n;r++)t[i-1]===e[r-1]?s[i][r]=s[i-1][r-1]+1:s[i][r]=Math.max(s[i-1][r],s[i][r-1]);return s}function w(t,e,r,n=""){const s=t.length,i=e.length,a=[];let o=s,c=i,l=null;const u=()=>{l&&(a.push(l),l=null)};for(;o>0||c>0;){var h=null;let s=null;o>0&&c>0&&t[o-1]===e[c-1]?(h="=",s=t[o-1],o--,c--):c>0&&(0===o||r[o][c-1]>=r[o-1][c])?(h="+",s=e[c-1],c--):o>0&&(0===c||r[o-1][c]>r[o][c-1])&&(h="-",s=t[o-1],o--),h&&null!==s?l&&l.type===h?l.value=s+(l.value?n:"")+l.value:(u(),l={type:h,value:s}):u()}return u(),a.reverse()}class LexerClass{tokenize(t,e){const r=[];for(;t;){const n=t.length;for(let n of e){const e=n.exec(t,this),s=e?.length;if(s>0){Array.prototype.push.apply(r,e);const n=e[s-1];t=t.substr((n.index||0)+n.raw.length);break}}if(t.length>=n)throw new Error(`Cannot parse\n"${t}"\n using the provided grammar.`)}return r}}let x=class Parser{constructor(t=new LexerClass){this._lexer=t}parse(t,e,r){const n=this._lexer.tokenize(t,e);return r.render(n)}};var b;!function(t){t.Text="text",t.Space="space",t.Newline="newline",t.Comment="comment",t.DocComment="doc-comment",t.Keyword="keyword",t.Identifier="identifier",t.String="string",t.Regex="regex",t.Number="number",t.Bracket="bracket",t.Punctuation="punctuation",t.Operator="operator",t.Preprocessor="preprocessor",t.Tag="tag",t.TagName="tagname",t.Attribute="attribute",t.Entity="entity"}(b||(b={}));const k=new Map;function _(t){return(t??"").trim().toLowerCase()}class Syntaxes{static register(t){if(null==t)return;const e=[t.name].concat(t.aliases??[]);for(let r of e){const e=_(r);k.set(e,t)}}static get(t){const e=_(t);return k.get(e)??null}static names(){const t=k.keys();return Array.from(t)}}const S=[b.Identifier],$=[b.Space,b.Newline,b.Comment,b.DocComment];function C(t){return null!=t.combined}const v=new WeakMap;function T(t){return"include"in t}function A(t){return null==t||0===t.length?null:new Set(t)}function N(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=t[e].concat(n)}return r}function R(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=n.concat(t[e])}return r}function E(t,e=0){const r=t.lexical??{states:{}},n={start:r.start,states:r.states??{},keywords:r.keywords??{},keywordSources:r.keywordSources,keywordExceptAfter:r.keywordExceptAfter,insignificant:r.insignificant},s=t.extends?Syntaxes.get(t.extends):null;if(null==s||s===t||e>=16)return n;const i=E(s,e+1);return{start:n.start??i.start,states:N(n.states,i.states),keywords:R(n.keywords,i.keywords),keywordSources:n.keywordSources??i.keywordSources,keywordExceptAfter:n.keywordExceptAfter??i.keywordExceptAfter,insignificant:n.insignificant??i.insignificant}}function L(t,e,r){const n=t[e]??[];if(r.has(e))return[];r.add(e);const s=[];for(let e of n){if(!T(e)){s.push(e);continue}const n=L(t,e.include,r);Array.prototype.push.apply(s,n)}return r.delete(e),s}function M(t){const e=Array.isArray(t.type)?t.type:null,r=Array.isArray(t.type)?t.type[0]:t.type,n=function(t){const e=t.split(""),r=new Set(e);return Array.from(r).join("")}((t.flags??"").replace(/[yd]/g,"")),s=n+"y"+(e?"d":""),i=new RegExp(t.match,s),a=t.until?new RegExp(t.until,"y"):null,o=!0===t.pop?1:"number"==typeof t.pop?t.pop:0;var c;return{regex:i,type:r,groupTypes:e,when:null==(c=t.when)?null:{previousTypes:A(c.previousTypes),previousNotTypes:A(c.previousNotTypes),previousTexts:A(c.previousTexts),previousNotTexts:A(c.previousNotTexts)},pop:o,until:a,source:t.match,flags:n,next:t.next??null,push:t.push??null,embed:t.embed??null,hasTransition:o>0||!!t.next||!!t.push||!!t.embed}}function I(t){const e=new Map;for(let r in t)for(let n of t[r])e.set(n,r);return e}const z=/\\[1-9]|\\k<|\(\?<(?![=!])/;function B(t,e){return new RegExp(t+"|",e).exec("").length-1}function O(t){return null==t.when&&!z.test(t.source)&&(e=t.source,r=t.flags,!new RegExp("^(?:"+e+")$",r).test(""));var e,r}function F(t){const e=[];let r=[];const n=()=>{if(r.length>0){const t=function(t){if(1===t.length)return{rule:t[0],combined:null};const e=[];let r=1;for(let n of t)e.push(r),r+=1+B(n.source,n.flags);const n=t.map(t=>"("+t.source+")").join("|");return{rule:null,combined:new RegExp(n,t[0].flags+"y"),rules:t,groupIndices:e}}(r);e.push(t)}r=[]};for(let s of t)O(s)?(r.length>0&&r[0].flags!==s.flags&&n(),r.push(s)):(n(),e.push({rule:s,combined:null}));return n(),e}function j(t){const e=v.get(t);if(null!=e)return e;const r=E(t),n=new Map;for(let t in r.states){const e=new Set,s=F(L(r.states,t,e).map(M));n.set(t,s)}const s={name:t.name,start:r.start??"root",states:n,keywords:I(r.keywords),keywordSources:new Set(r.keywordSources??S),keywordExceptAfter:new Set(r.keywordExceptAfter??[]),insignificant:new Set(r.insignificant??$)};return v.set(t,s),s}class ScanRun{constructor(t,e){this._source=t,this._tokens=[],this._position=0,this._emitted=0,this._line=1,this._column=1,this._previous=null,this._emptyTransitions=0,this._stack=[{syntax:e,state:e.start,until:null}]}run(){const t=this._source.length;for(;this._position<t;)this._step();return this._flushText(),this._tokens}get _top(){const t=this._stack;return t[t.length-1]}_step(){const t=this._top;if(this._popOnUntil(t))return;const e=this._findRule(t);if(null==e)return void this._position++;this._flushText(),this._emitMatch(e,t.syntax),this._transition(e.rule,t.syntax);const r=e.match[0].length;this._position+=r,r>0&&(this._emptyTransitions=0)}_popOnUntil(t){const e=t.until;return!(null==e||this._stack.length<=1)&&(e.lastIndex=this._position,!!e.test(this._source)&&(this._flushText(),this._stack.pop(),!0))}_findRule(t){const e=t.syntax.states.get(t.state)??[];for(let t of e){const e=C(t)?this._tryCombined(t):this._trySingle(t.rule);if(null!=e)return e}return null}_trySingle(t){const e=this._tryRule(t);return null==e?null:{rule:t,match:e}}_tryCombined(t){const e=t.combined;e.lastIndex=this._position;const r=e.exec(this._source);if(null==r)return null;const n=t.groupIndices;for(let e=0;e<n.length;e++){if(void 0===r[n[e]])continue;const s=t.rules[e];return this._trySingle(s)}return null}_tryRule(t){if(null!=t.when&&!function(t,e){const r=e?.type??null,n=e?.raw??null;return!(null!=t.previousTypes&&!t.previousTypes.has(r)||null!=t.previousNotTypes&&t.previousNotTypes.has(r)||null!=t.previousTexts&&!t.previousTexts.has(n)||null!=t.previousNotTexts&&t.previousNotTexts.has(n))}(t.when,this._previous))return null;const e=t.regex;e.lastIndex=this._position;const r=e.exec(this._source);return null==r?null:r[0].length>0?r:!t.hasTransition||this._emptyTransitions>=64?null:(this._emptyTransitions++,r)}_emitMatch({rule:t,match:e},r){const n=e[0];null!=t.groupTypes?this._emitGroups(t,e,r):this._append(t.type,n,r)}_emitGroups(t,e,r){const n=e.indices,s=e.index,i=s+e[0].length,a=t.groupTypes;let o=s;for(let t=1;t<e.length;t++){const e=n[t];if(null==e||e[0]<o||e[1]===e[0])continue;if(e[0]>o){const t=this._source.slice(o,e[0]);this._append(b.Text,t,r)}const s=this._source.slice(e[0],e[1]),i=a[t-1]??a[a.length-1];this._append(i,s,r),o=e[1]}if(o<i){const t=this._source.slice(o,i);this._append(b.Text,t,r)}}_transition(t,e){const r=this._stack;for(let e=0;e<t.pop&&r.length>1;e++)r.pop();if(null!=t.next&&(this._top.state=t.next),null!=t.push&&r.push({syntax:e,state:t.push,until:null}),null==t.embed)return;const n=function(t){const e=Syntaxes.get(t);return null==e?null:j(e)}(t.embed);null!=n&&r.push({syntax:n,state:n.start,until:t.until})}_flushText(){if(this._emitted>=this._position)return;const t=this._source.slice(this._emitted,this._position),e=this._top.syntax;this._append(b.Text,t,e)}_resolveType(t,e,r){if(!r.keywordSources.has(t))return t;const n=this._previous?.raw;return r.keywordExceptAfter.has(n)?t:r.keywords.get(e)??t}_append(t,e,r){const n=this._resolveType(t,e,r),s={type:n,raw:e,text:e,index:this._emitted,line:this._line,column:this._column,depth:this._stack.length-1,syntax:r.name};this._tokens.push(s),this._advance(e),r.insignificant.has(n)||(this._previous=s)}_advance(t){this._emitted+=t.length;const e=t.lastIndexOf("\n");if(e<0)this._column+=t.length;else{for(let r=0;r<=e;r++)10===t.charCodeAt(r)&&this._line++;this._column=t.length-e}}}const D={name:b.Text,lexical:{states:{}}};class Scanner{tokenize(t,e){const r=t??"",n=j(("string"==typeof e?Syntaxes.get(e):e)??D);return new ScanRun(r,n).run()}}const U=Object.freeze({keyword:"code-keyword",preprocessor:"code-keyword",string:"code-string",regex:"code-string",number:"code-number",comment:"code-comment","doc-comment":"code-comment",tag:"code-tag",tagname:"code-tagname",attribute:"code-attribute"}),H={"&":"&","<":"<",">":">",'"':"""};class HighlightRenderer{constructor(t=U){this._classes=t}render(t){let e="";for(let r of t??[])e+=this._renderToken(r);return e}_renderToken(t){const e=(t.raw??"").replace(/[&<>"]/g,t=>H[t]);const r=this._classes[t.type];return null==r?e:`<span class="${r}">${e}</span>`}}function P(t){return(t??"").replace(/</g,"<")}function q(t){return(t??"").replace(/&(?!(?:#\d+|#x[\da-fA-F]+|\w+);)/g,"&").replace(/"/g,""").replace(/</g,"<")}function Q(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));return e.split(/(?<!\\)\|/).map(t=>t.trim().replace(/\\\|/g,"|"))}function X(t){const e=t.startsWith(":"),r=t.endsWith(":");return e&&r?"center":r?"right":e?"left":null}function Y(t){return/^ */.exec(t)[0].length}const Z=new Scanner;function G(t){return t?.index||void 0}function W(t){return t?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function K(t,e,r){const n=e.exec(t);return n&&n.length?r(n):null}const J=/(<!--)([\s\S]*?)(-->|$)/,V=/^ {0,3}(={3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,}|(?:\*[ \t]*){3,})(\r?\n|$)/,tt=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,et=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,rt=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,nt=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,st=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,it=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,at=/^( {0,3}([-+]|\*(?=[ \t])).*(\r?\n|$))((?!(?: ?\d+[.\)]|\r?\n\S)).*(\r?\n|$))*/,ot=/^( {0,3}(\d+[.\)]).*(\r?\n|$))((?!(?: {0,2}(?:[-+]|\*[ \t])|\r?\n\S)).*(\r?\n|$))*/,ct=/^( *)([-+*]|\d+[.\)])([ \t]+|$)/,lt=/^\[([ xX])\][ \t]+/,ut=/^(?! {4,})(?=[ \t]*\S)(.+(\n(?![ \t]*(?:\n|$))(?! {0,3}```)(?! {0,3}([-+]|\*[ \t]|\d+[.\)]))(?! {0,3}#{1,6}[ \t])(?! {4,})(?! {0,3}>).+)*)/,ht=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,pt=/(?<!\\)!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,dt=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,gt=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,ft=/(\*\*?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1|(?<![A-Za-z0-9])(__?)((?!\3\s?)(?:(?!\3)[\S\s])*[^\s])\3(?![A-Za-z0-9])/,yt=/(~~?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,mt=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,wt=/^\s+/,xt=/^(?:[ \t]*\r?\n)+|^\s+/,bt=/(?: {2,}|\\)\r?\n/,kt=/^[^\r\n]+/,_t=/\\(<|[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/,St={"<":"<","<":"<","&":"&"},$t=/(?:<|<)((?:https?|ftp|mailto):[^\s<>]+|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)>/,Ct=/(?<![\w\/\\(\[<"'=;&@])(?:https?:\/\/|www\.)[^\s<>]*[^\s<>.,:;"'!?)\]*_~]/,vt=/\[\^([^\]\s]+)\]/,Tt=/^ {0,3}\[\^([^\]\s]+)\]: *([^\r\n]*(?:\r?\n {2,}[^\r\n]+)*)(\r?\n|$)+/,At=/^ {0,3}(\|?[^\r\n]*\|[^\r\n]*)\r?\n {0,3}(\|? *:?-+:? *(?:\| *:?-+:? *)*\|?) *(?:\r?\n|$)((?:(?! {0,3}(?:\r?\n|$))[^\r\n]*\|[^\r\n]*(?:\r?\n|$))*)/;var Nt,Rt;function Et(t=[]){const e={[Rt.Comment]:{exec:(t,e)=>K(t,J,r=>{const n=G(r),s=[{type:Nt.Html,index:n,raw:r[0],text:r[2]}];if(n>0){const r=t.substr(0,n),i=e.tokenize(r,y);Array.prototype.unshift.apply(s,i)}return s})},[Rt.Reference]:{exec:t=>K(t,ht,t=>{const e=G(t),r=t[0],n=r,s="!"===t[1],i=t[2],a=t[3],o=t[4];return[{type:Nt.Reference,index:e,raw:r,text:n,id:i,image:s,url:a,title:o}]})},[Rt.FootnoteDefinition]:{exec:(t,e)=>K(t,Tt,t=>{const r=t[0],n=W(t[1]),s=t[2].replace(/\r?\n {2,}/g," ");return[{type:Nt.FootnoteDefinition,index:G(t),raw:r,text:s,id:n,tokens:e.tokenize(s,l)}]})}},r=[],n=[],s={};for(let e of t){let t,i="inline";switch("type"in e?(i=e.type,t=e.rule):t=e,i){case"block":r.push(t);break;case"code":if("lang"in e){const r=e.lang.toLowerCase();(s[r]=s[r]||[]).push(t)}break;default:const i={exec:(e,r)=>{const n=t.exec(e,r);return o(e,n,r),n}};n.push(i)}}const i={[Rt.Text]:{exec:t=>K(t,kt,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.Text}]})},[Rt.Space]:{exec:t=>K(t,wt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},a={[Rt.ImageOrLink]:{exec:(t,e)=>c(t,pt,e,t=>{const r=G(t),n=t[0],s="!"===n.charAt(0),i=t[1],a=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\[/.test(t)&&/\]$/.test(t)))return/^\(/.test(t)&&/\)$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2]),o=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\(/.test(t)&&/\)$/.test(t)))return/^\[/.test(t)&&/\]$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2])??i,c=W(o),{url:u,title:h}=function(t){if(NullChecker.isNullOrEmpty(t))return{url:t};const e=t.trim(),r=/^(\S*)\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\))\s*$/.exec(e);if(null==r)return{url:e};const n=r[2]??r[3]??r[4];return{url:r[1],title:n}}(a),p=e.tokenize(i,l);return s?[{index:r,type:u?Nt.Image:Nt.ImageLike,raw:n,text:i,src:u,title:h,ref:c,tokens:p}]:[{index:r,type:u?Nt.Link:Nt.LinkLike,raw:n,text:i,href:u,title:h,ref:c,tokens:p}]})},[Rt.Escape]:{exec:(t,e)=>c(t,_t,e,t=>{const e=St[t[1]]??t[1];return[{index:G(t),raw:t[0],text:e,type:Nt.Text}]})},[Rt.AutoLink]:{exec:(t,e)=>c(t,$t,e,t=>{const e=t[1],r=!/^[a-z]+:/i.test(e)?"mailto:"+e:e;return[{index:G(t),raw:t[0],text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.BareUrl]:{exec:(t,e)=>c(t,Ct,e,t=>{const e=t[0],r=/^www\./i.test(e)?"http://"+e:e;return[{index:G(t),raw:e,text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.FootnoteReference]:{exec:(t,e)=>c(t,vt,e,t=>{const e=W(t[1]);return[{index:G(t),raw:t[0],text:t[1],id:e,type:Nt.FootnoteReference}]})},[Rt.Code]:{exec:(t,e)=>c(t,gt,e,t=>{const e=P(t[1]);return[{type:Nt.Code,raw:t[0],text:e,index:G(t)}]})},[Rt.EmphasizedLink]:{exec:(t,e)=>c(t,dt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=t[1].length>1?Nt.Bold:Nt.Italic,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Emphasize]:{exec:(t,e)=>c(t,ft,e,t=>{const r=t[1]??t[3],n=t[2]??t[4];if(NullChecker.isNullOrEmpty(n))return null;const s=r.length>1?Nt.Bold:Nt.Italic;return[{index:G(t),type:s,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.StrikeThrough]:{exec:(t,e)=>c(t,yt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.StrikeThrough,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Quote]:{exec:(t,e)=>c(t,mt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.Quote,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.LineBreak]:{exec:(t,e)=>c(t,bt,e,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.LineBreak}]})}},o=(t,e,r)=>{const n=e?.length>0&&e[0].index;if(n>0){const s=t.substr(0,n),i=r.tokenize(s,l)||[];Array.prototype.unshift.apply(e,i)}},c=(t,e,r,n)=>{const s=K(t,e,r=>{if(e!=gt){const e=gt.exec(t);if(e&&e.length&&e.index<r.index)return null}return n(r)});return o(t,s,r),s},l=[a[Rt.FootnoteReference],a[Rt.EmphasizedLink],a[Rt.ImageOrLink],a[Rt.Escape],a[Rt.AutoLink],a[Rt.Emphasize],a[Rt.StrikeThrough],a[Rt.Quote],a[Rt.Code],a[Rt.LineBreak],a[Rt.BareUrl]];Array.prototype.push.apply(l,n),l.push(i[Rt.Text],i[Rt.Space]);const u=t=>{const e=[i[Rt.Text],i[Rt.Space]],r=t?.toLowerCase()||"";return r&&r in s&&Array.prototype.unshift.apply(e,s[r]),e},h={[Rt.Paragraph]:{exec:(t,e)=>K(t,ut,t=>{const r=t[0],n=r.replace(/^[ \t]+/gm,"");return 0===n.trim().length?null:[{type:Nt.Paragraph,raw:r,text:n,tokens:e.tokenize(n,l)}]})},[Rt.Space]:{exec:t=>K(t,xt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},p=(t,e)=>{const r=function(t){const e=t.replace(/\t/g," ").split(/\r?\n/),r=[];for(let t of e){const e=r[r.length-1],n=ct.exec(t);if(null!=n&&(null==e||n[1].length<e.indent)){const e=n[0].length,s=t.slice(e);r.push({indent:e,lines:[s]});continue}if(null==e)continue;const s=Math.min(e.indent,Y(t)),i=t.slice(s);e.lines.push(i)}return r.map(t=>t.lines.join("\n").replace(/\s+$/,""))}(t);return r.filter(t=>!NullChecker.isNullOrEmpty(t)).map(t=>{const r=lt.exec(t),n=r?t.slice(r[0].length):t,s=((t,e)=>{if(!/^ {0,3}(`{3,}|$|>|[-+*]\s|\d+[.\)]|#{1,6}\s|\|)/m.test(t))return e.tokenize(t,l);const r=e.tokenize(t,f),n=r[0];if(/\n[ \t]*\n/.test(t)||n?.type!==Nt.Paragraph)return r;const s=n.tokens??[],i=r.slice(1);return s.concat(i)})(n,e);if(null==r)return{type:Nt.ListItem,raw:t,text:n,tokens:s};const i=" "!==r[1];return{type:Nt.ListItem,raw:t,text:n,tokens:s,task:!0,checked:i}})},d=(t,e,r,n)=>{const s=e.map((e,s)=>{const i=t[s]??"",a=n.tokenize(i,l);return{type:Nt.TableCell,raw:i,text:i,header:r,align:e,tokens:a}}),i=t.join(" | ");return{type:Nt.TableRow,raw:i,text:i,header:r,tokens:s}},g={[Rt.HorizontalRule]:{exec:(t,e)=>K(t,V,t=>{const e=t[0],r=e;return[{type:Nt.HorizontalRule,raw:e,text:r}]})},[Rt.Heading]:{exec:(t,e)=>K(t,tt,t=>{const r=t[2].replace(/[ \t]+#+[ \t]*$/,"");return[{type:Nt.Heading,raw:t[0],text:r,level:t[1].length,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading1]:{exec:(t,e)=>K(t,et,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:1,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading2]:{exec:(t,e)=>K(t,rt,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:2,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.CodeBlock]:{exec:(t,e)=>K(t,nt,t=>{const r=t[0],n=r.replace(/^ {4}/gm,"").replace(/\s+$/,""),s=P(n);return 0===n.length?null:[{type:Nt.CodeBlock,raw:r,text:s,tokens:e.tokenize(s,u(""))}]})},[Rt.Fences]:{exec:(t,e)=>K(t,st,t=>{const r=(t[1]??"").trim().split(/\s+/)[0].toLowerCase(),n=r in s?null:Syntaxes.get(r);if(null==n){const n=P(t[2]);return[{type:Nt.CodeBlock,raw:t[0],text:n,lang:r,tokens:e.tokenize(n,u(r))}]}const i=function(t){return(t??"").replace(/</g,"<")}(t[2]),a=Z.tokenize(i,n);return[{type:Nt.CodeBlock,raw:t[0],text:i,lang:r,syntax:n.name,highlighted:!0,tokens:a}]})},[Rt.BlockQuote]:{exec:(t,e)=>K(t,it,t=>{const r=t[0],n=r.replace(/^ {0,3}> ?/gm,"");return[{type:Nt.BlockQuote,raw:r,text:n,tokens:e.tokenize(n,f)}]})},[Rt.OrderedList]:{exec:(t,e)=>K(t,ot,t=>{const r=t[0],n=/\d+/.exec(r),s=parseInt(n[0]),i=p(r,e);return[{type:Nt.OrderedList,start:s,raw:r,text:r,tokens:i}]})},[Rt.UnorderedList]:{exec:(t,e)=>K(t,at,t=>{const r=t[0],n=p(r,e);return[{type:Nt.UnorderedList,raw:r,text:r,tokens:n}]})},[Rt.Table]:{exec:(t,e)=>K(t,At,t=>{const r=Q(t[1]),n=Q(t[2]);if(r.length!==n.length)return null;const s=n.map(X),i=t[3].split(/\r?\n/).filter(t=>t.trim().length>0),a=d(r,s,!0,e),o=i.map(t=>{const r=Q(t);return d(r,s,!1,e)}),c=[a].concat(o);return[{type:Nt.Table,raw:t[0],text:t[0],align:s,tokens:c}]})}},f=Object.values(g);Array.prototype.push.apply(f,r),f.push(h[Rt.Paragraph],h[Rt.Space]);const y=[e[Rt.Comment],e[Rt.FootnoteDefinition],e[Rt.Reference]].concat(f);return y}!function(t){t.Html="html",t.Text="text",t.Paragraph="paragraph",t.BlockQuote="blockquote",t.Space="space",t.Heading="heading",t.Bold="bold",t.Italic="italic",t.CodeBlock="codeblock",t.Code="code",t.Image="img",t.ImageLike="imglike",t.Link="link",t.LinkLike="linklike",t.LineBreak="br",t.StrikeThrough="strike",t.Quote="quote",t.HorizontalRule="hr",t.OrderedList="ol",t.UnorderedList="ul",t.ListItem="listitem",t.Reference="ref",t.Table="table",t.TableRow="tr",t.TableCell="td",t.FootnoteReference="fnref",t.FootnoteDefinition="fndef"}(Nt||(Nt={})),function(t){t[t.Comment=0]="Comment",t[t.Reference=1]="Reference",t[t.HorizontalRule=2]="HorizontalRule",t[t.Heading=3]="Heading",t[t.Heading1=4]="Heading1",t[t.Heading2=5]="Heading2",t[t.CodeBlock=6]="CodeBlock",t[t.Fences=7]="Fences",t[t.BlockQuote=8]="BlockQuote",t[t.OrderedList=9]="OrderedList",t[t.UnorderedList=10]="UnorderedList",t[t.Paragraph=11]="Paragraph",t[t.EmphasizedLink=12]="EmphasizedLink",t[t.ImageOrLink=13]="ImageOrLink",t[t.Emphasize=14]="Emphasize",t[t.StrikeThrough=15]="StrikeThrough",t[t.Quote=16]="Quote",t[t.Code=17]="Code",t[t.LineBreak=18]="LineBreak",t[t.FootnoteDefinition=19]="FootnoteDefinition",t[t.Table=20]="Table",t[t.Escape=21]="Escape",t[t.AutoLink=22]="AutoLink",t[t.FootnoteReference=23]="FootnoteReference",t[t.BareUrl=24]="BareUrl",t[t.Text=254]="Text",t[t.Space=255]="Space"}(Rt||(Rt={}));const Lt="\0",Mt=/[ \r\n]*\0+[ \r\n]*/g;function It(t){if(NullChecker.isNullOrEmpty(t))return"";return` title="${q(t)}"`}function zt(t){return null==t?"":` style="text-align: ${t}"`}class HtmlRenderer{constructor(t=(t,e)=>t?.text||""){this._extraItemRender=t,this.#e=[],this.#r=new Map,this.#n=[],this.#s=new HighlightRenderer,this._renderContent=t=>{const e=t.tokens;return NullChecker.isNullOrEmpty(e)?t.text:this._render(e)}}#e;#r;#n;#s;_collectDefinitions(t){for(let e of t??[])e?.type===Nt.Reference&&this.#e.push(e),e?.type!==Nt.FootnoteDefinition||this.#r.has(e.id)||this.#r.set(e.id,e),this._collectDefinitions(e?.tokens)}_findReference(t,e){if(NullChecker.isNullOrEmpty(t))return;const r=t.toLowerCase();return this.#e.find(t=>!0===t.image===e&&t.id?.toLowerCase()===r)}_renderCodeBlock(t){const e=Lt,r=t.lang;if(!0!==t.highlighted){return`<pre>${e}<code${r?' class="'+r+'"':""}>${this._renderContent(t)}</code>${e}</pre>${e}`}const n=[r,"code-highlighted"];"markup"===t.syntax&&n.push("code-markup");return`<pre>${e}<code class="${q(n.join(" "))}">${this.#s.render(t.tokens)}</code>${e}</pre>${e}`}_renderImage(t){let e=t.src,r=t.title;if(!e){const n=this._findReference(t.ref,!0);e=n?.url,r=n?.title}if(!e){return`![${this._renderContent(t)}]`}const n=It(r);return`<img src="${e}" alt="${t.text}"${n} />`}_renderLink(t){let e=t.href,r=t.title;if(!e){const n=this._findReference(t.ref,!1);e=n?.url,r=n?.title}const n=this._renderContent(t);if(!e)return`[${n}]`;return`<a href="${e}"${It(r)}>${n}</a>`}_renderListItem(t){const e=Lt,r=this._renderContent(t);if(!0!==t.task)return`\t<li>${r}</li>${e}`;return`\t<li class="task-list-item"><input type="checkbox" disabled${!0===t.checked?" checked":""} /> ${r}</li>${e}`}_renderTableRow(t){const e=Lt;let r="";for(let e of t.tokens??[]){const t=!0===e.header?"th":"td";r+=`<${t}${zt(e.align)}>${this._renderContent(e)}</${t}>`}return`<tr>${r}</tr>${e}`}_renderTable(t){const e=Lt,r=t.tokens??[],n=r.filter(t=>!0===t.header),s=r.filter(t=>!0!==t.header);let i=`<table>${e}<thead>${e}${n.map(t=>this._renderTableRow(t)).join("")}</thead>${e}`;if(s.length>0){i+=`<tbody>${e}${s.map(t=>this._renderTableRow(t)).join("")}</tbody>${e}`}return i+`</table>${e}`}_renderFootnoteReference(t){const e=t.id;if(!this.#r.has(e))return`[^${t.text}]`;const r=this.#n,n=!r.includes(e);n&&r.push(e);return`<sup class="footnote-ref"><a href="#fn-${e}"${n?` id="fnref-${e}"`:""}>${r.indexOf(e)+1}</a></sup>`}_renderFootnotes(){const t=this.#n;if(0===t.length)return"";const e=Lt;let r="";for(let n=0;n<t.length;n++){const s=t[n],i=this.#r.get(s);r+=`<li id="fn-${s}">${this._renderContent(i)} <a href="#fnref-${s}" class="footnote-backref">↩</a></li>${e}`}return`<section class="footnotes">${e}<ol>${e}${r}</ol>${e}</section>${e}`}_rendeItem(t,e){const r=this._renderContent,n=Lt;switch(t?.type){case Nt.Reference:case Nt.FootnoteDefinition:return"";case Nt.Html:return t.raw;case Nt.BlockQuote:return`<blockquote>\n${r(t)}</blockquote>${n}`;case Nt.Bold:return`<b>${r(t)}</b>`;case Nt.CodeBlock:return this._renderCodeBlock(t);case Nt.Code:return`<code>${r(t)}</code>`;case Nt.HorizontalRule:return`<hr />${n}`;case Nt.Heading:const e=t.level;return`<h${e} id="${t.ref}">${r(t)}</h${e}>${n}`;case Nt.Image:case Nt.ImageLike:return this._renderImage(t);case Nt.Italic:return`<i>${r(t)}</i>`;case Nt.StrikeThrough:return`<s>${r(t)}</s>`;case Nt.Quote:return`<q>${r(t)}</q>`;case Nt.LineBreak:return"<br />\0";case Nt.OrderedList:return`<ol start="${t.start}">\n${r(t)}</ol>${n}`;case Nt.UnorderedList:return`<ul>\n${r(t)}</ul>${n}`;case Nt.ListItem:return this._renderListItem(t);case Nt.Link:case Nt.LinkLike:return this._renderLink(t);case Nt.Table:return this._renderTable(t);case Nt.FootnoteReference:return this._renderFootnoteReference(t);case Nt.Paragraph:return`<p>${r(t)}</p>${n}`;case Nt.Text:case Nt.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let r of t||[])e+=this._rendeItem(r,t);return e}render(t){this.#e=[],this.#r.clear(),this.#n=[],this._collectDefinitions(t);const e=this._render(t),r=this._renderFootnotes();return n=e+r,n?.replace(Mt,"\n").trim();var n}}class TokenRenderer{_render(t){return NullChecker.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(t=>!NullChecker.isNullOrEmpty(t)).map(this._render).join(",")+"]"}}var Bt=Object.freeze({__proto__:null,Parser:class Parser extends x{toHtml(t,e,r){const n=new HtmlRenderer(r);return NullChecker.isNullOrEmpty(e)?this.parse(t,n):this.parse(t,Et(e),n)}tokenize(t,e){const r=this.parse(t,Et(e),new TokenRenderer);return JSON.parse(r)}parse(t,e=Et(),r=new HtmlRenderer){const n=(t??"").replace(/\r\n?/g,"\n");if((s=e)&&"object"==typeof s&&"function"==typeof s.render){const t=Et();return super.parse(n,t,e)}var s;return super.parse(n,e,r)}}});const Ot={name:"javascript",aliases:["js","mjs","cjs","jsx","typescript","ts","tsx","script","ecmascript"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n
]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:"`",type:"string",push:"template"},{match:String.raw`"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\[\s\S]|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\[\r\n])+/[a-z]*`,type:"regex",when:{previousNotTypes:["identifier","number","string","regex"],previousNotTexts:[")","]","}","this","super","null","undefined","true","false","++","--"]}},{match:String.raw`0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d[\d_]*)?n?`,type:"number"},{match:String.raw`#?[A-Za-z_$ -][\w$ -]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.(?!\d)|\.\.\.|[;,.]`,type:"punctuation"},{match:String.raw`>>>=|<<=|>>=|>>>|\*\*=|&&=|\|\|=|\?\?=|===|!==|=>|\*\*|\+\+|--|<<|>>|&&|\|\||\?\?|[-+*/%&|^<>!=]=?|[~?:@]`,type:"operator"}],template:[{match:"`",type:"string",pop:!0},{match:String.raw`\$\{`,type:"punctuation",push:"templateExpression"},{match:String.raw`(?:\\[\s\S]|\$(?!\{)|[^\\`+"`"+String.raw`$])+`,type:"string"}],templateExpression:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","import","in","instanceof","let","new","null","of","return","set","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield","abstract","accessor","any","as","asserts","bigint","boolean","declare","implements","infer","interface","is","keyof","module","namespace","never","number","object","override","package","private","protected","public","readonly","satisfies","string","symbol","type","unique","unknown"]},keywordExceptAfter:[".","?."]}},Ft={previousNotTexts:[".","?."]},jt={name:"pacem-binding",aliases:["pacem","binding"],extends:"javascript",lexical:{states:{root:[{match:String.raw`:host(?=\.)`,type:"binding-host",when:Ft},{match:String.raw`::[A-Za-z_$][\w$]*`,type:"binding-host-property"},{match:String.raw`\^+item(?![\w$])`,type:"binding-item"},{match:String.raw`\^+index(?![\w$])`,type:"binding-index"},{match:String.raw`#[A-Za-z_][\w]*`,type:"binding-element",when:Ft},{match:String.raw`\$?this(?![\w$])`,type:"binding-this",when:Ft}]}}},Dt={match:String.raw`\r\n|[\r\n]`,type:"newline"},Ut=[Dt,{match:String.raw`[ \t\f]+`,type:"space"},{match:'"',type:"string",push:"doubleQuoted"},{match:"'",type:"string",push:"singleQuoted"},{match:String.raw`[^\s=/>"']+`,type:"attribute"},{match:"=",type:"operator"},{match:"/",type:"punctuation"}],Ht=[{match:String.raw`\{\{`,type:"punctuation",embed:"pacem-binding",until:String.raw`\}\}`},{match:String.raw`\}\}`,type:"punctuation"}],Pt={name:"markup",aliases:["html","htm","xml","xhtml","svg"],lexical:{start:"root",states:{root:[{match:String.raw`<!--[\s\S]*?(?:-->|$)`,type:"comment"},{match:String.raw`<![^>]*>?`,type:"tag"},{match:String.raw`(<\/)([\w:.-]+)(\s*>?)`,type:["tag","tagname","tag"]},{match:String.raw`(<)(script)(?![\w:.-])`,flags:"i",type:["tag","tagname"],push:"scriptTag"},{match:String.raw`(<)([\w:.-]+)`,type:["tag","tagname"],push:"tag"},{match:String.raw`&(?:#\d+|#[xX][\da-fA-F]+|\w+);`,type:"entity"},Dt,{match:String.raw`[^<&\r\n]+`,type:"text"}],tag:[{match:String.raw`/?>`,type:"tag",pop:!0},{include:"attributes"}],scriptTag:[{match:"/>",type:"tag",pop:!0},{match:">",type:"tag",pop:!0,embed:"javascript",until:String.raw`<\/script`},{include:"attributes"}],attributes:Ut,doubleQuoted:[{match:'"',type:"string",pop:!0},...Ht,{match:String.raw`(?:[^"{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}],singleQuoted:[{match:"'",type:"string",pop:!0},...Ht,{match:String.raw`(?:[^'{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}]},insignificant:["space","newline","comment","text"]}},qt={name:"csharp",aliases:["cs","c#","c-sharp","dotnet"],lexical:{start:"root",states:{root:[{match:String.raw`///[^\r\n]*`,type:"doc-comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*[a-z]+[^\r\n]*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v\u00A0\uFEFF]+`,type:"space"},{match:String.raw`\$*("{3,})[\s\S]*?\1`,type:"string"},{match:String.raw`\$@"|@\$"`,type:"string",push:"interpolatedVerbatim"},{match:String.raw`\$"`,type:"string",push:"interpolated"},{match:String.raw`@"(?:[^"]|"")*"?`,type:"string"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F_]+[uUlL]*|0[bB][01_]+[uUlL]*|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?[fFdDmMuUlL]*`,type:"number"},{match:String.raw`@?[A-Za-z_\u00A0-\uFFFF][\w\u00A0-\uFFFF]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.|::|[;,.]`,type:"punctuation"},{match:String.raw`\?\?=|<<=|>>>=|>>=|>>>|=>|==|!=|<=|>=|&&|\|\||\?\?|\+\+|--|->|<<|[-+*/%&|^<>!=]=?|[~?:]`,type:"operator"}],interpolated:[{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`(?:\\.|[^"\\{}\r\n])+`,type:"string"}],interpolatedVerbatim:[{match:'""',type:"string"},{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`[^"{}]+`,type:"string"}],interpolation:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["abstract","add","alias","and","args","as","ascending","async","await","base","bool","break","by","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","do","double","dynamic","else","enum","equals","event","explicit","extern","false","file","finally","fixed","float","for","foreach","from","get","global","goto","group","if","implicit","in","init","int","interface","internal","into","is","join","let","lock","long","managed","nameof","namespace","new","nint","not","notnull","nuint","null","object","on","operator","or","orderby","out","override","params","partial","private","protected","public","readonly","record","ref","remove","required","return","sbyte","scoped","sealed","select","set","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unmanaged","unsafe","ushort","using","value","var","virtual","void","volatile","when","where","while","with","yield"]},keywordExceptAfter:[".","?."]}},Qt={name:"c",aliases:["cpp","c++","cc","cxx","h","hpp","hxx","objc"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)|///[^\r\n]*`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*\w+(?:\\\r?\n|[^\r\n])*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v]+`,type:"space"},{match:String.raw`(?:u8|u|U|L)?R"([^()\\\s]{0,16})\([\s\S]*?\)\1"`,type:"string"},{match:String.raw`(?:u8|u|U|L)?"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`(?:u8|u|U|L)?'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F']+[uUlL]*|0[bB][01']+[uUlL]*|(?:\d[\d']*\.?[\d']*|\.\d[\d']*)(?:[eEpP][+-]?\d+)?[fFlLuU]*`,type:"number"},{match:String.raw`[A-Za-z_][\w]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`::|\.\.\.|->\*?|\.\*?|[;,]`,type:"punctuation"},{match:String.raw`<=>|<<=|>>=|<<|>>|\+\+|--|&&|\|\||[-+*/%&|^<>!=]=?|[~?:#]`,type:"operator"}]},keywords:{keyword:["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","bool","true","false","NULL","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","and","and_eq","asm","bitand","bitor","catch","char8_t","char16_t","char32_t","class","co_await","co_return","co_yield","compl","concept","consteval","constexpr","constinit","const_cast","decltype","delete","dynamic_cast","explicit","export","final","friend","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reinterpret_cast","requires","static_assert","static_cast","template","this","thread_local","throw","try","typeid","typename","using","virtual","wchar_t","xor","xor_eq"]},keywordExceptAfter:[".","->","::"]}},Xt={name:"json",aliases:["jsonc","json5","webmanifest"],lexical:{start:"root",states:{root:[{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:String.raw`(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')(?=\s*:)`,type:"attribute"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?|'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`-?(?:0[xX][\da-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)|-?Infinity|NaN`,type:"number"},{match:String.raw`[A-Za-z_$][\w$]*`,type:"identifier"},{match:String.raw`[\[\]{}]`,type:"bracket"},{match:String.raw`[:,]`,type:"punctuation"}]},keywords:{keyword:["true","false","null"]}}},Yt={javascript:Ot,"pacem-binding":jt,markup:Pt,csharp:qt,c:Qt,json:Xt};for(let t in Yt){const e=Yt[t];Syntaxes.register(e)}var Zt=Object.freeze({__proto__:null,CSharpSyntax:qt,CSyntax:Qt,DefaultHighlightClasses:U,HighlightRenderer:HighlightRenderer,JavaScriptSyntax:Ot,JsonSyntax:Xt,Markdown:Bt,MarkupSyntax:Pt,PacemBindingSyntax:jt,Parser:x,Scanner:Scanner,get SyntaxTokenType(){return b},Syntaxes:Syntaxes}),Gt=Object.freeze({__proto__:null,Angle:Angle,Arrays:class Arrays{static range(t,e,r=2){let n=t;NullChecker.isNull(e)&&(e=r=t,t=1);const s=(e-t)/(r-1),i=[];if(s>0)for(;i.length<r;)i.push(n.roundoff()),n+=s;return i}static chunkify(t,e){if(NullChecker.isNullOrEmpty(t))return[];if(e<=0||e%1!=0)throw new Error("Provide a positive integer number.");const r=Math.ceil(t.length/e);return Array.from({length:r},(r,n)=>{const s=n*e,i=s+e;return t.slice(s,i)})}},Blobs:Blobs,Colors:Colors,Compile:Zt,Dates:Dates,DeepMerger:DeepMerger,HistoryService:class HistoryService{constructor(t,e){this.#i=t,this.#a=e}#o=[];#c=[];#a;#i;get current(){return this.#i}get canUndo(){return this.#o.length>0}get canRedo(){return this.#c.length>0}set maxlength(t){this.#a=t}undo(){if(this.canUndo){const t=this.#o,e=this.#c,r=this.#i;e.unshift(r),this.#i=t.pop()}}redo(){if(this.canRedo){const t=this.#o,e=this.#c,r=this.#i;t.push(r),this.#i=e.shift()}}push(t){this.#c.splice(0),this.#o.push(this.#i),this.#i=t;const e=this.#a,r=this.#o;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#c.splice(0),this.#o.splice(0)}},Imaging:Imaging,Keys:Keys,Matrix2D:Matrix2D,NullChecker:NullChecker,Numbers:class Numbers{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){const n=t.toString(),s=parseInt(n,e);return n.endsWith(s.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}},Point:Point,Rect:Rect,Size:Size,Strings:class Strings{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){const r=Array.from(e);let n=t;for(let t=0;t<r.length;t++){const e=new RegExp("(^|[^\\{])\\{"+t+"\\}($|[^\\}])","g");n=n.replaceAll(e,(e,...n)=>e.replace("{"+t+"}",r[t]))}const s=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(n);if(!NullChecker.isNullOrEmpty(s))throw new Error(`Missing argument at index ${s[2]}.`);return n}static diff(t,e,r="char"){switch(r){case"line":return function(t,e){const r=/\r?\n/,n=t.split(r),s=e.split(r);return w(n,s,m(n,s),"\n")}(t,e);case"word":return function(t,e){const r=/(\S+|\s+)/g,n=t.match(r)||[],s=e.match(r)||[];return w(n,s,m(n,s),"")}(t,e);default:return function(t,e){const r=t.split(""),n=e.split("");return w(r,n,m(r,n),"")}(t,e)}}static async hash(t,e="SHA-256"){const r=await crypto.subtle.digest(e,(new TextEncoder).encode(t));return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}},detect:function(t=navigator.userAgent){let e="unknown",r=null;switch(/ucbrowser/i.test(t)?e="UCBrowser":/edg/i.test(t)?e="Edge":/googlebot/i.test(t)?e="GoogleBot":/chromium/i.test(t)?e="Chromium":/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t)?e="Firefox":/; msie|trident/i.test(t)&&!/ucbrowser/i.test(t)?e="IE":/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t)?e="Chrome":/safari/i.test(t)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(t)?e="Safari":/opr|opera/i.test(t)&&(e="Opera"),e){case"UCBrowser":r=n(t,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":r=n(t,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":r=n(t,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":r=n(t,/(chromium)\/([\d\.]+)/i);break;case"Firefox":r=n(t,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":r=n(t,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":r=n(t,/(safari)\/([\d\.]+)/i);break;case"Opera":r=n(t,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{const e=n(t,/(trident)\/([\d\.]+)/i);r=e?`${parseFloat(e)+4}`:"7.0";break}default:r="0.0.0.0"}return{name:e,version:r}},parseAsNumericalArray:f});DeepMerger.merge(Gt)}();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-foundation v2.0.0-
|
|
2
|
+
* @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
var Wt=Object.defineProperty;var kt=(n,t)=>{for(var e in t)Wt(n,e,{get:t[e],enumerable:!0})};Number.prototype.isCloseTo=function(n,t=14){let e=+`1e-${t}`;return this>n-e&&this<n+e};Number.prototype.roundoff=function(n=14){return parseFloat(this.toFixed(n))};Number.prototype.clamp=function(n,t){let e=this;return n!=null&&!isNaN(n)&&(e=Math.max(e,n)),t!=null&&!isNaN(t)&&(e=Math.min(e,t)),e};Number.prototype.toBase62=function(){for(var n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t=this,e="";t!=0;){var r=t%62;e=n.charAt(r)+e,t=Math.floor(t/62)}return e};Number.prototype.toBase36=function(){return this.toString(36)};var Kt=/^\/Date\([\d]+\)\/$/i,V=class n{static parse(t){let e;return typeof t=="string"?(Kt.test(t)?e=parseInt(t.substring(6)):e=Date.parse(t),new Date(e)):typeof t=="number"?new Date(t):t}static isLeapYear(t){return t%4===0&&t%100!==0||t%400===0}static daysInMonth(t,e){return[31,n.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),s=new Date(t),i=s.getMonth()+e,o=0;for(;i<0;)i+=12,o--;return s.setDate(1),s.setMonth(i%12),s.setFullYear(s.getFullYear()+o+Math.floor(i/12)),s.setDate(Math.min(r,n.daysInMonth(s.getFullYear(),s.getMonth()))),s}static addDays(t,e){return new Date(t.valueOf()+e*864e5)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}};var _=class n{static isNull(t){return t==null}static isEmpty(t){try{return Array.isArray(t)&&t.length===0||typeof t=="string"&&t===""||typeof t=="object"&&Object.keys(t).length===0&&!V.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch{return!1}}static isNullOrEmpty(t){return n.isNull(t)||n.isEmpty(t)}};Array.prototype.distinct=function(){return Array.from(new Set(this))};Array.prototype.union=function(n){let t=_.isNullOrEmpty(this),e=_.isNullOrEmpty(n);return t&&e?[]:e?this.slice():t?n.slice():this.concat(n).distinct()};Array.prototype.moveWithin=function(n,t){let e="Index must be greater or equal than 0 and less or equal than the length of the array.";var r=this;if(n<0||n>r.length)throw new Error(e);if(t<0||t>r.length)throw new Error(e);r.splice(t,0,Array.prototype.splice.apply(r,[n,1])[0])};Array.prototype.equalsContent=function(n){if(n==null||this.length!==n.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==n[t])return!1;return!0};Array.prototype.cloneFrom=function(n){if(n==null)throw"Cannot clone array from null object.";let t=n.length;var e=this.length!==n.length;for(let r=0;r<t;r++){let s=n[r];this.length>r?this[r]!==s&&(this[r]=s,e=!0):(Array.prototype.push.apply(this,[s]),e=!0)}e&&this.splice(t)};function _t(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)&&(n.constructor===Object||n.constructor===void 0)}function $t(n,t){let e=n;for(let r of Object.keys(t)){let s=t[r],i=e[r];_t(s)?e[r]=$t(_t(i)?i:{},s):Array.isArray(s)?e[r]=s.slice():e[r]=s}return e}var St=class{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},$t(e,t)}};var Ct=class{static range(t,e,r=2){let s=t;_.isNull(e)&&(e=r=t,t=1);let i=(e-t)/(r-1),o=[];if(i>0)for(;o.length<r;)o.push(s.roundoff()),s+=i;return o}static chunkify(t,e){if(_.isNullOrEmpty(t))return[];if(e<=0||e%1!==0)throw new Error("Provide a positive integer number.");let r=Math.ceil(t.length/e);return Array.from({length:r},(s,i)=>{let o=i*e,h=o+e;return t.slice(o,h)})}};var Tt=class n{static blobToDataURL(t){return new Promise((e,r)=>{let s=new FileReader;s.onload=i=>{e(i.target.result)},s.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length,r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){let r=n._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){let e=t.indexOf(",");if(e===-1)return n.base64ToBlob(t);{let r=t.substring(e+1),i=t.substring(0,e).match(/:(.*?);/)[1];return n.base64ToBlob(r,{type:i})}}static async blobToText(t,e){let r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",s,i=63){let o=r.toLowerCase(),h=()=>`${e};charset=${o}`;switch(o){case"utf-8":{let d=new TextEncoder().encode(t),x=s?[new Uint8Array([239,187,191]),d]:[d];return new Blob(x,{type:h()})}case"utf-16":o="utf-16le",s??=!0;case"utf-16le":case"utf-16be":{let l=o!=="utf-16be",d=s?1:0,x=new ArrayBuffer((t.length+d)*2),w=new DataView(x);s&&w.setUint16(0,65279,l);for(let b=0;b<t.length;b++)w.setUint16((b+d)*2,t.charCodeAt(b),l);return new Blob([x],{type:h()})}case"ascii":case"iso-8859-1":case"latin1":{let l=o==="ascii"?127:255,d=new Uint8Array(t.length),x=i>0;for(let w=0;w<t.length;w++){let b=t.charCodeAt(w);if(b>l)if(x)d[w]=i;else throw new Error(`Character "${t[w]}" cannot be encoded in ${r}.`);else d[w]=b}return new Blob([d],{type:h()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}};var L=(n,t)=>{let e=n.match(t);return e?e[2]:null};function Xn(n=navigator.userAgent){let t="unknown",e=null;switch(/ucbrowser/i.test(n)?t="UCBrowser":/edg/i.test(n)?t="Edge":/googlebot/i.test(n)?t="GoogleBot":/chromium/i.test(n)?t="Chromium":/firefox|fxios/i.test(n)&&!/seamonkey/i.test(n)?t="Firefox":/; msie|trident/i.test(n)&&!/ucbrowser/i.test(n)?t="IE":/chrome|crios/i.test(n)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(n)?t="Chrome":/safari/i.test(n)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(n)?t="Safari":/opr|opera/i.test(n)&&(t="Opera"),t){case"UCBrowser":e=L(n,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":e=L(n,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":e=L(n,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":e=L(n,/(chromium)\/([\d\.]+)/i);break;case"Firefox":e=L(n,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":e=L(n,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":e=L(n,/(safari)\/([\d\.]+)/i);break;case"Opera":e=L(n,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{let r=L(n,/(trident)\/([\d\.]+)/i);e=r?`${parseFloat(r)+4}`:"7.0";break}default:e="0.0.0.0";break}return{name:t,version:e}}var vt=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,It=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,Et=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,Ft=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,Bt=/^#[a-f0-9]{6}$/,At=/^#[a-f0-9]{3}$/;function R(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"r"in n&&"g"in n&&"b"in n&&typeof n.r=="number"&&typeof n.b=="number"&&typeof n.g=="number"?(n.a??=1,n.r>=0&&n.r<=1&&n.g>=0&&n.g<=1&&n.b>=0&&n.b<=1&&n.a>=0&&n.a<=1):!1}function A(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"h"in n&&"s"in n&&"l"in n&&typeof n.h=="number"&&typeof n.s=="number"&&typeof n.l=="number"?(n.a??=1,n.h>=0&&n.h<=360&&n.s>=0&&n.s<=1&&n.l>=0&&n.l<=1&&n.a>=0&&n.a<=1):!1}function te(n){let t=n.r,e=n.g,r=n.b;return(.5*(Math.max(t,e,r)+Math.min(t,e,r))).clamp(0,1)}var S={adjustRgbChannel:n=>n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),adjustRgbChannelInv:n=>n<=.00304?n*12.92:1.055*(Math.pow(n,1/2.4)-.055),adjustRgb:n=>({r:S.adjustRgbChannel(n.r),g:S.adjustRgbChannel(n.g),b:S.adjustRgbChannel(n.b),a:n.a}),adjustRgbInv:n=>({r:S.adjustRgbChannelInv(n.r),g:S.adjustRgbChannelInv(n.g),b:S.adjustRgbChannelInv(n.b),a:n.a}),X:n=>.4125*n.r+.3576*n.g+.1804*n.b,Y:n=>.2126*n.r+.7152*n.g+.0722*n.b,Z:n=>.0193*n.r+.1191*n.g+.9503*n.b,relativeLuminance:n=>{let t=S.adjustRgb(n);return S.Y(t)},rgbToCieXYZ:n=>{let t=S.adjustRgb(n);return{x:S.X(t),y:S.Y(t),z:S.Z(t),a:n.a}},cieXYZToRgb:n=>{let t=3.241*n.x-1.5374*n.y-.4986*n.z,e=-.9692*n.x+1.876*n.y+.0416*n.z,r=.0556*n.x-.204*n.y+1.057*n.z;return S.adjustRgbInv({r:t,g:e,b:r,a:n.a})},contrastRatio:(n,t)=>{let e=S.relativeLuminance(n)+.05,r=S.relativeLuminance(t)+.05;return e>r?e/r:r/e}};function ee(n,t){let e=n.r,r=n.g,s=n.b,i=Math.max(e,r,s),o=Math.min(e,r,s);return(t===0||t===1?0:(i-o)/(1-Math.abs(2*t-1))).clamp(0,1)}function ne(n){let t=n.r,e=n.g,r=n.b,s=Math.max(t,e,r),i=Math.min(t,e,r),o=0;return s!==i&&(s===t?o=(60*((e-r)/(s-i))+360)%360:s===e?o=(60*((r-t)/(s-i))+120)%360:o=(60*((t-e)/(s-i))+240)%360),o.clamp(0,360)}function et(n){return n.toString(16).padStart(2,"0")}var Lt=class n{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){let e=r=>Math.min(1,Math.max(0,r));return t[3]==null&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),Et.test(t)){let e=Et.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(Ft.test(t)){let e=Ft.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(Bt.test(t)){let e=Bt.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(At.test(t)){let e=At.exec(t)[0],r=e.substr(1,1),s=e.substr(2,1),i=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+s+s),parseInt("0x"+i+i),1]))}if(vt.test(t)){let e=vt.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01};return this.rgb(r)}if(It.test(t)){let e=It.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01,a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){let e=te(t),r=ee(t,e);return{h:ne(t),s:r,l:e,a:t.a}}static cieXYZ(t){return A(t)&&(t=this.rgb(t)),S.rgbToCieXYZ(t)}static rgb(t){if(A(t)){let e=t.h,r=t.s,s=t.l,i=e/60,o=(1-Math.abs(2*s-1))*r,h=o*(1-Math.abs(i%2-1)),l=s-o/2,d=(x,w,b)=>this._clampRGB([x+l,w+l,b+l,t.a]);if(i<=1)return d(o,h,0);if(i<=2)return d(h,o,0);if(i<=3)return d(0,o,h);if(i<=4)return d(0,h,o);if(i<=5)return d(h,0,o);if(i<=6)return d(o,0,h)}else{let e=S.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}}static stringify(t,e=1){if(A(t)){e??=1,t.a??=1;let r=typeof e=="number"?e:1;return`hsla(${t.h.roundoff(r)},${(t.s*100).roundoff(r)}%,${(t.l*100).roundoff(r)}%,${t.a.roundoff()})`}else if(R(t)){e??=!0,t.a??=1;let r=typeof e=="boolean"?e:!!e,s=Math.round(t.r*255),i=Math.round(t.g*255),o=Math.round(t.b*255),h=t.a.roundoff();return h===1?r?("#"+et(s)+et(i)+et(o)).toUpperCase():`rgb(${s},${i},${o})`:`rgba(${s},${i},${o},${h})`}}static contrastRatio(t,e){return A(t)&&(t=this.rgb(t)),A(e)&&(e=this.rgb(e)),S.contrastRatio(t,e)}static luminance(t){return A(t)&&(t=n.rgb(t)),S.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(R(t)){let r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(R(t)){let r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,s){r??=.5,s??=r;let i=(r+s).roundoff(),o=(r/i).roundoff(),h=(s/i).roundoff(),l=R(t),d=A(t),x=b=>R(b)||A(b)?n.cieXYZ(b):b;t=x(t),e=x(e);let w={x:(t.x*o+e.x*h).roundoff(),y:(t.y*o+e.y*h).roundoff(),z:(t.z*o+e.z*h).roundoff(),a:(t.a*o+e.a*h).roundoff()};return l?n.rgb(w):d?n.hsl(n.rgb(w)):w}};var re=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function Y(n){let t=[],e=n.match(re);return e&&e.length>0&&e.forEach(r=>t.push(parseFloat(r))),t}var zt=class n{static isAngle(t){return typeof t=="object"&&"vertex"in t&&H.isPoint(t.vertex)&&"start"in t&&H.isPoint(t.start)&&"end"in t&&H.isPoint(t.end)}static value(t){if(_.isNullOrEmpty(t)||!n.isAngle(t))return Number.NaN;let{vertex:e,start:r,end:s}=t;return n.angleBetween(e,r,s)}static angleBetween(t,e,r){let s={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y},o=s.x*i.x+s.y*i.y,h=s.x*i.y-s.y*i.x;return-Math.atan2(h,o)}},J=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return typeof t=="object"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"}},H=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return typeof t=="object"&&"x"in t&&typeof t.x=="number"&&"y"in t&&typeof t.y=="number"}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}};var X=class n{static isIdentity(t){return t.a===1&&t.d===1&&t.b===0&&t.f===0&&t.c===0&&t.e===0}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){let r=Math.cos(e),s=Math.sin(e);return n.multiply(t,{a:r,b:s,c:-s,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?typeof e=="number"?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:typeof e=="number"?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){let e=this.det(t);if(e===0)return null;let r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){let r=Math.sqrt(t.a*t.a+t.c*t.c),s=Math.sqrt(t.b*t.b+t.d*t.d),i=r!=0?t.a/r:0,o=r!=0?t.c/r:0,h=Math.atan2(o,i),{x:l,y:d}=e,x={x:t.e-l*(r*i-1)+d*r*o,y:t.f-d*(s*i-1)-l*s*o};return{scaleX:r,scaleY:s,rotation:h,translation:x}}static fromTransform([t,e,r],[s,i,o]){let h=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(h)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");let l=1/h;return{a:l*(s.x*(e.y-r.y)+i.x*(r.y-t.y)+o.x*(t.y-e.y)),b:l*(s.y*(e.y-r.y)+i.y*(r.y-t.y)+o.y*(t.y-e.y)),c:l*(s.x*(r.x-e.x)+i.x*(t.x-r.x)+o.x*(e.x-t.x)),d:l*(s.y*(r.x-e.x)+i.y*(t.x-r.x)+o.y*(e.x-t.x)),e:l*(s.x*(e.x*r.y-r.x*e.y)+i.x*(r.x*t.y-t.x*r.y)+o.x*(t.x*e.y-e.x*t.y)),f:l*(s.y*(e.x*r.y-r.x*e.y)+i.y*(r.x*t.y-t.x*r.y)+o.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}};var D=class n{static parse(t){let e=Y(t);if(e&&e.length===4)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return H.isPoint(t)&&J.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o>=h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _cover(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o<h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _align(t,e,r,s){let i=0,o=0;switch(r){case"left":i=e.x-t.x;break;case"right":i=e.x+e.width-t.width-t.x;break;default:i=e.x+e.width*.5-t.width*.5-t.x;break}switch(s){case"top":o=e.y-t.y;break;case"bottom":o=e.y+e.height-t.height-t.y;break;default:o=e.y+e.height*.5-t.height*.5-t.y;break}return{x:i,y:o}}static findTransform(t,e,r="stretch",s="center",i="middle"){switch(r){case"contain":return this._contain(t,e,s,i);case"cover":return this._cover(t,e,s,i);default:return this._stretch(t,e)}}static intersect(...t){let e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var s=r[0],i=1;i<r.length;i++){let o=r[i],h=Math.max(o.x,s.x),l=Math.max(o.y,s.y),d=Math.min(o.x+o.width,s.x+s.width),x=Math.min(o.y+o.height,s.y+s.height),w=d-h,b=x-l;if(w<0||b<=0)return e;s={x:h,y:l,width:w,height:b}}return s}static expand(t,...e){let r=Array.from(e||[]),s=t.x,i=t.y,o=s,h=i;n.isRect(t)&&(o+=t.width,h+=t.height);for(let l of r)s=Math.min(l.x,s),i=Math.min(l.y,i),o=Math.max(l.x,o),h=Math.max(l.y,h);return{x:s,y:i,width:o-s,height:h-i}}};var Ht=class{constructor(t,e){this.#n=t,this.#r=e}#t=[];#e=[];#r;#n;get current(){return this.#n}get canUndo(){return this.#t.length>0}get canRedo(){return this.#e.length>0}set maxlength(t){this.#r=t}undo(){if(this.canUndo){let t=this.#t,e=this.#e,r=this.#n;e.unshift(r),this.#n=t.pop()}}redo(){if(this.canRedo){let t=this.#t,e=this.#e,r=this.#n;t.push(r),this.#n=e.shift()}}push(t){this.#e.splice(0),this.#t.push(this.#n),this.#n=t;let e=this.#r,r=this.#t;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#e.splice(0),this.#t.splice(0)}};var se={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"},Nt=class n{static async loadImage(t){let e=await fetch(t);return e.ok?await e.blob():null}static async resizeImage(t,e,r,s){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");typeof t=="string"&&(t=await n.loadImage(t));let i=await self.createImageBitmap(t),o=i.width,h=i.height,l=new OffscreenCanvas(o,h),d=l.getContext("2d");d.imageSmoothingEnabled=d.mozImageSmoothingEnabled=d.oImageSmoothingEnabled=d.webkitImageSmoothingEnabled=!0;let{quality:x,type:w,mode:b,align:N,valign:Q,background:Z}=Object.assign({},se,s??{}),z={width:o,height:h,x:0,y:0},q={x:0,y:0,width:e,height:r},p=D.findTransform(z,q,b,N,Q);return l.width=e,l.height=r,Z&&(d.fillStyle=Z,d.fillRect(0,0,l.width,l.height)),d.setTransform(p),d.drawImage(i,0,0),await l.convertToBlob({quality:x,type:w})}};var jt=class n{static#t;static uniqueId(){let t=n.#t||Date.now();return n.#t=++t}static uniqueCode(){return n.uniqueId().toBase62()}static randomString(t){let e="";do e+=(Math.random()*62).toBase62();while(e.length<t);return e}};var Gt=class{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){let s=t.toString(),i=parseInt(s,e);return s.endsWith(i.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}};function nt(n,t){let e=n.length,r=t.length,s=Array.from({length:e+1},()=>Array(r+1).fill(0));for(let i=1;i<=e;i++)for(let o=1;o<=r;o++)n[i-1]===t[o-1]?s[i][o]=s[i-1][o-1]+1:s[i][o]=Math.max(s[i-1][o],s[i][o-1]);return s}function rt(n,t,e,r=""){let s=n.length,i=t.length,o=[],h=s,l=i,d=null,x=()=>{d&&(o.push(d),d=null)};for(;h>0||l>0;){var w=null;let b=null;h>0&&l>0&&n[h-1]===t[l-1]?(w="=",b=n[h-1],h--,l--):l>0&&(h===0||e[h][l-1]>=e[h-1][l])?(w="+",b=t[l-1],l--):h>0&&(l===0||e[h-1][l]>e[h][l-1])&&(w="-",b=n[h-1],h--),w&&b!==null?d&&d.type===w?d.value=b+(d.value?r:"")+d.value:(x(),d={type:w,value:b}):x()}return x(),o.reverse()}function ie(n,t){let e=n.split(""),r=t.split(""),s=nt(e,r);return rt(e,r,s,"")}function oe(n,t){let e=/(\S+|\s+)/g,r=n.match(e)||[],s=t.match(e)||[],i=nt(r,s);return rt(r,s,i,"")}function ae(n,t){let e=/\r?\n/,r=n.split(e),s=t.split(e),i=nt(r,s);return rt(r,s,i,`
|
|
6
|
+
var Wt=Object.defineProperty;var kt=(n,t)=>{for(var e in t)Wt(n,e,{get:t[e],enumerable:!0})};Number.prototype.isCloseTo=function(n,t=14){let e=+`1e-${t}`;return this>n-e&&this<n+e};Number.prototype.roundoff=function(n=14){return parseFloat(this.toFixed(n))};Number.prototype.clamp=function(n,t){let e=this;return n!=null&&!isNaN(n)&&(e=Math.max(e,n)),t!=null&&!isNaN(t)&&(e=Math.min(e,t)),e};Number.prototype.toBase62=function(){for(var n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t=this,e="";t!=0;){var r=t%62;e=n.charAt(r)+e,t=Math.floor(t/62)}return e};Number.prototype.toBase36=function(){return this.toString(36)};var Kt=/^\/Date\([\d]+\)\/$/i,V=class n{static parse(t){let e;return typeof t=="string"?(Kt.test(t)?e=parseInt(t.substring(6)):e=Date.parse(t),new Date(e)):typeof t=="number"?new Date(t):t}static isLeapYear(t){return t%4===0&&t%100!==0||t%400===0}static daysInMonth(t,e){return[31,n.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),s=new Date(t),i=s.getMonth()+e,o=0;for(;i<0;)i+=12,o--;return s.setDate(1),s.setMonth(i%12),s.setFullYear(s.getFullYear()+o+Math.floor(i/12)),s.setDate(Math.min(r,n.daysInMonth(s.getFullYear(),s.getMonth()))),s}static addDays(t,e){return new Date(t.valueOf()+e*864e5)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}};var _=class n{static isNull(t){return t==null}static isEmpty(t){try{return Array.isArray(t)&&t.length===0||typeof t=="string"&&t===""||typeof t=="object"&&Object.keys(t).length===0&&!V.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch{return!1}}static isNullOrEmpty(t){return n.isNull(t)||n.isEmpty(t)}};Array.prototype.distinct=function(){return Array.from(new Set(this))};Array.prototype.union=function(n){let t=_.isNullOrEmpty(this),e=_.isNullOrEmpty(n);return t&&e?[]:e?this.slice():t?n.slice():this.concat(n).distinct()};Array.prototype.moveWithin=function(n,t){let e="Index must be greater or equal than 0 and less or equal than the length of the array.";var r=this;if(n<0||n>r.length)throw new Error(e);if(t<0||t>r.length)throw new Error(e);r.splice(t,0,Array.prototype.splice.apply(r,[n,1])[0])};Array.prototype.equalsContent=function(n){if(n==null||this.length!==n.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==n[t])return!1;return!0};Array.prototype.cloneFrom=function(n){if(n==null)throw"Cannot clone array from null object.";let t=n.length;var e=this.length!==n.length;for(let r=0;r<t;r++){let s=n[r];this.length>r?this[r]!==s&&(this[r]=s,e=!0):(Array.prototype.push.apply(this,[s]),e=!0)}e&&this.splice(t)};function _t(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)&&(n.constructor===Object||n.constructor===void 0)}function $t(n,t){let e=n;for(let r of Object.keys(t)){let s=t[r],i=e[r];_t(s)?e[r]=$t(_t(i)?i:{},s):Array.isArray(s)?e[r]=s.slice():e[r]=s}return e}var St=class{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},$t(e,t)}};var Ct=class{static range(t,e,r=2){let s=t;_.isNull(e)&&(e=r=t,t=1);let i=(e-t)/(r-1),o=[];if(i>0)for(;o.length<r;)o.push(s.roundoff()),s+=i;return o}static chunkify(t,e){if(_.isNullOrEmpty(t))return[];if(e<=0||e%1!==0)throw new Error("Provide a positive integer number.");let r=Math.ceil(t.length/e);return Array.from({length:r},(s,i)=>{let o=i*e,h=o+e;return t.slice(o,h)})}};var Tt=class n{static blobToDataURL(t){return new Promise((e,r)=>{let s=new FileReader;s.onload=i=>{e(i.target.result)},s.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length,r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){let r=n._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){let e=t.indexOf(",");if(e===-1)return n.base64ToBlob(t);{let r=t.substring(e+1),i=t.substring(0,e).match(/:(.*?);/)[1];return n.base64ToBlob(r,{type:i})}}static async blobToText(t,e){let r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",s,i=63){let o=r.toLowerCase(),h=()=>`${e};charset=${o}`;switch(o){case"utf-8":{let d=new TextEncoder().encode(t),x=s?[new Uint8Array([239,187,191]),d]:[d];return new Blob(x,{type:h()})}case"utf-16":o="utf-16le",s??=!0;case"utf-16le":case"utf-16be":{let l=o!=="utf-16be",d=s?1:0,x=new ArrayBuffer((t.length+d)*2),w=new DataView(x);s&&w.setUint16(0,65279,l);for(let b=0;b<t.length;b++)w.setUint16((b+d)*2,t.charCodeAt(b),l);return new Blob([x],{type:h()})}case"ascii":case"iso-8859-1":case"latin1":{let l=o==="ascii"?127:255,d=new Uint8Array(t.length),x=i>0;for(let w=0;w<t.length;w++){let b=t.charCodeAt(w);if(b>l)if(x)d[w]=i;else throw new Error(`Character "${t[w]}" cannot be encoded in ${r}.`);else d[w]=b}return new Blob([d],{type:h()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}};var L=(n,t)=>{let e=n.match(t);return e?e[2]:null};function Xn(n=navigator.userAgent){let t="unknown",e=null;switch(/ucbrowser/i.test(n)?t="UCBrowser":/edg/i.test(n)?t="Edge":/googlebot/i.test(n)?t="GoogleBot":/chromium/i.test(n)?t="Chromium":/firefox|fxios/i.test(n)&&!/seamonkey/i.test(n)?t="Firefox":/; msie|trident/i.test(n)&&!/ucbrowser/i.test(n)?t="IE":/chrome|crios/i.test(n)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(n)?t="Chrome":/safari/i.test(n)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(n)?t="Safari":/opr|opera/i.test(n)&&(t="Opera"),t){case"UCBrowser":e=L(n,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":e=L(n,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":e=L(n,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":e=L(n,/(chromium)\/([\d\.]+)/i);break;case"Firefox":e=L(n,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":e=L(n,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":e=L(n,/(safari)\/([\d\.]+)/i);break;case"Opera":e=L(n,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{let r=L(n,/(trident)\/([\d\.]+)/i);e=r?`${parseFloat(r)+4}`:"7.0";break}default:e="0.0.0.0";break}return{name:t,version:e}}var vt=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,It=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,Et=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,Ft=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,Bt=/^#[a-f0-9]{6}$/,At=/^#[a-f0-9]{3}$/;function R(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"r"in n&&"g"in n&&"b"in n&&typeof n.r=="number"&&typeof n.b=="number"&&typeof n.g=="number"?(n.a??=1,n.r>=0&&n.r<=1&&n.g>=0&&n.g<=1&&n.b>=0&&n.b<=1&&n.a>=0&&n.a<=1):!1}function A(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"h"in n&&"s"in n&&"l"in n&&typeof n.h=="number"&&typeof n.s=="number"&&typeof n.l=="number"?(n.a??=1,n.h>=0&&n.h<=360&&n.s>=0&&n.s<=1&&n.l>=0&&n.l<=1&&n.a>=0&&n.a<=1):!1}function te(n){let t=n.r,e=n.g,r=n.b;return(.5*(Math.max(t,e,r)+Math.min(t,e,r))).clamp(0,1)}var S={adjustRgbChannel:n=>n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),adjustRgbChannelInv:n=>n<=.00304?n*12.92:1.055*(Math.pow(n,1/2.4)-.055),adjustRgb:n=>({r:S.adjustRgbChannel(n.r),g:S.adjustRgbChannel(n.g),b:S.adjustRgbChannel(n.b),a:n.a}),adjustRgbInv:n=>({r:S.adjustRgbChannelInv(n.r),g:S.adjustRgbChannelInv(n.g),b:S.adjustRgbChannelInv(n.b),a:n.a}),X:n=>.4125*n.r+.3576*n.g+.1804*n.b,Y:n=>.2126*n.r+.7152*n.g+.0722*n.b,Z:n=>.0193*n.r+.1191*n.g+.9503*n.b,relativeLuminance:n=>{let t=S.adjustRgb(n);return S.Y(t)},rgbToCieXYZ:n=>{let t=S.adjustRgb(n);return{x:S.X(t),y:S.Y(t),z:S.Z(t),a:n.a}},cieXYZToRgb:n=>{let t=3.241*n.x-1.5374*n.y-.4986*n.z,e=-.9692*n.x+1.876*n.y+.0416*n.z,r=.0556*n.x-.204*n.y+1.057*n.z;return S.adjustRgbInv({r:t,g:e,b:r,a:n.a})},contrastRatio:(n,t)=>{let e=S.relativeLuminance(n)+.05,r=S.relativeLuminance(t)+.05;return e>r?e/r:r/e}};function ee(n,t){let e=n.r,r=n.g,s=n.b,i=Math.max(e,r,s),o=Math.min(e,r,s);return(t===0||t===1?0:(i-o)/(1-Math.abs(2*t-1))).clamp(0,1)}function ne(n){let t=n.r,e=n.g,r=n.b,s=Math.max(t,e,r),i=Math.min(t,e,r),o=0;return s!==i&&(s===t?o=(60*((e-r)/(s-i))+360)%360:s===e?o=(60*((r-t)/(s-i))+120)%360:o=(60*((t-e)/(s-i))+240)%360),o.clamp(0,360)}function et(n){return n.toString(16).padStart(2,"0")}var Lt=class n{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){let e=r=>Math.min(1,Math.max(0,r));return t[3]==null&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),Et.test(t)){let e=Et.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(Ft.test(t)){let e=Ft.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(Bt.test(t)){let e=Bt.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(At.test(t)){let e=At.exec(t)[0],r=e.substr(1,1),s=e.substr(2,1),i=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+s+s),parseInt("0x"+i+i),1]))}if(vt.test(t)){let e=vt.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01};return this.rgb(r)}if(It.test(t)){let e=It.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01,a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){let e=te(t),r=ee(t,e);return{h:ne(t),s:r,l:e,a:t.a}}static cieXYZ(t){return A(t)&&(t=this.rgb(t)),S.rgbToCieXYZ(t)}static rgb(t){if(A(t)){let e=t.h,r=t.s,s=t.l,i=e/60,o=(1-Math.abs(2*s-1))*r,h=o*(1-Math.abs(i%2-1)),l=s-o/2,d=(x,w,b)=>this._clampRGB([x+l,w+l,b+l,t.a]);if(i<=1)return d(o,h,0);if(i<=2)return d(h,o,0);if(i<=3)return d(0,o,h);if(i<=4)return d(0,h,o);if(i<=5)return d(h,0,o);if(i<=6)return d(o,0,h)}else{let e=S.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}}static stringify(t,e=1){if(A(t)){e??=1,t.a??=1;let r=typeof e=="number"?e:1;return`hsla(${t.h.roundoff(r)},${(t.s*100).roundoff(r)}%,${(t.l*100).roundoff(r)}%,${t.a.roundoff()})`}else if(R(t)){e??=!0,t.a??=1;let r=typeof e=="boolean"?e:!!e,s=Math.round(t.r*255),i=Math.round(t.g*255),o=Math.round(t.b*255),h=t.a.roundoff();return h===1?r?("#"+et(s)+et(i)+et(o)).toUpperCase():`rgb(${s},${i},${o})`:`rgba(${s},${i},${o},${h})`}}static contrastRatio(t,e){return A(t)&&(t=this.rgb(t)),A(e)&&(e=this.rgb(e)),S.contrastRatio(t,e)}static luminance(t){return A(t)&&(t=n.rgb(t)),S.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(R(t)){let r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(R(t)){let r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,s){r??=.5,s??=r;let i=(r+s).roundoff(),o=(r/i).roundoff(),h=(s/i).roundoff(),l=R(t),d=A(t),x=b=>R(b)||A(b)?n.cieXYZ(b):b;t=x(t),e=x(e);let w={x:(t.x*o+e.x*h).roundoff(),y:(t.y*o+e.y*h).roundoff(),z:(t.z*o+e.z*h).roundoff(),a:(t.a*o+e.a*h).roundoff()};return l?n.rgb(w):d?n.hsl(n.rgb(w)):w}};var re=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function Y(n){let t=[],e=n.match(re);return e&&e.length>0&&e.forEach(r=>t.push(parseFloat(r))),t}var zt=class n{static isAngle(t){return typeof t=="object"&&"vertex"in t&&H.isPoint(t.vertex)&&"start"in t&&H.isPoint(t.start)&&"end"in t&&H.isPoint(t.end)}static value(t){if(_.isNullOrEmpty(t)||!n.isAngle(t))return Number.NaN;let{vertex:e,start:r,end:s}=t;return n.angleBetween(e,r,s)}static angleBetween(t,e,r){let s={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y},o=s.x*i.x+s.y*i.y,h=s.x*i.y-s.y*i.x;return-Math.atan2(h,o)}},J=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return typeof t=="object"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"}},H=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return typeof t=="object"&&"x"in t&&typeof t.x=="number"&&"y"in t&&typeof t.y=="number"}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}};var X=class n{static isIdentity(t){return t.a===1&&t.d===1&&t.b===0&&t.f===0&&t.c===0&&t.e===0}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){let r=Math.cos(e),s=Math.sin(e);return n.multiply(t,{a:r,b:s,c:-s,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?typeof e=="number"?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:typeof e=="number"?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){let e=this.det(t);if(e===0)return null;let r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){let r=Math.sqrt(t.a*t.a+t.c*t.c),s=Math.sqrt(t.b*t.b+t.d*t.d),i=r!=0?t.a/r:0,o=r!=0?t.c/r:0,h=Math.atan2(o,i),{x:l,y:d}=e,x={x:t.e-l*(r*i-1)+d*r*o,y:t.f-d*(s*i-1)-l*s*o};return{scaleX:r,scaleY:s,rotation:h,translation:x}}static fromTransform([t,e,r],[s,i,o]){let h=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(h)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");let l=1/h;return{a:l*(s.x*(e.y-r.y)+i.x*(r.y-t.y)+o.x*(t.y-e.y)),b:l*(s.y*(e.y-r.y)+i.y*(r.y-t.y)+o.y*(t.y-e.y)),c:l*(s.x*(r.x-e.x)+i.x*(t.x-r.x)+o.x*(e.x-t.x)),d:l*(s.y*(r.x-e.x)+i.y*(t.x-r.x)+o.y*(e.x-t.x)),e:l*(s.x*(e.x*r.y-r.x*e.y)+i.x*(r.x*t.y-t.x*r.y)+o.x*(t.x*e.y-e.x*t.y)),f:l*(s.y*(e.x*r.y-r.x*e.y)+i.y*(r.x*t.y-t.x*r.y)+o.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}};var D=class n{static parse(t){let e=Y(t);if(e&&e.length===4)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return H.isPoint(t)&&J.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o>=h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _cover(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o<h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _align(t,e,r,s){let i=0,o=0;switch(r){case"left":i=e.x-t.x;break;case"right":i=e.x+e.width-t.width-t.x;break;default:i=e.x+e.width*.5-t.width*.5-t.x;break}switch(s){case"top":o=e.y-t.y;break;case"bottom":o=e.y+e.height-t.height-t.y;break;default:o=e.y+e.height*.5-t.height*.5-t.y;break}return{x:i,y:o}}static findTransform(t,e,r="stretch",s="center",i="middle"){switch(r){case"contain":return this._contain(t,e,s,i);case"cover":return this._cover(t,e,s,i);default:return this._stretch(t,e)}}static intersect(...t){let e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var s=r[0],i=1;i<r.length;i++){let o=r[i],h=Math.max(o.x,s.x),l=Math.max(o.y,s.y),d=Math.min(o.x+o.width,s.x+s.width),x=Math.min(o.y+o.height,s.y+s.height),w=d-h,b=x-l;if(w<0||b<=0)return e;s={x:h,y:l,width:w,height:b}}return s}static expand(t,...e){let r=Array.from(e||[]),s=t.x,i=t.y,o=s,h=i;n.isRect(t)&&(o+=t.width,h+=t.height);for(let l of r)s=Math.min(l.x,s),i=Math.min(l.y,i),o=Math.max(l.x,o),h=Math.max(l.y,h);return{x:s,y:i,width:o-s,height:h-i}}};var Ht=class{constructor(t,e){this.#n=t,this.#r=e}#t=[];#e=[];#r;#n;get current(){return this.#n}get canUndo(){return this.#t.length>0}get canRedo(){return this.#e.length>0}set maxlength(t){this.#r=t}undo(){if(this.canUndo){let t=this.#t,e=this.#e,r=this.#n;e.unshift(r),this.#n=t.pop()}}redo(){if(this.canRedo){let t=this.#t,e=this.#e,r=this.#n;t.push(r),this.#n=e.shift()}}push(t){this.#e.splice(0),this.#t.push(this.#n),this.#n=t;let e=this.#r,r=this.#t;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#e.splice(0),this.#t.splice(0)}};var se={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"},Nt=class n{static async loadImage(t){let e=await fetch(t);return e.ok?await e.blob():null}static async resizeImage(t,e,r,s){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");let i=await n._toDrawable(t),o=i.width||e,h=i.height||r,l=new OffscreenCanvas(o,h),d=l.getContext("2d");d.imageSmoothingEnabled=d.mozImageSmoothingEnabled=d.oImageSmoothingEnabled=d.webkitImageSmoothingEnabled=!0;let{quality:x,type:w,mode:b,align:N,valign:Q,background:Z}=Object.assign({},se,s??{}),z={width:o,height:h,x:0,y:0},q={x:0,y:0,width:e,height:r},p=D.findTransform(z,q,b,N,Q);return l.width=e,l.height=r,Z&&(d.fillStyle=Z,d.fillRect(0,0,l.width,l.height)),d.setTransform(p),d.drawImage(i,0,0),await l.convertToBlob({quality:x,type:w})}static async _toDrawable(t){return typeof t=="string"&&(t=await n.loadImage(t)),t instanceof Blob?await self.createImageBitmap(t):t}};var jt=class n{static#t;static uniqueId(){let t=n.#t||Date.now();return n.#t=++t}static uniqueCode(){return n.uniqueId().toBase62()}static randomString(t){let e="";do e+=(Math.random()*62).toBase62();while(e.length<t);return e}};var Gt=class{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){let s=t.toString(),i=parseInt(s,e);return s.endsWith(i.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}};function nt(n,t){let e=n.length,r=t.length,s=Array.from({length:e+1},()=>Array(r+1).fill(0));for(let i=1;i<=e;i++)for(let o=1;o<=r;o++)n[i-1]===t[o-1]?s[i][o]=s[i-1][o-1]+1:s[i][o]=Math.max(s[i-1][o],s[i][o-1]);return s}function rt(n,t,e,r=""){let s=n.length,i=t.length,o=[],h=s,l=i,d=null,x=()=>{d&&(o.push(d),d=null)};for(;h>0||l>0;){var w=null;let b=null;h>0&&l>0&&n[h-1]===t[l-1]?(w="=",b=n[h-1],h--,l--):l>0&&(h===0||e[h][l-1]>=e[h-1][l])?(w="+",b=t[l-1],l--):h>0&&(l===0||e[h-1][l]>e[h][l-1])&&(w="-",b=n[h-1],h--),w&&b!==null?d&&d.type===w?d.value=b+(d.value?r:"")+d.value:(x(),d={type:w,value:b}):x()}return x(),o.reverse()}function ie(n,t){let e=n.split(""),r=t.split(""),s=nt(e,r);return rt(e,r,s,"")}function oe(n,t){let e=/(\S+|\s+)/g,r=n.match(e)||[],s=t.match(e)||[],i=nt(r,s);return rt(r,s,i,"")}function ae(n,t){let e=/\r?\n/,r=n.split(e),s=t.split(e),i=nt(r,s);return rt(r,s,i,`
|
|
7
7
|
`)}var Rt=class{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){let r=Array.from(e),s=t;for(let o=0;o<r.length;o++){let h=new RegExp("(^|[^\\{])\\{"+o+"\\}($|[^\\}])","g");s=s.replaceAll(h,(l,...d)=>l.replace("{"+o+"}",r[o]))}let i=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(s);if(!_.isNullOrEmpty(i))throw new Error(`Missing argument at index ${i[2]}.`);return s}static diff(t,e,r="char"){switch(r){case"line":return ae(t,e);case"word":return oe(t,e);default:return ie(t,e)}}static async hash(t,e="SHA-256"){let r=await crypto.subtle.digest(e,new TextEncoder().encode(t));return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}};var Dt={};kt(Dt,{CSharpSyntax:()=>mt,CSyntax:()=>xt,DefaultHighlightClasses:()=>Zt,HighlightRenderer:()=>M,JavaScriptSyntax:()=>dt,JsonSyntax:()=>wt,Markdown:()=>pt,MarkupSyntax:()=>yt,PacemBindingSyntax:()=>gt,Parser:()=>P,Scanner:()=>O,SyntaxTokenType:()=>v,Syntaxes:()=>F});var pt={};kt(pt,{Parser:()=>ht});var st=class{tokenize(t,e){let r=[];for(;t;){let s=t.length;for(let i of e){let o=i.exec(t,this),h=o?.length;if(h>0){Array.prototype.push.apply(r,o);let l=o[h-1];t=t.substr((l.index||0)+l.raw.length);break}}if(t.length>=s)throw new Error(`Cannot parse
|
|
8
8
|
"${t}"
|
|
9
9
|
using the provided grammar.`)}return r}},P=class{constructor(t=new st){this._lexer=t}parse(t,e,r){let s=this._lexer.tokenize(t,e);return r.render(s)}};var v;(function(n){n.Text="text",n.Space="space",n.Newline="newline",n.Comment="comment",n.DocComment="doc-comment",n.Keyword="keyword",n.Identifier="identifier",n.String="string",n.Regex="regex",n.Number="number",n.Bracket="bracket",n.Punctuation="punctuation",n.Operator="operator",n.Preprocessor="preprocessor",n.Tag="tag",n.TagName="tagname",n.Attribute="attribute",n.Entity="entity"})(v||(v={}));var it=new Map;function Xt(n){return(n??"").trim().toLowerCase()}var F=class{static register(t){if(t==null)return;let e=[t.name].concat(t.aliases??[]);for(let r of e){let s=Xt(r);it.set(s,t)}}static get(t){let e=Xt(t);return it.get(e)??null}static names(){let t=it.keys();return Array.from(t)}};var le="root",ue=[v.Identifier],he=[v.Space,v.Newline,v.Comment,v.DocComment],pe=64,de=16;function fe(n){return n.combined!=null}var Pt=new WeakMap;function ge(n){return"include"in n}function W(n){return n==null||n.length===0?null:new Set(n)}function ye(n){let t=n.split(""),e=new Set(t);return Array.from(e).join("")}function me(n,t){let e={};for(let r in t)e[r]=t[r].slice();for(let r in n){let s=e[r]??[];e[r]=n[r].concat(s)}return e}function xe(n,t){let e={};for(let r in t)e[r]=t[r].slice();for(let r in n){let s=e[r]??[];e[r]=s.concat(n[r])}return e}function Ot(n,t=0){let e=n.lexical??{states:{}},r={start:e.start,states:e.states??{},keywords:e.keywords??{},keywordSources:e.keywordSources,keywordExceptAfter:e.keywordExceptAfter,insignificant:e.insignificant},s=n.extends?F.get(n.extends):null;if(s==null||s===n||t>=de)return r;let i=Ot(s,t+1);return{start:r.start??i.start,states:me(r.states,i.states),keywords:xe(r.keywords,i.keywords),keywordSources:r.keywordSources??i.keywordSources,keywordExceptAfter:r.keywordExceptAfter??i.keywordExceptAfter,insignificant:r.insignificant??i.insignificant}}function Mt(n,t,e){let r=n[t]??[];if(e.has(t))return[];e.add(t);let s=[];for(let i of r){if(!ge(i)){s.push(i);continue}let o=Mt(n,i.include,e);Array.prototype.push.apply(s,o)}return e.delete(t),s}function we(n){return n==null?null:{previousTypes:W(n.previousTypes),previousNotTypes:W(n.previousNotTypes),previousTexts:W(n.previousTexts),previousNotTexts:W(n.previousNotTexts)}}function be(n){let t=Array.isArray(n.type)?n.type:null,e=Array.isArray(n.type)?n.type[0]:n.type,r=(n.flags??"").replace(/[yd]/g,""),s=ye(r),i=s+"y"+(t?"d":""),o=new RegExp(n.match,i),h=n.until?new RegExp(n.until,"y"):null,l=n.pop===!0?1:typeof n.pop=="number"?n.pop:0,d=we(n.when);return{regex:o,type:e,groupTypes:t,when:d,pop:l,until:h,source:n.match,flags:s,next:n.next??null,push:n.push??null,embed:n.embed??null,hasTransition:l>0||!!n.next||!!n.push||!!n.embed}}function ke(n){let t=new Map;for(let e in n)for(let r of n[e])t.set(r,e);return t}var _e=/\\[1-9]|\\k<|\(\?<(?![=!])/;function Se(n,t){return new RegExp(n+"|",t).exec("").length-1}function $e(n,t){return new RegExp("^(?:"+n+")$",t).test("")}function Ce(n){return n.when!=null||_e.test(n.source)?!1:!$e(n.source,n.flags)}function Te(n){if(n.length===1)return{rule:n[0],combined:null};let t=[],e=1;for(let o of n){t.push(e);let h=Se(o.source,o.flags);e+=1+h}let s=n.map(o=>"("+o.source+")").join("|");return{rule:null,combined:new RegExp(s,n[0].flags+"y"),rules:n,groupIndices:t}}function ve(n){let t=[],e=[],r=()=>{if(e.length>0){let s=Te(e);t.push(s)}e=[]};for(let s of n){if(!Ce(s)){r(),t.push({rule:s,combined:null});continue}e.length>0&&e[0].flags!==s.flags&&r(),e.push(s)}return r(),t}function Qt(n){let t=Pt.get(n);if(t!=null)return t;let e=Ot(n),r=new Map;for(let i in e.states){let o=new Set,l=Mt(e.states,i,o).map(be),d=ve(l);r.set(i,d)}let s={name:n.name,start:e.start??le,states:r,keywords:ke(e.keywords),keywordSources:new Set(e.keywordSources??ue),keywordExceptAfter:new Set(e.keywordExceptAfter??[]),insignificant:new Set(e.insignificant??he)};return Pt.set(n,s),s}function Ie(n){let t=F.get(n);return t==null?null:Qt(t)}function Ee(n,t){let e=t?.type??null,r=t?.raw??null;return n.previousTypes!=null&&!n.previousTypes.has(e)||n.previousNotTypes!=null&&n.previousNotTypes.has(e)||n.previousTexts!=null&&!n.previousTexts.has(r)?!1:n.previousNotTexts==null||!n.previousNotTexts.has(r)}var ot=class{constructor(t,e){this._source=t,this._tokens=[],this._position=0,this._emitted=0,this._line=1,this._column=1,this._previous=null,this._emptyTransitions=0,this._stack=[{syntax:e,state:e.start,until:null}]}run(){let t=this._source.length;for(;this._position<t;)this._step();return this._flushText(),this._tokens}get _top(){let t=this._stack;return t[t.length-1]}_step(){let t=this._top;if(this._popOnUntil(t))return;let e=this._findRule(t);if(e==null){this._position++;return}this._flushText(),this._emitMatch(e,t.syntax),this._transition(e.rule,t.syntax);let r=e.match[0].length;this._position+=r,r>0&&(this._emptyTransitions=0)}_popOnUntil(t){let e=t.until;return e==null||this._stack.length<=1||(e.lastIndex=this._position,!e.test(this._source))?!1:(this._flushText(),this._stack.pop(),!0)}_findRule(t){let e=t.syntax.states.get(t.state)??[];for(let r of e){let s=fe(r)?this._tryCombined(r):this._trySingle(r.rule);if(s!=null)return s}return null}_trySingle(t){let e=this._tryRule(t);return e==null?null:{rule:t,match:e}}_tryCombined(t){let e=t.combined;e.lastIndex=this._position;let r=e.exec(this._source);if(r==null)return null;let s=t.groupIndices;for(let i=0;i<s.length;i++){if(r[s[i]]===void 0)continue;let o=t.rules[i];return this._trySingle(o)}return null}_tryRule(t){if(t.when!=null&&!Ee(t.when,this._previous))return null;let e=t.regex;e.lastIndex=this._position;let r=e.exec(this._source);return r==null?null:r[0].length>0?r:!t.hasTransition||this._emptyTransitions>=pe?null:(this._emptyTransitions++,r)}_emitMatch({rule:t,match:e},r){let s=e[0];if(t.groupTypes==null){this._append(t.type,s,r);return}this._emitGroups(t,e,r)}_emitGroups(t,e,r){let s=e.indices,i=e.index,o=i+e[0].length,h=t.groupTypes,l=i;for(let d=1;d<e.length;d++){let x=s[d];if(x==null||x[0]<l||x[1]===x[0])continue;if(x[0]>l){let N=this._source.slice(l,x[0]);this._append(v.Text,N,r)}let w=this._source.slice(x[0],x[1]),b=h[d-1]??h[h.length-1];this._append(b,w,r),l=x[1]}if(l<o){let d=this._source.slice(l,o);this._append(v.Text,d,r)}}_transition(t,e){let r=this._stack;for(let i=0;i<t.pop&&r.length>1;i++)r.pop();if(t.next!=null&&(this._top.state=t.next),t.push!=null&&r.push({syntax:e,state:t.push,until:null}),t.embed==null)return;let s=Ie(t.embed);s!=null&&r.push({syntax:s,state:s.start,until:t.until})}_flushText(){if(this._emitted>=this._position)return;let t=this._source.slice(this._emitted,this._position),e=this._top.syntax;this._append(v.Text,t,e)}_resolveType(t,e,r){if(!r.keywordSources.has(t))return t;let s=this._previous?.raw;return r.keywordExceptAfter.has(s)?t:r.keywords.get(e)??t}_append(t,e,r){let s=this._resolveType(t,e,r),i={type:s,raw:e,text:e,index:this._emitted,line:this._line,column:this._column,depth:this._stack.length-1,syntax:r.name};this._tokens.push(i),this._advance(e),r.insignificant.has(s)||(this._previous=i)}_advance(t){this._emitted+=t.length;let e=t.lastIndexOf(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-foundation v2.0.0-
|
|
2
|
+
* @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -1299,11 +1299,8 @@ var Imaging = class _Imaging {
|
|
|
1299
1299
|
if (width <= 0 || height <= 0 || isNaN(width) || isNaN(height)) {
|
|
1300
1300
|
throw new Error("Invalid target size");
|
|
1301
1301
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
}
|
|
1305
|
-
const el = await self.createImageBitmap(img);
|
|
1306
|
-
const origWidth = el.width, origHeight = el.height;
|
|
1302
|
+
const el = await _Imaging._toDrawable(img);
|
|
1303
|
+
const origWidth = el.width || width, origHeight = el.height || height;
|
|
1307
1304
|
const cnv = new OffscreenCanvas(origWidth, origHeight);
|
|
1308
1305
|
const ctx = cnv.getContext("2d");
|
|
1309
1306
|
ctx.imageSmoothingEnabled = ctx["mozImageSmoothingEnabled"] = ctx["oImageSmoothingEnabled"] = ctx["webkitImageSmoothingEnabled"] = true;
|
|
@@ -1321,6 +1318,16 @@ var Imaging = class _Imaging {
|
|
|
1321
1318
|
const retval = await cnv.convertToBlob({ quality, type });
|
|
1322
1319
|
return retval;
|
|
1323
1320
|
}
|
|
1321
|
+
/** Turns a URL or a `Blob` into a drawable source, while passing an already drawable source through untouched. */
|
|
1322
|
+
static async _toDrawable(img) {
|
|
1323
|
+
if (typeof img === "string") {
|
|
1324
|
+
img = await _Imaging.loadImage(img);
|
|
1325
|
+
}
|
|
1326
|
+
if (!(img instanceof Blob)) {
|
|
1327
|
+
return img;
|
|
1328
|
+
}
|
|
1329
|
+
return await self.createImageBitmap(img);
|
|
1330
|
+
}
|
|
1324
1331
|
};
|
|
1325
1332
|
|
|
1326
1333
|
// packages/foundation/dist/esm/keygenerator.js
|