@kylincloud/flamegraph 0.36.2 → 0.36.3
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/CHANGELOG.md +7 -0
- package/dist/FlameGraph/FlameGraphComponent/index.d.ts.map +1 -1
- package/dist/flamegraphRenderWorker.js +1 -1
- package/dist/flamegraphRenderWorker.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +2 -2
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/dist/workers/createFlamegraphRenderWorker.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/FlameGraph/FlameGraphComponent/index.tsx +32 -6
- package/src/workers/createFlamegraphRenderWorker.ts +18 -2
- package/src/workers/flamegraphRenderWorker.ts +75 -45
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/FlameGraph/FlameGraphComponent/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,UAAU,MAAM,cAAc,CAAC;AAStC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAsB,MAAM,uBAAuB,CAAC;AAMrE,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE5B,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IACvD,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAEpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,UAAU,CAAC,EAAE;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;QACtC,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/FlameGraph/FlameGraphComponent/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,UAAU,MAAM,cAAc,CAAC;AAStC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAsB,MAAM,uBAAuB,CAAC;AAMrE,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE5B,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IACvD,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAEpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,UAAU,CAAC,EAAE;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;QACtC,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAK,EAAE,eAAe,2CA2kBjE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z as t}from"zod";const e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const t in e)Object.freeze(e[t]);var r=Object.freeze(e);const n=Object.create(null);for(const t in r)Object.hasOwn(r,t)&&(n[r[t]]=t);const i={to:{},get:{}};function a(t,e,r){return Math.min(Math.max(e,t),r)}function o(t){const e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}i.get=function(t){let e,r;switch(t.slice(0,3).toLowerCase()){case"hsl":e=i.get.hsl(t),r="hsl";break;case"hwb":e=i.get.hwb(t),r="hwb";break;default:e=i.get.rgb(t),r="rgb"}return e?{model:r,value:e}:null},i.get.rgb=function(t){if(!t)return null;let e,n,i,o=[0,0,0,1];if(e=t.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(i=e[2],e=e[1],n=0;n<3;n++){const t=2*n;o[n]=Number.parseInt(e.slice(t,t+2),16)}i&&(o[3]=Number.parseInt(i,16)/255)}else if(e=t.match(/^#([a-f\d]{3,4})$/i)){for(e=e[1],i=e[3],n=0;n<3;n++)o[n]=Number.parseInt(e[n]+e[n],16);i&&(o[3]=Number.parseInt(i+i,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(n=0;n<3;n++)o[n]=Number.parseFloat(e[n+1]);e[4]&&(o[3]=e[5]?.01*Number.parseFloat(e[4]):Number.parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(e=t.toLowerCase().match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Object.hasOwn(r,e[1])?(o=r[e[1]].slice(),o[3]=1,o):null:null;for(n=0;n<3;n++)o[n]=Math.round(2.55*Number.parseFloat(e[n+1]));e[4]&&(o[3]=e[5]?.01*Number.parseFloat(e[4]):Number.parseFloat(e[4]))}for(n=0;n<3;n++)o[n]=a(o[n],0,255);return o[3]=a(o[3],0,1),o},i.get.hsl=function(t){if(!t)return null;const e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(e){const t=Number.parseFloat(e[4]);return[(Number.parseFloat(e[1])%360+360)%360,a(Number.parseFloat(e[2]),0,100),a(Number.parseFloat(e[3]),0,100),a(Number.isNaN(t)?1:t,0,1)]}return null},i.get.hwb=function(t){if(!t)return null;const e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(e){const t=Number.parseFloat(e[4]);return[(Number.parseFloat(e[1])%360+360)%360,a(Number.parseFloat(e[2]),0,100),a(Number.parseFloat(e[3]),0,100),a(Number.isNaN(t)?1:t,0,1)]}return null},i.to.hex=function(...t){return"#"+o(t[0])+o(t[1])+o(t[2])+(t[3]<1?o(Math.round(255*t[3])):"")},i.to.rgb=function(...t){return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},i.to.rgb.percent=function(...t){const e=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+r+"%, "+n+"%)":"rgba("+e+"%, "+r+"%, "+n+"%, "+t[3]+")"},i.to.hsl=function(...t){return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},i.to.hwb=function(...t){let e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},i.to.keyword=function(...t){return n[t.slice(0,3)]};const s={};for(const t of Object.keys(r))s[r[t]]=t;const l={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},u=(6/29)**3;function c(t){const e=t>.0031308?1.055*t**(1/2.4)-.055:12.92*t;return Math.min(Math.max(0,e),1)}function h(t){return t>.04045?((t+.055)/1.055)**2.4:t/12.92}for(const t of Object.keys(l)){if(!("channels"in l[t]))throw new Error("missing channels property: "+t);if(!("labels"in l[t]))throw new Error("missing channel labels property: "+t);if(l[t].labels.length!==l[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:e,labels:r}=l[t];delete l[t].channels,delete l[t].labels,Object.defineProperty(l[t],"channels",{value:e}),Object.defineProperty(l[t],"labels",{value:r})}function f(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}function g(t){const e=function(){const t={},e=Object.keys(l);for(let{length:r}=e,n=0;n<r;n++)t[e[n]]={distance:-1,parent:null};return t}(),r=[t];for(e[t].distance=0;r.length>0;){const t=r.pop(),n=Object.keys(l[t]);for(let{length:i}=n,a=0;a<i;a++){const i=n[a],o=e[i];-1===o.distance&&(o.distance=e[t].distance+1,o.parent=t,r.unshift(i))}}return e}function d(t,e){return function(r){return e(t(r))}}function m(t,e){const r=[e[t].parent,t];let n=l[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)r.unshift(e[i].parent),n=d(l[e[i].parent][i],n),i=e[i].parent;return n.conversion=r,n}function p(t){const e=g(t),r={},n=Object.keys(e);for(let{length:t}=n,i=0;i<t;i++){const t=n[i];null!==e[t].parent&&(r[t]=m(t,e))}return r}l.rgb.hsl=function(t){const e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(e,r,n),a=Math.max(e,r,n),o=a-i;let s,l;switch(a){case i:s=0;break;case e:s=(r-n)/o;break;case r:s=2+(n-e)/o;break;case n:s=4+(e-r)/o}s=Math.min(60*s,360),s<0&&(s+=360);const u=(i+a)/2;return l=a===i?0:u<=.5?o/(a+i):o/(2-a-i),[s,100*l,100*u]},l.rgb.hsv=function(t){let e,r,n,i,a;const o=t[0]/255,s=t[1]/255,l=t[2]/255,u=Math.max(o,s,l),c=u-Math.min(o,s,l),h=function(t){return(u-t)/6/c+.5};if(0===c)i=0,a=0;else{switch(a=c/u,e=h(o),r=h(s),n=h(l),u){case o:i=n-r;break;case s:i=1/3+e-n;break;case l:i=2/3+r-e}i<0?i+=1:i>1&&(i-=1)}return[360*i,100*a,100*u]},l.rgb.hwb=function(t){const e=t[0],r=t[1];let n=t[2];const i=l.rgb.hsl(t)[0],a=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[i,100*a,100*n]},l.rgb.oklab=function(t){const e=h(t[0]/255),r=h(t[1]/255),n=h(t[2]/255),i=Math.cbrt(.4122214708*e+.5363325363*r+.0514459929*n),a=Math.cbrt(.2119034982*e+.6806995451*r+.1073969566*n),o=Math.cbrt(.0883024619*e+.2817188376*r+.6299787005*n);return[100*(.2104542553*i+.793617785*a-.0040720468*o),100*(1.9779984951*i-2.428592205*a+.4505937099*o),100*(.0259040371*i+.7827717662*a-.808675766*o)]},l.rgb.cmyk=function(t){const e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(1-e,1-r,1-n);return[100*((1-e-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*i]},l.rgb.keyword=function(t){const e=s[t];if(e)return e;let n,i=Number.POSITIVE_INFINITY;for(const e of Object.keys(r)){const a=f(t,r[e]);a<i&&(i=a,n=e)}return n},l.keyword.rgb=function(t){return[...r[t]]},l.rgb.xyz=function(t){const e=h(t[0]/255),r=h(t[1]/255),n=h(t[2]/255);return[100*(.4124564*e+.3575761*r+.1804375*n),100*(.2126729*e+.7151522*r+.072175*n),100*(.0193339*e+.119192*r+.9503041*n)]},l.rgb.lab=function(t){const e=l.rgb.xyz(t);let r=e[0],n=e[1],i=e[2];r/=95.047,n/=100,i/=108.883,r=r>u?r**(1/3):7.787*r+16/116,n=n>u?n**(1/3):7.787*n+16/116,i=i>u?i**(1/3):7.787*i+16/116;return[116*n-16,500*(r-n),200*(n-i)]},l.hsl.rgb=function(t){const e=t[0]/360,r=t[1]/100,n=t[2]/100;let i,a;if(0===r)return a=255*n,[a,a,a];const o=n<.5?n*(1+r):n+r-n*r,s=2*n-o,l=[0,0,0];for(let t=0;t<3;t++)i=e+1/3*-(t-1),i<0&&i++,i>1&&i--,a=6*i<1?s+6*(o-s)*i:2*i<1?o:3*i<2?s+(o-s)*(2/3-i)*6:s,l[t]=255*a;return l},l.hsl.hsv=function(t){const e=t[0];let r=t[1]/100,n=t[2]/100,i=r;const a=Math.max(n,.01);n*=2,r*=n<=1?n:2-n,i*=a<=1?a:2-a;return[e,100*(0===n?2*i/(a+i):2*r/(n+r)),100*((n+r)/2)]},l.hsv.rgb=function(t){const e=t[0]/60,r=t[1]/100;let n=t[2]/100;const i=Math.floor(e)%6,a=e-Math.floor(e),o=255*n*(1-r),s=255*n*(1-r*a),l=255*n*(1-r*(1-a));switch(n*=255,i){case 0:return[n,l,o];case 1:return[s,n,o];case 2:return[o,n,l];case 3:return[o,s,n];case 4:return[l,o,n];case 5:return[n,o,s]}},l.hsv.hsl=function(t){const e=t[0],r=t[1]/100,n=t[2]/100,i=Math.max(n,.01);let a,o;o=(2-r)*n;const s=(2-r)*i;return a=r*i,a/=s<=1?s:2-s,a=a||0,o/=2,[e,100*a,100*o]},l.hwb.rgb=function(t){const e=t[0]/360;let r=t[1]/100,n=t[2]/100;const i=r+n;let a;i>1&&(r/=i,n/=i);const o=Math.floor(6*e),s=1-n;a=6*e-o,1&o&&(a=1-a);const l=r+a*(s-r);let u,c,h;switch(o){default:case 6:case 0:u=s,c=l,h=r;break;case 1:u=l,c=s,h=r;break;case 2:u=r,c=s,h=l;break;case 3:u=r,c=l,h=s;break;case 4:u=l,c=r,h=s;break;case 5:u=s,c=r,h=l}return[255*u,255*c,255*h]},l.cmyk.rgb=function(t){const e=t[0]/100,r=t[1]/100,n=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i))]},l.xyz.rgb=function(t){const e=t[0]/100,r=t[1]/100,n=t[2]/100;let i,a,o;return i=3.2404542*e+-1.5371385*r+-.4985314*n,a=-.969266*e+1.8760108*r+.041556*n,o=.0556434*e+-.2040259*r+1.0572252*n,i=c(i),a=c(a),o=c(o),[255*i,255*a,255*o]},l.xyz.lab=function(t){let e=t[0],r=t[1],n=t[2];e/=95.047,r/=100,n/=108.883,e=e>u?e**(1/3):7.787*e+16/116,r=r>u?r**(1/3):7.787*r+16/116,n=n>u?n**(1/3):7.787*n+16/116;return[116*r-16,500*(e-r),200*(r-n)]},l.xyz.oklab=function(t){const e=t[0]/100,r=t[1]/100,n=t[2]/100,i=Math.cbrt(.8189330101*e+.3618667424*r-.1288597137*n),a=Math.cbrt(.0329845436*e+.9293118715*r+.0361456387*n),o=Math.cbrt(.0482003018*e+.2643662691*r+.633851707*n);return[100*(.2104542553*i+.793617785*a-.0040720468*o),100*(1.9779984951*i-2.428592205*a+.4505937099*o),100*(.0259040371*i+.7827717662*a-.808675766*o)]},l.oklab.oklch=function(t){return l.lab.lch(t)},l.oklab.xyz=function(t){const e=t[0]/100,r=t[1]/100,n=t[2]/100,i=(.999999998*e+.396337792*r+.215803758*n)**3,a=(1.000000008*e-.105561342*r-.063854175*n)**3,o=(1.000000055*e-.089484182*r-1.291485538*n)**3;return[100*(1.227013851*i-.55779998*a+.281256149*o),100*(-.040580178*i+1.11225687*a-.071676679*o),100*(-.076381285*i-.421481978*a+1.58616322*o)]},l.oklab.rgb=function(t){const e=t[0]/100,r=t[1]/100,n=t[2]/100,i=(e+.3963377774*r+.2158037573*n)**3,a=(e-.1055613458*r-.0638541728*n)**3,o=(e-.0894841775*r-1.291485548*n)**3;return[255*c(4.0767416621*i-3.3077115913*a+.2309699292*o),255*c(-1.2684380046*i+2.6097574011*a-.3413193965*o),255*c(-.0041960863*i-.7034186147*a+1.707614701*o)]},l.oklch.oklab=function(t){return l.lch.lab(t)},l.lab.xyz=function(t){let e,r,n;r=(t[0]+16)/116,e=t[1]/500+r,n=r-t[2]/200;const i=r**3,a=e**3,o=n**3;return r=i>u?i:(r-16/116)/7.787,e=a>u?a:(e-16/116)/7.787,n=o>u?o:(n-16/116)/7.787,e*=95.047,r*=100,n*=108.883,[e,r,n]},l.lab.lch=function(t){const e=t[0],r=t[1],n=t[2];let i;i=360*Math.atan2(n,r)/2/Math.PI,i<0&&(i+=360);return[e,Math.sqrt(r*r+n*n),i]},l.lch.lab=function(t){const e=t[0],r=t[1],n=t[2]/360*2*Math.PI;return[e,r*Math.cos(n),r*Math.sin(n)]},l.rgb.ansi16=function(t,e=null){const[r,n,i]=t;let a=null===e?l.rgb.hsv(t)[2]:e;if(a=Math.round(a/50),0===a)return 30;let o=30+(Math.round(i/255)<<2|Math.round(n/255)<<1|Math.round(r/255));return 2===a&&(o+=60),o},l.hsv.ansi16=function(t){return l.rgb.ansi16(l.hsv.rgb(t),t[2])},l.rgb.ansi256=function(t){const e=t[0],r=t[1],n=t[2];if(e>>4==r>>4&&r>>4==n>>4)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;return 16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},l.ansi16.rgb=function(t){let e=(t=t[0])%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];const r=.5*(Math.trunc(t>50)+1);return[(1&e)*r*255,(e>>1&1)*r*255,(e>>2&1)*r*255]},l.ansi256.rgb=function(t){if((t=t[0])>=232){const e=10*(t-232)+8;return[e,e,e]}let e;t-=16;return[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},l.rgb.hex=function(t){const e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".slice(e.length)+e},l.hex.rgb=function(t){const e=t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!e)return[0,0,0];let r=e[0];3===e[0].length&&(r=[...r].map(t=>t+t).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},l.rgb.hcg=function(t){const e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.max(Math.max(e,r),n),a=Math.min(Math.min(e,r),n),o=i-a;let s;return s=o<=0?0:i===e?(r-n)/o%6:i===r?2+(n-e)/o:4+(e-r)/o,s/=6,s%=1,[360*s,100*o,100*(o<1?a/(1-o):0)]},l.hsl.hcg=function(t){const e=t[1]/100,r=t[2]/100,n=r<.5?2*e*r:2*e*(1-r);let i=0;return n<1&&(i=(r-.5*n)/(1-n)),[t[0],100*n,100*i]},l.hsv.hcg=function(t){const e=t[1]/100,r=t[2]/100,n=e*r;let i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],100*n,100*i]},l.hcg.rgb=function(t){const e=t[0]/360,r=t[1]/100,n=t[2]/100;if(0===r)return[255*n,255*n,255*n];const i=[0,0,0],a=e%1*6,o=a%1,s=1-o;let l=0;switch(Math.floor(a)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-r)*n,[255*(r*i[0]+l),255*(r*i[1]+l),255*(r*i[2]+l)]},l.hcg.hsv=function(t){const e=t[1]/100,r=e+t[2]/100*(1-e);let n=0;return r>0&&(n=e/r),[t[0],100*n,100*r]},l.hcg.hsl=function(t){const e=t[1]/100,r=t[2]/100*(1-e)+.5*e;let n=0;return r>0&&r<.5?n=e/(2*r):r>=.5&&r<1&&(n=e/(2*(1-r))),[t[0],100*n,100*r]},l.hcg.hwb=function(t){const e=t[1]/100,r=e+t[2]/100*(1-e);return[t[0],100*(r-e),100*(1-r)]},l.hwb.hcg=function(t){const e=t[1]/100,r=1-t[2]/100,n=r-e;let i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],100*n,100*i]},l.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},l.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},l.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},l.gray.hsl=function(t){return[0,0,t[0]]},l.gray.hsv=l.gray.hsl,l.gray.hwb=function(t){return[0,100,t[0]]},l.gray.cmyk=function(t){return[0,0,0,t[0]]},l.gray.lab=function(t){return[t[0],0,0]},l.gray.hex=function(t){const e=255&Math.round(t[0]/100*255),r=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".slice(r.length)+r},l.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};const b={},v=Object.keys(l);function y(t){const e=function(...e){const r=e[0];return null==r?r:(r.length>1&&(e=r),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}function w(t){const e=function(...e){const r=e[0];if(null==r)return r;r.length>1&&(e=r);const n=t(e);if("object"==typeof n)for(let{length:t}=n,e=0;e<t;e++)n[e]=Math.round(n[e]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}for(const t of v){b[t]={},Object.defineProperty(b[t],"channels",{value:l[t].channels}),Object.defineProperty(b[t],"labels",{value:l[t].labels});const e=p(t),r=Object.keys(e);for(const n of r){const r=e[n];b[t][n]=w(r),b[t][n].raw=y(r)}}const k=["keyword","gray","hex"],x={};for(const t of Object.keys(b))x[[...b[t].labels].sort().join("")]=t;const M={};function N(t,e){if(!(this instanceof N))return new N(t,e);if(e&&e in k&&(e=null),e&&!(e in b))throw new Error("Unknown model: "+e);let r,n;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof N)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if("string"==typeof t){const e=i.get(t);if(null===e)throw new Error("Unable to parse color from string: "+t);this.model=e.model,n=b[this.model].channels,this.color=e.value.slice(0,n),this.valpha="number"==typeof e.value[n]?e.value[n]:1}else if(t.length>0){this.model=e||"rgb",n=b[this.model].channels;const r=Array.prototype.slice.call(t,0,n);this.color=O(r,n),this.valpha="number"==typeof t[n]?t[n]:1}else if("number"==typeof t)this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;const e=Object.keys(t);"alpha"in t&&(e.splice(e.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);const n=e.sort().join("");if(!(n in x))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=x[n];const{labels:i}=b[this.model],a=[];for(r=0;r<i.length;r++)a.push(t[i[r]]);this.color=O(a)}if(M[this.model])for(n=b[this.model].channels,r=0;r<n;r++){const t=M[this.model][r];t&&(this.color[r]=t(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}N.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in i.to?this:this.rgb();e=e.round("number"==typeof t?t:1);const r=1===e.valpha?e.color:[...e.color,this.valpha];return i.to[e.model](...r)},percentString(t){const e=this.rgb().round("number"==typeof t?t:1),r=1===e.valpha?e.color:[...e.color,this.valpha];return i.to.rgb.percent(...r)},array(){return 1===this.valpha?[...this.color]:[...this.color,this.valpha]},object(){const t={},{channels:e}=b[this.model],{labels:r}=b[this.model];for(let n=0;n<e;n++)t[r[n]]=this.color[n];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray(){const t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject(){const t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new N([...this.color.map($(t)),this.valpha],this.model)},alpha(t){return void 0!==t?new N([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:j("rgb",0,T(255)),green:j("rgb",1,T(255)),blue:j("rgb",2,T(255)),hue:j(["hsl","hsv","hsl","hwb","hcg"],0,t=>(t%360+360)%360),saturationl:j("hsl",1,T(100)),lightness:j("hsl",2,T(100)),saturationv:j("hsv",1,T(100)),value:j("hsv",2,T(100)),chroma:j("hcg",1,T(100)),gray:j("hcg",2,T(100)),white:j("hwb",1,T(100)),wblack:j("hwb",2,T(100)),cyan:j("cmyk",0,T(100)),magenta:j("cmyk",1,T(100)),yellow:j("cmyk",2,T(100)),black:j("cmyk",3,T(100)),x:j("xyz",0,T(95.047)),y:j("xyz",1,T(100)),z:j("xyz",2,T(108.833)),l:j("lab",0,T(100)),a:j("lab",1),b:j("lab",2),keyword(t){return void 0!==t?new N(t):b[this.model].keyword(this.color)},hex(t){return void 0!==t?new N(t):i.to.hex(...this.rgb().round().color)},hexa(t){if(void 0!==t)return new N(t);const e=this.rgb().round().color;let r=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===r.length&&(r="0"+r),i.to.hex(...e)+r},rgbNumber(){const t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity(){const t=this.rgb().color,e=[];for(const[r,n]of t.entries()){const t=n/255;e[r]=t<=.04045?t/12.92:((t+.055)/1.055)**2.4}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){const e=this.luminosity(),r=t.luminosity();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},level(t){const e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){const t=this.rgb().color;return(2126*t[0]+7152*t[1]+722*t[2])/1e4<128},isLight(){return!this.isDark()},negate(){const t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){const e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){const e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){const e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){const e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){const e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){const e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){const t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return N.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){const e=this.hsl();let r=e.color[0];return r=(r+t)%360,r=r<0?360+r:r,e.color[0]=r,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);const r=t.rgb(),n=this.rgb(),i=void 0===e?.5:e,a=2*i-1,o=r.alpha()-n.alpha(),s=((a*o===-1?a:(a+o)/(1+a*o))+1)/2,l=1-s;return N.rgb(s*r.red()+l*n.red(),s*r.green()+l*n.green(),s*r.blue()+l*n.blue(),r.alpha()*i+n.alpha()*(1-i))}};for(const t of Object.keys(b)){if(k.includes(t))continue;const{channels:e}=b[t];N.prototype[t]=function(...e){return this.model===t?new N(this):e.length>0?new N(e,t):new N([...(r=b[this.model][t].raw(this.color),Array.isArray(r)?r:[r]),this.valpha],t);var r},N[t]=function(...r){let n=r[0];return"number"==typeof n&&(n=O(r,e)),new N(n,t)}}function $(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}function j(t,e,r){t=Array.isArray(t)?t:[t];for(const n of t)(M[n]||=[])[e]=r;return t=t[0],function(n){let i;return void 0!==n?(r&&(n=r(n)),i=this[t](),i.color[e]=n,i):(i=this[t]().color[e],r&&(i=r(i)),i)}}function T(t){return function(e){return Math.max(0,Math.min(t,e))}}function O(t,e){for(let r=0;r<e;r++)"number"!=typeof t[r]&&(t[r]=0);return t}const S=Symbol("BrandTag");const C=new class{constructor(t){this[S]=t}}("unit"),B=t=>null==t;function E(t,e){return void 0!==e?t(e):t}function P(t){if(function(t,e){return"object"==typeof t&&null!==t&&e in t}(t,"toString")&&"function"==typeof t.toString){const e=t.toString();return"string"==typeof e?e:JSON.stringify(t)}return JSON.stringify(t)}const R="Ok",J="Err";class I{constructor(t){this.repr=t}static ok(t){return B(t)?new I(["Ok",C]):new I(["Ok",t])}static err(t){return B(t)?new I(["Err",C]):new I(["Err",t])}get variant(){return this.repr[0]}get value(){if(this.repr[0]===J)throw new Error("Cannot get the value of Err");return this.repr[1]}get error(){if(this.repr[0]===R)throw new Error("Cannot get the error of Ok");return this.repr[1]}get isOk(){return this.repr[0]===R}get isErr(){return this.repr[0]===J}map(t){return function(t,e){const r=e=>e.isOk?z(t(e.value)):e;return E(r,e)}(t,this)}mapOr(t,e){return function(t,e,r){function n(e,r){return r.isOk?e(r.value):t}function i(t,e){return void 0!==e?n(t,e):e=>n(t,e)}return void 0===e?i:void 0===r?i(e):i(e,r)}(t,e,this)}mapOrElse(t,e){return A(t,e,this)}match(t){return function(t,e){const r=e=>A(t.Err,t.Ok,e);return E(r,e)}(t,this)}mapErr(t){return function(t,e){const r=e=>e.isOk?e:F(t(e.error));return E(r,e)}(t,this)}or(t){return e=t,E(t=>t.isOk?z(t.value):e,this);var e}orElse(t){return e=t,E(t=>t.isOk?z(t.value):e(t.error),this);var e}and(t){return e=t,E(t=>t.isOk?e:F(t.error),this);var e}andThen(t){return e=t,E(t=>t.isOk?e(t.value):F(t.error),this);var e}unwrapOr(t){return function(t,e){const r=e=>e.isOk?e.value:t;return E(r,e)}(t,this)}unwrapOrElse(t){return e=t,E(t=>t.isOk?t.value:e(t.error),this);var e}toMaybe(){return(t=this).isOk?Z.just(t.value):Z.nothing();var t}toString(){return L(this)}toJSON(){return q(this)}equals(t){return e=t,void 0!==(r=this)?r.match({Err:()=>e.isErr,Ok:t=>e.isOk&&e.value===t}):t=>t.match({Err:()=>e.isErr,Ok:t=>e.isOk&&e.value===t});var e,r}ap(t){return function(t,e){const r=e=>e.andThen(e=>t.map(t=>t(e)));return E(r,e)}(this,t)}}const z=I.ok,F=I.err;function A(t,e,r){function n(e,r){return r.isOk?e(r.value):t(r.error)}function i(t,e){return void 0!==e?n(t,e):e=>n(t,e)}return void 0===e?i:void 0===r?i(e):i(e,r)}const L=t=>{const e=t.match({Ok:P,Err:P});return`${t.variant.toString()}(${e})`},q=t=>t.isOk?{variant:t.variant,value:t.value}:{variant:t.variant,error:t.error};const D=I,W="Just",_="Nothing";let U;class H{constructor(t){if(B(t))return this.repr=[_],U||(U=this),U;this.repr=[W,t]}static of(t){return new H(t)}static just(t){if(B(t))throw new Error(`attempted to call "just" with ${t}`);return new H(t)}static nothing(t){return new H}get variant(){return this.repr[0]}get value(){if(this.repr[0]===_)throw new Error("Cannot get the value of `Nothing`");return this.repr[1]}get isJust(){return this.repr[0]===W}get isNothing(){return this.repr[0]===_}map(t){return function(t,e){const r=e=>e.isJust?X(t(e.value)):Q();return E(r,e)}(t,this)}mapOr(t,e){return function(t,e,r){function n(e,r){return r.isJust?e(r.value):t}function i(t,e){return void 0!==e?n(t,e):e=>n(t,e)}return void 0===e?i:void 0===r?i(e):i(e,r)}(t,e,this)}mapOrElse(t,e){return G(t,e,this)}match(t){return function(t,e){const r=e=>G(t.Nothing,t.Just,e);return E(r,e)}(t,this)}or(t){return function(t,e){const r=e=>e.isJust?e:t;return void 0!==e?r(e):r}(t,this)}orElse(t){return e=t,E(t=>t.isJust?t:e(),this);var e}and(t){return e=t,E(t=>t.isJust?e:Q(),this);var e}andThen(t){return V(t,this)}unwrapOr(t){return function(t,e){const r=e=>e.isJust?e.value:t;return E(r,e)}(t,this)}unwrapOrElse(t){return e=t,E(t=>t.isJust?t.value:e(),this);var e}toOkOrErr(t){return function(t,e){const r=e=>e.isJust?D.ok(e.value):D.err(t);return void 0!==e?r(e):r}(t,this)}toOkOrElseErr(t){return function(t,e){return E(e=>e.isJust?D.ok(e.value):D.err(t()),e)}(t,this)}toString(){return function(t){const e=t.map(t=>`(${P(t)})`).unwrapOr("");return`${t.variant}${e}`}(this)}toJSON(){return(t=this).isJust?{variant:t.variant,value:Y(t.value)?t.value.toJSON():t.value}:{variant:t.variant};var t}equals(t){return e=t,E(t=>t.match({Just:t=>e.isJust&&e.value===t,Nothing:()=>e.isNothing}),this);var e}ap(t){return function(t,e){const r=e=>e.andThen(e=>t.map(t=>t(e)));return E(r,e)}(this,t)}get(t){return function(t,e){return E(V(function(t,e){const r=e=>Z.of(e[t]);return E(r,e)}(t)),e)}(t,this)}}const X=H.just,Q=H.nothing;function G(t,e,r){function n(e,r){return r.isJust?e(r.value):t()}function i(t,e){return void 0!==e?n(t,e):e=>n(t,e)}return void 0===e?i:void 0===r?i(e):i(e,r)}function V(t,e){const r=e=>e.isJust?t(e.value):Q();return void 0!==e?r(e):r}function Y(t){return t instanceof Z}const Z=H,K=["dotnetspy","ebpfspy","gospy","phpspy","pyspy","rbspy","nodespy","javaspy","pyroscope-rs","scrape","tracing","unknown"],tt=t.preprocess(t=>t&&K.includes(t)?t:"unknown",t.enum(K).default("unknown")),et=["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions"],rt=t.preprocess(t=>"string"==typeof t&&et.includes(t)?t:"unknown",t.enum(["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions","unknown"])),nt=t.object({names:t.array(t.preprocess(t=>t||"unknown",t.string().min(1))),levels:t.array(t.array(t.number())),numTicks:t.number(),maxSelf:t.number()}),it=t.object({appName:t.string().optional(),name:t.string().optional(),startTime:t.number().optional(),endTime:t.number().optional(),query:t.string().optional(),maxNodes:t.number().optional(),format:t.enum(["single","double"]),sampleRate:t.number(),spyName:tt,units:rt});t.object({version:t.number().min(1).max(1).default(1),flamebearer:nt,metadata:it,leftTicks:t.number().optional(),rightTicks:t.number().optional()});const at={format:"single",jStep:4,jName:3,getBarOffset:(t,e)=>t[e],getBarTotal:(t,e)=>t[e+1],getBarTotalDiff:(t,e)=>0,getBarSelf:(t,e)=>t[e+2],getBarSelfDiff:(t,e)=>0,getBarName:(t,e)=>t[e+3]},ot={format:"double",jStep:7,jName:6,getBarOffset:(t,e)=>t[e]+t[e+3],getBarTotal:(t,e)=>t[e+4]+t[e+1],getBarTotalLeft:(t,e)=>t[e+1],getBarTotalRght:(t,e)=>t[e+4],getBarTotalDiff:(t,e)=>t[e+4]-t[e+1],getBarSelf:(t,e)=>t[e+5]+t[e+2],getBarSelfLeft:(t,e)=>t[e+2],getBarSelfRght:(t,e)=>t[e+5],getBarSelfDiff:(t,e)=>t[e+5]-t[e+2],getBarName:(t,e)=>t[e+6]};function st(t){switch(t){case"single":return at;case"double":return ot;default:throw new Error(`Unsupported type: '${t}'`)}}const lt=t.object({refType:t.string(),traceID:t.string(),spanID:t.string()}),ut=t.object({key:t.string(),type:t.string(),value:t.union([t.boolean(),t.number(),t.string()])}),ct=t.object({traceID:t.string(),spanID:t.string(),flags:t.string(),operationName:t.string(),references:t.array(lt),startTime:t.number(),duration:t.number(),tags:t.array(ut),logs:t.object({timestamp:t.number(),fields:t.array(ut)}),processID:t.string(),warnings:t.any()}),ht=t.object({serviceName:t.string(),tags:t.array(ut)});t.object({traceID:t.string(),spans:t.array(ct),processes:t.record(ht),warnings:t.any()});const ft=t.object({watermark:t.object({}).optional(),startTime:t.number(),samples:t.array(t.number()),durationDelta:t.number()});t.record(t.string(),ft);const gt=22,dt=21.5;function mt(t,e=!1){if(!t||!e)return t;const r=function(t){if(null==t)return null;if("number"==typeof t)return{value:t,unit:"",hasLessThan:!1,sign:""};let e=String(t).trim().replace(/\u2212/g,"-");if(!e)return null;let r=!1;e.startsWith("<")&&(r=!0,e=e.slice(1).trim());const n=e.match(/^([+\-]?)(\d*\.?\d+)\s*(.*)$/);if(!n)return null;const i=n[1]||"",a=n[2],o=(n[3]||"").trim(),s=parseFloat(a);return Number.isFinite(s)?{value:s,unit:o,hasLessThan:r,sign:i}:null}(t);if(!r)return t;const{unit:n}=r;let i=n;const a=n.toLowerCase();"ms"===a?i="毫秒":"μs"===a||"µs"===a||"us"===a?i="微秒":"second"===a||"seconds"===a?i="秒":"minute"===a||"minutes"===a||"min"===a||"mins"===a?i="分钟":"hour"===a||"hours"===a?i="小时":"day"===a||"days"===a?i="天":"month"===a||"months"===a?i="月":"year"!==a&&"years"!==a||(i="年");const o=String(t).match(/^([<\s]*)([+\-]?\d*\.?\d+)(.*)$/);if(!o)return t;return`${o[1]||""}${o[2]||""} ${i}`.trim()}function pt(t){return Math.round(1e4*t)/100}class bt{constructor(t,e,r){this.divider=1,this.enableSubsecondPrecision=!1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],this.units="",r&&(this.enableSubsecondPrecision=r,this.durations=[[1e3,"ms"],[1e3,"second"],...this.durations],this.suffix="μs",t*=1e6),this.units=e||"";for(let e=0;e<this.durations.length;e++){const r=this.durations[e];if(!r){console.warn("Could not calculate level");break}if(!(t>=r[0]))break;this.divider*=r[0],t/=r[0],this.suffix=r[1]}}format(t,e,r=!0){this.enableSubsecondPrecision&&(e/=1e6);const n=t/e/this.divider;let i=n.toFixed(2);return 0===n?i="0.00":(n>=0&&n<.01||n<=0&&n>-.01)&&(i="< 0.01"),r?`${i} ${this.units||`${this.suffix}${1===n||2===this.suffix.length?"":"s"}`}`:i}formatPrecise(t,e){this.enableSubsecondPrecision&&(e/=1e6);const r=t/e/this.divider;return`${parseFloat(r.toFixed(5))} ${this.units||`${this.suffix}${1===r||2===this.suffix.length?"":"s"}`}`}}class vt{constructor(t){this.divider=1,this.multiplier=1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],t/=1e9;for(let e=0;e<this.durations.length;e++){const r=this.durations[e];if(!r){console.warn("Could not calculate level");break}if(!(t>=r[0]))break;this.divider*=r[0],t/=r[0],this.suffix=r[1]}}format(t){const e=t/1e9/this.divider;let r=e.toFixed(2);return(e>=0&&e<.01||e<=0&&e>-.01)&&(r="< 0.01"),`${r} ${this.suffix}${1===e?"":"s"}`}formatPrecise(t){const e=t/1e9/this.divider;return`${parseFloat(e.toFixed(5))} ${this.suffix}${1===e?"":"s"}`}}class yt{constructor(t){this.divider=1,this.suffix="",this.objects=[[1e3,"K"],[1e3,"M"],[1e3,"G"],[1e3,"T"],[1e3,"P"]];for(let e=0;e<this.objects.length;e++){const r=this.objects[e];if(!r){console.warn("Could not calculate level");break}if(!(t>=r[0]))break;this.divider*=r[0],t/=r[0],this.suffix=r[1]}}format(t){const e=t/this.divider;let r=e.toFixed(2);return(e>=0&&e<.01||e<=0&&e>-.01)&&(r="< 0.01"),`${r} ${this.suffix}`}formatPrecise(t){const e=t/this.divider;return`${parseFloat(e.toFixed(5))} ${this.suffix}`}}class wt{constructor(t){this.divider=1,this.suffix="bytes",this.bytes=[[1024,"KB"],[1024,"MB"],[1024,"GB"],[1024,"TB"],[1024,"PB"]];for(let e=0;e<this.bytes.length;e++){const r=this.bytes[e];if(!r){console.warn("Could not calculate level");break}if(!(t>=r[0]))break;{this.divider*=r[0],t/=r[0];const e=r[1];e?this.suffix=e:(console.warn("Could not calculate suffix"),this.suffix="")}}}format(t){const e=t/this.divider;let r=e.toFixed(2);return(e>=0&&e<.01||e<=0&&e>-.01)&&(r="< 0.01"),`${r} ${this.suffix}`}formatPrecise(t){const e=t/this.divider;return`${parseFloat(e.toFixed(5))} ${this.suffix}`}}function kt({mode:t,charSize:e,rectWidth:r,fullText:n,shortText:i}){if("TAIL"===t){if(e*n.length<=r)return{mode:t,text:n,marginLeft:3};const a=e*i.length;return a<=r?{mode:t,text:i,marginLeft:3}:{mode:t,text:i,marginLeft:-(a-r+3)}}return{mode:t,text:n,marginLeft:3}}function xt(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Mt(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Nt(t){let e,r,n;function i(t,n,i=0,a=t.length){if(i<a){if(0!==e(n,n))return a;do{const e=i+a>>>1;r(t[e],n)<0?i=e+1:a=e}while(i<a)}return i}return 2!==t.length?(e=xt,r=(e,r)=>xt(t(e),r),n=(e,r)=>t(e)-r):(e=t===xt||t===Mt?t:$t,r=t,n=t),{left:i,center:function(t,e,r=0,a=t.length){const o=i(t,e,r,a-1);return o>r&&n(t[o-1],e)>-n(t[o],e)?o-1:o},right:function(t,n,i=0,a=t.length){if(i<a){if(0!==e(n,n))return a;do{const e=i+a>>>1;r(t[e],n)<=0?i=e+1:a=e}while(i<a)}return i}}}function $t(){return 0}const jt=Nt(xt).right;Nt(function(t){return null===t?NaN:+t}).center;const Tt=Math.sqrt(50),Ot=Math.sqrt(10),St=Math.sqrt(2);function Ct(t,e,r){const n=(e-t)/Math.max(0,r),i=Math.floor(Math.log10(n)),a=n/Math.pow(10,i),o=a>=Tt?10:a>=Ot?5:a>=St?2:1;let s,l,u;return i<0?(u=Math.pow(10,-i)/o,s=Math.round(t*u),l=Math.round(e*u),s/u<t&&++s,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*o,s=Math.round(t/u),l=Math.round(e/u),s*u<t&&++s,l*u>e&&--l),l<s&&.5<=r&&r<2?Ct(t,e,2*r):[s,l,u]}function Bt(t,e,r){return Ct(t=+t,e=+e,r=+r)[2]}function Et(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Pt(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function Rt(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function Jt(){}var It=.7,zt=1/It,Ft="\\s*([+-]?\\d+)\\s*",At="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qt=/^#([0-9a-f]{3,8})$/,Dt=new RegExp(`^rgb\\(${Ft},${Ft},${Ft}\\)$`),Wt=new RegExp(`^rgb\\(${Lt},${Lt},${Lt}\\)$`),_t=new RegExp(`^rgba\\(${Ft},${Ft},${Ft},${At}\\)$`),Ut=new RegExp(`^rgba\\(${Lt},${Lt},${Lt},${At}\\)$`),Ht=new RegExp(`^hsl\\(${At},${Lt},${Lt}\\)$`),Xt=new RegExp(`^hsla\\(${At},${Lt},${Lt},${At}\\)$`),Qt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Gt(){return this.rgb().formatHex()}function Vt(){return this.rgb().formatRgb()}function Yt(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=qt.exec(t))?(r=e[1].length,e=parseInt(e[1],16),6===r?Zt(e):3===r?new ee(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===r?Kt(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===r?Kt(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=Dt.exec(t))?new ee(e[1],e[2],e[3],1):(e=Wt.exec(t))?new ee(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=_t.exec(t))?Kt(e[1],e[2],e[3],e[4]):(e=Ut.exec(t))?Kt(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Ht.exec(t))?se(e[1],e[2]/100,e[3]/100,1):(e=Xt.exec(t))?se(e[1],e[2]/100,e[3]/100,e[4]):Qt.hasOwnProperty(t)?Zt(Qt[t]):"transparent"===t?new ee(NaN,NaN,NaN,0):null}function Zt(t){return new ee(t>>16&255,t>>8&255,255&t,1)}function Kt(t,e,r,n){return n<=0&&(t=e=r=NaN),new ee(t,e,r,n)}function te(t,e,r,n){return 1===arguments.length?((i=t)instanceof Jt||(i=Yt(i)),i?new ee((i=i.rgb()).r,i.g,i.b,i.opacity):new ee):new ee(t,e,r,null==n?1:n);var i}function ee(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function re(){return`#${oe(this.r)}${oe(this.g)}${oe(this.b)}`}function ne(){const t=ie(this.opacity);return`${1===t?"rgb(":"rgba("}${ae(this.r)}, ${ae(this.g)}, ${ae(this.b)}${1===t?")":`, ${t})`}`}function ie(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ae(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function oe(t){return((t=ae(t))<16?"0":"")+t.toString(16)}function se(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new ue(t,e,r,n)}function le(t){if(t instanceof ue)return new ue(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=Yt(t)),!t)return new ue;if(t instanceof ue)return t;var e=(t=t.rgb()).r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),a=Math.max(e,r,n),o=NaN,s=a-i,l=(a+i)/2;return s?(o=e===a?(r-n)/s+6*(r<n):r===a?(n-e)/s+2:(e-r)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new ue(o,s,l,t.opacity)}function ue(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function ce(t){return(t=(t||0)%360)<0?t+360:t}function he(t){return Math.max(0,Math.min(1,t||0))}function fe(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}Pt(Jt,Yt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Gt,formatHex:Gt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return le(this).formatHsl()},formatRgb:Vt,toString:Vt}),Pt(ee,te,Rt(Jt,{brighter(t){return t=null==t?zt:Math.pow(zt,t),new ee(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?It:Math.pow(It,t),new ee(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ee(ae(this.r),ae(this.g),ae(this.b),ie(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:re,formatHex:re,formatHex8:function(){return`#${oe(this.r)}${oe(this.g)}${oe(this.b)}${oe(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ne,toString:ne})),Pt(ue,function(t,e,r,n){return 1===arguments.length?le(t):new ue(t,e,r,null==n?1:n)},Rt(Jt,{brighter(t){return t=null==t?zt:Math.pow(zt,t),new ue(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?It:Math.pow(It,t),new ue(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new ee(fe(t>=240?t-240:t+120,i,n),fe(t,i,n),fe(t<120?t+240:t-120,i,n),this.opacity)},clamp(){return new ue(ce(this.h),he(this.s),he(this.l),ie(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ie(this.opacity);return`${1===t?"hsl(":"hsla("}${ce(this.h)}, ${100*he(this.s)}%, ${100*he(this.l)}%${1===t?")":`, ${t})`}`}}));var ge=t=>()=>t;function de(t){return 1===(t=+t)?me:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):ge(isNaN(e)?r:e)}}function me(t,e){var r=e-t;return r?function(t,e){return function(r){return t+r*e}}(t,r):ge(isNaN(t)?e:t)}var pe=function t(e){var r=de(e);function n(t,e){var n=r((t=te(t)).r,(e=te(e)).r),i=r(t.g,e.g),a=r(t.b,e.b),o=me(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return n.gamma=t,n}(1);function be(t,e){e||(e=[]);var r,n=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(r=0;r<n;++r)i[r]=t[r]*(1-a)+e[r]*a;return i}}function ve(t,e){var r,n=e?e.length:0,i=t?Math.min(n,t.length):0,a=new Array(i),o=new Array(n);for(r=0;r<i;++r)a[r]=$e(t[r],e[r]);for(;r<n;++r)o[r]=e[r];return function(t){for(r=0;r<i;++r)o[r]=a[r](t);return o}}function ye(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function we(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function ke(t,e){var r,n={},i={};for(r in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)r in t?n[r]=$e(t[r],e[r]):i[r]=e[r];return function(t){for(r in n)i[r]=n[r](t);return i}}var xe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Me=new RegExp(xe.source,"g");function Ne(t,e){var r,n,i,a=xe.lastIndex=Me.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=xe.exec(t))&&(n=Me.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:we(r,n)})),a=Me.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var r,n=0;n<e;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function $e(t,e){var r,n,i=typeof e;return null==e||"boolean"===i?ge(e):("number"===i?we:"string"===i?(r=Yt(e))?(e=r,pe):Ne:e instanceof Yt?pe:e instanceof Date?ye:(n=e,!ArrayBuffer.isView(n)||n instanceof DataView?Array.isArray(e)?ve:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?ke:we:be))(t,e)}function je(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}function Te(t){return+t}var Oe=[0,1];function Se(t){return t}function Ce(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:(r=isNaN(e)?NaN:.5,function(){return r});var r}function Be(t,e,r){var n=t[0],i=t[1],a=e[0],o=e[1];return i<n?(n=Ce(i,n),a=r(o,a)):(n=Ce(n,i),a=r(a,o)),function(t){return a(n(t))}}function Ee(t,e,r){var n=Math.min(t.length,e.length)-1,i=new Array(n),a=new Array(n),o=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<n;)i[o]=Ce(t[o],t[o+1]),a[o]=r(e[o],e[o+1]);return function(e){var r=jt(t,e,1,n)-1;return a[r](i[r](e))}}function Pe(){var t,e,r,n,i,a,o=Oe,s=Oe,l=$e,u=Se;function c(){var t,e,r,l=Math.min(o.length,s.length);return u!==Se&&(t=o[0],e=o[l-1],t>e&&(r=t,t=e,e=r),u=function(r){return Math.max(t,Math.min(e,r))}),n=l>2?Ee:Be,i=a=null,h}function h(e){return null==e||isNaN(e=+e)?r:(i||(i=n(o.map(t),s,l)))(t(u(e)))}return h.invert=function(r){return u(e((a||(a=n(s,o.map(t),we)))(r)))},h.domain=function(t){return arguments.length?(o=Array.from(t,Te),c()):o.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),c()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=je,c()},h.clamp=function(t){return arguments.length?(u=!!t||Se,c()):u!==Se},h.interpolate=function(t){return arguments.length?(l=t,c()):l},h.unknown=function(t){return arguments.length?(r=t,h):r},function(r,n){return t=r,e=n,c()}}function Re(t,e){if((r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function Je(t){return(t=Re(Math.abs(t)))?t[1]:NaN}var Ie,ze=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Fe(t){if(!(e=ze.exec(t)))throw new Error("invalid format: "+t);var e;return new Ae({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Ae(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Le(t,e){var r=Re(t,e);if(!r)return t+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}Fe.prototype=Ae.prototype,Ae.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var qe={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Le(100*t,e),r:Le,s:function(t,e){var r=Re(t,e);if(!r)return t+"";var n=r[0],i=r[1],a=i-(Ie=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=n.length;return a===o?n:a>o?n+new Array(a-o+1).join("0"):a>0?n.slice(0,a)+"."+n.slice(a):"0."+new Array(1-a).join("0")+Re(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function De(t){return t}var We,_e,Ue,He=Array.prototype.map,Xe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Qe(t){var e,r,n=void 0===t.grouping||void 0===t.thousands?De:(e=He.call(t.grouping,Number),r=t.thousands+"",function(t,n){for(var i=t.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>n&&(s=Math.max(1,n-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>n));)s=e[o=(o+1)%e.length];return a.reverse().join(r)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?De:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(He.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Fe(t)).fill,r=t.align,h=t.sign,f=t.symbol,g=t.zero,d=t.width,m=t.comma,p=t.precision,b=t.trim,v=t.type;"n"===v?(m=!0,v="g"):qe[v]||(void 0===p&&(p=12),b=!0,v="g"),(g||"0"===e&&"="===r)&&(g=!0,e="0",r="=");var y="$"===f?i:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",w="$"===f?a:/[%p]/.test(v)?l:"",k=qe[v],x=/[defgprs%]/.test(v);function M(t){var i,a,l,f=y,M=w;if("c"===v)M=k(t)+M,t="";else{var N=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:k(Math.abs(t),p),b&&(t=function(t){t:for(var e,r=t.length,n=1,i=-1;n<r;++n)switch(t[n]){case".":i=e=n;break;case"0":0===i&&(i=n),e=n;break;default:if(!+t[n])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),N&&0===+t&&"+"!==h&&(N=!1),f=(N?"("===h?h:u:"-"===h||"("===h?"":h)+f,M=("s"===v?Xe[8+Ie/3]:"")+M+(N&&"("===h?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(l=t.charCodeAt(i))||l>57){M=(46===l?o+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}m&&!g&&(t=n(t,1/0));var $=f.length+t.length+M.length,j=$<d?new Array(d-$+1).join(e):"";switch(m&&g&&(t=n(j+t,j.length?d-M.length:1/0),j=""),r){case"<":t=f+t+M+j;break;case"=":t=f+j+t+M;break;case"^":t=j.slice(0,$=j.length>>1)+f+t+M+j.slice($);break;default:t=j+f+t+M}return s(t)}return p=void 0===p?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p)),M.toString=function(){return t+""},M}return{format:h,formatPrefix:function(t,e){var r=h(((t=Fe(t)).type="f",t)),n=3*Math.max(-8,Math.min(8,Math.floor(Je(e)/3))),i=Math.pow(10,-n),a=Xe[8+n/3];return function(t){return r(i*t)+a}}}}function Ge(t,e,r,n){var i,a=function(t,e,r){r=+r;const n=(e=+e)<(t=+t),i=n?Bt(e,t,r):Bt(t,e,r);return(n?-1:1)*(i<0?1/-i:i)}(t,e,r);switch((n=Fe(null==n?",f":n)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=n.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Je(e)/3)))-Je(Math.abs(t)))}(a,o))||(n.precision=i),Ue(n,o);case"":case"e":case"g":case"p":case"r":null!=n.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Je(e)-Je(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(n.precision=i-("e"===n.type));break;case"f":case"%":null!=n.precision||isNaN(i=function(t){return Math.max(0,-Je(Math.abs(t)))}(a))||(n.precision=i-2*("%"===n.type))}return _e(n)}function Ve(t){var e=t.domain;return t.ticks=function(t){var r=e();return function(t,e,r){if(!((r=+r)>0))return[];if((t=+t)===(e=+e))return[t];const n=e<t,[i,a,o]=n?Ct(e,t,r):Ct(t,e,r);if(!(a>=i))return[];const s=a-i+1,l=new Array(s);if(n)if(o<0)for(let t=0;t<s;++t)l[t]=(a-t)/-o;else for(let t=0;t<s;++t)l[t]=(a-t)*o;else if(o<0)for(let t=0;t<s;++t)l[t]=(i+t)/-o;else for(let t=0;t<s;++t)l[t]=(i+t)*o;return l}(r[0],r[r.length-1],null==t?10:t)},t.tickFormat=function(t,r){var n=e();return Ge(n[0],n[n.length-1],null==t?10:t,r)},t.nice=function(r){null==r&&(r=10);var n,i,a=e(),o=0,s=a.length-1,l=a[o],u=a[s],c=10;for(u<l&&(i=l,l=u,u=i,i=o,o=s,s=i);c-- >0;){if((i=Bt(l,u,r))===n)return a[o]=l,a[s]=u,e(a);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}n=i}return t},t}function Ye(){var t=Pe()(Se,Se);return t.copy=function(){return e=t,Ye().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Et.apply(t,arguments),Ve(t)}function Ze(t,e){if(t===e)return 0;if(0===t)return 100;const r=(e-t)/t*100;return r>100?100:r<-100?-100:r}function Ke(t,e){return N.rgb(t,t,t).alpha(e)}function tr(t,e){if(0===e.length)return e;const r=function(t){switch(t){case"dotnetspy":return/^(?<packageName>.+)\.(.+)\.(.+)\(.*\)$/;case"ebpfspy":case"unknown":return/^(?<packageName>.+)$/;case"gospy":case"scrape":return/^(?<packageName>.*?\/.*?\.|.*?\.|.+)(?<functionName>.*)$/;case"phpspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.php+)(?<line_info>.*)$/;case"pyspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.py+)(?<line_info>.*)$/;case"rbspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.rb+)(?<line_info>.*)$/;case"nodespy":return/^(\.\/node_modules\/)?(?<packageName>[^/]*)(?<filename>.*\.?(jsx?|tsx?)?):(?<functionName>.*):(?<line_info>.*)$/;case"tracing":return/^(?<packageName>.+?):.*$/;case"javaspy":return/^(?<packageName>.+\/)(?<filename>.+\.)(?<functionName>.+)$/;case"pyroscope-rs":return/^(?<packageName>[^::]+)/}return/^(?<packageName>.+)$/}(t),n=e.match(r);return n&&n.groups?n.groups.packageName||"":e}function er(t,e){const r=function(t,e=0){let r,n,i,a,o,s,l,u;for(r=3&t.length,n=t.length-r,i=e,o=3432918353,s=461845907,u=0;u<n;)l=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,i^=l,i=i<<13|i>>>19,a=5*(65535&i)+((5*(i>>>16)&65535)<<16)&4294967295,i=27492+(65535&a)+(((a>>>16)+58964&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:l^=255&t.charCodeAt(u);default:l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,i^=l}return i^=t.length,i^=i>>>16,i=2246822507*(65535&i)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(65535&i)+((3266489909*(i>>>16)&65535)<<16)&4294967295,i^=i>>>16,i>>>0}(e,0)%t.colors.length,n=t.colors[r];return n||(console.warn("Could not calculate color. Defaulting to the first one"),t.colors[0])}function rr(t){const{goodColor:e,neutralColor:r,badColor:n}=t,i=Ye().domain([-100,0,100]).range([e.rgb().toString(),r.rgb().toString(),n.rgb().toString()]);return t=>N(i(t).toString())}We=Qe({thousands:",",grouping:[3],currency:["$",""]}),_e=We.format,Ue=We.formatPrefix,N.rgb(148,142,142),N.rgb(200,0,0),N.rgb(0,170,0),N("#48CE73");const nr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap;const sr={collapsedLevelsSingular:"total (1 level collapsed)",collapsedLevelsPlural:"total ({n} levels collapsed)",isZh:!1};function lr(t){var e,r,n,i,a,o,s,l;const u=performance.now(),c=!1!==t.renderRects,h=!1!==t.renderText,f=null!==(e=t.renderMode)&&void 0!==e?e:"normal",g=t.timeBudgetMs,{canvas:d,fitMode:m,units:p,tickToX:b,levels:v,palette:y}=t,{numTicks:w,sampleRate:k,pxPerTick:x}=t,{rangeMin:M,rangeMax:N}=t,{focusedNode:$,zoom:j}=t,T=t.messages||sr,O=t.skipCanvasResize?d.width:function(t){if("clientWidth"in t&&"number"==typeof t.clientWidth)return t.clientWidth;return t.width}(d);if(t.skipCanvasResize||(d.width=O),M>=N)throw new Error("'rangeMin' should be strictly smaller than 'rangeMax'");const{format:S}=t,C=st(S),B=d.getContext("2d");if(!B)throw new Error("Could not get ctx");const E=j.mapOrElse(()=>0,t=>t.i),P=function(t,e,r){switch(r){case"samples":return new bt(t/e);case"objects":case"goroutines":case"lock_samples":case"exceptions":return new yt(t);case"bytes":return new wt(t);case"lock_nanoseconds":return new vt(t);case"trace_samples":return new bt(t/e,"",!0);default:return console.warn(`Unsupported unit: '${r}'. Defaulting to ''`),new bt(t/e," ")}}(w,k,p),R=$.isJust,J=$.mapOrElse(()=>0,t=>t.i),I=R?dt:0,z=!!t.highlightQuery&&t.highlightQuery.length>0,F=gt*(v.length-J)+(R?dt:0);t.skipCanvasResize||(d.height=F);const A="number"==typeof t.devicePixelRatio?t.devicePixelRatio:"undefined"!=typeof devicePixelRatio?devicePixelRatio:1;!t.skipDprScale&&A>1&&(d.width*=A,d.height*=A,B.scale(A,A)),B.textBaseline="middle",B.font="400 11.5px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace";const L=B.measureText("a").width,{names:q}=t,D=function(t){const e=nr.get(t);if(e)return e;const r=new Map;return nr.set(t,r),r}(d),W=z?function(t,e){const r=ir.get(t);if(r){const t=r.get(e);if(t)return t}const n=e.toLowerCase(),i=new Uint8Array(t.length);for(let e=1;e<t.length;e+=1){const r=t[e];r&&r.toLowerCase().includes(n)&&(i[e]=1)}const a=null!=r?r:new Map;return a.set(e,i),ir.set(t,a),i}(q,t.highlightQuery):null,_="single"===t.format?function(t,e,r){const n=`${e}|${r.name}`,i=ar.get(t);if(i){const t=i.get(n);if(t)return t}const a=new Array(t.length);for(let n=0;n<t.length;n+=1){const i=tr(e,t[n]||"")||"";a[n]=er(r,i)}const o=null!=i?i:new Map;return o.set(n,a),ar.set(t,o),a}(q,t.spyName,y):null,U="double"===t.format?rr({name:y.name,goodColor:y.goodColor,neutralColor:y.neutralColor,badColor:y.badColor}):null,H=(t,e)=>{const r=t[e+C.jName];return!(!r||r<0||!W)&&1===W[r]},X=null!==(r=t.startI)&&void 0!==r?r:0,Q=null!==(n=t.startJ)&&void 0!==n?n:0;if(R&&"highlightOnly"!==f&&0===(null!==(i=t.levelStart)&&void 0!==i?i:0)&&0===X&&0===Q){const t=w*x;c&&(B.beginPath(),B.rect(0,0,w*x,dt),B.fillStyle=Ke(200,1).rgb().string(),B.fill());const e=$.mapOrElse(()=>"total",t=>function(t,e){return 1===t?e.collapsedLevelsSingular:e.collapsedLevelsPlural.replace("{n}",String(t))}(t.i-1,T)),r=kt({mode:m,charSize:L,rectWidth:t,fullText:e,shortText:e}),n=0,i=0,a=dt;if(h){B.beginPath(),B.rect(0,0,t,dt),B.save(),B.clip(),B.fillStyle="black";const e=Math.round(Math.max(n,0));B.fillText(r.text,e+r.marginLeft,i+a/2+1),B.restore()}}const G=Math.max(0,null!==(a=t.levelStart)&&void 0!==a?a:0),V=v.length-J,Y=Math.min(V,null!==(o=t.levelEnd)&&void 0!==o?o:V),Z=Math.max(G,null!==(s=t.startI)&&void 0!==s?s:G),K=Math.max(0,null!==(l=t.startJ)&&void 0!==l?l:0),{spyName:tt}=t,et=(e,r,n,i,a)=>{const o={level:e,j:r,i:n+$.mapOrElse(()=>0,t=>t.i),names:q,collapsed:i,selectedLevel:E,highlightModeOn:z,isHighlighted:a,spyName:tt,palette:y,colorByNameIndex:_,diffColorFn:U};switch(S){case"single":return function(t){const e=hr(t);if(e)return e;const r=st("single"),n=t.selectedLevel>t.i?.33:1;let i=t.level[t.j+r.jName];void 0===i&&(console.warn("Could nto find level",{l:t.j,jName:r.jName,level:t.level}),i=-1);if(t.colorByNameIndex&&i>=0&&t.colorByNameIndex[i])return t.colorByNameIndex[i].alpha(n);const a=t.names[i]||"",o=tr(t.spyName,a)||"";return er(t.palette,o).alpha(n)}({...o});case"double":return function(t){const e=hr(t);if(e)return e;const r=t.selectedLevel>t.i?.33:1,{leftRatio:n,rightRatio:i}=function(t,e,r,n){const i=ot;return r&&n?{leftRatio:i.getBarTotalLeft(t,e)/r,rightRatio:i.getBarTotalRght(t,e)/n}:(console.error("Properties 'rightTicks' and 'leftTicks' are required. Can't calculate ratio."),{leftRatio:0,rightRatio:0})}(t.level,t.j,t.leftTicks,t.rightTicks),a=pt(n),o=pt(i);if(t.diffColorFn)return t.diffColorFn(Ze(a,o)).alpha(r);return function(t,e,r){const n=Ze(e,r);return rr(t)(n)}(t.palette,a,o).alpha(r)}({...o,leftTicks:t.leftTicks,rightTicks:t.rightTicks});default:throw new Error(`Unsupported format: ${S}`)}};if("highlightOnly"===f&&z&&c){const t=function(t,e){const r=or.get(t);if(r)return r;const n=st(e),i=new Map;for(let e=0;e<t.length;e+=1){const r=t[e];for(let t=0;t<r.length;t+=n.jStep){const a=n.getBarName(r,t);if(void 0===a||a<0)continue;const o=i.get(a);o?o.push({i:e,j:t}):i.set(a,[{i:e,j:t}])}}return or.set(t,i),i}(v,S),e=[];for(let t=1;t<q.length;t+=1)W&&1===W[t]&&e.push(t);for(let r=0;r<e.length;r+=1){const n=e[r],i=t.get(n);if(i)for(let t=0;t<i.length;t+=1){const e=i[t],r=e.i-J;if(e.i<J||r<G||r>=Y)continue;const n=v[e.i],a=b(C.getBarOffset(n,e.j)),o=r*gt+I,s=dt,l=C.getBarTotal(n,e.j),u=l*x<=5,c=l*x-(u?0:.5);if(c<=0)continue;B.beginPath(),B.rect(a,o,c,s);const h=et(n,e.j,r,u,!0);B.fillStyle=h.string(),B.fill()}}return{done:!0,nextI:Y,nextJ:0}}for(let t=Z;t<Y;t+=1){const e=v[J+t];if(!e)throw new Error(`Could not find level: ${J+t}`);let r=t===Z?K:0;for(;r<e.length;r+=C.jStep){const n=C.getBarOffset(e,r),i=b(n),a=t*gt+I,o=dt,s=z&&H(e,r);let l=C.getBarTotal(e,r);const d=l*x<=5;if(d)for(;r<e.length-C.jStep&&n+l===C.getBarOffset(e,r+C.jStep)&&C.getBarTotal(e,r+C.jStep)*x<=5&&s===(z&&H(e,r+C.jStep));)r+=C.jStep,l+=C.getBarTotal(e,r);const p=l*x-(d?0:.5);if(B.beginPath(),B.rect(i,a,p,o),c){if("forceGrey"===f)B.fillStyle=Ke(200,.66).rgb().string();else{const n=et(e,r,t,d,s);B.fillStyle=n.string()}B.fill()}if(!h||d||"forceGrey"===f){if(g&&performance.now()-u>g)return{done:!1,nextI:t,nextJ:r+C.jStep};continue}if(p<20)continue;const v=ur(q,r,S,e),y=kt({mode:m,charSize:L,rectWidth:p,fullText:cr(v,l,k,P,T,D),shortText:v});B.save(),B.clip(),B.fillStyle="black";const w=Math.round(Math.max(i,0));if(B.fillText(y.text,w+y.marginLeft,a+o/2+1),B.restore(),g&&performance.now()-u>g)return{done:!1,nextI:t,nextJ:r+C.jStep}}if(g&&performance.now()-u>g)return{done:!1,nextI:t+1,nextJ:0}}return{done:!0,nextI:Y,nextJ:0}}function ur(t,e,r,n){let i=n[e+st(r).jName];void 0===i&&(i=-1);const a=t[i];return a||(console.warn("Could not find function name for",{j:e,format:r,level:n,names:t}),"")}function cr(t,e,r,n,i,a){let o=null==a?void 0:a.get(e);if(!o){const t=n.format(e,r);o=mt(t,!!i.isZh)||t,null==a||a.set(e,o)}return`${t} (${o})`}function hr({collapsed:t,highlightModeOn:e,isHighlighted:r}){return t||e&&!r?Ke(200,.66):null}class fr{constructor(t,e,r,n,i,a,o,s){if(this.flamebearer=t,this.canvas=e,this.focusedNode=r,this.fitMode=n,this.highlightQuery=i,this.zoom=a,this.palette=o,this.messages=s,this.cachedRange=null,this.cachedPxPerTick=null,this.tickToX=t=>{var e;const r=this.cachedRange?this.cachedRange.rangeMin:this.getRange().rangeMin,n=null!==(e=this.cachedPxPerTick)&&void 0!==e?e:this.pxPerTick();return(t-this.flamebearer.numTicks*r)*n},this.xyToBarPosition=t=>{const{ff:e}=this,{i:r,j:n}=this.xyToBarIndex(t.x,t.y),i=this.focusedNode.mapOrElse(()=>0,t=>t.i<0?0:t.i-1),a=this.flamebearer.levels[r];if(!a)throw new Error(`Could not find level: '${r}'`);const o=Math.max(this.tickToX(e.getBarOffset(a,n)),0);return{x:o,y:Math.max((r-i)*gt,0),width:Math.min(this.tickToX(e.getBarOffset(a,n)+e.getBarTotal(a,n))-o,this.getCanvasWidth())}},this.xyToBarData=t=>{const{i:e,j:r}=this.xyToBarIndex(t.x,t.y),n=this.flamebearer.levels[e];if(!n)throw new Error(`Could not find level: '${e}'`);switch(this.flamebearer.format){case"single":{const t=at;return{format:"single",name:this.flamebearer.names[t.getBarName(n,r)],self:t.getBarSelf(n,r),offset:t.getBarOffset(n,r),total:t.getBarTotal(n,r)}}case"double":{const t=ot;return{format:"double",barTotal:t.getBarTotal(n,r),totalLeft:t.getBarTotalLeft(n,r),totalRight:t.getBarTotalRght(n,r),totalDiff:t.getBarTotalDiff(n,r),name:this.flamebearer.names[t.getBarName(n,r)]}}default:throw new Error("Unsupported type")}},this.isWithinBounds=(t,e)=>{if(t<0||t>this.getCanvasWidth())return!1;try{const{i:r,j:n}=this.xyToBarIndex(t,e);if(-1===n||-1===r)return!1}catch(t){return!1}return!0},this.zoom=a,this.focusedNode=r,this.flamebearer=t,this.canvas=e,this.highlightQuery=i,this.ff=st(t.format),this.palette=o,this.messages=s,r.isJust&&a.isJust&&a.value.i<r.value.i)throw new Error("Zoom i level should be bigger than Focus")}render(t){var e;const{rangeMin:r,rangeMax:n,pxPerTick:i}=this.updateCachedMetrics(),a=null!==(e=null==t?void 0:t.highlightQueryOverride)&&void 0!==e?e:this.highlightQuery,o={canvas:this.canvas,format:this.flamebearer.format,numTicks:this.flamebearer.numTicks,sampleRate:this.flamebearer.sampleRate,names:this.flamebearer.names,levels:this.flamebearer.levels,spyName:this.flamebearer.spyName,units:this.flamebearer.units,maxSelf:this.flamebearer.maxSelf,rangeMin:r,rangeMax:n,fitMode:this.fitMode,highlightQuery:a,zoom:this.zoom,focusedNode:this.focusedNode,pxPerTick:i,tickToX:t=>(t-this.flamebearer.numTicks*r)*i,palette:this.palette,messages:this.messages,renderRects:null==t?void 0:t.renderRects,renderText:null==t?void 0:t.renderText,renderMode:null==t?void 0:t.renderMode,levelStart:null==t?void 0:t.levelStart,levelEnd:null==t?void 0:t.levelEnd,startI:null==t?void 0:t.startI,startJ:null==t?void 0:t.startJ,timeBudgetMs:null==t?void 0:t.timeBudgetMs,skipCanvasResize:null==t?void 0:t.skipCanvasResize,skipDprScale:null==t?void 0:t.skipDprScale,devicePixelRatio:null==t?void 0:t.devicePixelRatio},{format:s}=this.flamebearer;switch(s){case"single":return lr({...o,format:"single"});case"double":return lr({...o,leftTicks:this.flamebearer.leftTicks,rightTicks:this.flamebearer.rightTicks});default:throw new Error(`Invalid format: '${s}'`)}}pxPerTick(){if(null!==this.cachedPxPerTick)return this.cachedPxPerTick;const{rangeMin:t,rangeMax:e}=this.getRange(),r=this.getCanvasWidth()/this.flamebearer.numTicks/(e-t);return this.cachedRange={rangeMin:t,rangeMax:e},this.cachedPxPerTick=r,r}updateCachedMetrics(){const{rangeMin:t,rangeMax:e}=this.getRange(),r=this.getCanvasWidth()/this.flamebearer.numTicks/(e-t);return this.cachedRange={rangeMin:t,rangeMax:e},this.cachedPxPerTick=r,{rangeMin:t,rangeMax:e,pxPerTick:r}}getRange(){const{ff:t}=this,e=e=>{const r=this.flamebearer.levels[e.i];if(!r)throw new Error(`Could not find level: '${e.i}'`);return{rangeMin:t.getBarOffset(r,e.j)/this.flamebearer.numTicks,rangeMax:(t.getBarOffset(r,e.j)+t.getBarTotal(r,e.j))/this.flamebearer.numTicks}},r=e=>{const r=this.flamebearer.levels[e.i];if(!r)throw new Error(`Could not find level: '${e.i}'`);return{rangeMin:t.getBarOffset(r,e.j)/this.flamebearer.numTicks,rangeMax:(t.getBarOffset(r,e.j)+t.getBarTotal(r,e.j))/this.flamebearer.numTicks}},{zoom:n,focusedNode:i}=this;return n.match({Just:t=>i.match({Just:n=>{const i=r(n),a=e(t);return i.rangeMax-i.rangeMin<a.rangeMax-a.rangeMin?(console.warn("Focus is smaller than range, this shouldnt happen. Verify that the zoom is always bigger than the focus."),r(n)):e(t)},Nothing:()=>e(t)}),Nothing:()=>i.match({Just:t=>r(t),Nothing:()=>({rangeMin:0,rangeMax:1})})})}getCanvasWidth(){return"clientWidth"in this.canvas&&"number"==typeof this.canvas.clientWidth?this.canvas.clientWidth:this.canvas.width}isFocused(){return this.focusedNode.isJust}binarySearchLevel(t,e){const{ff:r}=this;let n=0,i=e.length-r.jStep;for(;n<=i;){const a=r.jStep*(n/r.jStep+i/r.jStep>>1),o=this.tickToX(r.getBarOffset(e,a)),s=this.tickToX(r.getBarOffset(e,a)+r.getBarTotal(e,a));if(o<=t&&s>=t)return s-o>5?a:-1;o>t?i=a-r.jStep:n=a+r.jStep}return-1}xyToBarIndex(t,e){if(t<0||e<0)throw new Error(`x and y must be bigger than 0. x = ${t}, y = ${e}`);if(this.isFocused()&&e<=dt)return{i:0,j:0};const r=this.isFocused()?e-dt:e,n=this.focusedNode.mapOrElse(()=>0,t=>t.i<=0?0:t.i),i=this.zoom.match({Just:()=>this.focusedNode.match({Just:()=>n,Nothing:()=>0}),Nothing:()=>this.focusedNode.match({Just:()=>n,Nothing:()=>0})}),a=Math.floor(r/gt)+i;if(a>=0&&a<this.flamebearer.levels.length){const e=this.flamebearer.levels[a];if(!e)throw new Error(`Could not find level: '${a}'`);return{i:a,j:this.binarySearchLevel(t,e)}}return{i:0,j:0}}parseXY(t,e){const r={x:t,y:e};return this.isWithinBounds(t,e)?Z.of(r):Z.nothing()}xyToBar(t,e){return this.parseXY(t,e).map(r=>{const{i:n,j:i}=this.xyToBarIndex(t,e);return{i:n,j:i,...this.xyToBarPosition(r),...this.xyToBarData(r)}})}}const gr={rectCanvas:null,textCanvas:null,renderState:{rect:{token:0,running:!1,nextI:0,nextJ:0,firstChunk:!0,payload:null,flamegraph:null},text:{token:0,running:!1,nextI:0,nextJ:0,firstChunk:!0,payload:null,flamegraph:null}}},dr=t=>t?Z.just(t):Z.nothing(),mr=(t,e)=>{const r=gr.renderState[t],n=r.payload;if(!n||r.token!==e)return;const i="rect"===t?gr.rectCanvas:gr.textCanvas;if(!i)return void(r.running=!1);r.flamegraph||(r.flamegraph=new fr(n.flamebearer,i,dr(n.focusedNode),n.fitMode,n.highlightQuery,dr(n.zoom),(t=>({name:t.name,goodColor:N.rgb(...t.goodColor),neutralColor:N.rgb(...t.neutralColor),badColor:N.rgb(...t.badColor),colors:t.colors.map(t=>N.rgb(...t))}))(n.palette),n.messages));const a=r.flamegraph.render({renderRects:n.renderRects,renderText:n.renderText,timeBudgetMs:"rect"===t?12:8,startI:r.nextI,startJ:r.nextJ,skipCanvasResize:!r.firstChunk,skipDprScale:!r.firstChunk,devicePixelRatio:n.devicePixelRatio});if(r.firstChunk=!1,!a.done)return r.nextI=a.nextI,r.nextJ=a.nextJ,void setTimeout(()=>mr(t,e),0);r.running=!1,r.nextI=0,r.nextJ=0,r.firstChunk=!0,r.flamegraph=null};self.onmessage=t=>{const e=t.data;e&&e.type&&("init"!==e.type?"render"===e.type&&(t=>{const e="rect"===t.kind?gr.rectCanvas:gr.textCanvas;if(!e)return;t.width>0&&(e.width=t.width);const r=gr.renderState[t.kind];r.token+=1,r.running=!0,r.nextI=0,r.nextJ=0,r.firstChunk=!0,r.payload=t,r.flamegraph=null;const n=r.token;setTimeout(()=>mr(t.kind,n),0)})(e.payload):"rect"===e.payload.kind?gr.rectCanvas=e.payload.canvas:gr.textCanvas=e.payload.canvas)};
|
|
1
|
+
const e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const t in e)Object.freeze(e[t]);var t=Object.freeze(e);const n=Object.create(null);for(const e in t)Object.hasOwn(t,e)&&(n[t[e]]=e);const r={to:{},get:{}};function a(e,t,n){return Math.min(Math.max(t,e),n)}function s(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}r.get=function(e){let t,n;switch(e.slice(0,3).toLowerCase()){case"hsl":t=r.get.hsl(e),n="hsl";break;case"hwb":t=r.get.hwb(e),n="hwb";break;default:t=r.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},r.get.rgb=function(e){if(!e)return null;let n,r,s,i=[0,0,0,1];if(n=e.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(s=n[2],n=n[1],r=0;r<3;r++){const e=2*r;i[r]=Number.parseInt(n.slice(e,e+2),16)}s&&(i[3]=Number.parseInt(s,16)/255)}else if(n=e.match(/^#([a-f\d]{3,4})$/i)){for(n=n[1],s=n[3],r=0;r<3;r++)i[r]=Number.parseInt(n[r]+n[r],16);s&&(i[3]=Number.parseInt(s+s,16)/255)}else if(n=e.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(r=0;r<3;r++)i[r]=Number.parseFloat(n[r+1]);n[4]&&(i[3]=n[5]?.01*Number.parseFloat(n[4]):Number.parseFloat(n[4]))}else{if(!(n=e.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(n=e.toLowerCase().match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:Object.hasOwn(t,n[1])?(i=t[n[1]].slice(),i[3]=1,i):null:null;for(r=0;r<3;r++)i[r]=Math.round(2.55*Number.parseFloat(n[r+1]));n[4]&&(i[3]=n[5]?.01*Number.parseFloat(n[4]):Number.parseFloat(n[4]))}for(r=0;r<3;r++)i[r]=a(i[r],0,255);return i[3]=a(i[3],0,1),i},r.get.hsl=function(e){if(!e)return null;const t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,a(Number.parseFloat(t[2]),0,100),a(Number.parseFloat(t[3]),0,100),a(Number.isNaN(e)?1:e,0,1)]}return null},r.get.hwb=function(e){if(!e)return null;const t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,a(Number.parseFloat(t[2]),0,100),a(Number.parseFloat(t[3]),0,100),a(Number.isNaN(e)?1:e,0,1)]}return null},r.to.hex=function(...e){return"#"+s(e[0])+s(e[1])+s(e[2])+(e[3]<1?s(Math.round(255*e[3])):"")},r.to.rgb=function(...e){return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},r.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},r.to.hsl=function(...e){return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},r.to.hwb=function(...e){let t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},r.to.keyword=function(...e){return n[e.slice(0,3)]};const i={};for(const e of Object.keys(t))i[t[e]]=e;const o={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},u=(6/29)**3;function l(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function c(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(o)){if(!("channels"in o[e]))throw new Error("missing channels property: "+e);if(!("labels"in o[e]))throw new Error("missing channel labels property: "+e);if(o[e].labels.length!==o[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=o[e];delete o[e].channels,delete o[e].labels,Object.defineProperty(o[e],"channels",{value:t}),Object.defineProperty(o[e],"labels",{value:n})}function d(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function h(e){const t=function(){const e={},t=Object.keys(o);for(let{length:n}=t,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}(),n=[e];for(t[e].distance=0;n.length>0;){const e=n.pop(),r=Object.keys(o[e]);for(let{length:a}=r,s=0;s<a;s++){const a=r[s],i=t[a];-1===i.distance&&(i.distance=t[e].distance+1,i.parent=e,n.unshift(a))}}return t}function f(e,t){return function(n){return t(e(n))}}function p(e,t){const n=[t[e].parent,e];let r=o[t[e].parent][e],a=t[e].parent;for(;t[a].parent;)n.unshift(t[a].parent),r=f(o[t[a].parent][a],r),a=t[a].parent;return r.conversion=n,r}function m(e){const t=h(e),n={},r=Object.keys(t);for(let{length:e}=r,a=0;a<e;a++){const e=r[a];null!==t[e].parent&&(n[e]=p(e,t))}return n}o.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,a=Math.min(t,n,r),s=Math.max(t,n,r),i=s-a;let o,u;switch(s){case a:o=0;break;case t:o=(n-r)/i;break;case n:o=2+(r-t)/i;break;case r:o=4+(t-n)/i}o=Math.min(60*o,360),o<0&&(o+=360);const l=(a+s)/2;return u=s===a?0:l<=.5?i/(s+a):i/(2-s-a),[o,100*u,100*l]},o.rgb.hsv=function(e){let t,n,r,a,s;const i=e[0]/255,o=e[1]/255,u=e[2]/255,l=Math.max(i,o,u),c=l-Math.min(i,o,u),d=function(e){return(l-e)/6/c+.5};if(0===c)a=0,s=0;else{switch(s=c/l,t=d(i),n=d(o),r=d(u),l){case i:a=r-n;break;case o:a=1/3+t-r;break;case u:a=2/3+n-t}a<0?a+=1:a>1&&(a-=1)}return[360*a,100*s,100*l]},o.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const a=o.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[a,100*s,100*r]},o.rgb.oklab=function(e){const t=c(e[0]/255),n=c(e[1]/255),r=c(e[2]/255),a=Math.cbrt(.4122214708*t+.5363325363*n+.0514459929*r),s=Math.cbrt(.2119034982*t+.6806995451*n+.1073969566*r),i=Math.cbrt(.0883024619*t+.2817188376*n+.6299787005*r);return[100*(.2104542553*a+.793617785*s-.0040720468*i),100*(1.9779984951*a-2.428592205*s+.4505937099*i),100*(.0259040371*a+.7827717662*s-.808675766*i)]},o.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,a=Math.min(1-t,1-n,1-r);return[100*((1-t-a)/(1-a)||0),100*((1-n-a)/(1-a)||0),100*((1-r-a)/(1-a)||0),100*a]},o.rgb.keyword=function(e){const n=i[e];if(n)return n;let r,a=Number.POSITIVE_INFINITY;for(const n of Object.keys(t)){const s=d(e,t[n]);s<a&&(a=s,r=n)}return r},o.keyword.rgb=function(e){return[...t[e]]},o.rgb.xyz=function(e){const t=c(e[0]/255),n=c(e[1]/255),r=c(e[2]/255);return[100*(.4124564*t+.3575761*n+.1804375*r),100*(.2126729*t+.7151522*n+.072175*r),100*(.0193339*t+.119192*n+.9503041*r)]},o.rgb.lab=function(e){const t=o.rgb.xyz(e);let n=t[0],r=t[1],a=t[2];n/=95.047,r/=100,a/=108.883,n=n>u?n**(1/3):7.787*n+16/116,r=r>u?r**(1/3):7.787*r+16/116,a=a>u?a**(1/3):7.787*a+16/116;return[116*r-16,500*(n-r),200*(r-a)]},o.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let a,s;if(0===n)return s=255*r,[s,s,s];const i=r<.5?r*(1+n):r+n-r*n,o=2*r-i,u=[0,0,0];for(let e=0;e<3;e++)a=t+1/3*-(e-1),a<0&&a++,a>1&&a--,s=6*a<1?o+6*(i-o)*a:2*a<1?i:3*a<2?o+(i-o)*(2/3-a)*6:o,u[e]=255*s;return u},o.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,a=n;const s=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,a*=s<=1?s:2-s;return[t,100*(0===r?2*a/(s+a):2*n/(r+n)),100*((r+n)/2)]},o.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const a=Math.floor(t)%6,s=t-Math.floor(t),i=255*r*(1-n),o=255*r*(1-n*s),u=255*r*(1-n*(1-s));switch(r*=255,a){case 0:return[r,u,i];case 1:return[o,r,i];case 2:return[i,r,u];case 3:return[i,o,r];case 4:return[u,i,r];case 5:return[r,i,o]}},o.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,a=Math.max(r,.01);let s,i;i=(2-n)*r;const o=(2-n)*a;return s=n*a,s/=o<=1?o:2-o,s=s||0,i/=2,[t,100*s,100*i]},o.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const a=n+r;let s;a>1&&(n/=a,r/=a);const i=Math.floor(6*t),o=1-r;s=6*t-i,1&i&&(s=1-s);const u=n+s*(o-n);let l,c,d;switch(i){default:case 6:case 0:l=o,c=u,d=n;break;case 1:l=u,c=o,d=n;break;case 2:l=n,c=o,d=u;break;case 3:l=n,c=u,d=o;break;case 4:l=u,c=n,d=o;break;case 5:l=o,c=n,d=u}return[255*l,255*c,255*d]},o.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,a=e[3]/100;return[255*(1-Math.min(1,t*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},o.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let a,s,i;return a=3.2404542*t+-1.5371385*n+-.4985314*r,s=-.969266*t+1.8760108*n+.041556*r,i=.0556434*t+-.2040259*n+1.0572252*r,a=l(a),s=l(s),i=l(i),[255*a,255*s,255*i]},o.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>u?t**(1/3):7.787*t+16/116,n=n>u?n**(1/3):7.787*n+16/116,r=r>u?r**(1/3):7.787*r+16/116;return[116*n-16,500*(t-n),200*(n-r)]},o.xyz.oklab=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,a=Math.cbrt(.8189330101*t+.3618667424*n-.1288597137*r),s=Math.cbrt(.0329845436*t+.9293118715*n+.0361456387*r),i=Math.cbrt(.0482003018*t+.2643662691*n+.633851707*r);return[100*(.2104542553*a+.793617785*s-.0040720468*i),100*(1.9779984951*a-2.428592205*s+.4505937099*i),100*(.0259040371*a+.7827717662*s-.808675766*i)]},o.oklab.oklch=function(e){return o.lab.lch(e)},o.oklab.xyz=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,a=(.999999998*t+.396337792*n+.215803758*r)**3,s=(1.000000008*t-.105561342*n-.063854175*r)**3,i=(1.000000055*t-.089484182*n-1.291485538*r)**3;return[100*(1.227013851*a-.55779998*s+.281256149*i),100*(-.040580178*a+1.11225687*s-.071676679*i),100*(-.076381285*a-.421481978*s+1.58616322*i)]},o.oklab.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,a=(t+.3963377774*n+.2158037573*r)**3,s=(t-.1055613458*n-.0638541728*r)**3,i=(t-.0894841775*n-1.291485548*r)**3;return[255*l(4.0767416621*a-3.3077115913*s+.2309699292*i),255*l(-1.2684380046*a+2.6097574011*s-.3413193965*i),255*l(-.0041960863*a-.7034186147*s+1.707614701*i)]},o.oklch.oklab=function(e){return o.lch.lab(e)},o.lab.xyz=function(e){let t,n,r;n=(e[0]+16)/116,t=e[1]/500+n,r=n-e[2]/200;const a=n**3,s=t**3,i=r**3;return n=a>u?a:(n-16/116)/7.787,t=s>u?s:(t-16/116)/7.787,r=i>u?i:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},o.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let a;a=360*Math.atan2(r,n)/2/Math.PI,a<0&&(a+=360);return[t,Math.sqrt(n*n+r*r),a]},o.lch.lab=function(e){const t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},o.rgb.ansi16=function(e,t=null){const[n,r,a]=e;let s=null===t?o.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let i=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===s&&(i+=60),i},o.hsv.ansi16=function(e){return o.rgb.ansi16(o.hsv.rgb(e),e[2])},o.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];if(t>>4==n>>4&&n>>4==r>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},o.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=.5*(Math.trunc(e>50)+1);return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},o.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},o.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},o.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let n=t[0];3===t[0].length&&(n=[...n].map(e=>e+e).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},o.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,a=Math.max(Math.max(t,n),r),s=Math.min(Math.min(t,n),r),i=a-s;let o;return o=i<=0?0:a===t?(n-r)/i%6:a===n?2+(r-t)/i:4+(t-n)/i,o/=6,o%=1,[360*o,100*i,100*(i<1?s/(1-i):0)]},o.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let a=0;return r<1&&(a=(n-.5*r)/(1-r)),[e[0],100*r,100*a]},o.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let a=0;return r<1&&(a=(n-r)/(1-r)),[e[0],100*r,100*a]},o.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];const a=[0,0,0],s=t%1*6,i=s%1,o=1-i;let u=0;switch(Math.floor(s)){case 0:a[0]=1,a[1]=i,a[2]=0;break;case 1:a[0]=o,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=i;break;case 3:a[0]=0,a[1]=o,a[2]=1;break;case 4:a[0]=i,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=o}return u=(1-n)*r,[255*(n*a[0]+u),255*(n*a[1]+u),255*(n*a[2]+u)]},o.hcg.hsv=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);let r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},o.hcg.hsl=function(e){const t=e[1]/100,n=e[2]/100*(1-t)+.5*t;let r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},o.hcg.hwb=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},o.hwb.hcg=function(e){const t=e[1]/100,n=1-e[2]/100,r=n-t;let a=0;return r<1&&(a=(n-r)/(1-r)),[e[0],100*r,100*a]},o.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},o.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},o.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},o.gray.hsl=function(e){return[0,0,e[0]]},o.gray.hsv=o.gray.hsl,o.gray.hwb=function(e){return[0,100,e[0]]},o.gray.cmyk=function(e){return[0,0,0,e[0]]},o.gray.lab=function(e){return[e[0],0,0]},o.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(n.length)+n},o.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const g={},v=Object.keys(o);function y(e){const t=function(...t){const n=t[0];return null==n?n:(n.length>1&&(t=n),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function b(e){const t=function(...t){const n=t[0];if(null==n)return n;n.length>1&&(t=n);const r=e(t);if("object"==typeof r)for(let{length:e}=r,t=0;t<e;t++)r[t]=Math.round(r[t]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}for(const e of v){g[e]={},Object.defineProperty(g[e],"channels",{value:o[e].channels}),Object.defineProperty(g[e],"labels",{value:o[e].labels});const t=m(e),n=Object.keys(t);for(const r of n){const n=t[r];g[e][r]=b(n),g[e][r].raw=y(n)}}const _=["keyword","gray","hex"],k={};for(const e of Object.keys(g))k[[...g[e].labels].sort().join("")]=e;const x={};function w(e,t){if(!(this instanceof w))return new w(e,t);if(t&&t in _&&(t=null),t&&!(t in g))throw new Error("Unknown model: "+t);let n,a;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof w)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if("string"==typeof e){const t=r.get(e);if(null===t)throw new Error("Unable to parse color from string: "+e);this.model=t.model,a=g[this.model].channels,this.color=t.value.slice(0,a),this.valpha="number"==typeof t.value[a]?t.value[a]:1}else if(e.length>0){this.model=t||"rgb",a=g[this.model].channels;const n=Array.prototype.slice.call(e,0,a);this.color=O(n,a),this.valpha="number"==typeof e[a]?e[a]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const r=t.sort().join("");if(!(r in k))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=k[r];const{labels:a}=g[this.model],s=[];for(n=0;n<a.length;n++)s.push(e[a[n]]);this.color=O(s)}if(x[this.model])for(a=g[this.model].channels,n=0;n<a;n++){const e=x[this.model][n];e&&(this.color[n]=e(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}w.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in r.to?this:this.rgb();t=t.round("number"==typeof e?e:1);const n=1===t.valpha?t.color:[...t.color,this.valpha];return r.to[t.model](...n)},percentString(e){const t=this.rgb().round("number"==typeof e?e:1),n=1===t.valpha?t.color:[...t.color,this.valpha];return r.to.rgb.percent(...n)},array(){return 1===this.valpha?[...this.color]:[...this.color,this.valpha]},object(){const e={},{channels:t}=g[this.model],{labels:n}=g[this.model];for(let r=0;r<t;r++)e[n[r]]=this.color[r];return 1!==this.valpha&&(e.alpha=this.valpha),e},unitArray(){const e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,1!==this.valpha&&e.push(this.valpha),e},unitObject(){const e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,1!==this.valpha&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new w([...this.color.map(N(e)),this.valpha],this.model)},alpha(e){return void 0!==e?new w([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:M("rgb",0,T(255)),green:M("rgb",1,T(255)),blue:M("rgb",2,T(255)),hue:M(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:M("hsl",1,T(100)),lightness:M("hsl",2,T(100)),saturationv:M("hsv",1,T(100)),value:M("hsv",2,T(100)),chroma:M("hcg",1,T(100)),gray:M("hcg",2,T(100)),white:M("hwb",1,T(100)),wblack:M("hwb",2,T(100)),cyan:M("cmyk",0,T(100)),magenta:M("cmyk",1,T(100)),yellow:M("cmyk",2,T(100)),black:M("cmyk",3,T(100)),x:M("xyz",0,T(95.047)),y:M("xyz",1,T(100)),z:M("xyz",2,T(108.833)),l:M("lab",0,T(100)),a:M("lab",1),b:M("lab",2),keyword(e){return void 0!==e?new w(e):g[this.model].keyword(this.color)},hex(e){return void 0!==e?new w(e):r.to.hex(...this.rgb().round().color)},hexa(e){if(void 0!==e)return new w(e);const t=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),r.to.hex(...t)+n},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const e=r/255;t[n]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return w.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),a=void 0===t?.5:t,s=2*a-1,i=n.alpha()-r.alpha(),o=((s*i===-1?s:(s+i)/(1+s*i))+1)/2,u=1-o;return w.rgb(o*n.red()+u*r.red(),o*n.green()+u*r.green(),o*n.blue()+u*r.blue(),n.alpha()*a+r.alpha()*(1-a))}};for(const e of Object.keys(g)){if(_.includes(e))continue;const{channels:t}=g[e];w.prototype[e]=function(...t){return this.model===e?new w(this):t.length>0?new w(t,e):new w([...(n=g[this.model][e].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],e);var n},w[e]=function(...n){let r=n[0];return"number"==typeof r&&(r=O(n,t)),new w(r,e)}}function N(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function M(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(x[r]||=[])[t]=n;return e=e[0],function(r){let a;return void 0!==r?(n&&(r=n(r)),a=this[e](),a.color[t]=r,a):(a=this[e]().color[t],n&&(a=n(a)),a)}}function T(e){return function(t){return Math.max(0,Math.min(e,t))}}function O(e,t){for(let n=0;n<t;n++)"number"!=typeof e[n]&&(e[n]=0);return e}const C=Symbol("BrandTag");const j=new class{constructor(e){this[C]=e}}("unit"),S=e=>null==e;function $(e,t){return void 0!==t?e(t):e}function E(e){if(function(e,t){return"object"==typeof e&&null!==e&&t in e}(e,"toString")&&"function"==typeof e.toString){const t=e.toString();return"string"==typeof t?t:JSON.stringify(e)}return JSON.stringify(e)}const A="Ok",Z="Err";class I{constructor(e){this.repr=e}static ok(e){return S(e)?new I(["Ok",j]):new I(["Ok",e])}static err(e){return S(e)?new I(["Err",j]):new I(["Err",e])}get variant(){return this.repr[0]}get value(){if(this.repr[0]===Z)throw new Error("Cannot get the value of Err");return this.repr[1]}get error(){if(this.repr[0]===A)throw new Error("Cannot get the error of Ok");return this.repr[1]}get isOk(){return this.repr[0]===A}get isErr(){return this.repr[0]===Z}map(e){return function(e,t){const n=t=>t.isOk?R(e(t.value)):t;return $(n,t)}(e,this)}mapOr(e,t){return function(e,t,n){function r(t,n){return n.isOk?t(n.value):e}function a(e,t){return void 0!==t?r(e,t):t=>r(e,t)}return void 0===t?a:void 0===n?a(t):a(t,n)}(e,t,this)}mapOrElse(e,t){return B(e,t,this)}match(e){return function(e,t){const n=t=>B(e.Err,e.Ok,t);return $(n,t)}(e,this)}mapErr(e){return function(e,t){const n=t=>t.isOk?t:P(e(t.error));return $(n,t)}(e,this)}or(e){return t=e,$(e=>e.isOk?R(e.value):t,this);var t}orElse(e){return t=e,$(e=>e.isOk?R(e.value):t(e.error),this);var t}and(e){return t=e,$(e=>e.isOk?t:P(e.error),this);var t}andThen(e){return t=e,$(e=>e.isOk?t(e.value):P(e.error),this);var t}unwrapOr(e){return function(e,t){const n=t=>t.isOk?t.value:e;return $(n,t)}(e,this)}unwrapOrElse(e){return t=e,$(e=>e.isOk?e.value:t(e.error),this);var t}toMaybe(){return(e=this).isOk?Q.just(e.value):Q.nothing();var e}toString(){return F(this)}toJSON(){return L(this)}equals(e){return t=e,void 0!==(n=this)?n.match({Err:()=>t.isErr,Ok:e=>t.isOk&&t.value===e}):e=>e.match({Err:()=>t.isErr,Ok:e=>t.isOk&&t.value===e});var t,n}ap(e){return function(e,t){const n=t=>t.andThen(t=>e.map(e=>e(t)));return $(n,t)}(this,e)}}const R=I.ok,P=I.err;function B(e,t,n){function r(t,n){return n.isOk?t(n.value):e(n.error)}function a(e,t){return void 0!==t?r(e,t):t=>r(e,t)}return void 0===t?a:void 0===n?a(t):a(t,n)}const F=e=>{const t=e.match({Ok:E,Err:E});return`${e.variant.toString()}(${t})`},L=e=>e.isOk?{variant:e.variant,value:e.value}:{variant:e.variant,error:e.error};const z=I,D="Just",J="Nothing";let q;class W{constructor(e){if(S(e))return this.repr=[J],q||(q=this),q;this.repr=[D,e]}static of(e){return new W(e)}static just(e){if(S(e))throw new Error(`attempted to call "just" with ${e}`);return new W(e)}static nothing(e){return new W}get variant(){return this.repr[0]}get value(){if(this.repr[0]===J)throw new Error("Cannot get the value of `Nothing`");return this.repr[1]}get isJust(){return this.repr[0]===D}get isNothing(){return this.repr[0]===J}map(e){return function(e,t){const n=t=>t.isJust?U(e(t.value)):V();return $(n,t)}(e,this)}mapOr(e,t){return function(e,t,n){function r(t,n){return n.isJust?t(n.value):e}function a(e,t){return void 0!==t?r(e,t):t=>r(e,t)}return void 0===t?a:void 0===n?a(t):a(t,n)}(e,t,this)}mapOrElse(e,t){return K(e,t,this)}match(e){return function(e,t){const n=t=>K(e.Nothing,e.Just,t);return $(n,t)}(e,this)}or(e){return function(e,t){const n=t=>t.isJust?t:e;return void 0!==t?n(t):n}(e,this)}orElse(e){return t=e,$(e=>e.isJust?e:t(),this);var t}and(e){return t=e,$(e=>e.isJust?t:V(),this);var t}andThen(e){return H(e,this)}unwrapOr(e){return function(e,t){const n=t=>t.isJust?t.value:e;return $(n,t)}(e,this)}unwrapOrElse(e){return t=e,$(e=>e.isJust?e.value:t(),this);var t}toOkOrErr(e){return function(e,t){const n=t=>t.isJust?z.ok(t.value):z.err(e);return void 0!==t?n(t):n}(e,this)}toOkOrElseErr(e){return function(e,t){return $(t=>t.isJust?z.ok(t.value):z.err(e()),t)}(e,this)}toString(){return function(e){const t=e.map(e=>`(${E(e)})`).unwrapOr("");return`${e.variant}${t}`}(this)}toJSON(){return(e=this).isJust?{variant:e.variant,value:X(e.value)?e.value.toJSON():e.value}:{variant:e.variant};var e}equals(e){return t=e,$(e=>e.match({Just:e=>t.isJust&&t.value===e,Nothing:()=>t.isNothing}),this);var t}ap(e){return function(e,t){const n=t=>t.andThen(t=>e.map(e=>e(t)));return $(n,t)}(this,e)}get(e){return function(e,t){return $(H(function(e,t){const n=t=>Q.of(t[e]);return $(n,t)}(e)),t)}(e,this)}}const U=W.just,V=W.nothing;function K(e,t,n){function r(t,n){return n.isJust?t(n.value):e()}function a(e,t){return void 0!==t?r(e,t):t=>r(e,t)}return void 0===t?a:void 0===n?a(t):a(t,n)}function H(e,t){const n=t=>t.isJust?e(t.value):V();return void 0!==t?n(t):n}function X(e){return e instanceof Q}const Q=W;var G,Y;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),r={};for(const e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(G||(G={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(Y||(Y={}));const ee=G.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),te=e=>{switch(typeof e){case"undefined":return ee.undefined;case"string":return ee.string;case"number":return Number.isNaN(e)?ee.nan:ee.number;case"boolean":return ee.boolean;case"function":return ee.function;case"bigint":return ee.bigint;case"symbol":return ee.symbol;case"object":return Array.isArray(e)?ee.array:null===e?ee.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?ee.promise:"undefined"!=typeof Map&&e instanceof Map?ee.map:"undefined"!=typeof Set&&e instanceof Set?ee.set:"undefined"!=typeof Date&&e instanceof Date?ee.date:ee.object;default:return ee.unknown}},ne=G.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class re extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(r);else if("invalid_return_type"===a.code)r(a.returnTypeError);else if("invalid_arguments"===a.code)r(a.argumentsError);else if(0===a.path.length)n._errors.push(t(a));else{let e=n,r=0;for(;r<a.path.length;){const n=a.path[r];r===a.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(a))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof re))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,G.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=e=>new re(e);const ae=(e,t)=>{let n;switch(e.code){case ne.invalid_type:n=e.received===ee.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case ne.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,G.jsonStringifyReplacer)}`;break;case ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${G.joinValues(e.keys,", ")}`;break;case ne.invalid_union:n="Invalid input";break;case ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${G.joinValues(e.options)}`;break;case ne.invalid_enum_value:n=`Invalid enum value. Expected ${G.joinValues(e.options)}, received '${e.received}'`;break;case ne.invalid_arguments:n="Invalid function arguments";break;case ne.invalid_return_type:n="Invalid function return type";break;case ne.invalid_date:n="Invalid date";break;case ne.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:G.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case ne.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case ne.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case ne.custom:n="Invalid input";break;case ne.invalid_intersection_types:n="Intersection results could not be merged";break;case ne.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ne.not_finite:n="Number must be finite";break;default:n=t.defaultError,G.assertNever(e)}return{message:n}};let se=ae;function ie(e,t){const n=se,r=(e=>{const{data:t,path:n,errorMaps:r,issueData:a}=e,s=[...n,...a.path||[]],i={...a,path:s};if(void 0!==a.message)return{...a,path:s,message:a.message};let o="";const u=r.filter(e=>!!e).slice().reverse();for(const e of u)o=e(i,{data:t,defaultError:o}).message;return{...a,path:s,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ae?void 0:ae].filter(e=>!!e)});e.common.issues.push(r)}class oe{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return ue;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,r=await e.value;n.push({key:t,value:r})}return oe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:a}=r;if("aborted"===t.status)return ue;if("aborted"===a.status)return ue;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"===t.value||void 0===a.value&&!r.alwaysSet||(n[t.value]=a.value)}return{status:e.value,value:n}}}const ue=Object.freeze({status:"aborted"}),le=e=>({status:"dirty",value:e}),ce=e=>({status:"valid",value:e}),de=e=>"aborted"===e.status,he=e=>"dirty"===e.status,fe=e=>"valid"===e.status,pe=e=>"undefined"!=typeof Promise&&e instanceof Promise;var me;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(me||(me={}));class ge{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ve=(e,t)=>{if(fe(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new re(e.common.issues);return this._error=t,this._error}}};function ye(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:a}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:(t,a)=>{const{message:s}=e;return"invalid_enum_value"===t.code?{message:s??a.defaultError}:void 0===a.data?{message:s??r??a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:s??n??a.defaultError}},description:a}}class be{get description(){return this._def.description}_getType(e){return te(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new oe,ctx:{common:e.parent.common,data:e.data,parsedType:te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(pe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:te(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ve(n,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:te(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return fe(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>fe(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:te(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(pe(r)?r:Promise.resolve(r));return ve(n,a)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const a=e(t),s=()=>r.addIssue({code:ne.custom,...n(t)});return"undefined"!=typeof Promise&&a instanceof Promise?a.then(e=>!!e||(s(),!1)):!!a||(s(),!1)})}refinement(e,t){return this._refinement((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1))}_refinement(e){return new yt({schema:this,typeName:Ot.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return bt.create(this,this._def)}nullable(){return _t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nt.create(this)}promise(){return vt.create(this,this._def)}or(e){return st.create([this,e],this._def)}and(e){return ot.create(this,e,this._def)}transform(e){return new yt({...ye(this._def),schema:this,typeName:Ot.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new kt({...ye(this._def),innerType:this,defaultValue:t,typeName:Ot.ZodDefault})}brand(){return new Nt({typeName:Ot.ZodBranded,type:this,...ye(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new xt({...ye(this._def),innerType:this,catchValue:t,typeName:Ot.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Mt.create(this,e)}readonly(){return Tt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _e=/^c[^\s-]{8,}$/i,ke=/^[0-9a-z]+$/,xe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,we=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ne=/^[a-z0-9_-]{21}$/i,Me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Te=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Oe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ce;const je=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$e=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ee=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ae=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ze=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ie="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Re=new RegExp(`^${Ie}$`);function Pe(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Be(e){return new RegExp(`^${Pe(e)}$`)}function Fe(e){let t=`${Ie}T${Pe(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Le(e,t){return!("v4"!==t&&t||!je.test(e))||!("v6"!==t&&t||!$e.test(e))}function ze(e,t){if(!Me.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(r));return"object"==typeof a&&null!==a&&((!("typ"in a)||"JWT"===a?.typ)&&(!!a.alg&&(!t||a.alg===t)))}catch{return!1}}function De(e,t){return!("v4"!==t&&t||!Se.test(e))||!("v6"!==t&&t||!Ee.test(e))}class Je extends be{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==ee.string){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.string,received:t.parsedType}),ue}const t=new oe;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const a=e.data.length>r.value,s=e.data.length<r.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?ie(n,{code:ne.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):s&&ie(n,{code:ne.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)Oe.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"email",code:ne.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)Ce||(Ce=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"emoji",code:ne.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)we.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"uuid",code:ne.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)Ne.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"nanoid",code:ne.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)_e.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"cuid",code:ne.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)ke.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"cuid2",code:ne.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)xe.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"ulid",code:ne.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),ie(n,{validation:"url",code:ne.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"regex",code:ne.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){Fe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){Re.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){Be(r).test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?Te.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"duration",code:ne.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?Le(e.data,r.version)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"ip",code:ne.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?ze(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"jwt",code:ne.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?De(e.data,r.version)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"cidr",code:ne.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?Ae.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"base64",code:ne.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?Ze.test(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{validation:"base64url",code:ne.invalid_string,message:r.message}),t.dirty()):G.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:ne.invalid_string,...me.errToObj(n)})}_addCheck(e){return new Je({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...me.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...me.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...me.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...me.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...me.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...me.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...me.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...me.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...me.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...me.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...me.errToObj(t)})}nonempty(e){return this.min(1,me.errToObj(e))}trim(){return new Je({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Je({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Je({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function qe(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,a=n>r?n:r;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}Je.create=e=>new Je({checks:[],typeName:Ot.ZodString,coerce:e?.coerce??!1,...ye(e)});class We extends be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==ee.number){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.number,received:t.parsedType}),ue}let t;const n=new oe;for(const r of this._def.checks)if("int"===r.kind)G.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==qe(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.not_finite,message:r.message}),n.dirty()):G.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,r){return new We({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(r)}]})}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&G.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}We.create=e=>new We({checks:[],typeName:Ot.ZodNumber,coerce:e?.coerce||!1,...ye(e)});class Ue extends be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ee.bigint)return this._getInvalidInput(e);let t;const n=new oe;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ne.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):G.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.bigint,received:t.parsedType}),ue}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,r){return new Ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(r)}]})}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Ue.create=e=>new Ue({checks:[],typeName:Ot.ZodBigInt,coerce:e?.coerce??!1,...ye(e)});class Ve extends be{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==ee.boolean){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.boolean,received:t.parsedType}),ue}return ce(e.data)}}Ve.create=e=>new Ve({typeName:Ot.ZodBoolean,coerce:e?.coerce||!1,...ye(e)});class Ke extends be{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==ee.date){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.date,received:t.parsedType}),ue}if(Number.isNaN(e.data.getTime())){return ie(this._getOrReturnCtx(e),{code:ne.invalid_date}),ue}const t=new oe;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),ie(n,{code:ne.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):G.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ke({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:me.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Ke.create=e=>new Ke({checks:[],coerce:e?.coerce||!1,typeName:Ot.ZodDate,...ye(e)});class He extends be{_parse(e){if(this._getType(e)!==ee.symbol){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.symbol,received:t.parsedType}),ue}return ce(e.data)}}He.create=e=>new He({typeName:Ot.ZodSymbol,...ye(e)});class Xe extends be{_parse(e){if(this._getType(e)!==ee.undefined){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.undefined,received:t.parsedType}),ue}return ce(e.data)}}Xe.create=e=>new Xe({typeName:Ot.ZodUndefined,...ye(e)});class Qe extends be{_parse(e){if(this._getType(e)!==ee.null){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.null,received:t.parsedType}),ue}return ce(e.data)}}Qe.create=e=>new Qe({typeName:Ot.ZodNull,...ye(e)});class Ge extends be{constructor(){super(...arguments),this._any=!0}_parse(e){return ce(e.data)}}Ge.create=e=>new Ge({typeName:Ot.ZodAny,...ye(e)});class Ye extends be{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ce(e.data)}}Ye.create=e=>new Ye({typeName:Ot.ZodUnknown,...ye(e)});class et extends be{_parse(e){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.never,received:t.parsedType}),ue}}et.create=e=>new et({typeName:Ot.ZodNever,...ye(e)});class tt extends be{_parse(e){if(this._getType(e)!==ee.undefined){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.void,received:t.parsedType}),ue}return ce(e.data)}}tt.create=e=>new tt({typeName:Ot.ZodVoid,...ye(e)});class nt extends be{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==ee.array)return ie(t,{code:ne.invalid_type,expected:ee.array,received:t.parsedType}),ue;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,a=t.data.length<r.exactLength.value;(e||a)&&(ie(t,{code:e?ne.too_big:ne.too_small,minimum:a?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(ie(t,{code:ne.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(ie(t,{code:ne.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ge(t,e,t.path,n)))).then(e=>oe.mergeArray(n,e));const a=[...t.data].map((e,n)=>r.type._parseSync(new ge(t,e,t.path,n)));return oe.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new nt({...this._def,minLength:{value:e,message:me.toString(t)}})}max(e,t){return new nt({...this._def,maxLength:{value:e,message:me.toString(t)}})}length(e,t){return new nt({...this._def,exactLength:{value:e,message:me.toString(t)}})}nonempty(e){return this.min(1,e)}}function rt(e){if(e instanceof at){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=bt.create(rt(r))}return new at({...e._def,shape:()=>t})}return e instanceof nt?new nt({...e._def,type:rt(e.element)}):e instanceof bt?bt.create(rt(e.unwrap())):e instanceof _t?_t.create(rt(e.unwrap())):e instanceof ut?ut.create(e.items.map(e=>rt(e))):e}nt.create=(e,t)=>new nt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ot.ZodArray,...ye(t)});class at extends be{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=G.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ee.object){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.object,received:t.parsedType}),ue}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof et&&"strip"===this._def.unknownKeys))for(const e in n.data)a.includes(e)||s.push(e);const i=[];for(const e of a){const t=r[e],a=n.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new ge(n,a,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof et){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of s)i.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)s.length>0&&(ie(n,{code:ne.unrecognized_keys,keys:s}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of s){const r=n.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new ge(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of i){const n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>oe.mergeObjectSync(t,e)):oe.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return me.errToObj,new at({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const r=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:me.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new at({...this._def,unknownKeys:"strip"})}passthrough(){return new at({...this._def,unknownKeys:"passthrough"})}extend(e){return new at({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new at({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ot.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new at({...this._def,catchall:e})}pick(e){const t={};for(const n of G.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new at({...this._def,shape:()=>t})}omit(e){const t={};for(const n of G.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new at({...this._def,shape:()=>t})}deepPartial(){return rt(this)}partial(e){const t={};for(const n of G.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}return new at({...this._def,shape:()=>t})}required(e){const t={};for(const n of G.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof bt;)e=e._def.innerType;t[n]=e}return new at({...this._def,shape:()=>t})}keyof(){return pt(G.objectKeys(this.shape))}}at.create=(e,t)=>new at({shape:()=>e,unknownKeys:"strip",catchall:et.create(),typeName:Ot.ZodObject,...ye(t)}),at.strictCreate=(e,t)=>new at({shape:()=>e,unknownKeys:"strict",catchall:et.create(),typeName:Ot.ZodObject,...ye(t)}),at.lazycreate=(e,t)=>new at({shape:e,unknownKeys:"strip",catchall:et.create(),typeName:Ot.ZodObject,...ye(t)});class st extends be{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new re(e.ctx.common.issues));return ie(t,{code:ne.invalid_union,unionErrors:n}),ue});{let e;const r=[];for(const a of n){const n={...t,common:{...t.common,issues:[]},parent:null},s=a._parseSync({data:t.data,path:t.path,parent:n});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const a=r.map(e=>new re(e));return ie(t,{code:ne.invalid_union,unionErrors:a}),ue}}get options(){return this._def.options}}function it(e,t){const n=te(e),r=te(t);if(e===t)return{valid:!0,data:e};if(n===ee.object&&r===ee.object){const n=G.objectKeys(t),r=G.objectKeys(e).filter(e=>-1!==n.indexOf(e)),a={...e,...t};for(const n of r){const r=it(e[n],t[n]);if(!r.valid)return{valid:!1};a[n]=r.data}return{valid:!0,data:a}}if(n===ee.array&&r===ee.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const a=it(e[r],t[r]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}return n===ee.date&&r===ee.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}st.create=(e,t)=>new st({options:e,typeName:Ot.ZodUnion,...ye(t)});class ot extends be{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(de(e)||de(r))return ue;const a=it(e.value,r.value);return a.valid?((he(e)||he(r))&&t.dirty(),{status:t.value,value:a.data}):(ie(n,{code:ne.invalid_intersection_types}),ue)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ot.create=(e,t,n)=>new ot({left:e,right:t,typeName:Ot.ZodIntersection,...ye(n)});class ut extends be{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ee.array)return ie(n,{code:ne.invalid_type,expected:ee.array,received:n.parsedType}),ue;if(n.data.length<this._def.items.length)return ie(n,{code:ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ue;!this._def.rest&&n.data.length>this._def.items.length&&(ie(n,{code:ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new ge(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>oe.mergeArray(t,e)):oe.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ut({...this._def,rest:e})}}ut.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ut({items:e,typeName:Ot.ZodTuple,rest:null,...ye(t)})};class lt extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ee.object)return ie(n,{code:ne.invalid_type,expected:ee.object,received:n.parsedType}),ue;const r=[],a=this._def.keyType,s=this._def.valueType;for(const e in n.data)r.push({key:a._parse(new ge(n,e,n.path,e)),value:s._parse(new ge(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?oe.mergeObjectAsync(t,r):oe.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new lt(t instanceof be?{keyType:e,valueType:t,typeName:Ot.ZodRecord,...ye(n)}:{keyType:Je.create(),valueType:e,typeName:Ot.ZodRecord,...ye(t)})}}class ct extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ee.map)return ie(n,{code:ne.invalid_type,expected:ee.map,received:n.parsedType}),ue;const r=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([e,t],s)=>({key:r._parse(new ge(n,e,n.path,[s,"key"])),value:a._parse(new ge(n,t,n.path,[s,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of s){const r=await n.key,a=await n.value;if("aborted"===r.status||"aborted"===a.status)return ue;"dirty"!==r.status&&"dirty"!==a.status||t.dirty(),e.set(r.value,a.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of s){const r=n.key,a=n.value;if("aborted"===r.status||"aborted"===a.status)return ue;"dirty"!==r.status&&"dirty"!==a.status||t.dirty(),e.set(r.value,a.value)}return{status:t.value,value:e}}}}ct.create=(e,t,n)=>new ct({valueType:t,keyType:e,typeName:Ot.ZodMap,...ye(n)});class dt extends be{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ee.set)return ie(n,{code:ne.invalid_type,expected:ee.set,received:n.parsedType}),ue;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(ie(n,{code:ne.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(ie(n,{code:ne.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function s(e){const n=new Set;for(const r of e){if("aborted"===r.status)return ue;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const i=[...n.data.values()].map((e,t)=>a._parse(new ge(n,e,n.path,t)));return n.common.async?Promise.all(i).then(e=>s(e)):s(i)}min(e,t){return new dt({...this._def,minSize:{value:e,message:me.toString(t)}})}max(e,t){return new dt({...this._def,maxSize:{value:e,message:me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}dt.create=(e,t)=>new dt({valueType:e,minSize:null,maxSize:null,typeName:Ot.ZodSet,...ye(t)});class ht extends be{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ht.create=(e,t)=>new ht({getter:e,typeName:Ot.ZodLazy,...ye(t)});class ft extends be{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ie(t,{received:t.data,code:ne.invalid_literal,expected:this._def.value}),ue}return{status:"valid",value:e.data}}get value(){return this._def.value}}function pt(e,t){return new mt({values:e,typeName:Ot.ZodEnum,...ye(t)})}ft.create=(e,t)=>new ft({value:e,typeName:Ot.ZodLiteral,...ye(t)});class mt extends be{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{expected:G.joinValues(n),received:t.parsedType,code:ne.invalid_type}),ue}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{received:t.data,code:ne.invalid_enum_value,options:n}),ue}return ce(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return mt.create(e,{...this._def,...t})}exclude(e,t=this._def){return mt.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}mt.create=pt;class gt extends be{_parse(e){const t=G.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ee.string&&n.parsedType!==ee.number){const e=G.objectValues(t);return ie(n,{expected:G.joinValues(e),received:n.parsedType,code:ne.invalid_type}),ue}if(this._cache||(this._cache=new Set(G.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=G.objectValues(t);return ie(n,{received:n.data,code:ne.invalid_enum_value,options:e}),ue}return ce(e.data)}get enum(){return this._def.values}}gt.create=(e,t)=>new gt({values:e,typeName:Ot.ZodNativeEnum,...ye(t)});class vt extends be{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ee.promise&&!1===t.common.async)return ie(t,{code:ne.invalid_type,expected:ee.promise,received:t.parsedType}),ue;const n=t.parsedType===ee.promise?t.data:Promise.resolve(t.data);return ce(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}vt.create=(e,t)=>new vt({type:e,typeName:Ot.ZodPromise,...ye(t)});class yt extends be{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ot.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:e=>{ie(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===r.type){const e=r.transform(n.data,a);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return ue;const r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===r.status?ue:"dirty"===r.status||"dirty"===t.value?le(r.value):r});{if("aborted"===t.value)return ue;const r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===r.status?ue:"dirty"===r.status||"dirty"===t.value?le(r.value):r}}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,a);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===r.status?ue:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?ue:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if("transform"===r.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fe(e))return ue;const s=r.transform(e.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>fe(e)?Promise.resolve(r.transform(e.value,a)).then(e=>({status:t.value,value:e})):ue)}G.assertNever(r)}}yt.create=(e,t,n)=>new yt({schema:e,typeName:Ot.ZodEffects,effect:t,...ye(n)}),yt.createWithPreprocess=(e,t,n)=>new yt({schema:t,effect:{type:"preprocess",transform:e},typeName:Ot.ZodEffects,...ye(n)});class bt extends be{_parse(e){return this._getType(e)===ee.undefined?ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}bt.create=(e,t)=>new bt({innerType:e,typeName:Ot.ZodOptional,...ye(t)});class _t extends be{_parse(e){return this._getType(e)===ee.null?ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_t.create=(e,t)=>new _t({innerType:e,typeName:Ot.ZodNullable,...ye(t)});class kt extends be{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ee.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}kt.create=(e,t)=>new kt({innerType:e,typeName:Ot.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ye(t)});class xt extends be{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pe(r)?r.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}xt.create=(e,t)=>new xt({innerType:e,typeName:Ot.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ye(t)});class wt extends be{_parse(e){if(this._getType(e)!==ee.nan){const t=this._getOrReturnCtx(e);return ie(t,{code:ne.invalid_type,expected:ee.nan,received:t.parsedType}),ue}return{status:"valid",value:e.data}}}wt.create=e=>new wt({typeName:Ot.ZodNaN,...ye(e)});class Nt extends be{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Mt extends be{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?ue:"dirty"===e.status?(t.dirty(),le(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?ue:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new Mt({in:e,out:t,typeName:Ot.ZodPipeline})}}class Tt extends be{_parse(e){const t=this._def.innerType._parse(e),n=e=>(fe(e)&&(e.value=Object.freeze(e.value)),e);return pe(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}var Ot;Tt.create=(e,t)=>new Tt({innerType:e,typeName:Ot.ZodReadonly,...ye(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ot||(Ot={}));const Ct=Je.create,jt=We.create,St=Ve.create,$t=Ge.create;et.create;const Et=nt.create,At=at.create,Zt=st.create;ot.create,ut.create;const It=lt.create,Rt=mt.create;vt.create,bt.create,_t.create;const Pt=yt.createWithPreprocess,Bt=["dotnetspy","ebpfspy","gospy","phpspy","pyspy","rbspy","nodespy","javaspy","pyroscope-rs","scrape","tracing","unknown"],Ft=Pt(e=>e&&Bt.includes(e)?e:"unknown",Rt(Bt).default("unknown")),Lt=["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions"],zt=Pt(e=>"string"==typeof e&&Lt.includes(e)?e:"unknown",Rt(["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions","unknown"])),Dt=At({names:Et(Pt(e=>e||"unknown",Ct().min(1))),levels:Et(Et(jt())),numTicks:jt(),maxSelf:jt()}),Jt=At({appName:Ct().optional(),name:Ct().optional(),startTime:jt().optional(),endTime:jt().optional(),query:Ct().optional(),maxNodes:jt().optional(),format:Rt(["single","double"]),sampleRate:jt(),spyName:Ft,units:zt});At({version:jt().min(1).max(1).default(1),flamebearer:Dt,metadata:Jt,leftTicks:jt().optional(),rightTicks:jt().optional()});const qt={format:"single",jStep:4,jName:3,getBarOffset:(e,t)=>e[t],getBarTotal:(e,t)=>e[t+1],getBarTotalDiff:(e,t)=>0,getBarSelf:(e,t)=>e[t+2],getBarSelfDiff:(e,t)=>0,getBarName:(e,t)=>e[t+3]},Wt={format:"double",jStep:7,jName:6,getBarOffset:(e,t)=>e[t]+e[t+3],getBarTotal:(e,t)=>e[t+4]+e[t+1],getBarTotalLeft:(e,t)=>e[t+1],getBarTotalRght:(e,t)=>e[t+4],getBarTotalDiff:(e,t)=>e[t+4]-e[t+1],getBarSelf:(e,t)=>e[t+5]+e[t+2],getBarSelfLeft:(e,t)=>e[t+2],getBarSelfRght:(e,t)=>e[t+5],getBarSelfDiff:(e,t)=>e[t+5]-e[t+2],getBarName:(e,t)=>e[t+6]};function Ut(e){switch(e){case"single":return qt;case"double":return Wt;default:throw new Error(`Unsupported type: '${e}'`)}}const Vt=At({refType:Ct(),traceID:Ct(),spanID:Ct()}),Kt=At({key:Ct(),type:Ct(),value:Zt([St(),jt(),Ct()])}),Ht=At({traceID:Ct(),spanID:Ct(),flags:Ct(),operationName:Ct(),references:Et(Vt),startTime:jt(),duration:jt(),tags:Et(Kt),logs:At({timestamp:jt(),fields:Et(Kt)}),processID:Ct(),warnings:$t()}),Xt=At({serviceName:Ct(),tags:Et(Kt)});At({traceID:Ct(),spans:Et(Ht),processes:It(Xt),warnings:$t()});const Qt=At({watermark:At({}).optional(),startTime:jt(),samples:Et(jt()),durationDelta:jt()});It(Ct(),Qt);const Gt=22,Yt=21.5;function en(e,t=!1){if(!e||!t)return e;const n=function(e){if(null==e)return null;if("number"==typeof e)return{value:e,unit:"",hasLessThan:!1,sign:""};let t=String(e).trim().replace(/\u2212/g,"-");if(!t)return null;let n=!1;t.startsWith("<")&&(n=!0,t=t.slice(1).trim());const r=t.match(/^([+\-]?)(\d*\.?\d+)\s*(.*)$/);if(!r)return null;const a=r[1]||"",s=r[2],i=(r[3]||"").trim(),o=parseFloat(s);return Number.isFinite(o)?{value:o,unit:i,hasLessThan:n,sign:a}:null}(e);if(!n)return e;const{unit:r}=n;let a=r;const s=r.toLowerCase();"ms"===s?a="毫秒":"μs"===s||"µs"===s||"us"===s?a="微秒":"second"===s||"seconds"===s?a="秒":"minute"===s||"minutes"===s||"min"===s||"mins"===s?a="分钟":"hour"===s||"hours"===s?a="小时":"day"===s||"days"===s?a="天":"month"===s||"months"===s?a="月":"year"!==s&&"years"!==s||(a="年");const i=String(e).match(/^([<\s]*)([+\-]?\d*\.?\d+)(.*)$/);if(!i)return e;return`${i[1]||""}${i[2]||""} ${a}`.trim()}function tn(e){return Math.round(1e4*e)/100}class nn{constructor(e,t,n){this.divider=1,this.enableSubsecondPrecision=!1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],this.units="",n&&(this.enableSubsecondPrecision=n,this.durations=[[1e3,"ms"],[1e3,"second"],...this.durations],this.suffix="μs",e*=1e6),this.units=t||"";for(let t=0;t<this.durations.length;t++){const n=this.durations[t];if(!n){console.warn("Could not calculate level");break}if(!(e>=n[0]))break;this.divider*=n[0],e/=n[0],this.suffix=n[1]}}format(e,t,n=!0){this.enableSubsecondPrecision&&(t/=1e6);const r=e/t/this.divider;let a=r.toFixed(2);return 0===r?a="0.00":(r>=0&&r<.01||r<=0&&r>-.01)&&(a="< 0.01"),n?`${a} ${this.units||`${this.suffix}${1===r||2===this.suffix.length?"":"s"}`}`:a}formatPrecise(e,t){this.enableSubsecondPrecision&&(t/=1e6);const n=e/t/this.divider;return`${parseFloat(n.toFixed(5))} ${this.units||`${this.suffix}${1===n||2===this.suffix.length?"":"s"}`}`}}class rn{constructor(e){this.divider=1,this.multiplier=1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],e/=1e9;for(let t=0;t<this.durations.length;t++){const n=this.durations[t];if(!n){console.warn("Could not calculate level");break}if(!(e>=n[0]))break;this.divider*=n[0],e/=n[0],this.suffix=n[1]}}format(e){const t=e/1e9/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}${1===t?"":"s"}`}formatPrecise(e){const t=e/1e9/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}${1===t?"":"s"}`}}class an{constructor(e){this.divider=1,this.suffix="",this.objects=[[1e3,"K"],[1e3,"M"],[1e3,"G"],[1e3,"T"],[1e3,"P"]];for(let t=0;t<this.objects.length;t++){const n=this.objects[t];if(!n){console.warn("Could not calculate level");break}if(!(e>=n[0]))break;this.divider*=n[0],e/=n[0],this.suffix=n[1]}}format(e){const t=e/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}`}formatPrecise(e){const t=e/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}`}}class sn{constructor(e){this.divider=1,this.suffix="bytes",this.bytes=[[1024,"KB"],[1024,"MB"],[1024,"GB"],[1024,"TB"],[1024,"PB"]];for(let t=0;t<this.bytes.length;t++){const n=this.bytes[t];if(!n){console.warn("Could not calculate level");break}if(!(e>=n[0]))break;{this.divider*=n[0],e/=n[0];const t=n[1];t?this.suffix=t:(console.warn("Could not calculate suffix"),this.suffix="")}}}format(e){const t=e/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}`}formatPrecise(e){const t=e/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}`}}function on({mode:e,charSize:t,rectWidth:n,fullText:r,shortText:a}){if("TAIL"===e){if(t*r.length<=n)return{mode:e,text:r,marginLeft:3};const s=t*a.length;return s<=n?{mode:e,text:a,marginLeft:3}:{mode:e,text:a,marginLeft:-(s-n+3)}}return{mode:e,text:r,marginLeft:3}}function un(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function ln(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function cn(e){let t,n,r;function a(e,r,a=0,s=e.length){if(a<s){if(0!==t(r,r))return s;do{const t=a+s>>>1;n(e[t],r)<0?a=t+1:s=t}while(a<s)}return a}return 2!==e.length?(t=un,n=(t,n)=>un(e(t),n),r=(t,n)=>e(t)-n):(t=e===un||e===ln?e:dn,n=e,r=e),{left:a,center:function(e,t,n=0,s=e.length){const i=a(e,t,n,s-1);return i>n&&r(e[i-1],t)>-r(e[i],t)?i-1:i},right:function(e,r,a=0,s=e.length){if(a<s){if(0!==t(r,r))return s;do{const t=a+s>>>1;n(e[t],r)<=0?a=t+1:s=t}while(a<s)}return a}}}function dn(){return 0}const hn=cn(un).right;cn(function(e){return null===e?NaN:+e}).center;const fn=Math.sqrt(50),pn=Math.sqrt(10),mn=Math.sqrt(2);function gn(e,t,n){const r=(t-e)/Math.max(0,n),a=Math.floor(Math.log10(r)),s=r/Math.pow(10,a),i=s>=fn?10:s>=pn?5:s>=mn?2:1;let o,u,l;return a<0?(l=Math.pow(10,-a)/i,o=Math.round(e*l),u=Math.round(t*l),o/l<e&&++o,u/l>t&&--u,l=-l):(l=Math.pow(10,a)*i,o=Math.round(e/l),u=Math.round(t/l),o*l<e&&++o,u*l>t&&--u),u<o&&.5<=n&&n<2?gn(e,t,2*n):[o,u,l]}function vn(e,t,n){return gn(e=+e,t=+t,n=+n)[2]}function yn(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function bn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _n(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kn(){}var xn=.7,wn=1/xn,Nn="\\s*([+-]?\\d+)\\s*",Mn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Tn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",On=/^#([0-9a-f]{3,8})$/,Cn=new RegExp(`^rgb\\(${Nn},${Nn},${Nn}\\)$`),jn=new RegExp(`^rgb\\(${Tn},${Tn},${Tn}\\)$`),Sn=new RegExp(`^rgba\\(${Nn},${Nn},${Nn},${Mn}\\)$`),$n=new RegExp(`^rgba\\(${Tn},${Tn},${Tn},${Mn}\\)$`),En=new RegExp(`^hsl\\(${Mn},${Tn},${Tn}\\)$`),An=new RegExp(`^hsla\\(${Mn},${Tn},${Tn},${Mn}\\)$`),Zn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function In(){return this.rgb().formatHex()}function Rn(){return this.rgb().formatRgb()}function Pn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=On.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?Bn(t):3===n?new zn(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?Fn(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?Fn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Cn.exec(e))?new zn(t[1],t[2],t[3],1):(t=jn.exec(e))?new zn(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Sn.exec(e))?Fn(t[1],t[2],t[3],t[4]):(t=$n.exec(e))?Fn(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=En.exec(e))?Vn(t[1],t[2]/100,t[3]/100,1):(t=An.exec(e))?Vn(t[1],t[2]/100,t[3]/100,t[4]):Zn.hasOwnProperty(e)?Bn(Zn[e]):"transparent"===e?new zn(NaN,NaN,NaN,0):null}function Bn(e){return new zn(e>>16&255,e>>8&255,255&e,1)}function Fn(e,t,n,r){return r<=0&&(e=t=n=NaN),new zn(e,t,n,r)}function Ln(e,t,n,r){return 1===arguments.length?((a=e)instanceof kn||(a=Pn(a)),a?new zn((a=a.rgb()).r,a.g,a.b,a.opacity):new zn):new zn(e,t,n,null==r?1:r);var a}function zn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function Dn(){return`#${Un(this.r)}${Un(this.g)}${Un(this.b)}`}function Jn(){const e=qn(this.opacity);return`${1===e?"rgb(":"rgba("}${Wn(this.r)}, ${Wn(this.g)}, ${Wn(this.b)}${1===e?")":`, ${e})`}`}function qn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Un(e){return((e=Wn(e))<16?"0":"")+e.toString(16)}function Vn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Hn(e,t,n,r)}function Kn(e){if(e instanceof Hn)return new Hn(e.h,e.s,e.l,e.opacity);if(e instanceof kn||(e=Pn(e)),!e)return new Hn;if(e instanceof Hn)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,o=s-a,u=(s+a)/2;return o?(i=t===s?(n-r)/o+6*(n<r):n===s?(r-t)/o+2:(t-n)/o+4,o/=u<.5?s+a:2-s-a,i*=60):o=u>0&&u<1?0:i,new Hn(i,o,u,e.opacity)}function Hn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function Xn(e){return(e=(e||0)%360)<0?e+360:e}function Qn(e){return Math.max(0,Math.min(1,e||0))}function Gn(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}bn(kn,Pn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:In,formatHex:In,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Kn(this).formatHsl()},formatRgb:Rn,toString:Rn}),bn(zn,Ln,_n(kn,{brighter(e){return e=null==e?wn:Math.pow(wn,e),new zn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?xn:Math.pow(xn,e),new zn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zn(Wn(this.r),Wn(this.g),Wn(this.b),qn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Dn,formatHex:Dn,formatHex8:function(){return`#${Un(this.r)}${Un(this.g)}${Un(this.b)}${Un(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Jn,toString:Jn})),bn(Hn,function(e,t,n,r){return 1===arguments.length?Kn(e):new Hn(e,t,n,null==r?1:r)},_n(kn,{brighter(e){return e=null==e?wn:Math.pow(wn,e),new Hn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?xn:Math.pow(xn,e),new Hn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new zn(Gn(e>=240?e-240:e+120,a,r),Gn(e,a,r),Gn(e<120?e+240:e-120,a,r),this.opacity)},clamp(){return new Hn(Xn(this.h),Qn(this.s),Qn(this.l),qn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=qn(this.opacity);return`${1===e?"hsl(":"hsla("}${Xn(this.h)}, ${100*Qn(this.s)}%, ${100*Qn(this.l)}%${1===e?")":`, ${e})`}`}}));var Yn=e=>()=>e;function er(e){return 1===(e=+e)?tr:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):Yn(isNaN(t)?n:t)}}function tr(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):Yn(isNaN(e)?t:e)}var nr=function e(t){var n=er(t);function r(e,t){var r=n((e=Ln(e)).r,(t=Ln(t)).r),a=n(e.g,t.g),s=n(e.b,t.b),i=tr(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=a(t),e.b=s(t),e.opacity=i(t),e+""}}return r.gamma=e,r}(1);function rr(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,a=t.slice();return function(s){for(n=0;n<r;++n)a[n]=e[n]*(1-s)+t[n]*s;return a}}function ar(e,t){var n,r=t?t.length:0,a=e?Math.min(r,e.length):0,s=new Array(a),i=new Array(r);for(n=0;n<a;++n)s[n]=dr(e[n],t[n]);for(;n<r;++n)i[n]=t[n];return function(e){for(n=0;n<a;++n)i[n]=s[n](e);return i}}function sr(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ir(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function or(e,t){var n,r={},a={};for(n in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)n in e?r[n]=dr(e[n],t[n]):a[n]=t[n];return function(e){for(n in r)a[n]=r[n](e);return a}}var ur=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,lr=new RegExp(ur.source,"g");function cr(e,t){var n,r,a,s=ur.lastIndex=lr.lastIndex=0,i=-1,o=[],u=[];for(e+="",t+="";(n=ur.exec(e))&&(r=lr.exec(t));)(a=r.index)>s&&(a=t.slice(s,a),o[i]?o[i]+=a:o[++i]=a),(n=n[0])===(r=r[0])?o[i]?o[i]+=r:o[++i]=r:(o[++i]=null,u.push({i:i,x:ir(n,r)})),s=lr.lastIndex;return s<t.length&&(a=t.slice(s),o[i]?o[i]+=a:o[++i]=a),o.length<2?u[0]?function(e){return function(t){return e(t)+""}}(u[0].x):function(e){return function(){return e}}(t):(t=u.length,function(e){for(var n,r=0;r<t;++r)o[(n=u[r]).i]=n.x(e);return o.join("")})}function dr(e,t){var n,r,a=typeof t;return null==t||"boolean"===a?Yn(t):("number"===a?ir:"string"===a?(n=Pn(t))?(t=n,nr):cr:t instanceof Pn?nr:t instanceof Date?sr:(r=t,!ArrayBuffer.isView(r)||r instanceof DataView?Array.isArray(t)?ar:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?or:ir:rr))(e,t)}function hr(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function fr(e){return+e}var pr=[0,1];function mr(e){return e}function gr(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:(n=isNaN(t)?NaN:.5,function(){return n});var n}function vr(e,t,n){var r=e[0],a=e[1],s=t[0],i=t[1];return a<r?(r=gr(a,r),s=n(i,s)):(r=gr(r,a),s=n(s,i)),function(e){return s(r(e))}}function yr(e,t,n){var r=Math.min(e.length,t.length)-1,a=new Array(r),s=new Array(r),i=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++i<r;)a[i]=gr(e[i],e[i+1]),s[i]=n(t[i],t[i+1]);return function(t){var n=hn(e,t,1,r)-1;return s[n](a[n](t))}}function br(){var e,t,n,r,a,s,i=pr,o=pr,u=dr,l=mr;function c(){var e,t,n,u=Math.min(i.length,o.length);return l!==mr&&(e=i[0],t=i[u-1],e>t&&(n=e,e=t,t=n),l=function(n){return Math.max(e,Math.min(t,n))}),r=u>2?yr:vr,a=s=null,d}function d(t){return null==t||isNaN(t=+t)?n:(a||(a=r(i.map(e),o,u)))(e(l(t)))}return d.invert=function(n){return l(t((s||(s=r(o,i.map(e),ir)))(n)))},d.domain=function(e){return arguments.length?(i=Array.from(e,fr),c()):i.slice()},d.range=function(e){return arguments.length?(o=Array.from(e),c()):o.slice()},d.rangeRound=function(e){return o=Array.from(e),u=hr,c()},d.clamp=function(e){return arguments.length?(l=!!e||mr,c()):l!==mr},d.interpolate=function(e){return arguments.length?(u=e,c()):u},d.unknown=function(e){return arguments.length?(n=e,d):n},function(n,r){return e=n,t=r,c()}}function _r(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function kr(e){return(e=_r(Math.abs(e)))?e[1]:NaN}var xr,wr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Nr(e){if(!(t=wr.exec(e)))throw new Error("invalid format: "+e);var t;return new Mr({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Mr(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Tr(e,t){var n=_r(e,t);if(!n)return e+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}Nr.prototype=Mr.prototype,Mr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Or={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Tr(100*e,t),r:Tr,s:function(e,t){var n=_r(e,t);if(!n)return e+"";var r=n[0],a=n[1],s=a-(xr=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,i=r.length;return s===i?r:s>i?r+new Array(s-i+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+_r(e,Math.max(0,t+s-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Cr(e){return e}var jr,Sr,$r,Er=Array.prototype.map,Ar=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Zr(e){var t,n,r=void 0===e.grouping||void 0===e.thousands?Cr:(t=Er.call(e.grouping,Number),n=e.thousands+"",function(e,r){for(var a=e.length,s=[],i=0,o=t[0],u=0;a>0&&o>0&&(u+o+1>r&&(o=Math.max(1,r-u)),s.push(e.substring(a-=o,a+o)),!((u+=o+1)>r));)o=t[i=(i+1)%t.length];return s.reverse().join(n)}),a=void 0===e.currency?"":e.currency[0]+"",s=void 0===e.currency?"":e.currency[1]+"",i=void 0===e.decimal?".":e.decimal+"",o=void 0===e.numerals?Cr:function(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}(Er.call(e.numerals,String)),u=void 0===e.percent?"%":e.percent+"",l=void 0===e.minus?"−":e.minus+"",c=void 0===e.nan?"NaN":e.nan+"";function d(e){var t=(e=Nr(e)).fill,n=e.align,d=e.sign,h=e.symbol,f=e.zero,p=e.width,m=e.comma,g=e.precision,v=e.trim,y=e.type;"n"===y?(m=!0,y="g"):Or[y]||(void 0===g&&(g=12),v=!0,y="g"),(f||"0"===t&&"="===n)&&(f=!0,t="0",n="=");var b="$"===h?a:"#"===h&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===h?s:/[%p]/.test(y)?u:"",k=Or[y],x=/[defgprs%]/.test(y);function w(e){var a,s,u,h=b,w=_;if("c"===y)w=k(e)+w,e="";else{var N=(e=+e)<0||1/e<0;if(e=isNaN(e)?c:k(Math.abs(e),g),v&&(e=function(e){e:for(var t,n=e.length,r=1,a=-1;r<n;++r)switch(e[r]){case".":a=t=r;break;case"0":0===a&&(a=r),t=r;break;default:if(!+e[r])break e;a>0&&(a=0)}return a>0?e.slice(0,a)+e.slice(t+1):e}(e)),N&&0===+e&&"+"!==d&&(N=!1),h=(N?"("===d?d:l:"-"===d||"("===d?"":d)+h,w=("s"===y?Ar[8+xr/3]:"")+w+(N&&"("===d?")":""),x)for(a=-1,s=e.length;++a<s;)if(48>(u=e.charCodeAt(a))||u>57){w=(46===u?i+e.slice(a+1):e.slice(a))+w,e=e.slice(0,a);break}}m&&!f&&(e=r(e,1/0));var M=h.length+e.length+w.length,T=M<p?new Array(p-M+1).join(t):"";switch(m&&f&&(e=r(T+e,T.length?p-w.length:1/0),T=""),n){case"<":e=h+e+w+T;break;case"=":e=h+T+e+w;break;case"^":e=T.slice(0,M=T.length>>1)+h+e+w+T.slice(M);break;default:e=T+h+e+w}return o(e)}return g=void 0===g?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),w.toString=function(){return e+""},w}return{format:d,formatPrefix:function(e,t){var n=d(((e=Nr(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(kr(t)/3))),a=Math.pow(10,-r),s=Ar[8+r/3];return function(e){return n(a*e)+s}}}}function Ir(e,t,n,r){var a,s=function(e,t,n){n=+n;const r=(t=+t)<(e=+e),a=r?vn(t,e,n):vn(e,t,n);return(r?-1:1)*(a<0?1/-a:a)}(e,t,n);switch((r=Nr(null==r?",f":r)).type){case"s":var i=Math.max(Math.abs(e),Math.abs(t));return null!=r.precision||isNaN(a=function(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(kr(t)/3)))-kr(Math.abs(e)))}(s,i))||(r.precision=a),$r(r,i);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(a=function(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,kr(t)-kr(e))+1}(s,Math.max(Math.abs(e),Math.abs(t))))||(r.precision=a-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(a=function(e){return Math.max(0,-kr(Math.abs(e)))}(s))||(r.precision=a-2*("%"===r.type))}return Sr(r)}function Rr(e){var t=e.domain;return e.ticks=function(e){var n=t();return function(e,t,n){if(!((n=+n)>0))return[];if((e=+e)===(t=+t))return[e];const r=t<e,[a,s,i]=r?gn(t,e,n):gn(e,t,n);if(!(s>=a))return[];const o=s-a+1,u=new Array(o);if(r)if(i<0)for(let e=0;e<o;++e)u[e]=(s-e)/-i;else for(let e=0;e<o;++e)u[e]=(s-e)*i;else if(i<0)for(let e=0;e<o;++e)u[e]=(a+e)/-i;else for(let e=0;e<o;++e)u[e]=(a+e)*i;return u}(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var r=t();return Ir(r[0],r[r.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var r,a,s=t(),i=0,o=s.length-1,u=s[i],l=s[o],c=10;for(l<u&&(a=u,u=l,l=a,a=i,i=o,o=a);c-- >0;){if((a=vn(u,l,n))===r)return s[i]=u,s[o]=l,t(s);if(a>0)u=Math.floor(u/a)*a,l=Math.ceil(l/a)*a;else{if(!(a<0))break;u=Math.ceil(u*a)/a,l=Math.floor(l*a)/a}r=a}return e},e}function Pr(){var e=br()(mr,mr);return e.copy=function(){return t=e,Pr().domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());var t},yn.apply(e,arguments),Rr(e)}function Br(e,t){if(e===t)return 0;if(0===e)return 100;const n=(t-e)/e*100;return n>100?100:n<-100?-100:n}function Fr(e,t){return w.rgb(e,e,e).alpha(t)}function Lr(e,t){if(0===t.length)return t;const n=function(e){switch(e){case"dotnetspy":return/^(?<packageName>.+)\.(.+)\.(.+)\(.*\)$/;case"ebpfspy":case"unknown":return/^(?<packageName>.+)$/;case"gospy":case"scrape":return/^(?<packageName>.*?\/.*?\.|.*?\.|.+)(?<functionName>.*)$/;case"phpspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.php+)(?<line_info>.*)$/;case"pyspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.py+)(?<line_info>.*)$/;case"rbspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.rb+)(?<line_info>.*)$/;case"nodespy":return/^(\.\/node_modules\/)?(?<packageName>[^/]*)(?<filename>.*\.?(jsx?|tsx?)?):(?<functionName>.*):(?<line_info>.*)$/;case"tracing":return/^(?<packageName>.+?):.*$/;case"javaspy":return/^(?<packageName>.+\/)(?<filename>.+\.)(?<functionName>.+)$/;case"pyroscope-rs":return/^(?<packageName>[^::]+)/}return/^(?<packageName>.+)$/}(e),r=t.match(n);return r&&r.groups?r.groups.packageName||"":t}function zr(e,t){const n=function(e,t=0){let n,r,a,s,i,o,u,l;for(n=3&e.length,r=e.length-n,a=t,i=3432918353,o=461845907,l=0;l<r;)u=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*o+(((u>>>16)*o&65535)<<16)&4294967295,a^=u,a=a<<13|a>>>19,s=5*(65535&a)+((5*(a>>>16)&65535)<<16)&4294967295,a=27492+(65535&s)+(((s>>>16)+58964&65535)<<16);switch(u=0,n){case 3:u^=(255&e.charCodeAt(l+2))<<16;case 2:u^=(255&e.charCodeAt(l+1))<<8;case 1:u^=255&e.charCodeAt(l);default:u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*o+(((u>>>16)*o&65535)<<16)&4294967295,a^=u}return a^=e.length,a^=a>>>16,a=2246822507*(65535&a)+((2246822507*(a>>>16)&65535)<<16)&4294967295,a^=a>>>13,a=3266489909*(65535&a)+((3266489909*(a>>>16)&65535)<<16)&4294967295,a^=a>>>16,a>>>0}(t,0)%e.colors.length,r=e.colors[n];return r||(console.warn("Could not calculate color. Defaulting to the first one"),e.colors[0])}function Dr(e){const{goodColor:t,neutralColor:n,badColor:r}=e,a=Pr().domain([-100,0,100]).range([t.rgb().toString(),n.rgb().toString(),r.rgb().toString()]);return e=>w(a(e).toString())}jr=Zr({thousands:",",grouping:[3],currency:["$",""]}),Sr=jr.format,$r=jr.formatPrefix,w.rgb(148,142,142),w.rgb(200,0,0),w.rgb(0,170,0),w("#48CE73");const Jr=new WeakMap,qr=new WeakMap,Wr=new WeakMap,Ur=new WeakMap;const Vr={collapsedLevelsSingular:"total (1 level collapsed)",collapsedLevelsPlural:"total ({n} levels collapsed)",isZh:!1};function Kr(e){var t,n,r,a,s,i,o,u;const l=performance.now(),c=!1!==e.renderRects,d=!1!==e.renderText,h=null!==(t=e.renderMode)&&void 0!==t?t:"normal",f=e.timeBudgetMs,{canvas:p,fitMode:m,units:g,tickToX:v,levels:y,palette:b}=e,{numTicks:_,sampleRate:k,pxPerTick:x}=e,{rangeMin:w,rangeMax:N}=e,{focusedNode:M,zoom:T}=e,O=e.messages||Vr,C=e.skipCanvasResize?p.width:function(e){if("clientWidth"in e&&"number"==typeof e.clientWidth)return e.clientWidth;return e.width}(p);if(e.skipCanvasResize||(p.width=C),w>=N)throw new Error("'rangeMin' should be strictly smaller than 'rangeMax'");const{format:j}=e,S=Ut(j),$=p.getContext("2d");if(!$)throw new Error("Could not get ctx");const E=T.mapOrElse(()=>0,e=>e.i),A=function(e,t,n){switch(n){case"samples":return new nn(e/t);case"objects":case"goroutines":case"lock_samples":case"exceptions":return new an(e);case"bytes":return new sn(e);case"lock_nanoseconds":return new rn(e);case"trace_samples":return new nn(e/t,"",!0);default:return console.warn(`Unsupported unit: '${n}'. Defaulting to ''`),new nn(e/t," ")}}(_,k,g),Z=M.isJust,I=M.mapOrElse(()=>0,e=>e.i),R=Z?Yt:0,P=!!e.highlightQuery&&e.highlightQuery.length>0,B=Gt*(y.length-I)+(Z?Yt:0);e.skipCanvasResize||(p.height=B);const F="number"==typeof e.devicePixelRatio?e.devicePixelRatio:"undefined"!=typeof devicePixelRatio?devicePixelRatio:1;!e.skipDprScale&&F>1&&(p.width*=F,p.height*=F,$.scale(F,F)),$.textBaseline="middle",$.font="400 11.5px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace";const L=$.measureText("a").width,{names:z}=e,D=function(e){const t=Jr.get(e);if(t)return t;const n=new Map;return Jr.set(e,n),n}(p),J=P?function(e,t){const n=qr.get(e);if(n){const e=n.get(t);if(e)return e}const r=t.toLowerCase(),a=new Uint8Array(e.length);for(let t=1;t<e.length;t+=1){const n=e[t];n&&n.toLowerCase().includes(r)&&(a[t]=1)}const s=null!=n?n:new Map;return s.set(t,a),qr.set(e,s),a}(z,e.highlightQuery):null,q="single"===e.format?function(e,t,n){const r=`${t}|${n.name}`,a=Wr.get(e);if(a){const e=a.get(r);if(e)return e}const s=new Array(e.length);for(let r=0;r<e.length;r+=1){const a=Lr(t,e[r]||"")||"";s[r]=zr(n,a)}const i=null!=a?a:new Map;return i.set(r,s),Wr.set(e,i),s}(z,e.spyName,b):null,W="double"===e.format?Dr({name:b.name,goodColor:b.goodColor,neutralColor:b.neutralColor,badColor:b.badColor}):null,U=(e,t)=>{const n=e[t+S.jName];return!(!n||n<0||!J)&&1===J[n]},V=null!==(n=e.startI)&&void 0!==n?n:0,K=null!==(r=e.startJ)&&void 0!==r?r:0;if(Z&&"highlightOnly"!==h&&0===(null!==(a=e.levelStart)&&void 0!==a?a:0)&&0===V&&0===K){const e=_*x;c&&($.beginPath(),$.rect(0,0,_*x,Yt),$.fillStyle=Fr(200,1).rgb().string(),$.fill());const t=M.mapOrElse(()=>"total",e=>function(e,t){return 1===e?t.collapsedLevelsSingular:t.collapsedLevelsPlural.replace("{n}",String(e))}(e.i-1,O)),n=on({mode:m,charSize:L,rectWidth:e,fullText:t,shortText:t}),r=0,a=0,s=Yt;if(d){$.beginPath(),$.rect(0,0,e,Yt),$.save(),$.clip(),$.fillStyle="black";const t=Math.round(Math.max(r,0));$.fillText(n.text,t+n.marginLeft,a+s/2+1),$.restore()}}const H=Math.max(0,null!==(s=e.levelStart)&&void 0!==s?s:0),X=y.length-I,Q=Math.min(X,null!==(i=e.levelEnd)&&void 0!==i?i:X),G=Math.max(H,null!==(o=e.startI)&&void 0!==o?o:H),Y=Math.max(0,null!==(u=e.startJ)&&void 0!==u?u:0),{spyName:ee}=e,te=(t,n,r,a,s)=>{const i={level:t,j:n,i:r+M.mapOrElse(()=>0,e=>e.i),names:z,collapsed:a,selectedLevel:E,highlightModeOn:P,isHighlighted:s,spyName:ee,palette:b,colorByNameIndex:q,diffColorFn:W};switch(j){case"single":return function(e){const t=Qr(e);if(t)return t;const n=Ut("single"),r=e.selectedLevel>e.i?.33:1;let a=e.level[e.j+n.jName];void 0===a&&(console.warn("Could nto find level",{l:e.j,jName:n.jName,level:e.level}),a=-1);if(e.colorByNameIndex&&a>=0&&e.colorByNameIndex[a])return e.colorByNameIndex[a].alpha(r);const s=e.names[a]||"",i=Lr(e.spyName,s)||"";return zr(e.palette,i).alpha(r)}({...i});case"double":return function(e){const t=Qr(e);if(t)return t;const n=e.selectedLevel>e.i?.33:1,{leftRatio:r,rightRatio:a}=function(e,t,n,r){const a=Wt;return n&&r?{leftRatio:a.getBarTotalLeft(e,t)/n,rightRatio:a.getBarTotalRght(e,t)/r}:(console.error("Properties 'rightTicks' and 'leftTicks' are required. Can't calculate ratio."),{leftRatio:0,rightRatio:0})}(e.level,e.j,e.leftTicks,e.rightTicks),s=tn(r),i=tn(a);if(e.diffColorFn)return e.diffColorFn(Br(s,i)).alpha(n);return function(e,t,n){const r=Br(t,n);return Dr(e)(r)}(e.palette,s,i).alpha(n)}({...i,leftTicks:e.leftTicks,rightTicks:e.rightTicks});default:throw new Error(`Unsupported format: ${j}`)}};if("highlightOnly"===h&&P&&c){const e=function(e,t){const n=Ur.get(e);if(n)return n;const r=Ut(t),a=new Map;for(let t=0;t<e.length;t+=1){const n=e[t];for(let e=0;e<n.length;e+=r.jStep){const s=r.getBarName(n,e);if(void 0===s||s<0)continue;const i=a.get(s);i?i.push({i:t,j:e}):a.set(s,[{i:t,j:e}])}}return Ur.set(e,a),a}(y,j),t=[];for(let e=1;e<z.length;e+=1)J&&1===J[e]&&t.push(e);for(let n=0;n<t.length;n+=1){const r=t[n],a=e.get(r);if(a)for(let e=0;e<a.length;e+=1){const t=a[e],n=t.i-I;if(t.i<I||n<H||n>=Q)continue;const r=y[t.i],s=v(S.getBarOffset(r,t.j)),i=n*Gt+R,o=Yt,u=S.getBarTotal(r,t.j),l=u*x<=5,c=u*x-(l?0:.5);if(c<=0)continue;$.beginPath(),$.rect(s,i,c,o);const d=te(r,t.j,n,l,!0);$.fillStyle=d.string(),$.fill()}}return{done:!0,nextI:Q,nextJ:0}}for(let e=G;e<Q;e+=1){const t=y[I+e];if(!t)throw new Error(`Could not find level: ${I+e}`);let n=e===G?Y:0;for(;n<t.length;n+=S.jStep){const r=S.getBarOffset(t,n),a=v(r),s=e*Gt+R,i=Yt,o=P&&U(t,n);let u=S.getBarTotal(t,n);const p=u*x<=5;if(p)for(;n<t.length-S.jStep&&r+u===S.getBarOffset(t,n+S.jStep)&&S.getBarTotal(t,n+S.jStep)*x<=5&&o===(P&&U(t,n+S.jStep));)n+=S.jStep,u+=S.getBarTotal(t,n);const g=u*x-(p?0:.5);if($.beginPath(),$.rect(a,s,g,i),c){if("forceGrey"===h)$.fillStyle=Fr(200,.66).rgb().string();else{const r=te(t,n,e,p,o);$.fillStyle=r.string()}$.fill()}if(!d||p||"forceGrey"===h){if(f&&performance.now()-l>f)return{done:!1,nextI:e,nextJ:n+S.jStep};continue}if(g<20)continue;const y=Hr(z,n,j,t),b=on({mode:m,charSize:L,rectWidth:g,fullText:Xr(y,u,k,A,O,D),shortText:y});$.save(),$.clip(),$.fillStyle="black";const _=Math.round(Math.max(a,0));if($.fillText(b.text,_+b.marginLeft,s+i/2+1),$.restore(),f&&performance.now()-l>f)return{done:!1,nextI:e,nextJ:n+S.jStep}}if(f&&performance.now()-l>f)return{done:!1,nextI:e+1,nextJ:0}}return{done:!0,nextI:Q,nextJ:0}}function Hr(e,t,n,r){let a=r[t+Ut(n).jName];void 0===a&&(a=-1);const s=e[a];return s||(console.warn("Could not find function name for",{j:t,format:n,level:r,names:e}),"")}function Xr(e,t,n,r,a,s){let i=null==s?void 0:s.get(t);if(!i){const e=r.format(t,n);i=en(e,!!a.isZh)||e,null==s||s.set(t,i)}return`${e} (${i})`}function Qr({collapsed:e,highlightModeOn:t,isHighlighted:n}){return e||t&&!n?Fr(200,.66):null}class Gr{constructor(e,t,n,r,a,s,i,o){if(this.flamebearer=e,this.canvas=t,this.focusedNode=n,this.fitMode=r,this.highlightQuery=a,this.zoom=s,this.palette=i,this.messages=o,this.cachedRange=null,this.cachedPxPerTick=null,this.tickToX=e=>{var t;const n=this.cachedRange?this.cachedRange.rangeMin:this.getRange().rangeMin,r=null!==(t=this.cachedPxPerTick)&&void 0!==t?t:this.pxPerTick();return(e-this.flamebearer.numTicks*n)*r},this.xyToBarPosition=e=>{const{ff:t}=this,{i:n,j:r}=this.xyToBarIndex(e.x,e.y),a=this.focusedNode.mapOrElse(()=>0,e=>e.i<0?0:e.i-1),s=this.flamebearer.levels[n];if(!s)throw new Error(`Could not find level: '${n}'`);const i=Math.max(this.tickToX(t.getBarOffset(s,r)),0);return{x:i,y:Math.max((n-a)*Gt,0),width:Math.min(this.tickToX(t.getBarOffset(s,r)+t.getBarTotal(s,r))-i,this.getCanvasWidth())}},this.xyToBarData=e=>{const{i:t,j:n}=this.xyToBarIndex(e.x,e.y),r=this.flamebearer.levels[t];if(!r)throw new Error(`Could not find level: '${t}'`);switch(this.flamebearer.format){case"single":{const e=qt;return{format:"single",name:this.flamebearer.names[e.getBarName(r,n)],self:e.getBarSelf(r,n),offset:e.getBarOffset(r,n),total:e.getBarTotal(r,n)}}case"double":{const e=Wt;return{format:"double",barTotal:e.getBarTotal(r,n),totalLeft:e.getBarTotalLeft(r,n),totalRight:e.getBarTotalRght(r,n),totalDiff:e.getBarTotalDiff(r,n),name:this.flamebearer.names[e.getBarName(r,n)]}}default:throw new Error("Unsupported type")}},this.isWithinBounds=(e,t)=>{if(e<0||e>this.getCanvasWidth())return!1;try{const{i:n,j:r}=this.xyToBarIndex(e,t);if(-1===r||-1===n)return!1}catch(e){return!1}return!0},this.zoom=s,this.focusedNode=n,this.flamebearer=e,this.canvas=t,this.highlightQuery=a,this.ff=Ut(e.format),this.palette=i,this.messages=o,n.isJust&&s.isJust&&s.value.i<n.value.i)throw new Error("Zoom i level should be bigger than Focus")}render(e){var t;const{rangeMin:n,rangeMax:r,pxPerTick:a}=this.updateCachedMetrics(),s=null!==(t=null==e?void 0:e.highlightQueryOverride)&&void 0!==t?t:this.highlightQuery,i={canvas:this.canvas,format:this.flamebearer.format,numTicks:this.flamebearer.numTicks,sampleRate:this.flamebearer.sampleRate,names:this.flamebearer.names,levels:this.flamebearer.levels,spyName:this.flamebearer.spyName,units:this.flamebearer.units,maxSelf:this.flamebearer.maxSelf,rangeMin:n,rangeMax:r,fitMode:this.fitMode,highlightQuery:s,zoom:this.zoom,focusedNode:this.focusedNode,pxPerTick:a,tickToX:e=>(e-this.flamebearer.numTicks*n)*a,palette:this.palette,messages:this.messages,renderRects:null==e?void 0:e.renderRects,renderText:null==e?void 0:e.renderText,renderMode:null==e?void 0:e.renderMode,levelStart:null==e?void 0:e.levelStart,levelEnd:null==e?void 0:e.levelEnd,startI:null==e?void 0:e.startI,startJ:null==e?void 0:e.startJ,timeBudgetMs:null==e?void 0:e.timeBudgetMs,skipCanvasResize:null==e?void 0:e.skipCanvasResize,skipDprScale:null==e?void 0:e.skipDprScale,devicePixelRatio:null==e?void 0:e.devicePixelRatio},{format:o}=this.flamebearer;switch(o){case"single":return Kr({...i,format:"single"});case"double":return Kr({...i,leftTicks:this.flamebearer.leftTicks,rightTicks:this.flamebearer.rightTicks});default:throw new Error(`Invalid format: '${o}'`)}}pxPerTick(){if(null!==this.cachedPxPerTick)return this.cachedPxPerTick;const{rangeMin:e,rangeMax:t}=this.getRange(),n=this.getCanvasWidth()/this.flamebearer.numTicks/(t-e);return this.cachedRange={rangeMin:e,rangeMax:t},this.cachedPxPerTick=n,n}updateCachedMetrics(){const{rangeMin:e,rangeMax:t}=this.getRange(),n=this.getCanvasWidth()/this.flamebearer.numTicks/(t-e);return this.cachedRange={rangeMin:e,rangeMax:t},this.cachedPxPerTick=n,{rangeMin:e,rangeMax:t,pxPerTick:n}}getRange(){const{ff:e}=this,t=t=>{const n=this.flamebearer.levels[t.i];if(!n)throw new Error(`Could not find level: '${t.i}'`);return{rangeMin:e.getBarOffset(n,t.j)/this.flamebearer.numTicks,rangeMax:(e.getBarOffset(n,t.j)+e.getBarTotal(n,t.j))/this.flamebearer.numTicks}},n=t=>{const n=this.flamebearer.levels[t.i];if(!n)throw new Error(`Could not find level: '${t.i}'`);return{rangeMin:e.getBarOffset(n,t.j)/this.flamebearer.numTicks,rangeMax:(e.getBarOffset(n,t.j)+e.getBarTotal(n,t.j))/this.flamebearer.numTicks}},{zoom:r,focusedNode:a}=this;return r.match({Just:e=>a.match({Just:r=>{const a=n(r),s=t(e);return a.rangeMax-a.rangeMin<s.rangeMax-s.rangeMin?(console.warn("Focus is smaller than range, this shouldnt happen. Verify that the zoom is always bigger than the focus."),n(r)):t(e)},Nothing:()=>t(e)}),Nothing:()=>a.match({Just:e=>n(e),Nothing:()=>({rangeMin:0,rangeMax:1})})})}getCanvasWidth(){return"clientWidth"in this.canvas&&"number"==typeof this.canvas.clientWidth?this.canvas.clientWidth:this.canvas.width}isFocused(){return this.focusedNode.isJust}binarySearchLevel(e,t){const{ff:n}=this;let r=0,a=t.length-n.jStep;for(;r<=a;){const s=n.jStep*(r/n.jStep+a/n.jStep>>1),i=this.tickToX(n.getBarOffset(t,s)),o=this.tickToX(n.getBarOffset(t,s)+n.getBarTotal(t,s));if(i<=e&&o>=e)return o-i>5?s:-1;i>e?a=s-n.jStep:r=s+n.jStep}return-1}xyToBarIndex(e,t){if(e<0||t<0)throw new Error(`x and y must be bigger than 0. x = ${e}, y = ${t}`);if(this.isFocused()&&t<=Yt)return{i:0,j:0};const n=this.isFocused()?t-Yt:t,r=this.focusedNode.mapOrElse(()=>0,e=>e.i<=0?0:e.i),a=this.zoom.match({Just:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0}),Nothing:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0})}),s=Math.floor(n/Gt)+a;if(s>=0&&s<this.flamebearer.levels.length){const t=this.flamebearer.levels[s];if(!t)throw new Error(`Could not find level: '${s}'`);return{i:s,j:this.binarySearchLevel(e,t)}}return{i:0,j:0}}parseXY(e,t){const n={x:e,y:t};return this.isWithinBounds(e,t)?Q.of(n):Q.nothing()}xyToBar(e,t){return this.parseXY(e,t).map(n=>{const{i:r,j:a}=this.xyToBarIndex(e,t);return{i:r,j:a,...this.xyToBarPosition(n),...this.xyToBarData(n)}})}}const Yr={rectCanvas:null,textCanvas:null,renderState:{rect:{token:0,running:!1,nextI:0,nextJ:0,firstChunk:!0,payload:null,flamegraph:null},text:{token:0,running:!1,nextI:0,nextJ:0,firstChunk:!0,payload:null,flamegraph:null}}},ea={initLogged:{rect:!1,text:!1},renderLogged:{rect:!1,text:!1}},ta=(e,t)=>{try{console.error("[flamegraph-worker] error",t,e)}catch{}},na=e=>e?Q.just(e):Q.nothing(),ra=(e,t)=>{try{const n=Yr.renderState[e],r=n.payload;if(!r||n.token!==t)return;const a="rect"===e?Yr.rectCanvas:Yr.textCanvas;if(!a)return void(n.running=!1);n.flamegraph||(n.flamegraph=new Gr(r.flamebearer,a,na(r.focusedNode),r.fitMode,r.highlightQuery,na(r.zoom),(e=>({name:e.name,goodColor:w.rgb(...e.goodColor),neutralColor:w.rgb(...e.neutralColor),badColor:w.rgb(...e.badColor),colors:e.colors.map(e=>w.rgb(...e))}))(r.palette),r.messages));const s=n.flamegraph.render({renderRects:r.renderRects,renderText:r.renderText,timeBudgetMs:"rect"===e?12:8,startI:n.nextI,startJ:n.nextJ,skipCanvasResize:!n.firstChunk,skipDprScale:!n.firstChunk,devicePixelRatio:r.devicePixelRatio});if(n.firstChunk=!1,!s.done)return n.nextI=s.nextI,n.nextJ=s.nextJ,void setTimeout(()=>ra(e,t),0);n.running=!1,n.nextI=0,n.nextJ=0,n.firstChunk=!0,n.flamegraph=null}catch(t){console.error("[flamegraph-worker] render error",t);const n=Yr.renderState[e];n.running=!1,n.nextI=0,n.nextJ=0,n.firstChunk=!0,n.flamegraph=null}};self.onmessage=e=>{const t=e.data;if(t&&t.type)return"init"===t.type?(ea.initLogged[t.payload.kind]||(ea.initLogged[t.payload.kind]=!0),void("rect"===t.payload.kind?Yr.rectCanvas=t.payload.canvas:Yr.textCanvas=t.payload.canvas)):void("render"===t.type&&(e=>{const t="rect"===e.kind?Yr.rectCanvas:Yr.textCanvas;if(!t)return;e.width>0&&(t.width=e.width),ea.renderLogged[e.kind]||(ea.renderLogged[e.kind]=!0);const n=Yr.renderState[e.kind];n.token+=1,n.running=!0,n.nextI=0,n.nextJ=0,n.firstChunk=!0,n.payload=e,n.flamegraph=null;const r=n.token;setTimeout(()=>ra(e.kind,r),0)})(t.payload))},self.onerror=e=>{ta(e,"self.error")},self.onmessageerror=e=>{ta(e,"self.messageerror")},self.addEventListener("unhandledrejection",e=>{ta(null==e?void 0:e.reason,"self.unhandledrejection")});
|
|
2
2
|
//# sourceMappingURL=flamegraphRenderWorker.js.map
|