@kylincloud/flamegraph 0.36.1 → 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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.36.3](/compare/v0.36.2...v0.36.3) (2026-01-30)
4
+
5
+
6
+ ### Bug Fixes | Bug 修复
7
+
8
+ * 修复web worker在生产环境无法使用的问题 a26e4f08
9
+
10
+ ## [0.36.2](/compare/v0.36.1...v0.36.2) (2026-01-29)
11
+
12
+
13
+ ### Bug Fixes | Bug 修复
14
+
15
+ * 修复表格搜索闪烁和回弹 6d887403
16
+ * 修复部分map警告 ea050a1f
17
+
3
18
  ## [0.36.1](/compare/v0.36.0...v0.36.1) (2026-01-29)
4
19
 
5
20
 
@@ -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,2CAwiBjE"}
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 e from"color";import{Maybe as t}from"true-myth";import{z as n}from"zod";import{scaleLinear as r}from"d3-scale";const s=["dotnetspy","ebpfspy","gospy","phpspy","pyspy","rbspy","nodespy","javaspy","pyroscope-rs","scrape","tracing","unknown"],i=n.preprocess(e=>e&&s.includes(e)?e:"unknown",n.enum(s).default("unknown")),a=["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions"],o=n.preprocess(e=>"string"==typeof e&&a.includes(e)?e:"unknown",n.enum(["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions","unknown"])),l=n.object({names:n.array(n.preprocess(e=>e||"unknown",n.string().min(1))),levels:n.array(n.array(n.number())),numTicks:n.number(),maxSelf:n.number()}),c=n.object({appName:n.string().optional(),name:n.string().optional(),startTime:n.number().optional(),endTime:n.number().optional(),query:n.string().optional(),maxNodes:n.number().optional(),format:n.enum(["single","double"]),sampleRate:n.number(),spyName:i,units:o});n.object({version:n.number().min(1).max(1).default(1),flamebearer:l,metadata:c,leftTicks:n.number().optional(),rightTicks:n.number().optional()});const u={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]},h={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 f(e){switch(e){case"single":return u;case"double":return h;default:throw new Error(`Unsupported type: '${e}'`)}}const d=n.object({refType:n.string(),traceID:n.string(),spanID:n.string()}),g=n.object({key:n.string(),type:n.string(),value:n.union([n.boolean(),n.number(),n.string()])}),m=n.object({traceID:n.string(),spanID:n.string(),flags:n.string(),operationName:n.string(),references:n.array(d),startTime:n.number(),duration:n.number(),tags:n.array(g),logs:n.object({timestamp:n.number(),fields:n.array(g)}),processID:n.string(),warnings:n.any()}),p=n.object({serviceName:n.string(),tags:n.array(g)});n.object({traceID:n.string(),spans:n.array(m),processes:n.record(p),warnings:n.any()});const x=n.object({watermark:n.object({}).optional(),startTime:n.number(),samples:n.array(n.number()),durationDelta:n.number()});n.record(n.string(),x);const v=22,b=21.5;function y(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 s=r[1]||"",i=r[2],a=(r[3]||"").trim(),o=parseFloat(i);return Number.isFinite(o)?{value:o,unit:a,hasLessThan:n,sign:s}:null}(e);if(!n)return e;const{unit:r}=n;let s=r;const i=r.toLowerCase();"ms"===i?s="毫秒":"μs"===i||"µs"===i||"us"===i?s="微秒":"second"===i||"seconds"===i?s="秒":"minute"===i||"minutes"===i||"min"===i||"mins"===i?s="分钟":"hour"===i||"hours"===i?s="小时":"day"===i||"days"===i?s="天":"month"===i||"months"===i?s="月":"year"!==i&&"years"!==i||(s="年");const a=String(e).match(/^([<\s]*)([+\-]?\d*\.?\d+)(.*)$/);if(!a)return e;return`${a[1]||""}${a[2]||""} ${s}`.trim()}function k(e){return Math.round(1e4*e)/100}class T{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 s=r.toFixed(2);return 0===r?s="0.00":(r>=0&&r<.01||r<=0&&r>-.01)&&(s="< 0.01"),n?`${s} ${this.units||`${this.suffix}${1===r||2===this.suffix.length?"":"s"}`}`:s}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 w{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 C{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 B{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 M({mode:e,charSize:t,rectWidth:n,fullText:r,shortText:s}){if("TAIL"===e){if(t*r.length<=n)return{mode:e,text:r,marginLeft:3};const i=t*s.length;return i<=n?{mode:e,text:s,marginLeft:3}:{mode:e,text:s,marginLeft:-(i-n+3)}}return{mode:e,text:r,marginLeft:3}}function j(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 S(t,n){return e.rgb(t,t,t).alpha(n)}function N(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 $(e,t){const n=function(e,t=0){let n,r,s,i,a,o,l,c;for(n=3&e.length,r=e.length-n,s=t,a=3432918353,o=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295,s^=l,s=s<<13|s>>>19,i=5*(65535&s)+((5*(s>>>16)&65535)<<16)&4294967295,s=27492+(65535&i)+(((i>>>16)+58964&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:l^=255&e.charCodeAt(c);default:l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295,s^=l}return s^=e.length,s^=s>>>16,s=2246822507*(65535&s)+((2246822507*(s>>>16)&65535)<<16)&4294967295,s^=s>>>13,s=3266489909*(65535&s)+((3266489909*(s>>>16)&65535)<<16)&4294967295,s^=s>>>16,s>>>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 P(t){const{goodColor:n,neutralColor:s,badColor:i}=t,a=r().domain([-100,0,100]).range([n.rgb().toString(),s.rgb().toString(),i.rgb().toString()]);return t=>e(a(t).toString())}e.rgb(148,142,142),e.rgb(200,0,0),e.rgb(0,170,0),e("#48CE73");const R=new WeakMap,I=new WeakMap,J=new WeakMap,L=new WeakMap;const O={collapsedLevelsSingular:"total (1 level collapsed)",collapsedLevelsPlural:"total ({n} levels collapsed)",isZh:!1};function E(e){var t,n,r,s,i,a,o,l;const c=performance.now(),u=!1!==e.renderRects,d=!1!==e.renderText,g=null!==(t=e.renderMode)&&void 0!==t?t:"normal",m=e.timeBudgetMs,{canvas:p,fitMode:x,units:y,tickToX:E,levels:z,palette:_}=e,{numTicks:A,sampleRate:Q,pxPerTick:X}=e,{rangeMin:U,rangeMax:G}=e,{focusedNode:Z,zoom:q}=e,H=e.messages||O,K=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=K),U>=G)throw new Error("'rangeMin' should be strictly smaller than 'rangeMax'");const{format:Y}=e,V=f(Y),ee=p.getContext("2d");if(!ee)throw new Error("Could not get ctx");const te=q.mapOrElse(()=>0,e=>e.i),ne=function(e,t,n){switch(n){case"samples":return new T(e/t);case"objects":case"goroutines":case"lock_samples":case"exceptions":return new C(e);case"bytes":return new B(e);case"lock_nanoseconds":return new w(e);case"trace_samples":return new T(e/t,"",!0);default:return console.warn(`Unsupported unit: '${n}'. Defaulting to ''`),new T(e/t," ")}}(A,Q,y),re=Z.isJust,se=Z.mapOrElse(()=>0,e=>e.i),ie=re?b:0,ae=!!e.highlightQuery&&e.highlightQuery.length>0,oe=v*(z.length-se)+(re?b:0);e.skipCanvasResize||(p.height=oe);const le="number"==typeof e.devicePixelRatio?e.devicePixelRatio:"undefined"!=typeof devicePixelRatio?devicePixelRatio:1;!e.skipDprScale&&le>1&&(p.width*=le,p.height*=le,ee.scale(le,le)),ee.textBaseline="middle",ee.font="400 11.5px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace";const ce=ee.measureText("a").width,{names:ue}=e,he=function(e){const t=R.get(e);if(t)return t;const n=new Map;return R.set(e,n),n}(p),fe=ae?function(e,t){const n=I.get(e);if(n){const e=n.get(t);if(e)return e}const r=t.toLowerCase(),s=new Uint8Array(e.length);for(let t=1;t<e.length;t+=1){const n=e[t];n&&n.toLowerCase().includes(r)&&(s[t]=1)}const i=null!=n?n:new Map;return i.set(t,s),I.set(e,i),s}(ue,e.highlightQuery):null,de="single"===e.format?function(e,t,n){const r=`${t}|${n.name}`,s=J.get(e);if(s){const e=s.get(r);if(e)return e}const i=new Array(e.length);for(let r=0;r<e.length;r+=1){const s=N(t,e[r]||"")||"";i[r]=$(n,s)}const a=null!=s?s:new Map;return a.set(r,i),J.set(e,a),i}(ue,e.spyName,_):null,ge="double"===e.format?P({name:_.name,goodColor:_.goodColor,neutralColor:_.neutralColor,badColor:_.badColor}):null,me=(e,t)=>{const n=e[t+V.jName];return!(!n||n<0||!fe)&&1===fe[n]},pe=null!==(n=e.startI)&&void 0!==n?n:0,xe=null!==(r=e.startJ)&&void 0!==r?r:0;if(re&&"highlightOnly"!==g&&0===(null!==(s=e.levelStart)&&void 0!==s?s:0)&&0===pe&&0===xe){const e=A*X;u&&(ee.beginPath(),ee.rect(0,0,A*X,b),ee.fillStyle=S(200,1).rgb().string(),ee.fill());const t=Z.mapOrElse(()=>"total",e=>function(e,t){return 1===e?t.collapsedLevelsSingular:t.collapsedLevelsPlural.replace("{n}",String(e))}(e.i-1,H)),n=M({mode:x,charSize:ce,rectWidth:e,fullText:t,shortText:t}),r=0,s=0,i=b;if(d){ee.beginPath(),ee.rect(0,0,e,b),ee.save(),ee.clip(),ee.fillStyle="black";const t=Math.round(Math.max(r,0));ee.fillText(n.text,t+n.marginLeft,s+i/2+1),ee.restore()}}const ve=Math.max(0,null!==(i=e.levelStart)&&void 0!==i?i:0),be=z.length-se,ye=Math.min(be,null!==(a=e.levelEnd)&&void 0!==a?a:be),ke=Math.max(ve,null!==(o=e.startI)&&void 0!==o?o:ve),Te=Math.max(0,null!==(l=e.startJ)&&void 0!==l?l:0),{spyName:we}=e,Ce=(t,n,r,s,i)=>{const a={level:t,j:n,i:r+Z.mapOrElse(()=>0,e=>e.i),names:ue,collapsed:s,selectedLevel:te,highlightModeOn:ae,isHighlighted:i,spyName:we,palette:_,colorByNameIndex:de,diffColorFn:ge};switch(Y){case"single":return function(e){const t=W(e);if(t)return t;const n=f("single"),r=e.selectedLevel>e.i?.33:1;let s=e.level[e.j+n.jName];void 0===s&&(console.warn("Could nto find level",{l:e.j,jName:n.jName,level:e.level}),s=-1);if(e.colorByNameIndex&&s>=0&&e.colorByNameIndex[s])return e.colorByNameIndex[s].alpha(r);const i=e.names[s]||"",a=N(e.spyName,i)||"";return $(e.palette,a).alpha(r)}({...a});case"double":return function(e){const t=W(e);if(t)return t;const n=e.selectedLevel>e.i?.33:1,{leftRatio:r,rightRatio:s}=function(e,t,n,r){const s=h;return n&&r?{leftRatio:s.getBarTotalLeft(e,t)/n,rightRatio:s.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),i=k(r),a=k(s);if(e.diffColorFn)return e.diffColorFn(j(i,a)).alpha(n);return function(e,t,n){const r=j(t,n);return P(e)(r)}(e.palette,i,a).alpha(n)}({...a,leftTicks:e.leftTicks,rightTicks:e.rightTicks});default:throw new Error(`Unsupported format: ${Y}`)}};if("highlightOnly"===g&&ae&&u){const e=function(e,t){const n=L.get(e);if(n)return n;const r=f(t),s=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 i=r.getBarName(n,e);if(void 0===i||i<0)continue;const a=s.get(i);a?a.push({i:t,j:e}):s.set(i,[{i:t,j:e}])}}return L.set(e,s),s}(z,Y),t=[];for(let e=1;e<ue.length;e+=1)fe&&1===fe[e]&&t.push(e);for(let n=0;n<t.length;n+=1){const r=t[n],s=e.get(r);if(s)for(let e=0;e<s.length;e+=1){const t=s[e],n=t.i-se;if(t.i<se||n<ve||n>=ye)continue;const r=z[t.i],i=E(V.getBarOffset(r,t.j)),a=n*v+ie,o=b,l=V.getBarTotal(r,t.j),c=l*X<=5,u=l*X-(c?0:.5);if(u<=0)continue;ee.beginPath(),ee.rect(i,a,u,o);const h=Ce(r,t.j,n,c,!0);ee.fillStyle=h.string(),ee.fill()}}return{done:!0,nextI:ye,nextJ:0}}for(let e=ke;e<ye;e+=1){const t=z[se+e];if(!t)throw new Error(`Could not find level: ${se+e}`);let n=e===ke?Te:0;for(;n<t.length;n+=V.jStep){const r=V.getBarOffset(t,n),s=E(r),i=e*v+ie,a=b,o=ae&&me(t,n);let l=V.getBarTotal(t,n);const h=l*X<=5;if(h)for(;n<t.length-V.jStep&&r+l===V.getBarOffset(t,n+V.jStep)&&V.getBarTotal(t,n+V.jStep)*X<=5&&o===(ae&&me(t,n+V.jStep));)n+=V.jStep,l+=V.getBarTotal(t,n);const f=l*X-(h?0:.5);if(ee.beginPath(),ee.rect(s,i,f,a),u){if("forceGrey"===g)ee.fillStyle=S(200,.66).rgb().string();else{const r=Ce(t,n,e,h,o);ee.fillStyle=r.string()}ee.fill()}if(!d||h||"forceGrey"===g){if(m&&performance.now()-c>m)return{done:!1,nextI:e,nextJ:n+V.jStep};continue}if(f<20)continue;const p=F(ue,n,Y,t),y=M({mode:x,charSize:ce,rectWidth:f,fullText:D(p,l,Q,ne,H,he),shortText:p});ee.save(),ee.clip(),ee.fillStyle="black";const k=Math.round(Math.max(s,0));if(ee.fillText(y.text,k+y.marginLeft,i+a/2+1),ee.restore(),m&&performance.now()-c>m)return{done:!1,nextI:e,nextJ:n+V.jStep}}if(m&&performance.now()-c>m)return{done:!1,nextI:e+1,nextJ:0}}return{done:!0,nextI:ye,nextJ:0}}function F(e,t,n,r){let s=r[t+f(n).jName];void 0===s&&(s=-1);const i=e[s];return i||(console.warn("Could not find function name for",{j:t,format:n,level:r,names:e}),"")}function D(e,t,n,r,s,i){let a=null==i?void 0:i.get(t);if(!a){const e=r.format(t,n);a=y(e,!!s.isZh)||e,null==i||i.set(t,a)}return`${e} (${a})`}function W({collapsed:e,highlightModeOn:t,isHighlighted:n}){return e||t&&!n?S(200,.66):null}class z{constructor(e,t,n,r,s,i,a,o){if(this.flamebearer=e,this.canvas=t,this.focusedNode=n,this.fitMode=r,this.highlightQuery=s,this.zoom=i,this.palette=a,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),s=this.focusedNode.mapOrElse(()=>0,e=>e.i<0?0:e.i-1),i=this.flamebearer.levels[n];if(!i)throw new Error(`Could not find level: '${n}'`);const a=Math.max(this.tickToX(t.getBarOffset(i,r)),0);return{x:a,y:Math.max((n-s)*v,0),width:Math.min(this.tickToX(t.getBarOffset(i,r)+t.getBarTotal(i,r))-a,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=u;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=h;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=i,this.focusedNode=n,this.flamebearer=e,this.canvas=t,this.highlightQuery=s,this.ff=f(e.format),this.palette=a,this.messages=o,n.isJust&&i.isJust&&i.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:s}=this.updateCachedMetrics(),i=null!==(t=null==e?void 0:e.highlightQueryOverride)&&void 0!==t?t:this.highlightQuery,a={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:i,zoom:this.zoom,focusedNode:this.focusedNode,pxPerTick:s,tickToX:e=>(e-this.flamebearer.numTicks*n)*s,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 E({...a,format:"single"});case"double":return E({...a,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:s}=this;return r.match({Just:e=>s.match({Just:r=>{const s=n(r),i=t(e);return s.rangeMax-s.rangeMin<i.rangeMax-i.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:()=>s.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,s=t.length-n.jStep;for(;r<=s;){const i=n.jStep*(r/n.jStep+s/n.jStep>>1),a=this.tickToX(n.getBarOffset(t,i)),o=this.tickToX(n.getBarOffset(t,i)+n.getBarTotal(t,i));if(a<=e&&o>=e)return o-a>5?i:-1;a>e?s=i-n.jStep:r=i+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<=b)return{i:0,j:0};const n=this.isFocused()?t-b:t,r=this.focusedNode.mapOrElse(()=>0,e=>e.i<=0?0:e.i),s=this.zoom.match({Just:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0}),Nothing:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0})}),i=Math.floor(n/v)+s;if(i>=0&&i<this.flamebearer.levels.length){const t=this.flamebearer.levels[i];if(!t)throw new Error(`Could not find level: '${i}'`);return{i:i,j:this.binarySearchLevel(e,t)}}return{i:0,j:0}}parseXY(e,n){const r={x:e,y:n};return this.isWithinBounds(e,n)?t.of(r):t.nothing()}xyToBar(e,t){return this.parseXY(e,t).map(n=>{const{i:r,j:s}=this.xyToBarIndex(e,t);return{i:r,j:s,...this.xyToBarPosition(n),...this.xyToBarData(n)}})}}const _={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}}},A=e=>e?t.just(e):t.nothing(),Q=(t,n)=>{const r=_.renderState[t],s=r.payload;if(!s||r.token!==n)return;const i="rect"===t?_.rectCanvas:_.textCanvas;if(!i)return void(r.running=!1);r.flamegraph||(r.flamegraph=new z(s.flamebearer,i,A(s.focusedNode),s.fitMode,s.highlightQuery,A(s.zoom),(t=>({name:t.name,goodColor:e.rgb(...t.goodColor),neutralColor:e.rgb(...t.neutralColor),badColor:e.rgb(...t.badColor),colors:t.colors.map(t=>e.rgb(...t))}))(s.palette),s.messages));const a=r.flamegraph.render({renderRects:s.renderRects,renderText:s.renderText,timeBudgetMs:"rect"===t?12:8,startI:r.nextI,startJ:r.nextJ,skipCanvasResize:!r.firstChunk,skipDprScale:!r.firstChunk,devicePixelRatio:s.devicePixelRatio});if(r.firstChunk=!1,!a.done)return r.nextI=a.nextI,r.nextJ=a.nextJ,void setTimeout(()=>Q(t,n),0);r.running=!1,r.nextI=0,r.nextJ=0,r.firstChunk=!0,r.flamegraph=null};self.onmessage=e=>{const t=e.data;t&&t.type&&("init"!==t.type?"render"===t.type&&(e=>{const t="rect"===e.kind?_.rectCanvas:_.textCanvas;if(!t)return;e.width>0&&(t.width=e.width);const n=_.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(()=>Q(e.kind,r),0)})(t.payload):"rect"===t.payload.kind?_.rectCanvas=t.payload.canvas:_.textCanvas=t.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