@biongff/vizarr 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/biongff-vizarr.cjs.js +1 -1
- package/dist/biongff-vizarr.es.js +1 -1
- package/dist/{deflate-Q4iCMMBa.js → deflate-B6UWtjyo.js} +1 -1
- package/dist/{deflate-DzrO3E-1.cjs → deflate-D4fVjT8X.cjs} +1 -1
- package/dist/{index-Ckhcz4QQ.cjs → index-BgZ4M3d8.cjs} +3 -3
- package/dist/{index-3CiumG5V.js → index-CGjf_l_H.js} +9 -9
- package/dist/{jpeg-DFzBPcur.cjs → jpeg-B4oirkAG.cjs} +1 -1
- package/dist/{jpeg-BdEIe3QG.js → jpeg-CH3LeEWt.js} +1 -1
- package/dist/{lerc-35FtXNGP.cjs → lerc-BYe2-QJc.cjs} +1 -1
- package/dist/{lerc-B6qlOBE2.js → lerc-DLV5-j0k.js} +1 -1
- package/dist/{lzw-CeXp5T9s.js → lzw-CdTlawLU.js} +1 -1
- package/dist/{lzw-DnHvgKbO.cjs → lzw-DOv7FpJp.cjs} +1 -1
- package/dist/{packbits-CAZoMCQq.js → packbits-C7gCMjHU.js} +1 -1
- package/dist/{packbits-DwdUAwAt.cjs → packbits-YFbkocqj.cjs} +1 -1
- package/dist/{raw-oTi55tWo.js → raw-Cd_Yrlnj.js} +1 -1
- package/dist/{raw-BB450wdT.cjs → raw-GJmfvqqS.cjs} +1 -1
- package/dist/{ref-CIxavIn6.cjs → ref-B0_Wl0Bd.cjs} +1 -1
- package/dist/{ref-Bd0nPTvp.js → ref-D7n2xWdV.js} +1 -1
- package/dist/{webimage-CKRNzqyG.js → webimage-D2mauvJo.js} +1 -1
- package/dist/{webimage-66a9vFf5.cjs → webimage-DACySx-6.cjs} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var vE=Object.defineProperty;var R_=n=>{throw TypeError(n)};var xE=(n,e,t)=>e in n?vE(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>xE(n,typeof e!="symbol"?e+"":e,t),gd=(n,e,t)=>e.has(n)||R_("Cannot "+t);var le=(n,e,t)=>(gd(n,e,"read from private field"),t?t.call(n):e.get(n)),Ge=(n,e,t)=>e.has(n)?R_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Be=(n,e,t,r)=>(gd(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),dt=(n,e,t)=>(gd(n,e,"access private method"),t);var _d=(n,e,t,r)=>({set _(s){Be(n,e,s,t)},get _(){return le(n,e,r)}});const ae=require("react"),he=require("@mui/material"),bn=require("@mui/icons-material"),bE=require("@emotion/styled"),xg=require("@emotion/react"),Eo=require("react-dom");function wE(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}function TE(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const xe=wE(ae),SE="1.3.
|
|
1
|
+
"use strict";var vE=Object.defineProperty;var R_=n=>{throw TypeError(n)};var xE=(n,e,t)=>e in n?vE(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>xE(n,typeof e!="symbol"?e+"":e,t),gd=(n,e,t)=>e.has(n)||R_("Cannot "+t);var le=(n,e,t)=>(gd(n,e,"read from private field"),t?t.call(n):e.get(n)),Ge=(n,e,t)=>e.has(n)?R_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Be=(n,e,t,r)=>(gd(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),dt=(n,e,t)=>(gd(n,e,"access private method"),t);var _d=(n,e,t,r)=>({set _(s){Be(n,e,s,t)},get _(){return le(n,e,r)}});const ae=require("react"),he=require("@mui/material"),bn=require("@mui/icons-material"),bE=require("@emotion/styled"),xg=require("@emotion/react"),Eo=require("react-dom");function wE(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}function TE(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const xe=wE(ae),SE="1.3.1",yc={black:"#000",white:"#fff"},to={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},no={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ro={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},so={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},io={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"},Ta={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Np={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"};function Fs(n,...e){const t=new URL(`https://mui.com/production-error/?code=${n}`);return e.forEach(r=>t.searchParams.append("args[]",r)),`Minified MUI error #${n}; visit ${t} for the full message.`}const Os="$$material";function EE(n){for(var e=0,t,r=0,s=n.length;s>=4;++r,s-=4)t=n.charCodeAt(r)&255|(n.charCodeAt(++r)&255)<<8|(n.charCodeAt(++r)&255)<<16|(n.charCodeAt(++r)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,e=(t&65535)*1540483477+((t>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(s){case 3:e^=(n.charCodeAt(r+2)&255)<<16;case 2:e^=(n.charCodeAt(r+1)&255)<<8;case 1:e^=n.charCodeAt(r)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var AE={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function CE(n){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=n(t)),e[t]}}var RE=/[A-Z]|^ms/g,IE=/_EMO_([^_]+?)_([^]*?)_EMO_/g,_1=function(e){return e.charCodeAt(1)===45},I_=function(e){return e!=null&&typeof e!="boolean"},yd=CE(function(n){return _1(n)?n:n.replace(RE,"-$&").toLowerCase()}),P_=function(e,t){switch(e){case"animation":case"animationName":if(typeof t=="string")return t.replace(IE,function(r,s,i){return Cs={name:s,styles:i,next:Cs},s})}return AE[e]!==1&&!_1(e)&&typeof t=="number"&&t!==0?t+"px":t};function Zu(n,e,t){if(t==null)return"";var r=t;if(r.__emotion_styles!==void 0)return r;switch(typeof t){case"boolean":return"";case"object":{var s=t;if(s.anim===1)return Cs={name:s.name,styles:s.styles,next:Cs},s.name;var i=t;if(i.styles!==void 0){var o=i.next;if(o!==void 0)for(;o!==void 0;)Cs={name:o.name,styles:o.styles,next:Cs},o=o.next;var a=i.styles+";";return a}return PE(n,e,t)}}var c=t;return c}function PE(n,e,t){var r="";if(Array.isArray(t))for(var s=0;s<t.length;s++)r+=Zu(n,e,t[s])+";";else for(var i in t){var o=t[i];if(typeof o!="object"){var a=o;I_(a)&&(r+=yd(i)+":"+P_(i,a)+";")}else if(Array.isArray(o)&&typeof o[0]=="string"&&e==null)for(var c=0;c<o.length;c++)I_(o[c])&&(r+=yd(i)+":"+P_(i,o[c])+";");else{var l=Zu(n,e,o);switch(i){case"animation":case"animationName":{r+=yd(i)+":"+l+";";break}default:r+=i+"{"+l+"}"}}}return r}var k_=/label:\s*([^\s;{]+)\s*(;|$)/g,Cs;function kE(n,e,t){if(n.length===1&&typeof n[0]=="object"&&n[0]!==null&&n[0].styles!==void 0)return n[0];var r=!0,s="";Cs=void 0;var i=n[0];if(i==null||i.raw===void 0)r=!1,s+=Zu(t,e,i);else{var o=i;s+=o[0]}for(var a=1;a<n.length;a++)if(s+=Zu(t,e,n[a]),r){var c=i;s+=c[a]}k_.lastIndex=0;for(var l="",u;(u=k_.exec(s))!==null;)l+="-"+u[1];var f=EE(s)+l;return{name:f,styles:s,next:Cs}}function cl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var $l={exports:{}},Vl={exports:{}},at={};/** @license React v16.13.1
|
|
2
2
|
* react-is.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -132,7 +132,7 @@ theme.transitions = createTransitions(theme.transitions || {});
|
|
|
132
132
|
|
|
133
133
|
export default theme;`}function dy(n){return typeof n=="number"?`${(n*100).toFixed(0)}%`:`calc((${n}) * 100%)`}const Q4=n=>{if(!Number.isNaN(+n))return+n;const e=n.match(/\d*\.?\d+/g);if(!e)return 0;let t=0;for(let r=0;r<e.length;r+=1)t+=+e[r];return t};function eC(n){Object.assign(n,{alpha(e,t){const r=this||n;return r.colorSpace?`oklch(from ${e} l c h / ${typeof t=="string"?`calc(${t})`:t})`:r.vars?`rgba(${e.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof t=="string"?`calc(${t})`:t})`:P1(e,Q4(t))},lighten(e,t){const r=this||n;return r.colorSpace?`color-mix(in ${r.colorSpace}, ${e}, #fff ${dy(t)})`:kh(e,t)},darken(e,t){const r=this||n;return r.colorSpace?`color-mix(in ${r.colorSpace}, ${e}, #000 ${dy(t)})`:Ph(e,t)}})}function Fp(n={},...e){const{breakpoints:t,mixins:r={},spacing:s,palette:i={},transitions:o={},typography:a={},shape:c,colorSpace:l,...u}=n;if(n.vars&&n.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Fs(20));const f=Mg({...i,colorSpace:l}),h=Ag(n);let d=On(h,{mixins:V4(h.breakpoints,r),palette:f,shadows:Z4.slice(),typography:B1(f,a),transitions:K4(o),zIndex:{...G4}});if(d=On(d,u),d=e.reduce((m,p)=>On(m,p),d),process.env.NODE_ENV!=="production"){const m=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],p=(_,y)=>{let T;for(T in _){const b=_[T];if(m.includes(T)&&Object.keys(b).length>0){if(process.env.NODE_ENV!=="production"){const w=qA("",T);console.error([`MUI: The \`${y}\` component increases the CSS specificity of the \`${T}\` internal state.`,"You can not override it like this: ",JSON.stringify(_,null,2),"",`Instead, you need to use the '&.${w}' syntax:`,JSON.stringify({root:{[`&.${w}`]:b}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
134
134
|
`))}_[T]={}}}};Object.keys(d.components).forEach(_=>{const y=d.components[_].styleOverrides;y&&_.startsWith("Mui")&&p(y,_)})}return d.unstable_sxConfig={...Rh,...u==null?void 0:u.unstable_sxConfig},d.unstable_sx=function(p){return Ci({sx:p,theme:this})},d.toRuntimeSource=U1,eC(d),d}function tC(n){let e;return n<1?e=5.11916*n**2:e=4.5*Math.log(n+1)+2,Math.round(e*10)/1e3}const nC=[...Array(25)].map((n,e)=>{if(e===0)return"none";const t=tC(e);return`linear-gradient(rgba(255 255 255 / ${t}), rgba(255 255 255 / ${t}))`});function $1(n){return{inputPlaceholder:n==="dark"?.5:.42,inputUnderline:n==="dark"?.7:.42,switchTrackDisabled:n==="dark"?.2:.12,switchTrack:n==="dark"?.3:.38}}function V1(n){return n==="dark"?nC:[]}function rC(n){const{palette:e={mode:"light"},opacity:t,overlays:r,colorSpace:s,...i}=n,o=Mg({...e,colorSpace:s});return{palette:o,opacity:{...$1(o.mode),...t},overlays:r||V1(o.mode),...i}}function sC(n){var e;return!!n[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!n[0].match(/sxConfig$/)||n[0]==="palette"&&!!((e=n[1])!=null&&e.match(/(mode|contrastThreshold|tonalOffset)/))}const iC=n=>[...[...Array(25)].map((e,t)=>`--${n?`${n}-`:""}overlays-${t}`),`--${n?`${n}-`:""}palette-AppBar-darkBg`,`--${n?`${n}-`:""}palette-AppBar-darkColor`],oC=n=>(e,t)=>{const r=n.rootSelector||":root",s=n.colorSchemeSelector;let i=s;if(s==="class"&&(i=".%s"),s==="data"&&(i="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(i=`[${s}="%s"]`),n.defaultColorScheme===e){if(e==="dark"){const o={};return iC(n.cssVarPrefix).forEach(a=>{o[a]=t[a],delete t[a]}),i==="media"?{[r]:t,"@media (prefers-color-scheme: dark)":{[r]:o}}:i?{[i.replace("%s",e)]:o,[`${r}, ${i.replace("%s",e)}`]:t}:{[r]:{...t,...o}}}if(i&&i!=="media")return`${r}, ${i.replace("%s",String(e))}`}else if(e){if(i==="media")return{[`@media (prefers-color-scheme: ${String(e)})`]:{[r]:t}};if(i)return i.replace("%s",String(e))}return r};function aC(n,e){e.forEach(t=>{n[t]||(n[t]={})})}function se(n,e,t){!n[e]&&t&&(n[e]=t)}function Va(n){return typeof n!="string"||!n.startsWith("hsl")?n:I1(n)}function Lr(n,e){`${e}Channel`in n||(n[`${e}Channel`]=$a(Va(n[e]),`MUI: Can't create \`palette.${e}Channel\` because \`palette.${e}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
|
|
135
|
-
To suppress this warning, you need to explicitly provide the \`palette.${e}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function cC(n){return typeof n=="number"?`${n}px`:typeof n=="string"||typeof n=="function"||Array.isArray(n)?n:"8px"}const hr=n=>{try{return n()}catch{}},lC=(n="mui")=>R4(n);function Id(n,e,t,r,s){if(!t)return;t=t===!0?{}:t;const i=s==="dark"?"dark":"light";if(!r){e[s]=rC({...t,palette:{mode:i,...t==null?void 0:t.palette},colorSpace:n});return}const{palette:o,...a}=Fp({...r,palette:{mode:i,...t==null?void 0:t.palette},colorSpace:n});return e[s]={...t,palette:o,opacity:{...$1(i),...t==null?void 0:t.opacity},overlays:(t==null?void 0:t.overlays)||V1(i)},a}function uC(n={},...e){const{colorSchemes:t={light:!0},defaultColorScheme:r,disableCssColorScheme:s=!1,cssVarPrefix:i="mui",nativeColor:o=!1,shouldSkipGeneratingVar:a=sC,colorSchemeSelector:c=t.light&&t.dark?"media":void 0,rootSelector:l=":root",...u}=n,f=Object.keys(t)[0],h=r||(t.light&&f!=="light"?"light":f),d=lC(i),{[h]:m,light:p,dark:_,...y}=t,T={...y};let b=m;if((h==="dark"&&!("dark"in t)||h==="light"&&!("light"in t))&&(b=!0),!b)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${h}\` option is either missing or invalid.`:Fs(21,h));let w;o&&(w="oklch");const v=Id(w,T,b,u,h);p&&!T.light&&Id(w,T,p,void 0,"light"),_&&!T.dark&&Id(w,T,_,void 0,"dark");let A={defaultColorScheme:h,...v,cssVarPrefix:i,colorSchemeSelector:c,rootSelector:l,getCssVar:d,colorSchemes:T,font:{...$4(v.typography),...v.font},spacing:cC(u.spacing)};Object.keys(A.colorSchemes).forEach(Q=>{const E=A.colorSchemes[Q].palette,J=ce=>{const k=ce.split("-"),z=k[1],$=k[2];return d(ce,E[z][$])};E.mode==="light"&&(se(E.common,"background","#fff"),se(E.common,"onBackground","#000")),E.mode==="dark"&&(se(E.common,"background","#000"),se(E.common,"onBackground","#fff"));function X(ce,k,z){if(w){let $;return ce===ni&&($=`transparent ${((1-z)*100).toFixed(0)}%`),ce===ut&&($=`#000 ${(z*100).toFixed(0)}%`),ce===ft&&($=`#fff ${(z*100).toFixed(0)}%`),`color-mix(in ${w}, ${k}, ${$})`}return ce(k,z)}if(aC(E,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),E.mode==="light"){se(E.Alert,"errorColor",X(ut,E.error.light,.6)),se(E.Alert,"infoColor",X(ut,E.info.light,.6)),se(E.Alert,"successColor",X(ut,E.success.light,.6)),se(E.Alert,"warningColor",X(ut,E.warning.light,.6)),se(E.Alert,"errorFilledBg",J("palette-error-main")),se(E.Alert,"infoFilledBg",J("palette-info-main")),se(E.Alert,"successFilledBg",J("palette-success-main")),se(E.Alert,"warningFilledBg",J("palette-warning-main")),se(E.Alert,"errorFilledColor",hr(()=>E.getContrastText(E.error.main))),se(E.Alert,"infoFilledColor",hr(()=>E.getContrastText(E.info.main))),se(E.Alert,"successFilledColor",hr(()=>E.getContrastText(E.success.main))),se(E.Alert,"warningFilledColor",hr(()=>E.getContrastText(E.warning.main))),se(E.Alert,"errorStandardBg",X(ft,E.error.light,.9)),se(E.Alert,"infoStandardBg",X(ft,E.info.light,.9)),se(E.Alert,"successStandardBg",X(ft,E.success.light,.9)),se(E.Alert,"warningStandardBg",X(ft,E.warning.light,.9)),se(E.Alert,"errorIconColor",J("palette-error-main")),se(E.Alert,"infoIconColor",J("palette-info-main")),se(E.Alert,"successIconColor",J("palette-success-main")),se(E.Alert,"warningIconColor",J("palette-warning-main")),se(E.AppBar,"defaultBg",J("palette-grey-100")),se(E.Avatar,"defaultBg",J("palette-grey-400")),se(E.Button,"inheritContainedBg",J("palette-grey-300")),se(E.Button,"inheritContainedHoverBg",J("palette-grey-A100")),se(E.Chip,"defaultBorder",J("palette-grey-400")),se(E.Chip,"defaultAvatarColor",J("palette-grey-700")),se(E.Chip,"defaultIconColor",J("palette-grey-700")),se(E.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),se(E.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),se(E.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),se(E.LinearProgress,"primaryBg",X(ft,E.primary.main,.62)),se(E.LinearProgress,"secondaryBg",X(ft,E.secondary.main,.62)),se(E.LinearProgress,"errorBg",X(ft,E.error.main,.62)),se(E.LinearProgress,"infoBg",X(ft,E.info.main,.62)),se(E.LinearProgress,"successBg",X(ft,E.success.main,.62)),se(E.LinearProgress,"warningBg",X(ft,E.warning.main,.62)),se(E.Skeleton,"bg",w?X(ni,E.text.primary,.11):`rgba(${J("palette-text-primaryChannel")} / 0.11)`),se(E.Slider,"primaryTrack",X(ft,E.primary.main,.62)),se(E.Slider,"secondaryTrack",X(ft,E.secondary.main,.62)),se(E.Slider,"errorTrack",X(ft,E.error.main,.62)),se(E.Slider,"infoTrack",X(ft,E.info.main,.62)),se(E.Slider,"successTrack",X(ft,E.success.main,.62)),se(E.Slider,"warningTrack",X(ft,E.warning.main,.62));const ce=w?X(ut,E.background.default,.6825):Wl(E.background.default,.8);se(E.SnackbarContent,"bg",ce),se(E.SnackbarContent,"color",hr(()=>w?Lp.text.primary:E.getContrastText(ce))),se(E.SpeedDialAction,"fabHoverBg",Wl(E.background.paper,.15)),se(E.StepConnector,"border",J("palette-grey-400")),se(E.StepContent,"border",J("palette-grey-400")),se(E.Switch,"defaultColor",J("palette-common-white")),se(E.Switch,"defaultDisabledColor",J("palette-grey-100")),se(E.Switch,"primaryDisabledColor",X(ft,E.primary.main,.62)),se(E.Switch,"secondaryDisabledColor",X(ft,E.secondary.main,.62)),se(E.Switch,"errorDisabledColor",X(ft,E.error.main,.62)),se(E.Switch,"infoDisabledColor",X(ft,E.info.main,.62)),se(E.Switch,"successDisabledColor",X(ft,E.success.main,.62)),se(E.Switch,"warningDisabledColor",X(ft,E.warning.main,.62)),se(E.TableCell,"border",X(ft,X(ni,E.divider,1),.88)),se(E.Tooltip,"bg",X(ni,E.grey[700],.92))}if(E.mode==="dark"){se(E.Alert,"errorColor",X(ft,E.error.light,.6)),se(E.Alert,"infoColor",X(ft,E.info.light,.6)),se(E.Alert,"successColor",X(ft,E.success.light,.6)),se(E.Alert,"warningColor",X(ft,E.warning.light,.6)),se(E.Alert,"errorFilledBg",J("palette-error-dark")),se(E.Alert,"infoFilledBg",J("palette-info-dark")),se(E.Alert,"successFilledBg",J("palette-success-dark")),se(E.Alert,"warningFilledBg",J("palette-warning-dark")),se(E.Alert,"errorFilledColor",hr(()=>E.getContrastText(E.error.dark))),se(E.Alert,"infoFilledColor",hr(()=>E.getContrastText(E.info.dark))),se(E.Alert,"successFilledColor",hr(()=>E.getContrastText(E.success.dark))),se(E.Alert,"warningFilledColor",hr(()=>E.getContrastText(E.warning.dark))),se(E.Alert,"errorStandardBg",X(ut,E.error.light,.9)),se(E.Alert,"infoStandardBg",X(ut,E.info.light,.9)),se(E.Alert,"successStandardBg",X(ut,E.success.light,.9)),se(E.Alert,"warningStandardBg",X(ut,E.warning.light,.9)),se(E.Alert,"errorIconColor",J("palette-error-main")),se(E.Alert,"infoIconColor",J("palette-info-main")),se(E.Alert,"successIconColor",J("palette-success-main")),se(E.Alert,"warningIconColor",J("palette-warning-main")),se(E.AppBar,"defaultBg",J("palette-grey-900")),se(E.AppBar,"darkBg",J("palette-background-paper")),se(E.AppBar,"darkColor",J("palette-text-primary")),se(E.Avatar,"defaultBg",J("palette-grey-600")),se(E.Button,"inheritContainedBg",J("palette-grey-800")),se(E.Button,"inheritContainedHoverBg",J("palette-grey-700")),se(E.Chip,"defaultBorder",J("palette-grey-700")),se(E.Chip,"defaultAvatarColor",J("palette-grey-300")),se(E.Chip,"defaultIconColor",J("palette-grey-300")),se(E.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),se(E.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),se(E.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),se(E.LinearProgress,"primaryBg",X(ut,E.primary.main,.5)),se(E.LinearProgress,"secondaryBg",X(ut,E.secondary.main,.5)),se(E.LinearProgress,"errorBg",X(ut,E.error.main,.5)),se(E.LinearProgress,"infoBg",X(ut,E.info.main,.5)),se(E.LinearProgress,"successBg",X(ut,E.success.main,.5)),se(E.LinearProgress,"warningBg",X(ut,E.warning.main,.5)),se(E.Skeleton,"bg",w?X(ni,E.text.primary,.13):`rgba(${J("palette-text-primaryChannel")} / 0.13)`),se(E.Slider,"primaryTrack",X(ut,E.primary.main,.5)),se(E.Slider,"secondaryTrack",X(ut,E.secondary.main,.5)),se(E.Slider,"errorTrack",X(ut,E.error.main,.5)),se(E.Slider,"infoTrack",X(ut,E.info.main,.5)),se(E.Slider,"successTrack",X(ut,E.success.main,.5)),se(E.Slider,"warningTrack",X(ut,E.warning.main,.5));const ce=w?X(ft,E.background.default,.985):Wl(E.background.default,.98);se(E.SnackbarContent,"bg",ce),se(E.SnackbarContent,"color",hr(()=>w?L1.text.primary:E.getContrastText(ce))),se(E.SpeedDialAction,"fabHoverBg",Wl(E.background.paper,.15)),se(E.StepConnector,"border",J("palette-grey-600")),se(E.StepContent,"border",J("palette-grey-600")),se(E.Switch,"defaultColor",J("palette-grey-300")),se(E.Switch,"defaultDisabledColor",J("palette-grey-600")),se(E.Switch,"primaryDisabledColor",X(ut,E.primary.main,.55)),se(E.Switch,"secondaryDisabledColor",X(ut,E.secondary.main,.55)),se(E.Switch,"errorDisabledColor",X(ut,E.error.main,.55)),se(E.Switch,"infoDisabledColor",X(ut,E.info.main,.55)),se(E.Switch,"successDisabledColor",X(ut,E.success.main,.55)),se(E.Switch,"warningDisabledColor",X(ut,E.warning.main,.55)),se(E.TableCell,"border",X(ut,X(ni,E.divider,1),.68)),se(E.Tooltip,"bg",X(ni,E.grey[700],.92))}Lr(E.background,"default"),Lr(E.background,"paper"),Lr(E.common,"background"),Lr(E.common,"onBackground"),Lr(E,"divider"),Object.keys(E).forEach(ce=>{const k=E[ce];ce!=="tonalOffset"&&k&&typeof k=="object"&&(k.main&&se(E[ce],"mainChannel",$a(Va(k.main))),k.light&&se(E[ce],"lightChannel",$a(Va(k.light))),k.dark&&se(E[ce],"darkChannel",$a(Va(k.dark))),k.contrastText&&se(E[ce],"contrastTextChannel",$a(Va(k.contrastText))),ce==="text"&&(Lr(E[ce],"primary"),Lr(E[ce],"secondary")),ce==="action"&&(k.active&&Lr(E[ce],"active"),k.selected&&Lr(E[ce],"selected")))})}),A=e.reduce((Q,E)=>On(Q,E),A);const N={prefix:i,disableCssColorScheme:s,shouldSkipGeneratingVar:a,getSelector:oC(A),enableContrastVars:o},{vars:D,generateThemeVars:B,generateStyleSheets:G}=k4(A,N);return A.vars=D,Object.entries(A.colorSchemes[A.defaultColorScheme]).forEach(([Q,E])=>{A[Q]=E}),A.generateThemeVars=B,A.generateStyleSheets=G,A.generateSpacing=function(){return w1(u.spacing,Sg(this))},A.getColorSchemeSelector=O4(c),A.spacing=A.generateSpacing(),A.shouldSkipGeneratingVar=a,A.unstable_sxConfig={...Rh,...u==null?void 0:u.unstable_sxConfig},A.unstable_sx=function(E){return Ci({sx:E,theme:this})},A.toRuntimeSource=U1,A}function py(n,e,t){n.colorSchemes&&t&&(n.colorSchemes[e]={...t!==!0&&t,palette:Mg({...t===!0?{}:t.palette,mode:e})})}function Ng(n={},...e){const{palette:t,cssVariables:r=!1,colorSchemes:s=t?void 0:{light:!0},defaultColorScheme:i=t==null?void 0:t.mode,...o}=n,a=i||"light",c=s==null?void 0:s[a],l={...s,...t?{[a]:{...typeof c!="boolean"&&c,palette:t}}:void 0};if(r===!1){if(!("colorSchemes"in n))return Fp(n,...e);let u=t;"palette"in n||l[a]&&(l[a]!==!0?u=l[a].palette:a==="dark"&&(u={mode:"dark"}));const f=Fp({...n,palette:u},...e);return f.defaultColorScheme=a,f.colorSchemes=l,f.palette.mode==="light"&&(f.colorSchemes.light={...l.light!==!0&&l.light,palette:f.palette},py(f,"dark",l.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...l.dark!==!0&&l.dark,palette:f.palette},py(f,"light",l.light)),f}return!t&&!("light"in l)&&a==="light"&&(l.light=!0),uC({...o,colorSchemes:l,defaultColorScheme:a,...typeof r!="boolean"&&r},...e)}const z1=Ng();function fC(){const n=T1(z1);return process.env.NODE_ENV!=="production"&&xe.useDebugValue(n),n[Os]||n}function hC(n){return n!=="ownerState"&&n!=="theme"&&n!=="sx"&&n!=="as"}const dC=n=>hC(n)&&n!=="classes",zi=t4({themeId:Os,defaultTheme:z1,rootShouldForwardProp:dC});function pC({theme:n,...e}){const t=Os in n?n[Os]:void 0;return U.jsx(vc,{...e,themeId:t?Os:void 0,theme:t||n})}const Hl={colorSchemeStorageKey:"mui-color-scheme",defaultLightColorScheme:"light",defaultDarkColorScheme:"dark",modeStorageKey:"mui-mode"};process.env.NODE_ENV!=="production"&&(oe.string,oe.string,oe.string,oe.string,oe.string,oe.oneOf(["dark","light","system"]),oe.string,oe.string);const{CssVarsProvider:mC}=C4({themeId:Os,theme:()=>Ng({cssVariables:!0}),colorSchemeStorageKey:Hl.colorSchemeStorageKey,modeStorageKey:Hl.modeStorageKey,defaultColorScheme:{light:Hl.defaultLightColorScheme,dark:Hl.defaultDarkColorScheme},resolveTheme:n=>{const e={...n,typography:B1(n.palette,n.typography)};return e.unstable_sx=function(r){return Ci({sx:r,theme:this})},e}}),gC=mC;function _C({theme:n,...e}){const t=xe.useMemo(()=>{if(typeof n=="function")return n;const r=Os in n?n[Os]:n;return"colorSchemes"in r?null:"vars"in r?n:{...n,vars:null}},[n]);return t?U.jsx(pC,{theme:t,...e}):U.jsx(gC,{theme:n,...e})}const Dg=Ng({palette:{mode:"dark",primary:{main:Np[500]},secondary:{main:Np[500]}},components:{MuiButton:{defaultProps:{size:"small"}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiFilledInput:{defaultProps:{margin:"dense"}},MuiFormControl:{defaultProps:{margin:"dense"}},MuiFormHelperText:{defaultProps:{margin:"dense"}},MuiIconButton:{defaultProps:{size:"small"}},MuiInputBase:{defaultProps:{margin:"dense"}},MuiInputLabel:{defaultProps:{margin:"dense"}},MuiOutlinedInput:{defaultProps:{margin:"dense"}},MuiSlider:{defaultProps:{size:"small"},styleOverrides:{thumb:{"&:focus, &:hover":{boxShadow:"none"},height:11,width:5,borderRadius:"15%",marginLeft:-1}}},MuiInput:{styleOverrides:{underline:{"&&&&:hover:before":{borderBottom:"1px solid #fff"}}}},MuiPaper:{styleOverrides:{root:{backgroundColor:"rgba(0, 0, 0, 0.8)"}}},MuiSvgIcon:{styleOverrides:{root:{width:"0.7em",height:"0.7em"}}}}});let yC=0;function vC(n,e){const t=`atom${++yC}`,r={toString:()=>t};return typeof n=="function"?r.read=n:(r.init=n,r.read=s=>s(r),r.write=(s,i,o)=>i(r,typeof o=="function"?o(s(r)):o)),e&&(r.write=e),r}const Cn={},Us=Symbol(),Bp=n=>!!n[Us],Zl=n=>!n[Us].c,Aa=n=>{var e;const{b:t,c:r}=n[Us];r&&(r(),(e=bC.get(t))==null||e())},Au=(n,e)=>{const t=n[Us].o,r=e[Us].o;return t===r||n===r||Bp(t)&&Au(t,e)},Up=(n,e)=>{const t={b:n,o:e,c:null},r=new Promise(s=>{t.c=()=>{t.c=null,s()},e.finally(t.c)});return r[Us]=t,r},xC=n=>Up(n[Us].b,n[Us].o),bC=new WeakMap,Xl=n=>"init"in n,$p="r",Vp="w",xc="c",zp="s",my="h",wC="n",TC="l",SC="a",EC="m",AC=n=>{const e=new WeakMap,t=new WeakMap,r=new Map;let s,i;if((Cn&&"production")!=="production"&&(s=new Set,i=new Set),n)for(const[C,I]of n){const M={v:I,r:0,y:!0,d:new Map};(Cn&&"production")!=="production"&&(Object.freeze(M),Xl(C)||console.warn("Found initial value for derived atom which can cause unexpected behavior",C)),e.set(C,M)}const o=new WeakMap,a=(C,I,M)=>{let V=o.get(I);V||(V=new Map,o.set(I,V)),M.then(()=>{V.get(C)===M&&(V.delete(C),V.size||o.delete(I))}),V.set(C,M)},c=C=>{const I=new Set,M=o.get(C);return M&&(o.delete(C),M.forEach((V,Z)=>{Aa(V),I.add(Z)})),I},l=new WeakMap,u=C=>{let I=l.get(C);return I||(I=new Map,l.set(C,I)),I},f=(C,I)=>{if(C){const M=u(C);let V=M.get(I);return V||(V=f(C.p,I),V&&"p"in V&&Zl(V.p)&&(V=void 0),V&&M.set(I,V)),V}return e.get(I)},h=(C,I,M)=>{if((Cn&&"production")!=="production"&&Object.freeze(M),C)u(C).set(I,M);else{const V=e.get(I);e.set(I,M),r.has(I)||r.set(I,V)}},d=(C,I=new Map,M)=>{if(!M)return I;const V=new Map;let Z=!1;return M.forEach(q=>{var ne;const te=((ne=f(C,q))==null?void 0:ne.r)||0;V.set(q,te),I.get(q)!==te&&(Z=!0)}),I.size===V.size&&!Z?I:V},m=(C,I,M,V,Z)=>{const q=f(C,I);if(q){if(Z&&(!("p"in q)||!Au(q.p,Z)))return q;"p"in q&&Aa(q.p)}const ne={v:M,r:(q==null?void 0:q.r)||0,y:!0,d:d(C,q==null?void 0:q.d,V)};let te=!(q!=null&&q.y);return!q||!("v"in q)||!Object.is(q.v,M)?(te=!0,++ne.r,ne.d.has(I)&&(ne.d=new Map(ne.d).set(I,ne.r))):ne.d!==q.d&&(ne.d.size!==q.d.size||!Array.from(ne.d.keys()).every(pe=>q.d.has(pe)))&&(te=!0,Promise.resolve().then(()=>{ce(C)})),q&&!te?q:(h(C,I,ne),ne)},p=(C,I,M,V,Z)=>{const q=f(C,I);if(q){if(Z&&(!("p"in q)||!Au(q.p,Z)))return q;"p"in q&&Aa(q.p)}const ne={e:M,r:((q==null?void 0:q.r)||0)+1,y:!0,d:d(C,q==null?void 0:q.d,V)};return h(C,I,ne),ne},_=(C,I,M,V)=>{const Z=f(C,I);if(Z&&"p"in Z){if(Au(Z.p,M)&&!Zl(Z.p))return Z.y?Z:{...Z,y:!0};Aa(Z.p)}a(C,I,M);const q={p:M,r:((Z==null?void 0:Z.r)||0)+1,y:!0,d:d(C,Z==null?void 0:Z.d,V)};return h(C,I,q),q},y=(C,I,M,V)=>{if(M instanceof Promise){const Z=Up(M,M.then(q=>{m(C,I,q,V,Z)}).catch(q=>{if(q instanceof Promise)return Bp(q)?q.then(()=>{b(C,I,!0)}):q;p(C,I,q,V,Z)}));return _(C,I,Z,V)}return m(C,I,M,V)},T=(C,I)=>{const M=f(C,I);if(M){const V={...M,y:!1};h(C,I,V)}else(Cn&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",I)},b=(C,I,M)=>{if(!M){const Z=f(C,I);if(Z){if(Z.y&&"p"in Z&&!Zl(Z.p))return Z;if(Z.d.forEach((q,ne)=>{if(ne!==I)if(!t.has(ne))b(C,ne);else{const te=f(C,ne);te&&!te.y&&b(C,ne)}}),Array.from(Z.d).every(([q,ne])=>{const te=f(C,q);return te&&!("p"in te)&&te.r===ne}))return Z.y?Z:{...Z,y:!0}}}const V=new Set;try{const Z=I.read(q=>{V.add(q);const ne=q===I?f(C,q):b(C,q);if(ne){if("e"in ne)throw ne.e;if("p"in ne)throw ne.p;return ne.v}if(Xl(q))return q.init;throw new Error("no atom init")});return y(C,I,Z,V)}catch(Z){if(Z instanceof Promise){const q=Bp(Z)&&Zl(Z)?xC(Z):Up(Z,Z);return _(C,I,q,V)}return p(C,I,Z,V)}},w=(C,I)=>b(I,C),v=(C,I)=>{let M=t.get(I);return M||(M=E(C,I)),M},A=(C,I)=>!I.l.size&&(!I.t.size||I.t.size===1&&I.t.has(C)),N=(C,I)=>{const M=t.get(I);M&&A(I,M)&&J(C,I)},D=(C,I)=>{const M=t.get(I);M==null||M.t.forEach(V=>{V!==I&&(T(C,V),D(C,V))})},B=(C,I,M)=>{let V=!0;const Z=(te,pe)=>{const me=b(C,te);if("e"in me)throw me.e;if("p"in me){if(pe!=null&&pe.unstable_promise)return me.p.then(()=>{const ye=f(C,te);return ye&&"p"in ye&&ye.p===me.p?new Promise(Qe=>setTimeout(Qe)).then(()=>Z(te,pe)):Z(te,pe)});throw(Cn&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",te),me.p}if("v"in me)return me.v;throw(Cn&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",te),new Error("no value found")},q=(te,pe)=>{let me;if(te===I){if(!Xl(te))throw new Error("atom not writable");c(te).forEach(xt=>{xt!==C&&y(xt,te,pe)});const Qe=f(C,te),ge=y(C,te,pe);Qe!==ge&&D(C,te)}else me=B(C,te,pe);return V||ce(C),me},ne=I.write(Z,q,M);return V=!1,ne},G=(C,I,M)=>{const V=B(M,C,I);return ce(M),V},Q=C=>!!C.write,E=(C,I,M)=>{const V={t:new Set(M&&[M]),l:new Set};if(t.set(I,V),(Cn&&"production")!=="production"&&i.add(I),b(void 0,I).d.forEach((q,ne)=>{const te=t.get(ne);te?te.t.add(I):ne!==I&&E(C,ne,I)}),Q(I)&&I.onMount){const q=te=>G(I,te,C),ne=I.onMount(q);C=void 0,ne&&(V.u=ne)}return V},J=(C,I)=>{var M;const V=(M=t.get(I))==null?void 0:M.u;V&&V(),t.delete(I),(Cn&&"production")!=="production"&&i.delete(I);const Z=f(C,I);Z?("p"in Z&&Aa(Z.p),Z.d.forEach((q,ne)=>{if(ne!==I){const te=t.get(ne);te&&(te.t.delete(I),A(ne,te)&&J(C,ne))}})):(Cn&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",I)},X=(C,I,M,V)=>{const Z=new Set(M.d.keys());V==null||V.forEach((q,ne)=>{if(Z.has(ne)){Z.delete(ne);return}const te=t.get(ne);te&&(te.t.delete(I),A(ne,te)&&J(C,ne))}),Z.forEach(q=>{const ne=t.get(q);ne?ne.t.add(I):t.has(I)&&E(C,q,I)})},ce=C=>{if(C){u(C).forEach((M,V)=>{const Z=e.get(V);if(M!==Z){const q=t.get(V);q==null||q.l.forEach(ne=>ne(C))}});return}for(;r.size;){const I=Array.from(r);r.clear(),I.forEach(([M,V])=>{const Z=f(void 0,M);if(Z&&Z.d!==(V==null?void 0:V.d)&&X(void 0,M,Z,V==null?void 0:V.d),V&&!V.y&&(Z!=null&&Z.y))return;const q=t.get(M);q==null||q.l.forEach(ne=>ne())})}(Cn&&"production")!=="production"&&s.forEach(I=>I())},k=C=>{u(C).forEach((M,V)=>{const Z=e.get(V);(!Z||M.r>Z.r||M.y!==Z.y||M.r===Z.r&&M.d!==Z.d)&&(e.set(V,M),M.d!==(Z==null?void 0:Z.d)&&X(C,V,M,Z==null?void 0:Z.d))})},z=(C,I)=>{I&&k(I),ce(void 0)},$=(C,I,M)=>{const Z=v(M,C).l;return Z.add(I),()=>{Z.delete(I),N(M,C)}},re=(C,I)=>{for(const[M,V]of C)Xl(M)&&(y(I,M,V),D(I,M));ce(I)};return(Cn&&"production")!=="production"?{[$p]:w,[Vp]:G,[xc]:z,[zp]:$,[my]:re,[wC]:C=>(s.add(C),()=>{s.delete(C)}),[TC]:()=>i.values(),[SC]:C=>e.get(C),[EC]:C=>t.get(C)}:{[$p]:w,[Vp]:G,[xc]:z,[zp]:$,[my]:re}},j1=(n,e)=>({s:e?e(n).SECRET_INTERNAL_store:AC(n)}),Pd=new Map,Lg=n=>(Pd.has(n)||Pd.set(n,ae.createContext(j1())),Pd.get(n)),W1=({children:n,initialValues:e,scope:t,unstable_createStore:r,unstable_enableVersionedWrite:s})=>{const[i,o]=ae.useState({});ae.useEffect(()=>{const l=a.current;l.w&&(l.s[xc](null,i),delete i.p,l.v=i)},[i]);const a=ae.useRef();if(!a.current){const l=j1(e,r);if(s){let u=0;l.w=f=>{o(h=>{const d=u?h:{p:h};return f(d),d})},l.v=i,l.r=f=>{++u,f(),--u}}a.current=l}const c=Lg(t);return ae.createElement(c.Provider,{value:a.current},n)};function Tt(n,e){return vC(n,e)}function kn(n,e){const t=Lg(e),r=ae.useContext(t),{s,v:i}=r,o=h=>{const d=s[$p](n,h);if((Cn&&"production")!=="production"&&!d.y)throw new Error("should not be invalidated");if("e"in d)throw d.e;if("p"in d)throw d.p;if("v"in d)return d.v;throw new Error("no atom value")},[[a,c,l],u]=ae.useReducer((h,d)=>{const m=o(d);return Object.is(h[1],m)&&h[2]===n?h:[d,m,n]},i,h=>{const d=o(h);return[h,d,n]});let f=c;return l!==n&&(u(a),f=o(a)),ae.useEffect(()=>{const{v:h}=r;h&&s[xc](n,h);const d=s[zp](n,u,h);return u(h),d},[s,n,r]),ae.useEffect(()=>{s[xc](n,a)}),ae.useDebugValue(f),f}function Tr(n,e){const t=Lg(e),{s:r,w:s}=ae.useContext(t);return ae.useCallback(o=>{if((Cn&&"production")!=="production"&&!("write"in n))throw new Error("not writable atom");const a=c=>r[Vp](n,o,c);return s?s(a):a()},[r,s,n])}function Oh(n,e){return"scope"in n&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),e=n.scope),[kn(n,e),Tr(n,e)]}class ji extends Error{constructor(e,t={}){super(`Node not found: ${e}`,t),this.name="NodeNotFoundError"}}class Fg extends Error{constructor(e){super(`Missing key: ${e}`),this.name="KeyError"}}var Rn;class H1{constructor(e,t,r){Ge(this,Rn);typeof e=="number"?Be(this,Rn,new Uint8Array(e)):e instanceof ArrayBuffer?Be(this,Rn,new Uint8Array(e,t,r)):Be(this,Rn,new Uint8Array(Array.from(e,s=>s?1:0)))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return le(this,Rn).byteOffset}get byteLength(){return le(this,Rn).byteLength}get buffer(){return le(this,Rn).buffer}get length(){return le(this,Rn).length}get(e){let t=le(this,Rn)[e];return typeof t=="number"?t!==0:t}set(e,t){le(this,Rn)[e]=t?1:0}fill(e){le(this,Rn).fill(e?1:0)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}Rn=new WeakMap;var jo;class Bg{constructor(e,t,r,s){x(this,"_data");x(this,"chars");Ge(this,jo);if(this.chars=e,Be(this,jo,new TextEncoder),typeof t=="number")this._data=new Uint8Array(t*e);else if(t instanceof ArrayBuffer)s&&(s=s*e),this._data=new Uint8Array(t,r,s);else{let i=Array.from(t);this._data=new Uint8Array(i.length*e);for(let o=0;o<i.length;o++)this.set(o,i[o])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(e){const t=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);return new TextDecoder().decode(t).replace(/\x00/g,"")}set(e,t){const r=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);r.fill(0),r.set(le(this,jo).encode(t))}fill(e){const t=le(this,jo).encode(e);for(let r=0;r<this.length;r++)this._data.set(t,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}jo=new WeakMap;var an;const v_=class v_{constructor(e,t,r,s){Ge(this,an);x(this,"chars");if(this.chars=e,typeof t=="number")Be(this,an,new Int32Array(t*e));else if(t instanceof ArrayBuffer)s&&(s*=e),Be(this,an,new Int32Array(t,r,s));else{const i=t,o=new v_(e,1);Be(this,an,new Int32Array(function*(){for(let a of i)o.set(0,a),yield*le(o,an)}()))}}get BYTES_PER_ELEMENT(){return le(this,an).BYTES_PER_ELEMENT*this.chars}get byteLength(){return le(this,an).byteLength}get byteOffset(){return le(this,an).byteOffset}get buffer(){return le(this,an).buffer}get length(){return le(this,an).length/this.chars}get(e){const t=this.chars*e;let r="";for(let s=0;s<this.chars;s++)r+=String.fromCodePoint(le(this,an)[t+s]);return r.replace(/\u0000/g,"")}set(e,t){const r=this.chars*e,s=le(this,an).subarray(r,r+this.chars);s.fill(0);for(let i=0;i<this.chars;i++)s[i]=t.codePointAt(i)??0}fill(e){this.set(0,e);let t=le(this,an).subarray(0,this.chars);for(let r=1;r<this.length;r++)le(this,an).set(t,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}};an=new WeakMap;let bc=v_;function fl(n){const e=new TextDecoder().decode(n);return JSON.parse(e)}function gy(n,e){const t=e/2,r=e-1;let s=0;for(let i=0;i<n.length;i+=e)for(let o=0;o<t;o+=1)s=n[i+o],n[i+o]=n[i+r-o],n[i+r-o]=s}function Z1(n){if(n==="v2:object")return globalThis.Array;let e=n.match(/v2:([US])(\d+)/);if(e){let[,r,s]=e;return(r==="U"?bc:Bg).bind(null,Number(s))}let t={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float16:globalThis.Float16Array,float32:Float32Array,float64:Float64Array,bool:H1}[n];return Zt(t,`Unknown or unsupported data_type: ${n}`),t}function Ri(n,e){const t=n.length;typeof e=="string"&&(e=e==="C"?Array.from({length:t},(i,o)=>o):Array.from({length:t},(i,o)=>t-1-o)),Zt(t===e.length,"Order length must match the number of dimensions.");let r=1,s=new Array(t);for(let i=e.length-1;i>=0;i--)s[e[i]]=r,r*=n[e[i]];return s}function CC({name:n,configuration:e}){if(n==="default"){const t=(e==null?void 0:e.separator)??"/";return r=>["c",...r].join(t)}if(n==="v2"){const t=(e==null?void 0:e.separator)??".";return r=>r.join(t)||"0"}throw new Error(`Unknown chunk key encoding: ${n}`)}function RC(n){if(n==="|O")return{data_type:"v2:object"};let e=n.match(/^([<|>])(.*)$/);Zt(e,`Invalid dtype: ${n}`);let[,t,r]=e,s={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f2:"float16",f4:"float32",f8:"float64"}[r]??(r.startsWith("S")||r.startsWith("U")?`v2:${r}`:void 0);return Zt(s,`Unsupported or unknown dtype: ${n}`),t==="|"?{data_type:s}:{data_type:s,endian:t==="<"?"little":"big"}}function IC(n,e={}){let t=[],r=RC(n.dtype);n.order==="F"&&t.push({name:"transpose",configuration:{order:"F"}}),"endian"in r&&r.endian==="big"&&t.push({name:"bytes",configuration:{endian:"big"}});for(let{id:s,...i}of n.filters??[])t.push({name:s,configuration:i});if(n.compressor){let{id:s,...i}=n.compressor;t.push({name:s,configuration:i})}return{zarr_format:3,node_type:"array",shape:n.shape,data_type:r.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:n.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:n.dimension_separator??"."}},codecs:t,fill_value:n.fill_value,attributes:e}}function PC(n,e={}){return{zarr_format:3,node_type:"group",attributes:e}}function kC(n,e){if(e!=="number"&&e!=="bigint"&&e!=="boolean"&&e!=="object"&&e!=="string")return n===e;let t=n==="bool";if(e==="boolean")return t;let r=n.startsWith("v2:U")||n.startsWith("v2:S");if(e==="string")return r;let s=n==="int64"||n==="uint64";if(e==="bigint")return s;let i=n==="v2:object";return e==="object"?i:!r&&!s&&!t&&!i}function OC(n){return(n==null?void 0:n.name)==="sharding_indexed"}function X1(n){return(n.data_type==="uint64"||n.data_type==="int64")&&n.fill_value!=null?BigInt(n.fill_value):n.fill_value}function Y1(n,...e){if(!e.some(t=>n instanceof t))throw n}function Zt(n,e=""){if(!n)throw new Error(e)}async function q1(n,{format:e,signal:t}){const r=n instanceof Response?n:new Response(n);Zt(r.body,"Response does not contain body.");try{return await new Response(r.body.pipeThrough(new DecompressionStream(e),{signal:t})).arrayBuffer()}catch{throw t==null||t.throwIfAborted(),new Error(`Failed to decode ${e}`)}}class Ug{constructor(e,t){x(this,"kind","array_to_array");Zt(e.keepbits>=0,"keepbits must be zero or positive")}static fromConfig(e,t){return new Ug(e,t)}encode(e){throw new Error("`BitroundCodec.encode` is not implemented. Please open an issue at https://github.com/manzt/zarrita.js/issues.")}decode(e){return e}}const _y=MC();function MC(){const n=new Uint32Array([305419896]);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)[0]!==18}function yy(n){return"BYTES_PER_ELEMENT"in n?n.BYTES_PER_ELEMENT:4}var qc,Ss,Kc,Gc,Wo;const x_=class x_{constructor(e,t){x(this,"kind","array_to_bytes");Ge(this,qc);Ge(this,Ss);Ge(this,Kc);Ge(this,Gc);Ge(this,Wo);Be(this,Wo,e==null?void 0:e.endian),Be(this,Ss,Z1(t.data_type)),Be(this,Gc,t.shape),Be(this,qc,Ri(t.shape,"C"));const r=new(le(this,Ss))(0);Be(this,Kc,r.BYTES_PER_ELEMENT)}static fromConfig(e,t){return new x_(e,t)}encode(e){let t=new Uint8Array(e.data.buffer);return _y&&le(this,Wo)==="big"&&gy(t,yy(le(this,Ss))),t}decode(e){return _y&&le(this,Wo)==="big"&&gy(e,yy(le(this,Ss))),{data:new(le(this,Ss))(e.buffer,e.byteOffset,e.byteLength/le(this,Kc)),shape:le(this,Gc),stride:le(this,qc)}}};qc=new WeakMap,Ss=new WeakMap,Kc=new WeakMap,Gc=new WeakMap,Wo=new WeakMap;let Ku=x_;class $g{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(){return new $g}encode(e){throw new Error("Not implemented")}decode(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength-4)}}class Vg{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(e){return new Vg}encode(e){throw new Error("Gzip encoding is not enabled by default. Please register a custom codec with `numcodecs/gzip`.")}async decode(e){const t=await q1(e,{format:"gzip"});return new Uint8Array(t)}}function NC(n,e){return Zt(!Number.isNaN(e),"JsonCodec allow_nan is false but NaN was encountered during encoding."),Zt(e!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),Zt(e!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),e}function DC(n,e){return e instanceof Object&&!Array.isArray(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}):e}var Jc,Qc;const b_=class b_{constructor(e={}){x(this,"configuration");x(this,"kind","array_to_bytes");Ge(this,Jc);Ge(this,Qc);this.configuration=e;const{encoding:t="utf-8",skipkeys:r=!1,ensure_ascii:s=!0,check_circular:i=!0,allow_nan:o=!0,sort_keys:a=!0,indent:c,strict:l=!0}=e;let u=e.separators;u||(c?u=[", ",": "]:u=[",",":"]),Be(this,Jc,{encoding:t,skipkeys:r,ensure_ascii:s,check_circular:i,allow_nan:o,indent:c,separators:u,sort_keys:a}),Be(this,Qc,{strict:l})}static fromConfig(e){return new b_(e)}encode(e){const{indent:t,encoding:r,ensure_ascii:s,check_circular:i,allow_nan:o,sort_keys:a}=le(this,Jc);Zt(r==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const c=[];Zt(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),o||c.push(NC),a&&c.push(DC);const l=Array.from(e.data);l.push("|O"),l.push(e.shape);let u;c.length&&(u=(h,d)=>{let m=d;for(let p of c)m=p(h,m);return m});let f=JSON.stringify(l,u,t);return s&&(f=f.replace(/[\u007F-\uFFFF]/g,h=>{const d=`0000${h.charCodeAt(0).toString(16)}`;return`\\u${d.substring(d.length-4)}`})),new TextEncoder().encode(f)}decode(e){const{strict:t}=le(this,Qc);Zt(t,"JsonCodec does not yet support non-strict decoding.");const r=fl(e),s=r.pop();r.pop(),Zt(s,"0D not implemented for JsonCodec.");const i=Ri(s,"C");return{data:r,shape:s,stride:i}}};Jc=new WeakMap,Qc=new WeakMap;let jp=b_;function vy(n){return n instanceof H1||n instanceof Bg||n instanceof bc?new Proxy(n,{get(t,r){return t.get(Number(r))},set(t,r,s){return t.set(Number(r),s),!0}}):n}function LC(n,e){let t;return n.data instanceof Bg||n.data instanceof bc?t=new n.constructor(n.data.length,n.data.chars):t=new n.constructor(n.data.length),{data:t,shape:n.shape,stride:Ri(n.shape,e)}}function FC(n,e){let t=LC(n,e),r=n.shape.length,s=n.data.length,i=Array(r).fill(0),o=vy(n.data),a=vy(t.data);for(let c=0;c<s;c++){let l=0;for(let u=0;u<r;u++)l+=i[u]*t.stride[u];a[l]=o[c],i[0]+=1;for(let u=0;u<r;u++)if(i[u]===n.shape[u]){if(u+1===r)break;i[u]=0,i[u+1]+=1}}return t}function BC(n){let e=n.shape.length;return Zt(e===n.stride.length,"Shape and stride must have the same length."),n.stride.map((t,r)=>({stride:t,index:r})).sort((t,r)=>r.stride-t.stride).map(t=>t.index)}function UC(n,e){let t=BC(n);return Zt(t.length===e.length,"Orders must match"),t.every((r,s)=>r===e[s])}var el,Ho;const w_=class w_{constructor(e,t){x(this,"kind","array_to_array");Ge(this,el);Ge(this,Ho);let r=e.order??"C",s=t.shape.length,i=new Array(s),o=new Array(s);if(r==="C")for(let a=0;a<s;++a)i[a]=a,o[a]=a;else if(r==="F")for(let a=0;a<s;++a)i[a]=s-a-1,o[a]=s-a-1;else i=r,i.forEach((a,c)=>{Zt(o[a]===void 0,`Invalid permutation: ${JSON.stringify(r)}`),o[a]=c});Be(this,el,i),Be(this,Ho,o)}static fromConfig(e,t){return new w_(e,t)}encode(e){return UC(e,le(this,Ho))?e:FC(e,le(this,Ho))}decode(e){return{data:e.data,shape:e.shape,stride:Ri(e.shape,le(this,el))}}};el=new WeakMap,Ho=new WeakMap;let Wp=w_;var tl,nl;const T_=class T_{constructor(e){x(this,"kind","array_to_bytes");Ge(this,tl);Ge(this,nl);Be(this,tl,e),Be(this,nl,Ri(e,"C"))}static fromConfig(e,t){return new T_(t.shape)}encode(e){throw new Error("Method not implemented.")}decode(e){let t=new TextDecoder,r=new DataView(e.buffer),s=Array(r.getUint32(0,!0)),i=4;for(let o=0;o<s.length;o++){let a=r.getUint32(i,!0);i+=4,s[o]=t.decode(e.buffer.slice(i,i+a)),i+=a}return{data:s,shape:le(this,tl),stride:le(this,nl)}}};tl=new WeakMap,nl=new WeakMap;let Hp=T_;class zg{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(e){return new zg}encode(e){throw new Error("Zlib encoding is not enabled by default. Please register a codec with `numcodecs/zlib`.")}async decode(e){const t=await q1(e,{format:"deflate"});return new Uint8Array(t)}}function $C(){return new Map().set("blosc",()=>Promise.resolve().then(()=>require("./blosc-CeItQ6qj.cjs")).then(n=>n.default)).set("lz4",()=>Promise.resolve().then(()=>require("./lz4-PFaIsPAh.cjs")).then(n=>n.default)).set("zstd",()=>Promise.resolve().then(()=>require("./zstd-_xUhkGOV.cjs")).then(n=>n.default)).set("gzip",()=>Vg).set("zlib",()=>zg).set("transpose",()=>Wp).set("bytes",()=>Ku).set("crc32c",()=>$g).set("vlen-utf8",()=>Hp).set("json2",()=>jp).set("bitround",()=>Ug)}const K1=$C();function Zp(n){let e;return{async encode(t){e||(e=await xy(n));for(const s of e.array_to_array)t=await s.encode(t);let r=await e.array_to_bytes.encode(t);for(const s of e.bytes_to_bytes)r=await s.encode(r);return r},async decode(t){e||(e=await xy(n));for(let s=e.bytes_to_bytes.length-1;s>=0;s--)t=await e.bytes_to_bytes[s].decode(t);let r=await e.array_to_bytes.decode(t);for(let s=e.array_to_array.length-1;s>=0;s--)r=await e.array_to_array[s].decode(r);return r}}}async function xy(n){let e=n.codecs.map(async i=>{var a;let o=await((a=K1.get(i.name))==null?void 0:a());return Zt(o,`Unknown codec: ${i.name}`),{Codec:o,meta:i}}),t=[],r,s=[];for await(let{Codec:i,meta:o}of e){let a=i.fromConfig(o.configuration,n);switch(a.kind){case"array_to_array":t.push(a);break;case"array_to_bytes":r=a;break;default:s.push(a)}}return r||(Zt(VC(n),`Cannot encode ${n.data_type} to bytes without a codec`),r=Ku.fromConfig({endian:"little"},n)),{array_to_array:t,array_to_bytes:r,bytes_to_bytes:s}}function VC(n){return n.data_type!=="v2:object"}const by=18446744073709551615n;function zC(n,e,t,r){Zt(n.store.getRange,"Store does not support range requests");let s=n.store.getRange.bind(n.store),i=e.map((c,l)=>c/r.chunk_shape[l]),o=Zp({data_type:"uint64",shape:[...i,2],codecs:r.index_codecs}),a={};return async c=>{let l=c.map((T,b)=>Math.floor(T/i[b])),u=n.resolve(t(l)).path,f;if(u in a)f=a[u];else{let T=4,b=16*i.reduce((v,A)=>v*A,1),w=await s(u,{suffixLength:b+T});f=a[u]=w?await o.decode(w):null}if(f===null)return;let{data:h,shape:d,stride:m}=f,p=c.map((T,b)=>T%d[b]).reduce((T,b,w)=>T+b*m[w],0),_=h[p],y=h[p+1];if(!(_===by&&y===by))return s(u,{offset:Number(_),length:Number(y)})}}class Ys{constructor(e,t="/"){x(this,"store");x(this,"path");this.store=e,this.path=t}resolve(e){let t=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new Ys(this.store,new URL(e,t).pathname)}}function jC(n){return new Ys(n??new Map)}var rl;class Mh extends Ys{constructor(t,r,s){super(t,r);x(this,"kind","group");Ge(this,rl);Be(this,rl,s)}get attrs(){return le(this,rl).attributes}}rl=new WeakMap;function wy(n){var t;const e=n.find(r=>r.name==="transpose");return((t=e==null?void 0:e.configuration)==null?void 0:t.order)??"C"}const za=Symbol("zarrita.context");function WC(n){return n[za]}function HC(n,e){let{configuration:t}=e.codecs.find(OC)??{},r={encode_chunk_key:CC(e.chunk_key_encoding),TypedArray:Z1(e.data_type),fill_value:e.fill_value};if(t){let i=wy(t.codecs);return{...r,kind:"sharded",chunk_shape:t.chunk_shape,codec:Zp({data_type:e.data_type,shape:t.chunk_shape,codecs:t.codecs}),get_strides(o){return Ri(o,i)},get_chunk_bytes:zC(n,e.chunk_grid.configuration.chunk_shape,r.encode_chunk_key,t)}}let s=wy(e.codecs);return{...r,kind:"regular",chunk_shape:e.chunk_grid.configuration.chunk_shape,codec:Zp({data_type:e.data_type,shape:e.chunk_grid.configuration.chunk_shape,codecs:e.codecs}),get_strides(i){return Ri(i,s)},async get_chunk_bytes(i,o){let a=r.encode_chunk_key(i),c=n.resolve(a).path;return n.store.get(c,o)}}}var d1,p1,_i,m1;let Gu=(m1=class extends(p1=Ys,d1=za,p1){constructor(t,r,s){super(t,r);x(this,"kind","array");Ge(this,_i);x(this,d1);Be(this,_i,{...s,fill_value:X1(s)}),this[za]=HC(this,s)}get attrs(){return le(this,_i).attributes}get shape(){return le(this,_i).shape}get chunks(){return this[za].chunk_shape}get dtype(){return le(this,_i).data_type}async getChunk(t,r){let s=this[za],i=await s.get_chunk_bytes(t,r);if(!i){let o=s.chunk_shape.reduce((c,l)=>c*l,1),a=new s.TypedArray(o);return a.fill(s.fill_value),{data:a,shape:s.chunk_shape,stride:s.get_strides(s.chunk_shape)}}return s.codec.decode(i)}is(t){return kC(this.dtype,t)}},_i=new WeakMap,m1),Nh=ZC();function ZC(){let n=new WeakMap;function e(t){let r=n.get(t)??{v2:0,v3:0};return n.set(t,r),r}return{increment(t,r){e(t)[r]+=1},version_max(t){let r=e(t);return r.v3>r.v2?"v3":"v2"}}}async function XC(n){let e=await n.store.get(n.resolve(".zattrs").path);return e?fl(e):{}}async function YC(n,e={}){let t="store"in n?n:new Ys(n),r={};return(e.attrs??!0)&&(r=await XC(t)),e.kind==="array"?Ty(t,r):e.kind==="group"?Sy(t,r):Ty(t,r).catch(s=>(Y1(s,ji),Sy(t,r)))}async function Ty(n,e){let{path:t}=n.resolve(".zarray"),r=await n.store.get(t);if(!r)throw new ji("v2 array",{cause:new Fg(t)});return Nh.increment(n.store,"v2"),new Gu(n.store,n.path,IC(fl(r),e))}async function Sy(n,e){let{path:t}=n.resolve(".zgroup"),r=await n.store.get(t);if(!r)throw new ji("v2 group",{cause:new Fg(t)});return Nh.increment(n.store,"v2"),new Mh(n.store,n.path,PC(fl(r),e))}async function qC(n){let{store:e,path:t}=n.resolve("zarr.json"),r=await n.store.get(t);if(!r)throw new ji("v3 array or group",{cause:new Fg(t)});let s=fl(r);return s.node_type==="array"&&(s.fill_value=X1(s)),s.node_type==="array"?new Gu(e,n.path,s):new Mh(e,n.path,s)}async function KC(n,e={}){let t="store"in n?n:new Ys(n),r=await qC(t);if(Nh.increment(t.store,"v3"),e.kind===void 0||e.kind==="array"&&r instanceof Gu||e.kind==="group"&&r instanceof Mh)return r;let s=r instanceof Gu?"array":"group";throw new Error(`Expected node of kind ${e.kind}, found ${s}.`)}async function en(n,e={}){let t="store"in n?n.store:n,r=Nh.version_max(t),s=r==="v2"?en.v2:en.v3,i=r==="v2"?en.v3:en.v2;return s(n,e).catch(o=>(Y1(o,ji),i(n,e)))}en.v2=YC;en.v3=KC;function*GC(n,e,t=1){e===void 0&&(e=n,n=0);for(let r=n;r<e;r+=t)yield r}function*JC(...n){if(n.length===0)return;const e=n.map(r=>r[Symbol.iterator]()),t=e.map(r=>r.next());if(t.some(r=>r.done))throw new Error("Input contains an empty iterator.");for(let r=0;;){if(t[r].done){if(e[r]=n[r][Symbol.iterator](),t[r]=e[r].next(),++r>=e.length)return}else yield t.map(({value:s})=>s),r=0;t[r]=e[r].next()}}function QC({start:n,stop:e,step:t},r){if(t===0)throw new Error("slice step cannot be zero");t=t??1;const s=t<0,[i,o]=s?[-1,r-1]:[0,r];return n===null?n=s?o:i:n<0?(n+=r,n<i&&(n=i)):n>o&&(n=o),e===null?e=s?i:o:e<0?(e+=r,e<i&&(e=i)):e>o&&(e=o),[n,e,t]}function fi(n,e,t=null){return e===void 0&&(e=n,n=null),{start:n,stop:e,step:t}}function eR(){const n=[];return{add:e=>n.push(e()),onIdle:()=>Promise.all(n)}}class jg extends Error{constructor(e){super(e),this.name="IndexError"}}function tR(n,e){throw new jg(`too many indicies for array; expected ${e.length}, got ${n.length}`)}function nR(n){throw new jg(`index out of bounds for dimension with length ${n}`)}function rR(){throw new jg("only slices with step >= 1 are supported")}function sR(n,e){n.length>e.length&&tR(n,e)}function iR(n,e){return n=Math.trunc(n),n<0&&(n=e+n),(n>=e||n<0)&&nR(e),n}class oR{constructor({dim_sel:e,dim_len:t,dim_chunk_len:r}){x(this,"dim_sel");x(this,"dim_len");x(this,"dim_chunk_len");x(this,"nitems");e=iR(e,t),this.dim_sel=e,this.dim_len=t,this.dim_chunk_len=r,this.nitems=1}*[Symbol.iterator](){const e=Math.floor(this.dim_sel/this.dim_chunk_len),t=e*this.dim_chunk_len,r=this.dim_sel-t;yield{dim_chunk_ix:e,dim_chunk_sel:r}}}class Ey{constructor({dim_sel:e,dim_len:t,dim_chunk_len:r}){x(this,"start");x(this,"stop");x(this,"step");x(this,"dim_len");x(this,"dim_chunk_len");x(this,"nitems");x(this,"nchunks");const[s,i,o]=QC(e,t);this.start=s,this.stop=i,this.step=o,this.step<1&&rR(),this.dim_len=t,this.dim_chunk_len=r,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dim_len/this.dim_chunk_len)}*[Symbol.iterator](){const e=Math.floor(this.start/this.dim_chunk_len),t=Math.ceil(this.stop/this.dim_chunk_len);for(const r of GC(e,t)){const s=r*this.dim_chunk_len,i=Math.min(this.dim_len,(r+1)*this.dim_chunk_len),o=i-s;let a=0,c=0;if(this.start<s){const d=(s-this.start)%this.step;d&&(c+=this.step-d),a=Math.ceil((s-this.start)/this.step)}else c=this.start-s;const l=this.stop>i?o:this.stop-s,u=[c,l,this.step],f=Math.ceil((l-c)/this.step),h=[a,a+f,1];yield{dim_chunk_ix:r,dim_chunk_sel:u,dim_out_sel:h}}}}function aR(n,e){let t=[];return n===null?t=e.map(r=>fi(null)):Array.isArray(n)&&(t=n.map(r=>r??fi(null))),sR(t,e),t}class cR{constructor({selection:e,shape:t,chunk_shape:r}){x(this,"dim_indexers");x(this,"shape");this.dim_indexers=aR(e,t).map((s,i)=>new(typeof s=="number"?oR:Ey)({dim_sel:s,dim_len:t[i],dim_chunk_len:r[i]})),this.shape=this.dim_indexers.filter(s=>s instanceof Ey).map(s=>s.nitems)}*[Symbol.iterator](){for(const e of JC(...this.dim_indexers)){const t=e.map(s=>s.dim_chunk_ix),r=e.map(s=>"dim_out_sel"in s?{from:s.dim_chunk_sel,to:s.dim_out_sel}:{from:s.dim_chunk_sel,to:null});yield{chunk_coords:t,mapping:r}}}}function lR(n,e){return"get"in n?n.get(e):n[e]}async function uR(n,e,t,r){var c;let s=WC(n),i=new cR({selection:e,shape:n.shape,chunk_shape:n.chunks}),o=r.prepare(new s.TypedArray(i.shape.reduce((l,u)=>l*u,1)),i.shape,s.get_strides(i.shape)),a=((c=t.create_queue)==null?void 0:c.call(t))??eR();for(const{chunk_coords:l,mapping:u}of i)a.add(async()=>{let{data:f,shape:h,stride:d}=await n.getChunk(l,t.opts),m=r.prepare(f,h,d);r.set_from_chunk(o,m,u)});return await a.onIdle(),i.shape.length===0?lR(o.data,0):o}function Wg(n,e=0,t){let r=t??n.length-e;return{length:r,subarray(s,i=r){return Wg(n,e+s,i-s)},set(s,i=0){for(let o=0;o<s.length;o++)n[e+i+o]=s.get(o)},get(s){return n[e+s]}}}function kd(n){return globalThis.Array.isArray(n.data)?{data:Wg(n.data),stride:n.stride,bytes_per_element:1}:{data:new Uint8Array(n.data.buffer,n.data.byteOffset,n.data.byteLength),stride:n.stride,bytes_per_element:n.data.BYTES_PER_ELEMENT}}function fR(n){return"chars"in n?n.constructor.bind(null,n.chars):n.constructor}function hR(n,e){if(globalThis.Array.isArray(n.data))return Wg([e]);let t=fR(n.data),r=new t([e]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}const dR={prepare(n,e,t){return{data:n,shape:e,stride:t}},set_scalar(n,e,t){let r=kd(n);Xp(r,e,hR(n,t),r.bytes_per_element)},set_from_chunk(n,e,t){let r=kd(n);Cu(r,kd(e),r.bytes_per_element,t)}};async function pR(n,e=null,t={}){return uR(n,e,t,dR)}function G1(n,e,t){return t<0&&e<n?Math.floor((n-e-1)/-t)+1:n<e?Math.floor((e-n-1)/t)+1:0}function Xp(n,e,t,r){if(e.length===0){n.data.set(t,0);return}const[s,...i]=e,[o,...a]=n.stride;if(typeof s=="number"){const h=n.data.subarray(o*s*r);Xp({data:h,stride:a},i,t,r);return}const[c,l,u]=s,f=G1(c,l,u);if(i.length===0){for(let h=0;h<f;h++)n.data.set(t,o*(c+u*h)*r);return}for(let h=0;h<f;h++){const d=n.data.subarray(o*(c+u*h)*r);Xp({data:d,stride:a},i,t,r)}}function Cu(n,e,t,r){const[s,...i]=r,[o,...a]=n.stride,[c,...l]=e.stride;if(s.from===null){if(i.length===0){n.data.set(e.data.subarray(0,t),s.to*t);return}Cu({data:n.data.subarray(o*s.to*t),stride:a},e,t,i);return}if(s.to===null){if(i.length===0){let y=s.from*t;n.data.set(e.data.subarray(y,y+t),0);return}Cu(n,{data:e.data.subarray(c*s.from*t),stride:l},t,i);return}const[u,f,h]=s.to,[d,m,p]=s.from,_=G1(u,f,h);if(i.length===0){if(h===1&&p===1&&o===1&&c===1){let y=d*t,T=_*t;n.data.set(e.data.subarray(y,y+T),u*t);return}for(let y=0;y<_;y++){let T=c*(d+p*y)*t;n.data.set(e.data.subarray(T,T+t),o*(u+h*y)*t)}return}for(let y=0;y<_;y++)Cu({data:n.data.subarray(o*(u+y*h)*t),stride:a},{data:e.data.subarray(c*(d+y*p)*t),stride:l},t,i)}function Ru(n){return n.slice(1)}function mR(n){let[e,t]=(typeof n=="string"?n:n.href).split("://");if(e==="https"||e==="http")return n;if(e==="gc")return`https://storage.googleapis.com/${t}`;if(e==="s3")return`https://s3.amazonaws.com/${t}`;throw Error(`Protocol not supported, got: ${JSON.stringify(e)}`)}function Dh(n,e,t,r={}){return e!==void 0&&t!==void 0&&(r={...r,headers:{...r.headers,Range:`bytes=${e}-${e+t-1}`}}),fetch(n,r)}function J1(n,e){return{...n,...e,headers:{...n.headers,...e.headers}}}function Ay(n,e=""){if(!n)throw new Error(e)}function Cy(n,e){const t=typeof n=="string"?new URL(n):n;t.pathname.endsWith("/")||(t.pathname+="/");const r=new URL(e.slice(1),t);return r.search=t.search,r}async function Ry(n){if(n.status!==404){if(n.status===200||n.status===206)return new Uint8Array(await n.arrayBuffer());throw new Error(`Unexpected response status ${n.status} ${n.statusText}`)}}async function gR(n,e,t,r){if(r)return fetch(n,{...t,headers:{...t.headers,Range:`bytes=-${e}`}});let s=await fetch(n,{...t,method:"HEAD"});if(!s.ok)return s;let i=s.headers.get("Content-Length"),o=Number(i);return Dh(n,o-e,o,t)}var sl,il,ol,Yp;class _R{constructor(e,t={}){Ge(this,ol);x(this,"url");Ge(this,sl);Ge(this,il);this.url=e,Be(this,sl,t.overrides??{}),Be(this,il,t.useSuffixRequest??!1)}async get(e,t={}){let r=Cy(this.url,e).href,s=await fetch(r,dt(this,ol,Yp).call(this,t));return Ry(s)}async getRange(e,t,r={}){let s=Cy(this.url,e),i=dt(this,ol,Yp).call(this,r),o;return"suffixLength"in t?o=await gR(s,t.suffixLength,i,le(this,il)):o=await Dh(s,t.offset,t.length,i),Ry(o)}}sl=new WeakMap,il=new WeakMap,ol=new WeakSet,Yp=function(e){return J1(le(this,sl),e)};function Q1(n){return n.arrayBuffer?n.arrayBuffer():new Promise((e,t)=>{const r=new FileReader;r.addEventListener("loadend",()=>{e(r.result)}),r.addEventListener("error",t),r.readAsArrayBuffer(n)})}async function yR(n){const e=await Q1(n);return new Uint8Array(e)}function e2(n){return typeof Blob<"u"&&n instanceof Blob}function wc(n){return typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}const vR=typeof process<"u"&&process.versions&&typeof process.versions.node<"u"&&typeof process.versions.electron>"u";function xR(n){return n.byteOffset===0&&n.byteLength===n.buffer.byteLength}class Iy{constructor(e){this.typedArray=e instanceof ArrayBuffer||wc(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}async getLength(){return this.typedArray.byteLength}async read(e,t){return new Uint8Array(this.typedArray.buffer,this.typedArray.byteOffset+e,t)}}let Py=class{constructor(e){this.blob=e}async getLength(){return this.blob.size}async read(e,t){const r=this.blob.slice(e,e+t),s=await Q1(r);return new Uint8Array(s)}async sliceAsBlob(e,t,r=""){return this.blob.slice(e,e+t,r)}};function bR(n,e){var t=Uint8Array;if(n[0]==3&&n[1]==0)return e||new t(0);var r=TR,s=t2,i=wR,o=n2,a=e==null;a&&(e=new t(n.length>>>2<<3));for(var c=0,l=0,u=0,f=0,h=0,d=0,m=0,p=0,_=0,y,T;c==0;){if(c=r(n,_,1),l=r(n,_+1,2),_+=3,l==0){(_&7)!=0&&(_+=8-(_&7));var b=(_>>>3)+4,w=n[b-4]|n[b-3]<<8;a&&(e=Od(e,p+w)),e.set(new t(n.buffer,n.byteOffset+b,w),p),_=b+w<<3,p+=w;continue}if(a&&(e=Od(e,p+(1<<17))),l==1&&(y=Pe.flmap,T=Pe.fdmap,d=511,m=31),l==2){u=s(n,_,5)+257,f=s(n,_+5,5)+1,h=s(n,_+10,4)+4,_+=14;for(var v=0;v<38;v+=2)Pe.itree[v]=0,Pe.itree[v+1]=0;for(var A=1,v=0;v<h;v++){var N=s(n,_+v*3,3);Pe.itree[(Pe.ordr[v]<<1)+1]=N,N>A&&(A=N)}_+=3*h,tc(Pe.itree,A),nc(Pe.itree,A,Pe.imap),y=Pe.lmap,T=Pe.dmap,_=i(Pe.imap,(1<<A)-1,u+f,n,_,Pe.ttree);var D=ky(Pe.ttree,0,u,Pe.ltree);d=(1<<D)-1;var B=ky(Pe.ttree,u,f,Pe.dtree);m=(1<<B)-1,tc(Pe.ltree,D),nc(Pe.ltree,D,y),tc(Pe.dtree,B),nc(Pe.dtree,B,T)}for(;;){var G=y[o(n,_)&d];_+=G&15;var Q=G>>>4;if(!(Q>>>8))e[p++]=Q;else{if(Q==256)break;var E=p+Q-254;if(Q>264){var J=Pe.ldef[Q-257];E=p+(J>>>3)+s(n,_,J&7),_+=J&7}var X=T[o(n,_)&m];_+=X&15;var ce=X>>>4,k=Pe.ddef[ce],z=(k>>>4)+r(n,_,k&15);for(_+=k&15,a&&(e=Od(e,p+(1<<17)));p<E;)e[p]=e[p++-z],e[p]=e[p++-z],e[p]=e[p++-z],e[p]=e[p++-z];p=E}}}return e.length==p?e:e.slice(0,p)}function Od(n,e){var t=n.length;if(e<=t)return n;var r=new Uint8Array(Math.max(t<<1,e));return r.set(n,0),r}function wR(n,e,t,r,s,i){for(var o=t2,a=n2,c=0;c<t;){var l=n[a(r,s)&e];s+=l&15;var u=l>>>4;if(u<=15)i[c]=u,c++;else{var f=0,h=0;u==16?(h=3+o(r,s,2),s+=2,f=i[c-1]):u==17?(h=3+o(r,s,3),s+=3):u==18&&(h=11+o(r,s,7),s+=7);for(var d=c+h;c<d;)i[c]=f,c++}}return s}function ky(n,e,t,r){for(var s=0,i=0,o=r.length>>>1;i<t;){var a=n[i+e];r[i<<1]=0,r[(i<<1)+1]=a,a>s&&(s=a),i++}for(;i<o;)r[i<<1]=0,r[(i<<1)+1]=0,i++;return s}function tc(n,e){for(var t=n.length,r,s,i,o,a,c=Pe.bl_count,o=0;o<=e;o++)c[o]=0;for(o=1;o<t;o+=2)c[n[o]]++;var l=Pe.next_code;for(r=0,c[0]=0,s=1;s<=e;s++)r=r+c[s-1]<<1,l[s]=r;for(i=0;i<t;i+=2)a=n[i+1],a!=0&&(n[i]=l[a],l[a]++)}function nc(n,e,t){for(var r=n.length,s=Pe.rev15,i=0;i<r;i+=2)if(n[i+1]!=0)for(var o=i>>1,a=n[i+1],c=o<<4|a,l=e-a,u=n[i]<<l,f=u+(1<<l);u!=f;){var h=s[u]>>>15-e;t[h]=c,u++}}function Oy(n,e){for(var t=Pe.rev15,r=15-e,s=0;s<n.length;s+=2){var i=n[s]<<e-n[s+1];n[s]=t[i]>>>r}}function t2(n,e,t){return(n[e>>>3]|n[(e>>>3)+1]<<8)>>>(e&7)&(1<<t)-1}function TR(n,e,t){return(n[e>>>3]|n[(e>>>3)+1]<<8|n[(e>>>3)+2]<<16)>>>(e&7)&(1<<t)-1}function n2(n,e){return(n[e>>>3]|n[(e>>>3)+1]<<8|n[(e>>>3)+2]<<16)>>>(e&7)}const Pe=function(){var n=Uint16Array,e=Uint32Array;return{next_code:new n(16),bl_count:new n(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new n(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new e(32),flmap:new n(512),fltree:[],fdmap:new n(32),fdtree:[],lmap:new n(32768),ltree:[],ttree:[],dmap:new n(32768),dtree:[],imap:new n(512),itree:[],rev15:new n(32768),lhst:new e(286),dhst:new e(30),ihst:new e(19),lits:new e(15e3),strt:new n(65536),prev:new n(32768)}}();(function(){for(var n=32768,e=0;e<n;e++){var t=e;t=(t&2863311530)>>>1|(t&1431655765)<<1,t=(t&3435973836)>>>2|(t&858993459)<<2,t=(t&4042322160)>>>4|(t&252645135)<<4,t=(t&4278255360)>>>8|(t&16711935)<<8,Pe.rev15[e]=(t>>>16|t<<16)>>>17}function r(s,i,o){for(;i--!=0;)s.push(0,o)}for(var e=0;e<32;e++)Pe.ldef[e]=Pe.of0[e]<<3|Pe.exb[e],Pe.ddef[e]=Pe.df0[e]<<4|Pe.dxb[e];r(Pe.fltree,144,8),r(Pe.fltree,112,9),r(Pe.fltree,24,7),r(Pe.fltree,8,8),tc(Pe.fltree,9),nc(Pe.fltree,9,Pe.flmap),Oy(Pe.fltree,9),r(Pe.fdtree,32,5),tc(Pe.fdtree,5),nc(Pe.fdtree,5,Pe.fdmap),Oy(Pe.fdtree,5),r(Pe.itree,19,0),r(Pe.ltree,286,0),r(Pe.dtree,30,0),r(Pe.ttree,320,0)})();(function(){for(var n=new Uint32Array(256),e=0;e<256;e++){for(var t=e,r=0;r<8;r++)t&1?t=3988292384^t>>>1:t=t>>>1;n[e]=t}return n})();function SR(n,e){return bR(n,e)}const My={numWorkers:1,workerURL:"",useWorkers:!1};let ER=0;const Iu=[];function Md(n){return new Promise((e,t)=>{const r=new Worker(n);r.onmessage=s=>{s.data==="start"?(r.onerror=void 0,r.onmessage=void 0,e(r)):t(new Error(`unexpected message: ${s.data}`))},r.onerror=t})}function AR(n,e){return n.require?n.require(e):{}}(function(){if(vR){const{Worker:n}=AR(module,"worker_threads");return{async createWorker(e){return new n(e)},addEventListener(e,t){e.on("message",r=>{t({target:e,data:r})})},async terminate(e){await e.terminate()}}}else return{async createWorker(n){try{return await Md(n)}catch{console.warn("could not load worker:",n)}let e;try{const t=await fetch(n,{mode:"cors"});if(!t.ok)throw new Error(`could not load: ${n}`);e=await t.text(),n=URL.createObjectURL(new Blob([e],{type:"application/javascript"}));const r=await Md(n);return My.workerURL=n,r}catch{console.warn("could not load worker via fetch:",n)}if(e!==void 0)try{n=`data:application/javascript;base64,${btoa(e)}`;const t=await Md(n);return My.workerURL=n,t}catch{console.warn("could not load worker via dataURI")}throw console.warn("workers will not be used"),new Error("can not start workers")},addEventListener(n,e){n.addEventListener("message",e)},async terminate(n){n.terminate()}}})();function CR(n,e,t,r){const s=new Uint8Array(e);SR(n,s),r(t?new Blob([s],{type:t}):s.buffer)}async function RR(){if(Iu.length!==0)for(;Iu.length;){const{src:n,uncompressedSize:e,type:t,resolve:r}=Iu.shift();let s=n;e2(n)&&(s=await yR(n)),CR(s,e,t,r)}}function r2(n,e,t){return new Promise((r,s)=>{Iu.push({src:n,uncompressedSize:e,type:t,resolve:r,reject:s,id:ER++}),RR()})}function IR(n,e){const t=n&31,r=(n>>5&15)-1,s=(n>>9&127)+1980,i=0,o=(e&31)*2,a=e>>5&63,c=e>>11&31;return new Date(s,r,t,c,a,o,i)}class PR{constructor(e,t){this._reader=e,this._rawEntry=t,this.name=t.name,this.nameBytes=t.nameBytes,this.size=t.uncompressedSize,this.compressedSize=t.compressedSize,this.comment=t.comment,this.commentBytes=t.commentBytes,this.compressionMethod=t.compressionMethod,this.lastModDate=IR(t.lastModFileDate,t.lastModFileTime),this.isDirectory=t.uncompressedSize===0&&t.name.endsWith("/"),this.encrypted=!!(t.generalPurposeBitFlag&1),this.externalFileAttributes=t.externalFileAttributes,this.versionMadeBy=t.versionMadeBy}async blob(e="application/octet-stream"){return await VR(this._reader,this._rawEntry,e)}async arrayBuffer(){return await $R(this._reader,this._rawEntry)}async text(){const e=await this.arrayBuffer();return rc(new Uint8Array(e))}async json(){const e=await this.text();return JSON.parse(e)}}const Nd=22,kR=65535,OR=101010256,MR=101075792;async function Ko(n,e,t){return await n.read(e,t)}async function qp(n,e,t,r){return n.sliceAsBlob?await n.sliceAsBlob(e,t,r):await n.read(e,t)}const NR={unsigned(){return 0}};function Jt(n,e){return n[e]+n[e+1]*256}function gn(n,e){return n[e]+n[e+1]*256+n[e+2]*65536+n[e+3]*16777216}function hi(n,e){return gn(n,e)+gn(n,e+4)*4294967296}const DR=new TextDecoder;function rc(n,e){return wc(n.buffer)&&(n=new Uint8Array(n)),DR.decode(n)}async function LR(n,e){const t=Math.min(Nd+kR,e),r=e-t,s=await Ko(n,r,t);for(let i=t-Nd;i>=0;--i){if(gn(s,i)!==OR)continue;const o=new Uint8Array(s.buffer,s.byteOffset+i,s.byteLength-i),a=Jt(o,4);if(a!==0)throw new Error(`multi-volume zip files are not supported. This is volume: ${a}`);const c=Jt(o,10),l=gn(o,12),u=gn(o,16),f=Jt(o,20),h=o.length-Nd;if(f!==h)throw new Error(`invalid comment length. expected: ${h}, actual: ${f}`);const d=new Uint8Array(o.buffer,o.byteOffset+22,f),m=rc(d);return c===65535||u===4294967295?await BR(n,r+i,m,d):await s2(n,u,l,c,m,d)}throw new Error("could not find end of central directory. maybe not zip file")}const FR=117853008;async function BR(n,e,t,r){const s=e-20,i=await Ko(n,s,20);if(gn(i,0)!==FR)throw new Error("invalid zip64 end of central directory locator signature");const o=hi(i,8),a=await Ko(n,o,56);if(gn(a,0)!==MR)throw new Error("invalid zip64 end of central directory record signature");const c=hi(a,32),l=hi(a,40),u=hi(a,48);return s2(n,u,l,c,t,r)}const UR=33639248;async function s2(n,e,t,r,s,i){let o=0;const a=await Ko(n,e,t),c=[];for(let u=0;u<r;++u){const f=a.subarray(o,o+46),h=gn(f,0);if(h!==UR)throw new Error(`invalid central directory file header signature: 0x${h.toString(16)}`);const d={versionMadeBy:Jt(f,4),versionNeededToExtract:Jt(f,6),generalPurposeBitFlag:Jt(f,8),compressionMethod:Jt(f,10),lastModFileTime:Jt(f,12),lastModFileDate:Jt(f,14),crc32:gn(f,16),compressedSize:gn(f,20),uncompressedSize:gn(f,24),fileNameLength:Jt(f,28),extraFieldLength:Jt(f,30),fileCommentLength:Jt(f,32),internalFileAttributes:Jt(f,36),externalFileAttributes:gn(f,38),relativeOffsetOfLocalHeader:gn(f,42)};if(d.generalPurposeBitFlag&64)throw new Error("strong encryption is not supported");o+=46;const m=a.subarray(o,o+d.fileNameLength+d.extraFieldLength+d.fileCommentLength);d.nameBytes=m.slice(0,d.fileNameLength),d.name=rc(d.nameBytes);const p=d.fileNameLength+d.extraFieldLength,_=m.slice(d.fileNameLength,p);d.extraFields=[];let y=0;for(;y<_.length-3;){const b=Jt(_,y+0),w=Jt(_,y+2),v=y+4,A=v+w;if(A>_.length)throw new Error("extra field length exceeds extra field buffer size");d.extraFields.push({id:b,data:_.slice(v,A)}),y=A}if(d.commentBytes=m.slice(p,p+d.fileCommentLength),d.comment=rc(d.commentBytes),o+=m.length,d.uncompressedSize===4294967295||d.compressedSize===4294967295||d.relativeOffsetOfLocalHeader===4294967295){const b=d.extraFields.find(A=>A.id===1);if(!b)throw new Error("expected zip64 extended information extra field");const w=b.data;let v=0;if(d.uncompressedSize===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include uncompressed size");d.uncompressedSize=hi(w,v),v+=8}if(d.compressedSize===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include compressed size");d.compressedSize=hi(w,v),v+=8}if(d.relativeOffsetOfLocalHeader===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include relative header offset");d.relativeOffsetOfLocalHeader=hi(w,v),v+=8}}const T=d.extraFields.find(b=>b.id===28789&&b.data.length>=6&&b.data[0]===1&&gn(b.data,1),NR.unsigned(d.nameBytes));if(T&&(d.fileName=rc(T.data.slice(5))),d.compressionMethod===0){let b=d.uncompressedSize;if((d.generalPurposeBitFlag&1)!==0&&(b+=12),d.compressedSize!==b)throw new Error(`compressed size mismatch for stored file: ${d.compressedSize} != ${b}`)}c.push(d)}return{zip:{comment:s,commentBytes:i},entries:c.map(u=>new PR(n,u))}}async function i2(n,e){if(e.generalPurposeBitFlag&1)throw new Error("encrypted entries not supported");const t=await Ko(n,e.relativeOffsetOfLocalHeader,30),r=await n.getLength(),s=gn(t,0);if(s!==67324752)throw new Error(`invalid local file header signature: 0x${s.toString(16)}`);const i=Jt(t,26),o=Jt(t,28),a=e.relativeOffsetOfLocalHeader+t.length+i+o;let c;if(e.compressionMethod===0)c=!1;else if(e.compressionMethod===8)c=!0;else throw new Error(`unsupported compression method: ${e.compressionMethod}`);const l=a,u=l+e.compressedSize;if(e.compressedSize!==0&&u>r)throw new Error(`file data overflows file bounds: ${l} + ${e.compressedSize} > ${r}`);return{decompress:c,fileDataStart:l}}async function $R(n,e){const{decompress:t,fileDataStart:r}=await i2(n,e);if(!t){const o=await Ko(n,r,e.compressedSize);return xR(o)?o.buffer:o.slice().buffer}const s=await qp(n,r,e.compressedSize);return await r2(s,e.uncompressedSize)}async function VR(n,e,t){const{decompress:r,fileDataStart:s}=await i2(n,e);if(!r){const a=await qp(n,s,e.compressedSize,t);return e2(a)?a:new Blob([wc(a.buffer)?new Uint8Array(a):a],{type:t})}const i=await qp(n,s,e.compressedSize);return await r2(i,e.uncompressedSize,t)}async function zR(n){let e;if(typeof Blob<"u"&&n instanceof Blob)e=new Py(n);else if(n instanceof ArrayBuffer||n&&n.buffer&&n.buffer instanceof ArrayBuffer)e=new Iy(n);else if(wc(n)||wc(n.buffer))e=new Iy(n);else if(typeof n=="string"){const r=await fetch(n);if(!r.ok)throw new Error(`failed http request ${n}, status: ${r.status}: ${r.statusText}`);const s=await r.blob();e=new Py(s)}else if(typeof n.getLength=="function"&&typeof n.read=="function")e=n;else throw new Error("unsupported source type");const t=await e.getLength();if(t>Number.MAX_SAFE_INTEGER)throw new Error(`file too large. size: ${t}. Only file sizes up 4503599627370496 bytes are supported`);return await LR(e,t)}async function jR(n){const{zip:e,entries:t}=await zR(n);return{zip:e,entries:Object.fromEntries(t.map(r=>[r.name,r]))}}function WR(n){if(!("compressionMethod"in n)||!("_rawEntry"in n))return!1;const e=n._rawEntry;return typeof n.compressionMethod=="number"&&typeof e=="object"&&e!==null&&"relativeOffsetOfLocalHeader"in e&&typeof e.relativeOffsetOfLocalHeader=="number"}class HR{constructor(e){x(this,"blob");this.blob=e}async getLength(){return this.blob.size}async read(e,t){const r=this.blob.slice(e,e+t);return new Uint8Array(await r.arrayBuffer())}}var Zo;class ZR{constructor(e,t={}){x(this,"url");x(this,"length");Ge(this,Zo);this.url=e,Be(this,Zo,t.overrides??{})}async getLength(){if(this.length===void 0){const e=await fetch(this.url,{...le(this,Zo),method:"HEAD"});if(Ay(e.ok,`failed http request ${this.url}, status: ${e.status}: ${e.statusText}`),this.length=Number(e.headers.get("content-length")),Number.isNaN(this.length))throw Error("could not get length")}return this.length}async read(e,t){if(t===0)return new Uint8Array(0);const r=await Dh(this.url,e,t,le(this,Zo));return Ay(r.ok,`failed http request ${this.url}, status: ${r.status} offset: ${e} size: ${t}: ${r.statusText}`),new Uint8Array(await r.arrayBuffer())}}Zo=new WeakMap;class Ju{constructor(e,t={}){x(this,"info");x(this,"reader");this.reader=e,this.info=jR(e).then(r=>(t.transformEntries&&(r.entries=t.transformEntries(r.entries)),r))}async getEntryDataOffset(e){const t=e._rawEntry.relativeOffsetOfLocalHeader,r=await this.reader.read(t,30),s=r[26]+r[27]*256,i=r[28]+r[29]*256;return t+30+s+i}async get(e){let t=(await this.info).entries[Ru(e)];if(t)return new Uint8Array(await t.arrayBuffer())}async getRange(e,t){const r=(await this.info).entries[Ru(e)];if(!r)return;if(!WR(r))throw new Error("ZipFileStore.getRange requires internal unzipit properties that are not available. This may indicate an incompatible version of unzipit.");if(r.compressionMethod!==0){const i=await this.get(e);return i?"suffixLength"in t?i.slice(-t.suffixLength):i.slice(t.offset,t.offset+t.length):void 0}const s=await this.getEntryDataOffset(r);if("suffixLength"in t){const i=s+r.size-t.suffixLength;return this.reader.read(i,t.suffixLength)}return this.reader.read(s+t.offset,t.length)}async has(e){return Ru(e)in(await this.info).entries}static fromUrl(e,t={}){return new Ju(new ZR(e,t),t)}static fromBlob(e,t={}){return new Ju(new HR(e),t)}}var Nn,At,Dt,Es,al,As,nt,Kp,Kn,o2,Gp,Jp,Qp,a2,em;class XR extends Map{constructor(t={}){super();Ge(this,nt);Ge(this,Nn,0);Ge(this,At,new Map);Ge(this,Dt,new Map);Ge(this,Es);Ge(this,al);Ge(this,As);if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof t.maxAge=="number"&&t.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");Be(this,Es,t.maxSize),Be(this,al,t.maxAge||Number.POSITIVE_INFINITY),Be(this,As,t.onEviction)}get __oldCache(){return le(this,Dt)}get(t){if(le(this,At).has(t)){const r=le(this,At).get(t);return dt(this,nt,Gp).call(this,t,r)}if(le(this,Dt).has(t)){const r=le(this,Dt).get(t);if(dt(this,nt,Kn).call(this,t,r)===!1)return dt(this,nt,a2).call(this,t,r),r.value}}set(t,r,{maxAge:s=le(this,al)}={}){const i=typeof s=="number"&&s!==Number.POSITIVE_INFINITY?Date.now()+s:void 0;return le(this,At).has(t)?le(this,At).set(t,{value:r,expiry:i}):dt(this,nt,Qp).call(this,t,{value:r,expiry:i}),this}has(t){return le(this,At).has(t)?!dt(this,nt,Kn).call(this,t,le(this,At).get(t)):le(this,Dt).has(t)?!dt(this,nt,Kn).call(this,t,le(this,Dt).get(t)):!1}peek(t){if(le(this,At).has(t))return dt(this,nt,Jp).call(this,t,le(this,At));if(le(this,Dt).has(t))return dt(this,nt,Jp).call(this,t,le(this,Dt))}delete(t){const r=le(this,At).delete(t);return r&&_d(this,Nn)._--,le(this,Dt).delete(t)||r}clear(){le(this,At).clear(),le(this,Dt).clear(),Be(this,Nn,0)}resize(t){if(!(t&&t>0))throw new TypeError("`maxSize` must be a number greater than 0");const r=[...dt(this,nt,em).call(this)],s=r.length-t;s<0?(Be(this,At,new Map(r)),Be(this,Dt,new Map),Be(this,Nn,r.length)):(s>0&&dt(this,nt,Kp).call(this,r.slice(0,s)),Be(this,Dt,new Map(r.slice(s))),Be(this,At,new Map),Be(this,Nn,0)),Be(this,Es,t)}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of le(this,At)){const[r,s]=t;dt(this,nt,Kn).call(this,r,s)===!1&&(yield[r,s.value])}for(const t of le(this,Dt)){const[r,s]=t;le(this,At).has(r)||dt(this,nt,Kn).call(this,r,s)===!1&&(yield[r,s.value])}}*entriesDescending(){let t=[...le(this,At)];for(let r=t.length-1;r>=0;--r){const s=t[r],[i,o]=s;dt(this,nt,Kn).call(this,i,o)===!1&&(yield[i,o.value])}t=[...le(this,Dt)];for(let r=t.length-1;r>=0;--r){const s=t[r],[i,o]=s;le(this,At).has(i)||dt(this,nt,Kn).call(this,i,o)===!1&&(yield[i,o.value])}}*entriesAscending(){for(const[t,r]of dt(this,nt,em).call(this))yield[t,r.value]}get size(){if(!le(this,Nn))return le(this,Dt).size;let t=0;for(const r of le(this,Dt).keys())le(this,At).has(r)||t++;return Math.min(le(this,Nn)+t,le(this,Es))}get maxSize(){return le(this,Es)}entries(){return this.entriesAscending()}forEach(t,r=this){for(const[s,i]of this.entriesAscending())t.call(r,i,s,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}Nn=new WeakMap,At=new WeakMap,Dt=new WeakMap,Es=new WeakMap,al=new WeakMap,As=new WeakMap,nt=new WeakSet,Kp=function(t){if(typeof le(this,As)=="function")for(const[r,s]of t)le(this,As).call(this,r,s.value)},Kn=function(t,r){return typeof r.expiry=="number"&&r.expiry<=Date.now()?(typeof le(this,As)=="function"&&le(this,As).call(this,t,r.value),this.delete(t)):!1},o2=function(t,r){if(dt(this,nt,Kn).call(this,t,r)===!1)return r.value},Gp=function(t,r){return r.expiry?dt(this,nt,o2).call(this,t,r):r.value},Jp=function(t,r){const s=r.get(t);return dt(this,nt,Gp).call(this,t,s)},Qp=function(t,r){le(this,At).set(t,r),_d(this,Nn)._++,le(this,Nn)>=le(this,Es)&&(Be(this,Nn,0),dt(this,nt,Kp).call(this,le(this,Dt)),Be(this,Dt,le(this,At)),Be(this,At,new Map))},a2=function(t,r){le(this,Dt).delete(t),dt(this,nt,Qp).call(this,t,r)},em=function*(){for(const t of le(this,Dt)){const[r,s]=t;le(this,At).has(r)||dt(this,nt,Kn).call(this,r,s)===!1&&(yield t)}for(const t of le(this,At)){const[r,s]=t;dt(this,nt,Kn).call(this,r,s)===!1&&(yield t)}};function Ny(n,e){return e?"suffixLength"in e?`${n}:-${e.suffixLength}`:`${n}:${e.offset}:${e.offset+e.length-1}`:n}function Dy(n){var e;return(e=n.split("/")[1])!=null&&e.includes(":")?`/.${n}`:n}function YR(n,e=100){const t=new XR({maxSize:e});let r=n.getRange?n.getRange.bind(n):void 0;function s(...i){const[o,a]=i,c=Ny(o),l=t.get(c);if(l)return l;const u=Dy(o),f=Promise.resolve(n.get(u,a));return t.set(c,f),f}if(r){const i=r;r=(...o)=>{const[a,c,l]=o,u=Ny(a,c),f=t.get(u);if(f)return f;const h=Dy(a),d=Promise.resolve(i==null?void 0:i(h,c,l)).catch(m=>{throw t.delete(u),m});return t.set(u,d),d}}return new Proxy(n,{get(i,o,a){return o==="get"?s:o==="getRange"&&r?r:Reflect.get(i,o,a)}})}const qR={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...qR}};const xn=globalThis.mathgl.config;function KR(n,{precision:e=xn.precision}={}){return n=GR(n),`${parseFloat(n.toPrecision(e))}`}function Ii(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Rt(n,e,t){return QR(n,r=>Math.max(e,Math.min(t,r)))}function vi(n,e,t){return Ii(n)?n.map((r,s)=>vi(r,e[s],t)):t*e+(1-t)*n}function Yr(n,e,t){const r=xn.EPSILON;try{if(n===e)return!0;if(Ii(n)&&Ii(e)){if(n.length!==e.length)return!1;for(let s=0;s<n.length;++s)if(!Yr(n[s],e[s]))return!1;return!0}return n&&n.equals?n.equals(e):e&&e.equals?e.equals(n):typeof n=="number"&&typeof e=="number"?Math.abs(n-e)<=xn.EPSILON*Math.max(1,Math.abs(n),Math.abs(e)):!1}finally{xn.EPSILON=r}}function GR(n){return Math.round(n/xn.EPSILON)*xn.EPSILON}function JR(n){return n.clone?n.clone():new Array(n.length)}function QR(n,e,t){if(Ii(n)){const r=n;t=t||JR(r);for(let s=0;s<t.length&&s<r.length;++s){const i=typeof n=="number"?n:n[s];t[s]=e(i,s,t)}return t}return e(n)}class Hg extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ii(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(xn)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+KR(this[r],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Yr(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(r===void 0)return this.lerp(this,e,t);for(let s=0;s<this.ELEMENTS;++s){const i=e[s],o=typeof t=="number"?t:t[s];this[s]=i+r*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=t[r];return this.check()}subtract(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=t[r];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(xn.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}}function eI(n,e){if(n.length!==e)return!1;for(let t=0;t<n.length;++t)if(!Number.isFinite(n[t]))return!1;return!0}function wt(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function sc(n,e,t=""){if(xn.debug&&!eI(n,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return n}function Tc(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}class c2 extends Hg{get x(){return this[0]}set x(e){this[0]=wt(e)}get y(){return this[1]}set y(e){this[1]=wt(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const s=this[r]-e[r];t+=s*s}return wt(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return wt(t)}normalize(){const e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]*=t[r];return this.check()}divide(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Tc(e>=0&&e<this.ELEMENTS,"index is out of range"),wt(this[e])}setComponent(e,t){return Tc(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}const ic=1e-6;let rr=typeof Float32Array<"u"?Float32Array:Array;function tI(){const n=new rr(2);return rr!=Float32Array&&(n[0]=0,n[1]=0),n}function Qu(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function l2(n,e){return n[0]=-e[0],n[1]=-e[1],n}function u2(n,e,t,r){const s=e[0],i=e[1];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n}function nI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[3]*s+t[6],n[1]=t[1]*r+t[4]*s+t[7],n}function rI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[4]*s+t[12],n[1]=t[1]*r+t[5]*s+t[13],n}(function(){const n=tI();return function(e,t,r,s,i,o){let a,c;for(t||(t=2),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],i(n,n,o),e[a]=n[0],e[a+1]=n[1];return e}})();function sI(n,e,t){const r=e[0],s=e[1],i=t[3]*r+t[7]*s||1;return n[0]=(t[0]*r+t[4]*s)/i,n[1]=(t[1]*r+t[5]*s)/i,n}function f2(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[3]*r+t[7]*s+t[11]*i||1;return n[0]=(t[0]*r+t[4]*s+t[8]*i)/o,n[1]=(t[1]*r+t[5]*s+t[9]*i)/o,n[2]=(t[2]*r+t[6]*s+t[10]*i)/o,n}function iI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[2]*s,n[1]=t[1]*r+t[3]*s,n[2]=e[2],n}function oI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[2]*s,n[1]=t[1]*r+t[3]*s,n[2]=e[2],n[3]=e[3],n}function h2(n,e,t){const r=e[0],s=e[1],i=e[2];return n[0]=t[0]*r+t[3]*s+t[6]*i,n[1]=t[1]*r+t[4]*s+t[7]*i,n[2]=t[2]*r+t[5]*s+t[8]*i,n[3]=e[3],n}function d2(){const n=new rr(3);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function aI(n){const e=n[0],t=n[1],r=n[2];return Math.sqrt(e*e+t*t+r*r)}function Ly(n,e,t){const r=new rr(3);return r[0]=n,r[1]=e,r[2]=t,r}function cI(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lI(n){const e=n[0],t=n[1],r=n[2];return e*e+t*t+r*r}function uI(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function fI(n,e){const t=e[0],r=e[1],s=e[2];let i=t*t+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n}function p2(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Pu(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2];return n[0]=s*c-i*a,n[1]=i*o-r*c,n[2]=r*a-s*o,n}function hI(n,e,t,r){const s=e[0],i=e[1],o=e[2];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n[2]=o+r*(t[2]-o),n}function Zg(n,e,t){const r=e[0],s=e[1],i=e[2];let o=t[3]*r+t[7]*s+t[11]*i+t[15];return o=o||1,n[0]=(t[0]*r+t[4]*s+t[8]*i+t[12])/o,n[1]=(t[1]*r+t[5]*s+t[9]*i+t[13])/o,n[2]=(t[2]*r+t[6]*s+t[10]*i+t[14])/o,n}function m2(n,e,t){const r=e[0],s=e[1],i=e[2];return n[0]=r*t[0]+s*t[3]+i*t[6],n[1]=r*t[1]+s*t[4]+i*t[7],n[2]=r*t[2]+s*t[5]+i*t[8],n}function g2(n,e,t){const r=t[0],s=t[1],i=t[2],o=t[3],a=e[0],c=e[1],l=e[2];let u=s*l-i*c,f=i*a-r*l,h=r*c-s*a,d=s*h-i*f,m=i*u-r*h,p=r*f-s*u;const _=o*2;return u*=_,f*=_,h*=_,d*=2,m*=2,p*=2,n[0]=a+u+d,n[1]=c+f+m,n[2]=l+h+p,n}function dI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function pI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function mI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function gI(n,e){const t=n[0],r=n[1],s=n[2],i=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+r*r+s*s)*(i*i+o*o+a*a)),l=c&&p2(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}const _2=cI,y2=aI,Dd=lI;(function(){const n=d2();return function(e,t,r,s,i,o){let a,c;for(t||(t=3),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],n[2]=e[a+2],i(n,n,o),e[a]=n[0],e[a+1]=n[1],e[a+2]=n[2];return e}})();const Ld=[0,0,0];let Yl;class Ce extends c2{static get ZERO(){return Yl||(Yl=new Ce(0,0,0),Object.freeze(Yl)),Yl}constructor(e=0,t=0,r=0){super(-0,-0,-0),arguments.length===1&&Ii(e)?this.copy(e):(xn.debug&&(wt(e),wt(t),wt(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return xn.debug&&(wt(e.x),wt(e.y),wt(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=wt(e)}angle(e){return gI(this,e)}cross(e){return Pu(this,this,e),this.check()}rotateX({radians:e,origin:t=Ld}){return dI(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Ld}){return pI(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Ld}){return mI(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Zg(this,this,e),this.check()}transformAsVector(e){return f2(this,this,e),this.check()}transformByMatrix3(e){return m2(this,this,e),this.check()}transformByMatrix2(e){return iI(this,this,e),this.check()}transformByQuaternion(e){return g2(this,this,e),this.check()}}let ql;class Xg extends c2{static get ZERO(){return ql||(ql=new Xg(0,0,0,0),Object.freeze(ql)),ql}constructor(e=0,t=0,r=0,s=0){super(-0,-0,-0,-0),Ii(e)&&arguments.length===1?this.copy(e):(xn.debug&&(wt(e),wt(t),wt(r),wt(s)),this[0]=e,this[1]=t,this[2]=r,this[3]=s)}set(e,t,r,s){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return xn.debug&&(wt(e.x),wt(e.y),wt(e.z),wt(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=wt(e)}get w(){return this[3]}set w(e){this[3]=wt(e)}transform(e){return Zg(this,this,e),this.check()}transformByMatrix3(e){return h2(this,this,e),this.check()}transformByMatrix2(e){return oI(this,this,e),this.check()}transformByQuaternion(e){return g2(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}class v2 extends Hg{toString(){let e="[";if(xn.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=wt(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let s=0;s<this.RANK;++s)t[s]=this[r+s];return t}setColumn(e,t){const r=e*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=t[s];return this}}function _I(){const n=new rr(9);return rr!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function yI(n,e){if(n===e){const t=e[1],r=e[2],s=e[5];n[1]=e[3],n[2]=e[6],n[3]=t,n[5]=e[7],n[6]=r,n[7]=s}else n[0]=e[0],n[1]=e[3],n[2]=e[6],n[3]=e[1],n[4]=e[4],n[5]=e[7],n[6]=e[2],n[7]=e[5],n[8]=e[8];return n}function vI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=u*o-a*l,h=-u*i+a*c,d=l*i-o*c;let m=t*f+r*h+s*d;return m?(m=1/m,n[0]=f*m,n[1]=(-u*r+s*l)*m,n[2]=(a*r-s*o)*m,n[3]=h*m,n[4]=(u*t-s*c)*m,n[5]=(-a*t+s*i)*m,n[6]=d*m,n[7]=(-l*t+r*c)*m,n[8]=(o*t-r*i)*m,n):null}function xI(n){const e=n[0],t=n[1],r=n[2],s=n[3],i=n[4],o=n[5],a=n[6],c=n[7],l=n[8];return e*(l*i-o*c)+t*(-l*s+o*a)+r*(c*s-i*a)}function Fy(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=t[0],d=t[1],m=t[2],p=t[3],_=t[4],y=t[5],T=t[6],b=t[7],w=t[8];return n[0]=h*r+d*o+m*l,n[1]=h*s+d*a+m*u,n[2]=h*i+d*c+m*f,n[3]=p*r+_*o+y*l,n[4]=p*s+_*a+y*u,n[5]=p*i+_*c+y*f,n[6]=T*r+b*o+w*l,n[7]=T*s+b*a+w*u,n[8]=T*i+b*c+w*f,n}function bI(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=r,n[1]=s,n[2]=i,n[3]=o,n[4]=a,n[5]=c,n[6]=h*r+d*o+l,n[7]=h*s+d*a+u,n[8]=h*i+d*c+f,n}function wI(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=Math.sin(t),d=Math.cos(t);return n[0]=d*r+h*o,n[1]=d*s+h*a,n[2]=d*i+h*c,n[3]=d*o-h*r,n[4]=d*a-h*s,n[5]=d*c-h*i,n[6]=l,n[7]=u,n[8]=f,n}function By(n,e,t){const r=t[0],s=t[1];return n[0]=r*e[0],n[1]=r*e[1],n[2]=r*e[2],n[3]=s*e[3],n[4]=s*e[4],n[5]=s*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function TI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t+t,a=r+r,c=s+s,l=t*o,u=r*o,f=r*a,h=s*o,d=s*a,m=s*c,p=i*o,_=i*a,y=i*c;return n[0]=1-f-m,n[3]=u-y,n[6]=h+_,n[1]=u+y,n[4]=1-l-m,n[7]=d-p,n[2]=h-_,n[5]=d+p,n[8]=1-l-f,n}var tm;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL1ROW0=3]="COL1ROW0",n[n.COL1ROW1=4]="COL1ROW1",n[n.COL1ROW2=5]="COL1ROW2",n[n.COL2ROW0=6]="COL2ROW0",n[n.COL2ROW1=7]="COL2ROW1",n[n.COL2ROW2=8]="COL2ROW2"})(tm||(tm={}));const SI=Object.freeze([1,0,0,0,1,0,0,0,1]);class tn extends v2{static get IDENTITY(){return AI()}static get ZERO(){return EI()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return tm}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(SI)}fromObject(e){return this.check()}fromQuaternion(e){return TI(this,e),this.check()}set(e,t,r,s,i,o,a,c,l){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,t,r,s,i,o,a,c,l){return this[0]=e,this[1]=s,this[2]=a,this[3]=t,this[4]=i,this[5]=c,this[6]=r,this[7]=o,this[8]=l,this.check()}determinant(){return xI(this)}transpose(){return yI(this,this),this.check()}invert(){return vI(this,this),this.check()}multiplyLeft(e){return Fy(this,e,this),this.check()}multiplyRight(e){return Fy(this,this,e),this.check()}rotate(e){return wI(this,this,e),this.check()}scale(e){return Array.isArray(e)?By(this,this,e):By(this,this,[e,e]),this.check()}translate(e){return bI(this,this,e),this.check()}transform(e,t){let r;switch(e.length){case 2:r=nI(t||[-0,-0],e,this);break;case 3:r=m2(t||[-0,-0,-0],e,this);break;case 4:r=h2(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Kl,Gl=null;function EI(){return Kl||(Kl=new tn([0,0,0,0,0,0,0,0,0]),Object.freeze(Kl)),Kl}function AI(){return Gl||(Gl=new tn,Object.freeze(Gl)),Gl}function CI(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function RI(n,e){if(n===e){const t=e[1],r=e[2],s=e[3],i=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=i,n[11]=e[14],n[12]=s,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function nm(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],p=e[13],_=e[14],y=e[15],T=t*a-r*o,b=t*c-s*o,w=t*l-i*o,v=r*c-s*a,A=r*l-i*a,N=s*l-i*c,D=u*p-f*m,B=u*_-h*m,G=u*y-d*m,Q=f*_-h*p,E=f*y-d*p,J=h*y-d*_;let X=T*J-b*E+w*Q+v*G-A*B+N*D;return X?(X=1/X,n[0]=(a*J-c*E+l*Q)*X,n[1]=(s*E-r*J-i*Q)*X,n[2]=(p*N-_*A+y*v)*X,n[3]=(h*A-f*N-d*v)*X,n[4]=(c*G-o*J-l*B)*X,n[5]=(t*J-s*G+i*B)*X,n[6]=(_*w-m*N-y*b)*X,n[7]=(u*N-h*w+d*b)*X,n[8]=(o*E-a*G+l*D)*X,n[9]=(r*G-t*E-i*D)*X,n[10]=(m*A-p*w+y*T)*X,n[11]=(f*w-u*A-d*T)*X,n[12]=(a*B-o*Q-c*D)*X,n[13]=(t*Q-r*B+s*D)*X,n[14]=(p*b-m*v-_*T)*X,n[15]=(u*v-f*b+h*T)*X,n):null}function II(n){const e=n[0],t=n[1],r=n[2],s=n[3],i=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],h=n[11],d=n[12],m=n[13],p=n[14],_=n[15],y=e*o-t*i,T=e*a-r*i,b=t*a-r*o,w=l*m-u*d,v=l*p-f*d,A=u*p-f*m,N=e*A-t*v+r*w,D=i*A-o*v+a*w,B=l*b-u*T+f*y,G=d*b-m*T+p*y;return c*N-s*D+_*B-h*G}function xi(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],m=e[11],p=e[12],_=e[13],y=e[14],T=e[15];let b=t[0],w=t[1],v=t[2],A=t[3];return n[0]=b*r+w*a+v*f+A*p,n[1]=b*s+w*c+v*h+A*_,n[2]=b*i+w*l+v*d+A*y,n[3]=b*o+w*u+v*m+A*T,b=t[4],w=t[5],v=t[6],A=t[7],n[4]=b*r+w*a+v*f+A*p,n[5]=b*s+w*c+v*h+A*_,n[6]=b*i+w*l+v*d+A*y,n[7]=b*o+w*u+v*m+A*T,b=t[8],w=t[9],v=t[10],A=t[11],n[8]=b*r+w*a+v*f+A*p,n[9]=b*s+w*c+v*h+A*_,n[10]=b*i+w*l+v*d+A*y,n[11]=b*o+w*u+v*m+A*T,b=t[12],w=t[13],v=t[14],A=t[15],n[12]=b*r+w*a+v*f+A*p,n[13]=b*s+w*c+v*h+A*_,n[14]=b*i+w*l+v*d+A*y,n[15]=b*o+w*u+v*m+A*T,n}function ef(n,e,t){const r=t[0],s=t[1],i=t[2];let o,a,c,l,u,f,h,d,m,p,_,y;return e===n?(n[12]=e[0]*r+e[4]*s+e[8]*i+e[12],n[13]=e[1]*r+e[5]*s+e[9]*i+e[13],n[14]=e[2]*r+e[6]*s+e[10]*i+e[14],n[15]=e[3]*r+e[7]*s+e[11]*i+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],m=e[8],p=e[9],_=e[10],y=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=h,n[7]=d,n[8]=m,n[9]=p,n[10]=_,n[11]=y,n[12]=o*r+u*s+m*i+e[12],n[13]=a*r+f*s+p*i+e[13],n[14]=c*r+h*s+_*i+e[14],n[15]=l*r+d*s+y*i+e[15]),n}function Yg(n,e,t){const r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*s,n[5]=e[5]*s,n[6]=e[6]*s,n[7]=e[7]*s,n[8]=e[8]*i,n[9]=e[9]*i,n[10]=e[10]*i,n[11]=e[11]*i,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function PI(n,e,t,r){let s=r[0],i=r[1],o=r[2],a=Math.sqrt(s*s+i*i+o*o),c,l,u,f,h,d,m,p,_,y,T,b,w,v,A,N,D,B,G,Q,E,J,X,ce;return a<ic?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],h=e[1],d=e[2],m=e[3],p=e[4],_=e[5],y=e[6],T=e[7],b=e[8],w=e[9],v=e[10],A=e[11],N=s*s*u+c,D=i*s*u+o*l,B=o*s*u-i*l,G=s*i*u-o*l,Q=i*i*u+c,E=o*i*u+s*l,J=s*o*u+i*l,X=i*o*u-s*l,ce=o*o*u+c,n[0]=f*N+p*D+b*B,n[1]=h*N+_*D+w*B,n[2]=d*N+y*D+v*B,n[3]=m*N+T*D+A*B,n[4]=f*G+p*Q+b*E,n[5]=h*G+_*Q+w*E,n[6]=d*G+y*Q+v*E,n[7]=m*G+T*Q+A*E,n[8]=f*J+p*X+b*ce,n[9]=h*J+_*X+w*ce,n[10]=d*J+y*X+v*ce,n[11]=m*J+T*X+A*ce,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function x2(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=i*s+l*r,n[5]=o*s+u*r,n[6]=a*s+f*r,n[7]=c*s+h*r,n[8]=l*s-i*r,n[9]=u*s-o*r,n[10]=f*s-a*r,n[11]=h*s-c*r,n}function kI(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s-l*r,n[1]=o*s-u*r,n[2]=a*s-f*r,n[3]=c*s-h*r,n[8]=i*r+l*s,n[9]=o*r+u*s,n[10]=a*r+f*s,n[11]=c*r+h*s,n}function b2(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s+l*r,n[1]=o*s+u*r,n[2]=a*s+f*r,n[3]=c*s+h*r,n[4]=l*s-i*r,n[5]=u*s-o*r,n[6]=f*s-a*r,n[7]=h*s-c*r,n}function OI(n,e){const t=e[0],r=e[1],s=e[2],i=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+r*r+s*s),n[1]=Math.sqrt(i*i+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function MI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t+t,a=r+r,c=s+s,l=t*o,u=r*o,f=r*a,h=s*o,d=s*a,m=s*c,p=i*o,_=i*a,y=i*c;return n[0]=1-f-m,n[1]=u+y,n[2]=h-_,n[3]=0,n[4]=u-y,n[5]=1-l-m,n[6]=d+p,n[7]=0,n[8]=h+_,n[9]=d-p,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function NI(n,e,t,r,s,i,o){const a=1/(t-e),c=1/(s-r),l=1/(i-o);return n[0]=i*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(s+r)*c,n[10]=(o+i)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*i*2*l,n[15]=0,n}function DI(n,e,t,r,s){const i=1/Math.tan(e/2);if(n[0]=i/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){const o=1/(r-s);n[10]=(s+r)*o,n[14]=2*s*r*o}else n[10]=-1,n[14]=-2*r;return n}const LI=DI;function FI(n,e,t,r,s,i,o){const a=1/(e-t),c=1/(r-s),l=1/(i-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(s+r)*c,n[14]=(o+i)*l,n[15]=1,n}const BI=FI;function UI(n,e,t,r){let s,i,o,a,c,l,u,f,h,d;const m=e[0],p=e[1],_=e[2],y=r[0],T=r[1],b=r[2],w=t[0],v=t[1],A=t[2];return Math.abs(m-w)<ic&&Math.abs(p-v)<ic&&Math.abs(_-A)<ic?CI(n):(f=m-w,h=p-v,d=_-A,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,i=T*d-b*h,o=b*f-y*d,a=y*h-T*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=h*a-d*o,l=d*i-f*a,u=f*o-h*i,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),n[0]=i,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=h,n[7]=0,n[8]=a,n[9]=u,n[10]=d,n[11]=0,n[12]=-(i*m+o*p+a*_),n[13]=-(c*m+l*p+u*_),n[14]=-(f*m+h*p+d*_),n[15]=1,n)}function $I(){const n=new rr(4);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function VI(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function qg(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function zI(n){const e=n[0],t=n[1],r=n[2],s=n[3];return Math.sqrt(e*e+t*t+r*r+s*s)}function jI(n){const e=n[0],t=n[1],r=n[2],s=n[3];return e*e+t*t+r*r+s*s}function WI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3];let o=t*t+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=r*o,n[2]=s*o,n[3]=i*o,n}function HI(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function ZI(n,e,t,r){const s=e[0],i=e[1],o=e[2],a=e[3];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n[2]=o+r*(t[2]-o),n[3]=a+r*(t[3]-a),n}function pa(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3];return n[0]=t[0]*r+t[4]*s+t[8]*i+t[12]*o,n[1]=t[1]*r+t[5]*s+t[9]*i+t[13]*o,n[2]=t[2]*r+t[6]*s+t[10]*i+t[14]*o,n[3]=t[3]*r+t[7]*s+t[11]*i+t[15]*o,n}function XI(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*r+a*i-c*s,f=l*s+c*r-o*i,h=l*i+o*s-a*r,d=-o*r-a*s-c*i;return n[0]=u*l+d*-o+f*-c-h*-a,n[1]=f*l+d*-a+h*-o-u*-c,n[2]=h*l+d*-c+u*-a-f*-o,n[3]=e[3],n}(function(){const n=$I();return function(e,t,r,s,i,o){let a,c;for(t||(t=4),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],n[2]=e[a+2],n[3]=e[a+3],i(n,n,o),e[a]=n[0],e[a+1]=n[1],e[a+2]=n[2],e[a+3]=n[3];return e}})();var rm;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(rm||(rm={}));const YI=45*Math.PI/180,qI=1,Fd=.1,Bd=500,KI=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class qe extends v2{static get IDENTITY(){return JI()}static get ZERO(){return GI()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rm}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,s,i,o,a,c,l,u,f,h,d,m,p,_){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=m,this[14]=p,this[15]=_,this.check()}setRowMajor(e,t,r,s,i,o,a,c,l,u,f,h,d,m,p,_){return this[0]=e,this[1]=i,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=u,this[7]=m,this[8]=r,this[9]=a,this[10]=f,this[11]=p,this[12]=s,this[13]=c,this[14]=h,this[15]=_,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(KI)}fromObject(e){return this.check()}fromQuaternion(e){return MI(this,e),this.check()}frustum(e){const{left:t,right:r,bottom:s,top:i,near:o=Fd,far:a=Bd}=e;return a===1/0?QI(this,t,r,s,i,o):NI(this,t,r,s,i,o,a),this.check()}lookAt(e){const{eye:t,center:r=[0,0,0],up:s=[0,1,0]}=e;return UI(this,t,r,s),this.check()}ortho(e){const{left:t,right:r,bottom:s,top:i,near:o=Fd,far:a=Bd}=e;return BI(this,t,r,s,i,o,a),this.check()}orthographic(e){const{fovy:t=YI,aspect:r=qI,focalDistance:s=1,near:i=Fd,far:o=Bd}=e;Uy(t);const a=t/2,c=s*Math.tan(a),l=c*r;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=e;return Uy(t),LI(this,t,r,s,i),this.check()}determinant(){return II(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),s=1/r[0],i=1/r[1],o=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),s=1/r[0],i=1/r[1],o=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*s,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*s,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return RI(this,this),this.check()}invert(){return nm(this,this),this.check()}multiplyLeft(e){return xi(this,e,this),this.check()}multiplyRight(e){return xi(this,this,e),this.check()}rotateX(e){return x2(this,this,e),this.check()}rotateY(e){return kI(this,this,e),this.check()}rotateZ(e){return b2(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return PI(this,this,e,t),this.check()}scale(e){return Yg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return ef(this,this,e),this.check()}transform(e,t){return e.length===4?(t=pa(t||[-0,-0,-0,-0],e,this),sc(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:r}=e;let s;switch(r){case 2:s=rI(t||[-0,-0],e,this);break;case 3:s=Zg(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(s,e.length),s}transformAsVector(e,t){let r;switch(e.length){case 2:r=sI(t||[-0,-0],e,this);break;case 3:r=f2(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}}let Jl,Ql;function GI(){return Jl||(Jl=new qe([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jl)),Jl}function JI(){return Ql||(Ql=new qe,Object.freeze(Ql)),Ql}function Uy(n){if(n>Math.PI*2)throw Error("expected radians")}function QI(n,e,t,r,s,i){const o=2*i/(t-e),a=2*i/(s-r),c=(t+e)/(t-e),l=(s+r)/(s-r),u=-1,f=-1,h=-2*i;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=h,n[15]=0,n}function $y(){const n=new rr(4);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function eP(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function w2(n,e,t){t=t*.5;const r=Math.sin(t);return n[0]=r*e[0],n[1]=r*e[1],n[2]=r*e[2],n[3]=Math.cos(t),n}function Vy(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=t[0],c=t[1],l=t[2],u=t[3];return n[0]=r*u+o*a+s*l-i*c,n[1]=s*u+o*c+i*a-r*l,n[2]=i*u+o*l+r*c-s*a,n[3]=o*u-r*a-s*c-i*l,n}function tP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c+o*a,n[1]=s*c+i*a,n[2]=i*c-s*a,n[3]=o*c-r*a,n}function nP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c-i*a,n[1]=s*c+o*a,n[2]=i*c+r*a,n[3]=o*c-s*a,n}function rP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c+s*a,n[1]=s*c-r*a,n[2]=i*c+o*a,n[3]=o*c-i*a,n}function sP(n,e){const t=e[0],r=e[1],s=e[2];return n[0]=t,n[1]=r,n[2]=s,n[3]=Math.sqrt(Math.abs(1-t*t-r*r-s*s)),n}function ku(n,e,t,r){const s=e[0],i=e[1],o=e[2],a=e[3];let c=t[0],l=t[1],u=t[2],f=t[3],h,d,m,p,_;return h=s*c+i*l+o*u+a*f,h<0&&(h=-h,c=-c,l=-l,u=-u,f=-f),1-h>ic?(d=Math.acos(h),_=Math.sin(d),m=Math.sin((1-r)*d)/_,p=Math.sin(r*d)/_):(m=1-r,p=r),n[0]=m*s+p*c,n[1]=m*i+p*l,n[2]=m*o+p*u,n[3]=m*a+p*f,n}function iP(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t*t+r*r+s*s+i*i,a=o?1/o:0;return n[0]=-t*a,n[1]=-r*a,n[2]=-s*a,n[3]=i*a,n}function oP(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n}function T2(n,e){const t=e[0]+e[4]+e[8];let r;if(t>0)r=Math.sqrt(t+1),n[3]=.5*r,r=.5/r,n[0]=(e[5]-e[7])*r,n[1]=(e[6]-e[2])*r,n[2]=(e[1]-e[3])*r;else{let s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);const i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(e[s*3+s]-e[i*3+i]-e[o*3+o]+1),n[s]=.5*r,r=.5/r,n[3]=(e[i*3+o]-e[o*3+i])*r,n[i]=(e[i*3+s]+e[s*3+i])*r,n[o]=(e[o*3+s]+e[s*3+o])*r}return n}const aP=VI,cP=qg,lP=HI,uP=ZI,fP=zI,hP=jI,S2=WI,dP=function(){const n=d2(),e=Ly(1,0,0),t=Ly(0,1,0);return function(r,s,i){const o=p2(s,i);return o<-.999999?(Pu(n,e,s),y2(n)<1e-6&&Pu(n,t,s),fI(n,n),w2(r,n,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Pu(n,s,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=1+o,S2(r,r))}}();(function(){const n=$y(),e=$y();return function(t,r,s,i,o,a){return ku(n,r,o,a),ku(e,s,i,a),ku(t,n,e,2*a*(1-a)),t}})();(function(){const n=_I();return function(e,t,r,s){return n[0]=r[0],n[3]=r[1],n[6]=r[2],n[1]=s[0],n[4]=s[1],n[7]=s[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],S2(e,T2(e,n))}})();const pP=[0,0,0,1];class zy extends Hg{constructor(e=0,t=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,t,r,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,r,s){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return T2(this,e),this.check()}fromAxisRotation(e,t){return w2(this,e,t),this.check()}identity(){return eP(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=wt(e)}get y(){return this[1]}set y(e){this[1]=wt(e)}get z(){return this[2]}set z(e){this[2]=wt(e)}get w(){return this[3]}set w(e){this[3]=wt(e)}len(){return fP(this)}lengthSquared(){return hP(this)}dot(e){return lP(this,e)}rotationTo(e,t){return dP(this,e,t),this.check()}add(e){return aP(this,this,e),this.check()}calculateW(){return sP(this,this),this.check()}conjugate(){return oP(this,this),this.check()}invert(){return iP(this,this),this.check()}lerp(e,t,r){return r===void 0?this.lerp(this,e,t):(uP(this,e,t,r),this.check())}multiplyRight(e){return Vy(this,this,e),this.check()}multiplyLeft(e){return Vy(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,e===0&&(this[3]=1),this.check()}rotateX(e){return tP(this,this,e),this.check()}rotateY(e){return nP(this,this,e),this.check()}rotateZ(e){return rP(this,this,e),this.check()}scale(e){return cP(this,this,e),this.check()}slerp(e,t,r){let s,i,o;switch(arguments.length){case 1:({start:s=pP,target:i,ratio:o}=e);break;case 2:s=this,i=e,o=t;break;default:s=e,i=t,o=r}return ku(this,s,i,o),this.check()}transformVector4(e,t=new Xg){return XI(t,e,this),sc(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const mP=1e-15,gP=1e-20,bi=6,Sr={cyan:"#00FFFF",yellow:"#FFFF00",magenta:"#FF00FF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",white:"#FFFFFF"},_P=[Sr.magenta,Sr.green],yP=[Sr.red,Sr.green,Sr.blue],jy=Object.values(Sr).slice(0,bi),vP="https://ome.github.io/ome-ngff-validator/";async function xP(n){if(typeof n=="string"){let e,t="/";if(n.endsWith(".json")){const[{default:r},s]=await Promise.all([Promise.resolve().then(()=>require("./ref-CIxavIn6.cjs")),fetch(n).then(i=>i.json())]);e=r.fromSpec(s)}else try{const r=Ju.fromUrl(n);await r.has("/"),e=r}catch{const r=new URL(n);t=bP(r.pathname),r.pathname="/",e=new _R(r.href)}return new Ys(YR(e),t)}return jC(n)}function bP(n){return n==="/"||n.startsWith("/")?n:`/${n}`}async function wP(n){const e=await xP(n);return en(e)}async function Ud(n,e){const t=new TextDecoder;if(e.path&&(n=n.resolve(e.path)),e.zarrVersion===3){const o=await en.v3(n).then(a=>a.attrs);return Pi(o)}const r=n.resolve(".zattrs"),s=await n.store.get(r.path),i=s?JSON.parse(t.decode(s)):{};return Pi(i)}async function Kg(n,e){const{datasets:t}=e[0]||[{path:"0"}];return Promise.all(t.map(({path:r})=>en(n.resolve(r),{kind:"array",attrs:!1})))}function Gg(n){n.startsWith("#")&&(n=n.slice(1));const e=Number.parseInt(n.slice(0,2),16),t=Number.parseInt(n.slice(2,4),16),r=Number.parseInt(n.slice(4,6),16);return[e,t,r]}function Sc(n){return Array.from({length:n},(e,t)=>t)}function TP(n,e=" "){for(;n.length>0&&e.includes(n.charAt(n.length-1));)n=n.substr(0,n.length-1);return n}function Ao(...n){return n.filter(e=>e!==void 0).map(e=>TP(e,"/")).join("/")}function SP(n,e){return(!e||e.length!==n.shape.length)&&(e=n.shape.slice(0,-2).map((r,s)=>`${s}`).concat(["y","x"])),e}function E2(n){return Sc(n).map(e=>`channel_${e}`)}function Wy(n){return n==="t"?"time":n==="c"?"channel":"space"}function Lh(n){return typeof n[0]=="object"&&n[0]&&"axes"in n[0]&&Array.isArray(n[0].axes)?n[0].axes.map(t=>{if(typeof t=="string")return{name:t,type:Wy(t)};const{name:r,type:s,unit:i}=t;return{name:r,type:s??Wy(r),unit:i}}):[{type:"channel",name:"c"},{type:"space",name:"z"},{type:"space",name:"y"},{type:"space",name:"x"}]}function hl(n){return n.map(t=>t.name)}function A2(n,e){return e||(n<=bi?e=Array(n).fill(!0):e=[...Array(bi).fill(!0),...Array(n-bi).fill(!1)]),e}function C2(n,e){let t=[];if(n===1)t=[Sr.white];else if(n===2)t=_P;else if(n===3)t=yP;else if(n<=bi)t=jy.slice(0,n);else{t=Array(n).fill(Sr.white);const r=e.flatMap((s,i)=>s?i:[]);for(const[s,i]of r.entries())t[i]=jy[s]}return t}function R2(n){const e=n[n.length-1];return e===3||e===4}function dl(n){const e=R2(n.shape),[t,r]=n.chunks.slice(e?-3:-2),s=Math.min(t,r);return 2**Math.floor(Math.log2(s))}function I2(n){const{image:e,viewport:t,padding:r,matrix:s=new qe().identity()}=n,i=[[0,0,0],[e.width,0,0],[e.width,e.height,0],[0,e.height,0]].map(h=>s.transformAsPoint(h)),o=Math.min(...i.map(h=>h[0])),a=Math.max(...i.map(h=>h[0])),c=Math.min(...i.map(h=>h[1])),l=Math.max(...i.map(h=>h[1])),u=t.width-2*r,f=t.height-2*r;return{zoom:Math.log2(Math.min(u/(a-o),f/(l-c))),target:[(o+a)/2,(c+l)/2]}}function EP(n){return Array.isArray(n)?n.length===16&&n.every(e=>typeof e=="number"):!1}function Fh(n){if(!n)return qe.IDENTITY;const e=new qe;try{const t=typeof n=="string"?JSON.parse(n):n;it(EP(t),"Invalid modelMatrix size. Must be 16."),e.setRowMajor(...t)}catch{const t=`Failed to parse modelMatrix. Got ${JSON.stringify(n)}, using identity.`;console.warn(t)}return e}async function Jg(n,e){if(n.dtype==="Uint8")return[0,255];const{data:t}=await n.getRaster({selection:e});let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let i=0;i<t.length;i++)t[i]>s&&(s=t[i]),t[i]<r&&(r=t[i]);return r===s&&(r=0,s=1),[r,s]}async function P2(n,e,t,r){const s=n.shape.map(()=>0),i=n.shape[e];return e!==-1&&it(i===t.length,"visibilities do not match number of channels"),Promise.all(t.map(async(o,a)=>{if(!o)return;const c=[...s];return e>-1&&(c[e]=a),Jg(n,c)}))}function AP(){let n,e;return{promise:new Promise((r,s)=>{n=r,e=s}),resolve:n,reject:e}}function CP(){let n=new EventTarget;return{on:(e,t)=>{n.addEventListener(e,r=>t(r.detail))},emit:(e,t)=>{n.dispatchEvent(new CustomEvent(e,{detail:t}))}}}function Pi(n){return"omero"in n&&"ome"in n?{version:typeof n.ome=="object"&&n.ome!==null&&"version"in n.ome?n.ome.version:"",multiscales:typeof n.ome=="object"&&n.ome!==null&&"multiscales"in n.ome?n.ome.multiscales:{},omero:{channels:typeof n.omero=="object"&&n.omero!==null&&"channels"in n.omero?n.omero.channels:{}}}:"ome"in n?n.ome:n}class k2 extends Error{constructor(e){super(e),this.name="AssertionError"}}class O2 extends Error{constructor(t,r){super(t);x(this,"url");this.name="RedirectError",this.url=r}}function it(n,e=""){if(!n)throw new k2(e)}async function RP(n){try{return await en.v3(n),3}catch(e){if(!(e instanceof ji))throw e;return 2}}function Hy(n){return"plate"in n}function IP(n){return"well"in n}function PP(n){return"image-label"in n&&Ec(n)}function M2(n){return"omero"in n&&Ec(n)}function Ec(n){return"multiscales"in n}function kP(n){return"bioformats2raw.layout"in n}/**
|
|
135
|
+
To suppress this warning, you need to explicitly provide the \`palette.${e}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function cC(n){return typeof n=="number"?`${n}px`:typeof n=="string"||typeof n=="function"||Array.isArray(n)?n:"8px"}const hr=n=>{try{return n()}catch{}},lC=(n="mui")=>R4(n);function Id(n,e,t,r,s){if(!t)return;t=t===!0?{}:t;const i=s==="dark"?"dark":"light";if(!r){e[s]=rC({...t,palette:{mode:i,...t==null?void 0:t.palette},colorSpace:n});return}const{palette:o,...a}=Fp({...r,palette:{mode:i,...t==null?void 0:t.palette},colorSpace:n});return e[s]={...t,palette:o,opacity:{...$1(i),...t==null?void 0:t.opacity},overlays:(t==null?void 0:t.overlays)||V1(i)},a}function uC(n={},...e){const{colorSchemes:t={light:!0},defaultColorScheme:r,disableCssColorScheme:s=!1,cssVarPrefix:i="mui",nativeColor:o=!1,shouldSkipGeneratingVar:a=sC,colorSchemeSelector:c=t.light&&t.dark?"media":void 0,rootSelector:l=":root",...u}=n,f=Object.keys(t)[0],h=r||(t.light&&f!=="light"?"light":f),d=lC(i),{[h]:m,light:p,dark:_,...y}=t,T={...y};let b=m;if((h==="dark"&&!("dark"in t)||h==="light"&&!("light"in t))&&(b=!0),!b)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${h}\` option is either missing or invalid.`:Fs(21,h));let w;o&&(w="oklch");const v=Id(w,T,b,u,h);p&&!T.light&&Id(w,T,p,void 0,"light"),_&&!T.dark&&Id(w,T,_,void 0,"dark");let A={defaultColorScheme:h,...v,cssVarPrefix:i,colorSchemeSelector:c,rootSelector:l,getCssVar:d,colorSchemes:T,font:{...$4(v.typography),...v.font},spacing:cC(u.spacing)};Object.keys(A.colorSchemes).forEach(Q=>{const E=A.colorSchemes[Q].palette,J=ce=>{const k=ce.split("-"),z=k[1],$=k[2];return d(ce,E[z][$])};E.mode==="light"&&(se(E.common,"background","#fff"),se(E.common,"onBackground","#000")),E.mode==="dark"&&(se(E.common,"background","#000"),se(E.common,"onBackground","#fff"));function X(ce,k,z){if(w){let $;return ce===ni&&($=`transparent ${((1-z)*100).toFixed(0)}%`),ce===ut&&($=`#000 ${(z*100).toFixed(0)}%`),ce===ft&&($=`#fff ${(z*100).toFixed(0)}%`),`color-mix(in ${w}, ${k}, ${$})`}return ce(k,z)}if(aC(E,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),E.mode==="light"){se(E.Alert,"errorColor",X(ut,E.error.light,.6)),se(E.Alert,"infoColor",X(ut,E.info.light,.6)),se(E.Alert,"successColor",X(ut,E.success.light,.6)),se(E.Alert,"warningColor",X(ut,E.warning.light,.6)),se(E.Alert,"errorFilledBg",J("palette-error-main")),se(E.Alert,"infoFilledBg",J("palette-info-main")),se(E.Alert,"successFilledBg",J("palette-success-main")),se(E.Alert,"warningFilledBg",J("palette-warning-main")),se(E.Alert,"errorFilledColor",hr(()=>E.getContrastText(E.error.main))),se(E.Alert,"infoFilledColor",hr(()=>E.getContrastText(E.info.main))),se(E.Alert,"successFilledColor",hr(()=>E.getContrastText(E.success.main))),se(E.Alert,"warningFilledColor",hr(()=>E.getContrastText(E.warning.main))),se(E.Alert,"errorStandardBg",X(ft,E.error.light,.9)),se(E.Alert,"infoStandardBg",X(ft,E.info.light,.9)),se(E.Alert,"successStandardBg",X(ft,E.success.light,.9)),se(E.Alert,"warningStandardBg",X(ft,E.warning.light,.9)),se(E.Alert,"errorIconColor",J("palette-error-main")),se(E.Alert,"infoIconColor",J("palette-info-main")),se(E.Alert,"successIconColor",J("palette-success-main")),se(E.Alert,"warningIconColor",J("palette-warning-main")),se(E.AppBar,"defaultBg",J("palette-grey-100")),se(E.Avatar,"defaultBg",J("palette-grey-400")),se(E.Button,"inheritContainedBg",J("palette-grey-300")),se(E.Button,"inheritContainedHoverBg",J("palette-grey-A100")),se(E.Chip,"defaultBorder",J("palette-grey-400")),se(E.Chip,"defaultAvatarColor",J("palette-grey-700")),se(E.Chip,"defaultIconColor",J("palette-grey-700")),se(E.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),se(E.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),se(E.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),se(E.LinearProgress,"primaryBg",X(ft,E.primary.main,.62)),se(E.LinearProgress,"secondaryBg",X(ft,E.secondary.main,.62)),se(E.LinearProgress,"errorBg",X(ft,E.error.main,.62)),se(E.LinearProgress,"infoBg",X(ft,E.info.main,.62)),se(E.LinearProgress,"successBg",X(ft,E.success.main,.62)),se(E.LinearProgress,"warningBg",X(ft,E.warning.main,.62)),se(E.Skeleton,"bg",w?X(ni,E.text.primary,.11):`rgba(${J("palette-text-primaryChannel")} / 0.11)`),se(E.Slider,"primaryTrack",X(ft,E.primary.main,.62)),se(E.Slider,"secondaryTrack",X(ft,E.secondary.main,.62)),se(E.Slider,"errorTrack",X(ft,E.error.main,.62)),se(E.Slider,"infoTrack",X(ft,E.info.main,.62)),se(E.Slider,"successTrack",X(ft,E.success.main,.62)),se(E.Slider,"warningTrack",X(ft,E.warning.main,.62));const ce=w?X(ut,E.background.default,.6825):Wl(E.background.default,.8);se(E.SnackbarContent,"bg",ce),se(E.SnackbarContent,"color",hr(()=>w?Lp.text.primary:E.getContrastText(ce))),se(E.SpeedDialAction,"fabHoverBg",Wl(E.background.paper,.15)),se(E.StepConnector,"border",J("palette-grey-400")),se(E.StepContent,"border",J("palette-grey-400")),se(E.Switch,"defaultColor",J("palette-common-white")),se(E.Switch,"defaultDisabledColor",J("palette-grey-100")),se(E.Switch,"primaryDisabledColor",X(ft,E.primary.main,.62)),se(E.Switch,"secondaryDisabledColor",X(ft,E.secondary.main,.62)),se(E.Switch,"errorDisabledColor",X(ft,E.error.main,.62)),se(E.Switch,"infoDisabledColor",X(ft,E.info.main,.62)),se(E.Switch,"successDisabledColor",X(ft,E.success.main,.62)),se(E.Switch,"warningDisabledColor",X(ft,E.warning.main,.62)),se(E.TableCell,"border",X(ft,X(ni,E.divider,1),.88)),se(E.Tooltip,"bg",X(ni,E.grey[700],.92))}if(E.mode==="dark"){se(E.Alert,"errorColor",X(ft,E.error.light,.6)),se(E.Alert,"infoColor",X(ft,E.info.light,.6)),se(E.Alert,"successColor",X(ft,E.success.light,.6)),se(E.Alert,"warningColor",X(ft,E.warning.light,.6)),se(E.Alert,"errorFilledBg",J("palette-error-dark")),se(E.Alert,"infoFilledBg",J("palette-info-dark")),se(E.Alert,"successFilledBg",J("palette-success-dark")),se(E.Alert,"warningFilledBg",J("palette-warning-dark")),se(E.Alert,"errorFilledColor",hr(()=>E.getContrastText(E.error.dark))),se(E.Alert,"infoFilledColor",hr(()=>E.getContrastText(E.info.dark))),se(E.Alert,"successFilledColor",hr(()=>E.getContrastText(E.success.dark))),se(E.Alert,"warningFilledColor",hr(()=>E.getContrastText(E.warning.dark))),se(E.Alert,"errorStandardBg",X(ut,E.error.light,.9)),se(E.Alert,"infoStandardBg",X(ut,E.info.light,.9)),se(E.Alert,"successStandardBg",X(ut,E.success.light,.9)),se(E.Alert,"warningStandardBg",X(ut,E.warning.light,.9)),se(E.Alert,"errorIconColor",J("palette-error-main")),se(E.Alert,"infoIconColor",J("palette-info-main")),se(E.Alert,"successIconColor",J("palette-success-main")),se(E.Alert,"warningIconColor",J("palette-warning-main")),se(E.AppBar,"defaultBg",J("palette-grey-900")),se(E.AppBar,"darkBg",J("palette-background-paper")),se(E.AppBar,"darkColor",J("palette-text-primary")),se(E.Avatar,"defaultBg",J("palette-grey-600")),se(E.Button,"inheritContainedBg",J("palette-grey-800")),se(E.Button,"inheritContainedHoverBg",J("palette-grey-700")),se(E.Chip,"defaultBorder",J("palette-grey-700")),se(E.Chip,"defaultAvatarColor",J("palette-grey-300")),se(E.Chip,"defaultIconColor",J("palette-grey-300")),se(E.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),se(E.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),se(E.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),se(E.LinearProgress,"primaryBg",X(ut,E.primary.main,.5)),se(E.LinearProgress,"secondaryBg",X(ut,E.secondary.main,.5)),se(E.LinearProgress,"errorBg",X(ut,E.error.main,.5)),se(E.LinearProgress,"infoBg",X(ut,E.info.main,.5)),se(E.LinearProgress,"successBg",X(ut,E.success.main,.5)),se(E.LinearProgress,"warningBg",X(ut,E.warning.main,.5)),se(E.Skeleton,"bg",w?X(ni,E.text.primary,.13):`rgba(${J("palette-text-primaryChannel")} / 0.13)`),se(E.Slider,"primaryTrack",X(ut,E.primary.main,.5)),se(E.Slider,"secondaryTrack",X(ut,E.secondary.main,.5)),se(E.Slider,"errorTrack",X(ut,E.error.main,.5)),se(E.Slider,"infoTrack",X(ut,E.info.main,.5)),se(E.Slider,"successTrack",X(ut,E.success.main,.5)),se(E.Slider,"warningTrack",X(ut,E.warning.main,.5));const ce=w?X(ft,E.background.default,.985):Wl(E.background.default,.98);se(E.SnackbarContent,"bg",ce),se(E.SnackbarContent,"color",hr(()=>w?L1.text.primary:E.getContrastText(ce))),se(E.SpeedDialAction,"fabHoverBg",Wl(E.background.paper,.15)),se(E.StepConnector,"border",J("palette-grey-600")),se(E.StepContent,"border",J("palette-grey-600")),se(E.Switch,"defaultColor",J("palette-grey-300")),se(E.Switch,"defaultDisabledColor",J("palette-grey-600")),se(E.Switch,"primaryDisabledColor",X(ut,E.primary.main,.55)),se(E.Switch,"secondaryDisabledColor",X(ut,E.secondary.main,.55)),se(E.Switch,"errorDisabledColor",X(ut,E.error.main,.55)),se(E.Switch,"infoDisabledColor",X(ut,E.info.main,.55)),se(E.Switch,"successDisabledColor",X(ut,E.success.main,.55)),se(E.Switch,"warningDisabledColor",X(ut,E.warning.main,.55)),se(E.TableCell,"border",X(ut,X(ni,E.divider,1),.68)),se(E.Tooltip,"bg",X(ni,E.grey[700],.92))}Lr(E.background,"default"),Lr(E.background,"paper"),Lr(E.common,"background"),Lr(E.common,"onBackground"),Lr(E,"divider"),Object.keys(E).forEach(ce=>{const k=E[ce];ce!=="tonalOffset"&&k&&typeof k=="object"&&(k.main&&se(E[ce],"mainChannel",$a(Va(k.main))),k.light&&se(E[ce],"lightChannel",$a(Va(k.light))),k.dark&&se(E[ce],"darkChannel",$a(Va(k.dark))),k.contrastText&&se(E[ce],"contrastTextChannel",$a(Va(k.contrastText))),ce==="text"&&(Lr(E[ce],"primary"),Lr(E[ce],"secondary")),ce==="action"&&(k.active&&Lr(E[ce],"active"),k.selected&&Lr(E[ce],"selected")))})}),A=e.reduce((Q,E)=>On(Q,E),A);const N={prefix:i,disableCssColorScheme:s,shouldSkipGeneratingVar:a,getSelector:oC(A),enableContrastVars:o},{vars:D,generateThemeVars:B,generateStyleSheets:G}=k4(A,N);return A.vars=D,Object.entries(A.colorSchemes[A.defaultColorScheme]).forEach(([Q,E])=>{A[Q]=E}),A.generateThemeVars=B,A.generateStyleSheets=G,A.generateSpacing=function(){return w1(u.spacing,Sg(this))},A.getColorSchemeSelector=O4(c),A.spacing=A.generateSpacing(),A.shouldSkipGeneratingVar=a,A.unstable_sxConfig={...Rh,...u==null?void 0:u.unstable_sxConfig},A.unstable_sx=function(E){return Ci({sx:E,theme:this})},A.toRuntimeSource=U1,A}function py(n,e,t){n.colorSchemes&&t&&(n.colorSchemes[e]={...t!==!0&&t,palette:Mg({...t===!0?{}:t.palette,mode:e})})}function Ng(n={},...e){const{palette:t,cssVariables:r=!1,colorSchemes:s=t?void 0:{light:!0},defaultColorScheme:i=t==null?void 0:t.mode,...o}=n,a=i||"light",c=s==null?void 0:s[a],l={...s,...t?{[a]:{...typeof c!="boolean"&&c,palette:t}}:void 0};if(r===!1){if(!("colorSchemes"in n))return Fp(n,...e);let u=t;"palette"in n||l[a]&&(l[a]!==!0?u=l[a].palette:a==="dark"&&(u={mode:"dark"}));const f=Fp({...n,palette:u},...e);return f.defaultColorScheme=a,f.colorSchemes=l,f.palette.mode==="light"&&(f.colorSchemes.light={...l.light!==!0&&l.light,palette:f.palette},py(f,"dark",l.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...l.dark!==!0&&l.dark,palette:f.palette},py(f,"light",l.light)),f}return!t&&!("light"in l)&&a==="light"&&(l.light=!0),uC({...o,colorSchemes:l,defaultColorScheme:a,...typeof r!="boolean"&&r},...e)}const z1=Ng();function fC(){const n=T1(z1);return process.env.NODE_ENV!=="production"&&xe.useDebugValue(n),n[Os]||n}function hC(n){return n!=="ownerState"&&n!=="theme"&&n!=="sx"&&n!=="as"}const dC=n=>hC(n)&&n!=="classes",zi=t4({themeId:Os,defaultTheme:z1,rootShouldForwardProp:dC});function pC({theme:n,...e}){const t=Os in n?n[Os]:void 0;return U.jsx(vc,{...e,themeId:t?Os:void 0,theme:t||n})}const Hl={colorSchemeStorageKey:"mui-color-scheme",defaultLightColorScheme:"light",defaultDarkColorScheme:"dark",modeStorageKey:"mui-mode"};process.env.NODE_ENV!=="production"&&(oe.string,oe.string,oe.string,oe.string,oe.string,oe.oneOf(["dark","light","system"]),oe.string,oe.string);const{CssVarsProvider:mC}=C4({themeId:Os,theme:()=>Ng({cssVariables:!0}),colorSchemeStorageKey:Hl.colorSchemeStorageKey,modeStorageKey:Hl.modeStorageKey,defaultColorScheme:{light:Hl.defaultLightColorScheme,dark:Hl.defaultDarkColorScheme},resolveTheme:n=>{const e={...n,typography:B1(n.palette,n.typography)};return e.unstable_sx=function(r){return Ci({sx:r,theme:this})},e}}),gC=mC;function _C({theme:n,...e}){const t=xe.useMemo(()=>{if(typeof n=="function")return n;const r=Os in n?n[Os]:n;return"colorSchemes"in r?null:"vars"in r?n:{...n,vars:null}},[n]);return t?U.jsx(pC,{theme:t,...e}):U.jsx(gC,{theme:n,...e})}const Dg=Ng({palette:{mode:"dark",primary:{main:Np[500]},secondary:{main:Np[500]}},components:{MuiButton:{defaultProps:{size:"small"}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiFilledInput:{defaultProps:{margin:"dense"}},MuiFormControl:{defaultProps:{margin:"dense"}},MuiFormHelperText:{defaultProps:{margin:"dense"}},MuiIconButton:{defaultProps:{size:"small"}},MuiInputBase:{defaultProps:{margin:"dense"}},MuiInputLabel:{defaultProps:{margin:"dense"}},MuiOutlinedInput:{defaultProps:{margin:"dense"}},MuiSlider:{defaultProps:{size:"small"},styleOverrides:{thumb:{"&:focus, &:hover":{boxShadow:"none"},height:11,width:5,borderRadius:"15%",marginLeft:-1}}},MuiInput:{styleOverrides:{underline:{"&&&&:hover:before":{borderBottom:"1px solid #fff"}}}},MuiPaper:{styleOverrides:{root:{backgroundColor:"rgba(0, 0, 0, 0.8)"}}},MuiSvgIcon:{styleOverrides:{root:{width:"0.7em",height:"0.7em"}}}}});let yC=0;function vC(n,e){const t=`atom${++yC}`,r={toString:()=>t};return typeof n=="function"?r.read=n:(r.init=n,r.read=s=>s(r),r.write=(s,i,o)=>i(r,typeof o=="function"?o(s(r)):o)),e&&(r.write=e),r}const Cn={},Us=Symbol(),Bp=n=>!!n[Us],Zl=n=>!n[Us].c,Aa=n=>{var e;const{b:t,c:r}=n[Us];r&&(r(),(e=bC.get(t))==null||e())},Au=(n,e)=>{const t=n[Us].o,r=e[Us].o;return t===r||n===r||Bp(t)&&Au(t,e)},Up=(n,e)=>{const t={b:n,o:e,c:null},r=new Promise(s=>{t.c=()=>{t.c=null,s()},e.finally(t.c)});return r[Us]=t,r},xC=n=>Up(n[Us].b,n[Us].o),bC=new WeakMap,Xl=n=>"init"in n,$p="r",Vp="w",xc="c",zp="s",my="h",wC="n",TC="l",SC="a",EC="m",AC=n=>{const e=new WeakMap,t=new WeakMap,r=new Map;let s,i;if((Cn&&"production")!=="production"&&(s=new Set,i=new Set),n)for(const[C,I]of n){const M={v:I,r:0,y:!0,d:new Map};(Cn&&"production")!=="production"&&(Object.freeze(M),Xl(C)||console.warn("Found initial value for derived atom which can cause unexpected behavior",C)),e.set(C,M)}const o=new WeakMap,a=(C,I,M)=>{let V=o.get(I);V||(V=new Map,o.set(I,V)),M.then(()=>{V.get(C)===M&&(V.delete(C),V.size||o.delete(I))}),V.set(C,M)},c=C=>{const I=new Set,M=o.get(C);return M&&(o.delete(C),M.forEach((V,Z)=>{Aa(V),I.add(Z)})),I},l=new WeakMap,u=C=>{let I=l.get(C);return I||(I=new Map,l.set(C,I)),I},f=(C,I)=>{if(C){const M=u(C);let V=M.get(I);return V||(V=f(C.p,I),V&&"p"in V&&Zl(V.p)&&(V=void 0),V&&M.set(I,V)),V}return e.get(I)},h=(C,I,M)=>{if((Cn&&"production")!=="production"&&Object.freeze(M),C)u(C).set(I,M);else{const V=e.get(I);e.set(I,M),r.has(I)||r.set(I,V)}},d=(C,I=new Map,M)=>{if(!M)return I;const V=new Map;let Z=!1;return M.forEach(q=>{var ne;const te=((ne=f(C,q))==null?void 0:ne.r)||0;V.set(q,te),I.get(q)!==te&&(Z=!0)}),I.size===V.size&&!Z?I:V},m=(C,I,M,V,Z)=>{const q=f(C,I);if(q){if(Z&&(!("p"in q)||!Au(q.p,Z)))return q;"p"in q&&Aa(q.p)}const ne={v:M,r:(q==null?void 0:q.r)||0,y:!0,d:d(C,q==null?void 0:q.d,V)};let te=!(q!=null&&q.y);return!q||!("v"in q)||!Object.is(q.v,M)?(te=!0,++ne.r,ne.d.has(I)&&(ne.d=new Map(ne.d).set(I,ne.r))):ne.d!==q.d&&(ne.d.size!==q.d.size||!Array.from(ne.d.keys()).every(pe=>q.d.has(pe)))&&(te=!0,Promise.resolve().then(()=>{ce(C)})),q&&!te?q:(h(C,I,ne),ne)},p=(C,I,M,V,Z)=>{const q=f(C,I);if(q){if(Z&&(!("p"in q)||!Au(q.p,Z)))return q;"p"in q&&Aa(q.p)}const ne={e:M,r:((q==null?void 0:q.r)||0)+1,y:!0,d:d(C,q==null?void 0:q.d,V)};return h(C,I,ne),ne},_=(C,I,M,V)=>{const Z=f(C,I);if(Z&&"p"in Z){if(Au(Z.p,M)&&!Zl(Z.p))return Z.y?Z:{...Z,y:!0};Aa(Z.p)}a(C,I,M);const q={p:M,r:((Z==null?void 0:Z.r)||0)+1,y:!0,d:d(C,Z==null?void 0:Z.d,V)};return h(C,I,q),q},y=(C,I,M,V)=>{if(M instanceof Promise){const Z=Up(M,M.then(q=>{m(C,I,q,V,Z)}).catch(q=>{if(q instanceof Promise)return Bp(q)?q.then(()=>{b(C,I,!0)}):q;p(C,I,q,V,Z)}));return _(C,I,Z,V)}return m(C,I,M,V)},T=(C,I)=>{const M=f(C,I);if(M){const V={...M,y:!1};h(C,I,V)}else(Cn&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",I)},b=(C,I,M)=>{if(!M){const Z=f(C,I);if(Z){if(Z.y&&"p"in Z&&!Zl(Z.p))return Z;if(Z.d.forEach((q,ne)=>{if(ne!==I)if(!t.has(ne))b(C,ne);else{const te=f(C,ne);te&&!te.y&&b(C,ne)}}),Array.from(Z.d).every(([q,ne])=>{const te=f(C,q);return te&&!("p"in te)&&te.r===ne}))return Z.y?Z:{...Z,y:!0}}}const V=new Set;try{const Z=I.read(q=>{V.add(q);const ne=q===I?f(C,q):b(C,q);if(ne){if("e"in ne)throw ne.e;if("p"in ne)throw ne.p;return ne.v}if(Xl(q))return q.init;throw new Error("no atom init")});return y(C,I,Z,V)}catch(Z){if(Z instanceof Promise){const q=Bp(Z)&&Zl(Z)?xC(Z):Up(Z,Z);return _(C,I,q,V)}return p(C,I,Z,V)}},w=(C,I)=>b(I,C),v=(C,I)=>{let M=t.get(I);return M||(M=E(C,I)),M},A=(C,I)=>!I.l.size&&(!I.t.size||I.t.size===1&&I.t.has(C)),N=(C,I)=>{const M=t.get(I);M&&A(I,M)&&J(C,I)},D=(C,I)=>{const M=t.get(I);M==null||M.t.forEach(V=>{V!==I&&(T(C,V),D(C,V))})},B=(C,I,M)=>{let V=!0;const Z=(te,pe)=>{const me=b(C,te);if("e"in me)throw me.e;if("p"in me){if(pe!=null&&pe.unstable_promise)return me.p.then(()=>{const ye=f(C,te);return ye&&"p"in ye&&ye.p===me.p?new Promise(Qe=>setTimeout(Qe)).then(()=>Z(te,pe)):Z(te,pe)});throw(Cn&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",te),me.p}if("v"in me)return me.v;throw(Cn&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",te),new Error("no value found")},q=(te,pe)=>{let me;if(te===I){if(!Xl(te))throw new Error("atom not writable");c(te).forEach(xt=>{xt!==C&&y(xt,te,pe)});const Qe=f(C,te),ge=y(C,te,pe);Qe!==ge&&D(C,te)}else me=B(C,te,pe);return V||ce(C),me},ne=I.write(Z,q,M);return V=!1,ne},G=(C,I,M)=>{const V=B(M,C,I);return ce(M),V},Q=C=>!!C.write,E=(C,I,M)=>{const V={t:new Set(M&&[M]),l:new Set};if(t.set(I,V),(Cn&&"production")!=="production"&&i.add(I),b(void 0,I).d.forEach((q,ne)=>{const te=t.get(ne);te?te.t.add(I):ne!==I&&E(C,ne,I)}),Q(I)&&I.onMount){const q=te=>G(I,te,C),ne=I.onMount(q);C=void 0,ne&&(V.u=ne)}return V},J=(C,I)=>{var M;const V=(M=t.get(I))==null?void 0:M.u;V&&V(),t.delete(I),(Cn&&"production")!=="production"&&i.delete(I);const Z=f(C,I);Z?("p"in Z&&Aa(Z.p),Z.d.forEach((q,ne)=>{if(ne!==I){const te=t.get(ne);te&&(te.t.delete(I),A(ne,te)&&J(C,ne))}})):(Cn&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",I)},X=(C,I,M,V)=>{const Z=new Set(M.d.keys());V==null||V.forEach((q,ne)=>{if(Z.has(ne)){Z.delete(ne);return}const te=t.get(ne);te&&(te.t.delete(I),A(ne,te)&&J(C,ne))}),Z.forEach(q=>{const ne=t.get(q);ne?ne.t.add(I):t.has(I)&&E(C,q,I)})},ce=C=>{if(C){u(C).forEach((M,V)=>{const Z=e.get(V);if(M!==Z){const q=t.get(V);q==null||q.l.forEach(ne=>ne(C))}});return}for(;r.size;){const I=Array.from(r);r.clear(),I.forEach(([M,V])=>{const Z=f(void 0,M);if(Z&&Z.d!==(V==null?void 0:V.d)&&X(void 0,M,Z,V==null?void 0:V.d),V&&!V.y&&(Z!=null&&Z.y))return;const q=t.get(M);q==null||q.l.forEach(ne=>ne())})}(Cn&&"production")!=="production"&&s.forEach(I=>I())},k=C=>{u(C).forEach((M,V)=>{const Z=e.get(V);(!Z||M.r>Z.r||M.y!==Z.y||M.r===Z.r&&M.d!==Z.d)&&(e.set(V,M),M.d!==(Z==null?void 0:Z.d)&&X(C,V,M,Z==null?void 0:Z.d))})},z=(C,I)=>{I&&k(I),ce(void 0)},$=(C,I,M)=>{const Z=v(M,C).l;return Z.add(I),()=>{Z.delete(I),N(M,C)}},re=(C,I)=>{for(const[M,V]of C)Xl(M)&&(y(I,M,V),D(I,M));ce(I)};return(Cn&&"production")!=="production"?{[$p]:w,[Vp]:G,[xc]:z,[zp]:$,[my]:re,[wC]:C=>(s.add(C),()=>{s.delete(C)}),[TC]:()=>i.values(),[SC]:C=>e.get(C),[EC]:C=>t.get(C)}:{[$p]:w,[Vp]:G,[xc]:z,[zp]:$,[my]:re}},j1=(n,e)=>({s:e?e(n).SECRET_INTERNAL_store:AC(n)}),Pd=new Map,Lg=n=>(Pd.has(n)||Pd.set(n,ae.createContext(j1())),Pd.get(n)),W1=({children:n,initialValues:e,scope:t,unstable_createStore:r,unstable_enableVersionedWrite:s})=>{const[i,o]=ae.useState({});ae.useEffect(()=>{const l=a.current;l.w&&(l.s[xc](null,i),delete i.p,l.v=i)},[i]);const a=ae.useRef();if(!a.current){const l=j1(e,r);if(s){let u=0;l.w=f=>{o(h=>{const d=u?h:{p:h};return f(d),d})},l.v=i,l.r=f=>{++u,f(),--u}}a.current=l}const c=Lg(t);return ae.createElement(c.Provider,{value:a.current},n)};function Tt(n,e){return vC(n,e)}function kn(n,e){const t=Lg(e),r=ae.useContext(t),{s,v:i}=r,o=h=>{const d=s[$p](n,h);if((Cn&&"production")!=="production"&&!d.y)throw new Error("should not be invalidated");if("e"in d)throw d.e;if("p"in d)throw d.p;if("v"in d)return d.v;throw new Error("no atom value")},[[a,c,l],u]=ae.useReducer((h,d)=>{const m=o(d);return Object.is(h[1],m)&&h[2]===n?h:[d,m,n]},i,h=>{const d=o(h);return[h,d,n]});let f=c;return l!==n&&(u(a),f=o(a)),ae.useEffect(()=>{const{v:h}=r;h&&s[xc](n,h);const d=s[zp](n,u,h);return u(h),d},[s,n,r]),ae.useEffect(()=>{s[xc](n,a)}),ae.useDebugValue(f),f}function Tr(n,e){const t=Lg(e),{s:r,w:s}=ae.useContext(t);return ae.useCallback(o=>{if((Cn&&"production")!=="production"&&!("write"in n))throw new Error("not writable atom");const a=c=>r[Vp](n,o,c);return s?s(a):a()},[r,s,n])}function Oh(n,e){return"scope"in n&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),e=n.scope),[kn(n,e),Tr(n,e)]}class ji extends Error{constructor(e,t={}){super(`Node not found: ${e}`,t),this.name="NodeNotFoundError"}}class Fg extends Error{constructor(e){super(`Missing key: ${e}`),this.name="KeyError"}}var Rn;class H1{constructor(e,t,r){Ge(this,Rn);typeof e=="number"?Be(this,Rn,new Uint8Array(e)):e instanceof ArrayBuffer?Be(this,Rn,new Uint8Array(e,t,r)):Be(this,Rn,new Uint8Array(Array.from(e,s=>s?1:0)))}get BYTES_PER_ELEMENT(){return 1}get byteOffset(){return le(this,Rn).byteOffset}get byteLength(){return le(this,Rn).byteLength}get buffer(){return le(this,Rn).buffer}get length(){return le(this,Rn).length}get(e){let t=le(this,Rn)[e];return typeof t=="number"?t!==0:t}set(e,t){le(this,Rn)[e]=t?1:0}fill(e){le(this,Rn).fill(e?1:0)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}Rn=new WeakMap;var jo;class Bg{constructor(e,t,r,s){x(this,"_data");x(this,"chars");Ge(this,jo);if(this.chars=e,Be(this,jo,new TextEncoder),typeof t=="number")this._data=new Uint8Array(t*e);else if(t instanceof ArrayBuffer)s&&(s=s*e),this._data=new Uint8Array(t,r,s);else{let i=Array.from(t);this._data=new Uint8Array(i.length*e);for(let o=0;o<i.length;o++)this.set(o,i[o])}}get BYTES_PER_ELEMENT(){return this.chars}get byteOffset(){return this._data.byteOffset}get byteLength(){return this._data.byteLength}get buffer(){return this._data.buffer}get length(){return this.byteLength/this.BYTES_PER_ELEMENT}get(e){const t=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);return new TextDecoder().decode(t).replace(/\x00/g,"")}set(e,t){const r=new Uint8Array(this.buffer,this.byteOffset+this.chars*e,this.chars);r.fill(0),r.set(le(this,jo).encode(t))}fill(e){const t=le(this,jo).encode(e);for(let r=0;r<this.length;r++)this._data.set(t,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}}jo=new WeakMap;var an;const v_=class v_{constructor(e,t,r,s){Ge(this,an);x(this,"chars");if(this.chars=e,typeof t=="number")Be(this,an,new Int32Array(t*e));else if(t instanceof ArrayBuffer)s&&(s*=e),Be(this,an,new Int32Array(t,r,s));else{const i=t,o=new v_(e,1);Be(this,an,new Int32Array(function*(){for(let a of i)o.set(0,a),yield*le(o,an)}()))}}get BYTES_PER_ELEMENT(){return le(this,an).BYTES_PER_ELEMENT*this.chars}get byteLength(){return le(this,an).byteLength}get byteOffset(){return le(this,an).byteOffset}get buffer(){return le(this,an).buffer}get length(){return le(this,an).length/this.chars}get(e){const t=this.chars*e;let r="";for(let s=0;s<this.chars;s++)r+=String.fromCodePoint(le(this,an)[t+s]);return r.replace(/\u0000/g,"")}set(e,t){const r=this.chars*e,s=le(this,an).subarray(r,r+this.chars);s.fill(0);for(let i=0;i<this.chars;i++)s[i]=t.codePointAt(i)??0}fill(e){this.set(0,e);let t=le(this,an).subarray(0,this.chars);for(let r=1;r<this.length;r++)le(this,an).set(t,r*this.chars)}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.get(e)}};an=new WeakMap;let bc=v_;function fl(n){const e=new TextDecoder().decode(n);return JSON.parse(e)}function gy(n,e){const t=e/2,r=e-1;let s=0;for(let i=0;i<n.length;i+=e)for(let o=0;o<t;o+=1)s=n[i+o],n[i+o]=n[i+r-o],n[i+r-o]=s}function Z1(n){if(n==="v2:object")return globalThis.Array;let e=n.match(/v2:([US])(\d+)/);if(e){let[,r,s]=e;return(r==="U"?bc:Bg).bind(null,Number(s))}let t={int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:globalThis.BigInt64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:globalThis.BigUint64Array,float16:globalThis.Float16Array,float32:Float32Array,float64:Float64Array,bool:H1}[n];return Zt(t,`Unknown or unsupported data_type: ${n}`),t}function Ri(n,e){const t=n.length;typeof e=="string"&&(e=e==="C"?Array.from({length:t},(i,o)=>o):Array.from({length:t},(i,o)=>t-1-o)),Zt(t===e.length,"Order length must match the number of dimensions.");let r=1,s=new Array(t);for(let i=e.length-1;i>=0;i--)s[e[i]]=r,r*=n[e[i]];return s}function CC({name:n,configuration:e}){if(n==="default"){const t=(e==null?void 0:e.separator)??"/";return r=>["c",...r].join(t)}if(n==="v2"){const t=(e==null?void 0:e.separator)??".";return r=>r.join(t)||"0"}throw new Error(`Unknown chunk key encoding: ${n}`)}function RC(n){if(n==="|O")return{data_type:"v2:object"};let e=n.match(/^([<|>])(.*)$/);Zt(e,`Invalid dtype: ${n}`);let[,t,r]=e,s={b1:"bool",i1:"int8",u1:"uint8",i2:"int16",u2:"uint16",i4:"int32",u4:"uint32",i8:"int64",u8:"uint64",f2:"float16",f4:"float32",f8:"float64"}[r]??(r.startsWith("S")||r.startsWith("U")?`v2:${r}`:void 0);return Zt(s,`Unsupported or unknown dtype: ${n}`),t==="|"?{data_type:s}:{data_type:s,endian:t==="<"?"little":"big"}}function IC(n,e={}){let t=[],r=RC(n.dtype);n.order==="F"&&t.push({name:"transpose",configuration:{order:"F"}}),"endian"in r&&r.endian==="big"&&t.push({name:"bytes",configuration:{endian:"big"}});for(let{id:s,...i}of n.filters??[])t.push({name:s,configuration:i});if(n.compressor){let{id:s,...i}=n.compressor;t.push({name:s,configuration:i})}return{zarr_format:3,node_type:"array",shape:n.shape,data_type:r.data_type,chunk_grid:{name:"regular",configuration:{chunk_shape:n.chunks}},chunk_key_encoding:{name:"v2",configuration:{separator:n.dimension_separator??"."}},codecs:t,fill_value:n.fill_value,attributes:e}}function PC(n,e={}){return{zarr_format:3,node_type:"group",attributes:e}}function kC(n,e){if(e!=="number"&&e!=="bigint"&&e!=="boolean"&&e!=="object"&&e!=="string")return n===e;let t=n==="bool";if(e==="boolean")return t;let r=n.startsWith("v2:U")||n.startsWith("v2:S");if(e==="string")return r;let s=n==="int64"||n==="uint64";if(e==="bigint")return s;let i=n==="v2:object";return e==="object"?i:!r&&!s&&!t&&!i}function OC(n){return(n==null?void 0:n.name)==="sharding_indexed"}function X1(n){return(n.data_type==="uint64"||n.data_type==="int64")&&n.fill_value!=null?BigInt(n.fill_value):n.fill_value}function Y1(n,...e){if(!e.some(t=>n instanceof t))throw n}function Zt(n,e=""){if(!n)throw new Error(e)}async function q1(n,{format:e,signal:t}){const r=n instanceof Response?n:new Response(n);Zt(r.body,"Response does not contain body.");try{return await new Response(r.body.pipeThrough(new DecompressionStream(e),{signal:t})).arrayBuffer()}catch{throw t==null||t.throwIfAborted(),new Error(`Failed to decode ${e}`)}}class Ug{constructor(e,t){x(this,"kind","array_to_array");Zt(e.keepbits>=0,"keepbits must be zero or positive")}static fromConfig(e,t){return new Ug(e,t)}encode(e){throw new Error("`BitroundCodec.encode` is not implemented. Please open an issue at https://github.com/manzt/zarrita.js/issues.")}decode(e){return e}}const _y=MC();function MC(){const n=new Uint32Array([305419896]);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)[0]!==18}function yy(n){return"BYTES_PER_ELEMENT"in n?n.BYTES_PER_ELEMENT:4}var qc,Ss,Kc,Gc,Wo;const x_=class x_{constructor(e,t){x(this,"kind","array_to_bytes");Ge(this,qc);Ge(this,Ss);Ge(this,Kc);Ge(this,Gc);Ge(this,Wo);Be(this,Wo,e==null?void 0:e.endian),Be(this,Ss,Z1(t.data_type)),Be(this,Gc,t.shape),Be(this,qc,Ri(t.shape,"C"));const r=new(le(this,Ss))(0);Be(this,Kc,r.BYTES_PER_ELEMENT)}static fromConfig(e,t){return new x_(e,t)}encode(e){let t=new Uint8Array(e.data.buffer);return _y&&le(this,Wo)==="big"&&gy(t,yy(le(this,Ss))),t}decode(e){return _y&&le(this,Wo)==="big"&&gy(e,yy(le(this,Ss))),{data:new(le(this,Ss))(e.buffer,e.byteOffset,e.byteLength/le(this,Kc)),shape:le(this,Gc),stride:le(this,qc)}}};qc=new WeakMap,Ss=new WeakMap,Kc=new WeakMap,Gc=new WeakMap,Wo=new WeakMap;let Ku=x_;class $g{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(){return new $g}encode(e){throw new Error("Not implemented")}decode(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength-4)}}class Vg{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(e){return new Vg}encode(e){throw new Error("Gzip encoding is not enabled by default. Please register a custom codec with `numcodecs/gzip`.")}async decode(e){const t=await q1(e,{format:"gzip"});return new Uint8Array(t)}}function NC(n,e){return Zt(!Number.isNaN(e),"JsonCodec allow_nan is false but NaN was encountered during encoding."),Zt(e!==Number.POSITIVE_INFINITY,"JsonCodec allow_nan is false but Infinity was encountered during encoding."),Zt(e!==Number.NEGATIVE_INFINITY,"JsonCodec allow_nan is false but -Infinity was encountered during encoding."),e}function DC(n,e){return e instanceof Object&&!Array.isArray(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}):e}var Jc,Qc;const b_=class b_{constructor(e={}){x(this,"configuration");x(this,"kind","array_to_bytes");Ge(this,Jc);Ge(this,Qc);this.configuration=e;const{encoding:t="utf-8",skipkeys:r=!1,ensure_ascii:s=!0,check_circular:i=!0,allow_nan:o=!0,sort_keys:a=!0,indent:c,strict:l=!0}=e;let u=e.separators;u||(c?u=[", ",": "]:u=[",",":"]),Be(this,Jc,{encoding:t,skipkeys:r,ensure_ascii:s,check_circular:i,allow_nan:o,indent:c,separators:u,sort_keys:a}),Be(this,Qc,{strict:l})}static fromConfig(e){return new b_(e)}encode(e){const{indent:t,encoding:r,ensure_ascii:s,check_circular:i,allow_nan:o,sort_keys:a}=le(this,Jc);Zt(r==="utf-8","JsonCodec does not yet support non-utf-8 encoding.");const c=[];Zt(i,"JsonCodec does not yet support skipping the check for circular references during encoding."),o||c.push(NC),a&&c.push(DC);const l=Array.from(e.data);l.push("|O"),l.push(e.shape);let u;c.length&&(u=(h,d)=>{let m=d;for(let p of c)m=p(h,m);return m});let f=JSON.stringify(l,u,t);return s&&(f=f.replace(/[\u007F-\uFFFF]/g,h=>{const d=`0000${h.charCodeAt(0).toString(16)}`;return`\\u${d.substring(d.length-4)}`})),new TextEncoder().encode(f)}decode(e){const{strict:t}=le(this,Qc);Zt(t,"JsonCodec does not yet support non-strict decoding.");const r=fl(e),s=r.pop();r.pop(),Zt(s,"0D not implemented for JsonCodec.");const i=Ri(s,"C");return{data:r,shape:s,stride:i}}};Jc=new WeakMap,Qc=new WeakMap;let jp=b_;function vy(n){return n instanceof H1||n instanceof Bg||n instanceof bc?new Proxy(n,{get(t,r){return t.get(Number(r))},set(t,r,s){return t.set(Number(r),s),!0}}):n}function LC(n,e){let t;return n.data instanceof Bg||n.data instanceof bc?t=new n.constructor(n.data.length,n.data.chars):t=new n.constructor(n.data.length),{data:t,shape:n.shape,stride:Ri(n.shape,e)}}function FC(n,e){let t=LC(n,e),r=n.shape.length,s=n.data.length,i=Array(r).fill(0),o=vy(n.data),a=vy(t.data);for(let c=0;c<s;c++){let l=0;for(let u=0;u<r;u++)l+=i[u]*t.stride[u];a[l]=o[c],i[0]+=1;for(let u=0;u<r;u++)if(i[u]===n.shape[u]){if(u+1===r)break;i[u]=0,i[u+1]+=1}}return t}function BC(n){let e=n.shape.length;return Zt(e===n.stride.length,"Shape and stride must have the same length."),n.stride.map((t,r)=>({stride:t,index:r})).sort((t,r)=>r.stride-t.stride).map(t=>t.index)}function UC(n,e){let t=BC(n);return Zt(t.length===e.length,"Orders must match"),t.every((r,s)=>r===e[s])}var el,Ho;const w_=class w_{constructor(e,t){x(this,"kind","array_to_array");Ge(this,el);Ge(this,Ho);let r=e.order??"C",s=t.shape.length,i=new Array(s),o=new Array(s);if(r==="C")for(let a=0;a<s;++a)i[a]=a,o[a]=a;else if(r==="F")for(let a=0;a<s;++a)i[a]=s-a-1,o[a]=s-a-1;else i=r,i.forEach((a,c)=>{Zt(o[a]===void 0,`Invalid permutation: ${JSON.stringify(r)}`),o[a]=c});Be(this,el,i),Be(this,Ho,o)}static fromConfig(e,t){return new w_(e,t)}encode(e){return UC(e,le(this,Ho))?e:FC(e,le(this,Ho))}decode(e){return{data:e.data,shape:e.shape,stride:Ri(e.shape,le(this,el))}}};el=new WeakMap,Ho=new WeakMap;let Wp=w_;var tl,nl;const T_=class T_{constructor(e){x(this,"kind","array_to_bytes");Ge(this,tl);Ge(this,nl);Be(this,tl,e),Be(this,nl,Ri(e,"C"))}static fromConfig(e,t){return new T_(t.shape)}encode(e){throw new Error("Method not implemented.")}decode(e){let t=new TextDecoder,r=new DataView(e.buffer),s=Array(r.getUint32(0,!0)),i=4;for(let o=0;o<s.length;o++){let a=r.getUint32(i,!0);i+=4,s[o]=t.decode(e.buffer.slice(i,i+a)),i+=a}return{data:s,shape:le(this,tl),stride:le(this,nl)}}};tl=new WeakMap,nl=new WeakMap;let Hp=T_;class zg{constructor(){x(this,"kind","bytes_to_bytes")}static fromConfig(e){return new zg}encode(e){throw new Error("Zlib encoding is not enabled by default. Please register a codec with `numcodecs/zlib`.")}async decode(e){const t=await q1(e,{format:"deflate"});return new Uint8Array(t)}}function $C(){return new Map().set("blosc",()=>Promise.resolve().then(()=>require("./blosc-CeItQ6qj.cjs")).then(n=>n.default)).set("lz4",()=>Promise.resolve().then(()=>require("./lz4-PFaIsPAh.cjs")).then(n=>n.default)).set("zstd",()=>Promise.resolve().then(()=>require("./zstd-_xUhkGOV.cjs")).then(n=>n.default)).set("gzip",()=>Vg).set("zlib",()=>zg).set("transpose",()=>Wp).set("bytes",()=>Ku).set("crc32c",()=>$g).set("vlen-utf8",()=>Hp).set("json2",()=>jp).set("bitround",()=>Ug)}const K1=$C();function Zp(n){let e;return{async encode(t){e||(e=await xy(n));for(const s of e.array_to_array)t=await s.encode(t);let r=await e.array_to_bytes.encode(t);for(const s of e.bytes_to_bytes)r=await s.encode(r);return r},async decode(t){e||(e=await xy(n));for(let s=e.bytes_to_bytes.length-1;s>=0;s--)t=await e.bytes_to_bytes[s].decode(t);let r=await e.array_to_bytes.decode(t);for(let s=e.array_to_array.length-1;s>=0;s--)r=await e.array_to_array[s].decode(r);return r}}}async function xy(n){let e=n.codecs.map(async i=>{var a;let o=await((a=K1.get(i.name))==null?void 0:a());return Zt(o,`Unknown codec: ${i.name}`),{Codec:o,meta:i}}),t=[],r,s=[];for await(let{Codec:i,meta:o}of e){let a=i.fromConfig(o.configuration,n);switch(a.kind){case"array_to_array":t.push(a);break;case"array_to_bytes":r=a;break;default:s.push(a)}}return r||(Zt(VC(n),`Cannot encode ${n.data_type} to bytes without a codec`),r=Ku.fromConfig({endian:"little"},n)),{array_to_array:t,array_to_bytes:r,bytes_to_bytes:s}}function VC(n){return n.data_type!=="v2:object"}const by=18446744073709551615n;function zC(n,e,t,r){Zt(n.store.getRange,"Store does not support range requests");let s=n.store.getRange.bind(n.store),i=e.map((c,l)=>c/r.chunk_shape[l]),o=Zp({data_type:"uint64",shape:[...i,2],codecs:r.index_codecs}),a={};return async c=>{let l=c.map((T,b)=>Math.floor(T/i[b])),u=n.resolve(t(l)).path,f;if(u in a)f=a[u];else{let T=4,b=16*i.reduce((v,A)=>v*A,1),w=await s(u,{suffixLength:b+T});f=a[u]=w?await o.decode(w):null}if(f===null)return;let{data:h,shape:d,stride:m}=f,p=c.map((T,b)=>T%d[b]).reduce((T,b,w)=>T+b*m[w],0),_=h[p],y=h[p+1];if(!(_===by&&y===by))return s(u,{offset:Number(_),length:Number(y)})}}class Ys{constructor(e,t="/"){x(this,"store");x(this,"path");this.store=e,this.path=t}resolve(e){let t=new URL(`file://${this.path.endsWith("/")?this.path:`${this.path}/`}`);return new Ys(this.store,new URL(e,t).pathname)}}function jC(n){return new Ys(n??new Map)}var rl;class Mh extends Ys{constructor(t,r,s){super(t,r);x(this,"kind","group");Ge(this,rl);Be(this,rl,s)}get attrs(){return le(this,rl).attributes}}rl=new WeakMap;function wy(n){var t;const e=n.find(r=>r.name==="transpose");return((t=e==null?void 0:e.configuration)==null?void 0:t.order)??"C"}const za=Symbol("zarrita.context");function WC(n){return n[za]}function HC(n,e){let{configuration:t}=e.codecs.find(OC)??{},r={encode_chunk_key:CC(e.chunk_key_encoding),TypedArray:Z1(e.data_type),fill_value:e.fill_value};if(t){let i=wy(t.codecs);return{...r,kind:"sharded",chunk_shape:t.chunk_shape,codec:Zp({data_type:e.data_type,shape:t.chunk_shape,codecs:t.codecs}),get_strides(o){return Ri(o,i)},get_chunk_bytes:zC(n,e.chunk_grid.configuration.chunk_shape,r.encode_chunk_key,t)}}let s=wy(e.codecs);return{...r,kind:"regular",chunk_shape:e.chunk_grid.configuration.chunk_shape,codec:Zp({data_type:e.data_type,shape:e.chunk_grid.configuration.chunk_shape,codecs:e.codecs}),get_strides(i){return Ri(i,s)},async get_chunk_bytes(i,o){let a=r.encode_chunk_key(i),c=n.resolve(a).path;return n.store.get(c,o)}}}var d1,p1,_i,m1;let Gu=(m1=class extends(p1=Ys,d1=za,p1){constructor(t,r,s){super(t,r);x(this,"kind","array");Ge(this,_i);x(this,d1);Be(this,_i,{...s,fill_value:X1(s)}),this[za]=HC(this,s)}get attrs(){return le(this,_i).attributes}get shape(){return le(this,_i).shape}get chunks(){return this[za].chunk_shape}get dtype(){return le(this,_i).data_type}async getChunk(t,r){let s=this[za],i=await s.get_chunk_bytes(t,r);if(!i){let o=s.chunk_shape.reduce((c,l)=>c*l,1),a=new s.TypedArray(o);return a.fill(s.fill_value),{data:a,shape:s.chunk_shape,stride:s.get_strides(s.chunk_shape)}}return s.codec.decode(i)}is(t){return kC(this.dtype,t)}},_i=new WeakMap,m1),Nh=ZC();function ZC(){let n=new WeakMap;function e(t){let r=n.get(t)??{v2:0,v3:0};return n.set(t,r),r}return{increment(t,r){e(t)[r]+=1},version_max(t){let r=e(t);return r.v3>r.v2?"v3":"v2"}}}async function XC(n){let e=await n.store.get(n.resolve(".zattrs").path);return e?fl(e):{}}async function YC(n,e={}){let t="store"in n?n:new Ys(n),r={};return(e.attrs??!0)&&(r=await XC(t)),e.kind==="array"?Ty(t,r):e.kind==="group"?Sy(t,r):Ty(t,r).catch(s=>(Y1(s,ji),Sy(t,r)))}async function Ty(n,e){let{path:t}=n.resolve(".zarray"),r=await n.store.get(t);if(!r)throw new ji("v2 array",{cause:new Fg(t)});return Nh.increment(n.store,"v2"),new Gu(n.store,n.path,IC(fl(r),e))}async function Sy(n,e){let{path:t}=n.resolve(".zgroup"),r=await n.store.get(t);if(!r)throw new ji("v2 group",{cause:new Fg(t)});return Nh.increment(n.store,"v2"),new Mh(n.store,n.path,PC(fl(r),e))}async function qC(n){let{store:e,path:t}=n.resolve("zarr.json"),r=await n.store.get(t);if(!r)throw new ji("v3 array or group",{cause:new Fg(t)});let s=fl(r);return s.node_type==="array"&&(s.fill_value=X1(s)),s.node_type==="array"?new Gu(e,n.path,s):new Mh(e,n.path,s)}async function KC(n,e={}){let t="store"in n?n:new Ys(n),r=await qC(t);if(Nh.increment(t.store,"v3"),e.kind===void 0||e.kind==="array"&&r instanceof Gu||e.kind==="group"&&r instanceof Mh)return r;let s=r instanceof Gu?"array":"group";throw new Error(`Expected node of kind ${e.kind}, found ${s}.`)}async function en(n,e={}){let t="store"in n?n.store:n,r=Nh.version_max(t),s=r==="v2"?en.v2:en.v3,i=r==="v2"?en.v3:en.v2;return s(n,e).catch(o=>(Y1(o,ji),i(n,e)))}en.v2=YC;en.v3=KC;function*GC(n,e,t=1){e===void 0&&(e=n,n=0);for(let r=n;r<e;r+=t)yield r}function*JC(...n){if(n.length===0)return;const e=n.map(r=>r[Symbol.iterator]()),t=e.map(r=>r.next());if(t.some(r=>r.done))throw new Error("Input contains an empty iterator.");for(let r=0;;){if(t[r].done){if(e[r]=n[r][Symbol.iterator](),t[r]=e[r].next(),++r>=e.length)return}else yield t.map(({value:s})=>s),r=0;t[r]=e[r].next()}}function QC({start:n,stop:e,step:t},r){if(t===0)throw new Error("slice step cannot be zero");t=t??1;const s=t<0,[i,o]=s?[-1,r-1]:[0,r];return n===null?n=s?o:i:n<0?(n+=r,n<i&&(n=i)):n>o&&(n=o),e===null?e=s?i:o:e<0?(e+=r,e<i&&(e=i)):e>o&&(e=o),[n,e,t]}function fi(n,e,t=null){return e===void 0&&(e=n,n=null),{start:n,stop:e,step:t}}function eR(){const n=[];return{add:e=>n.push(e()),onIdle:()=>Promise.all(n)}}class jg extends Error{constructor(e){super(e),this.name="IndexError"}}function tR(n,e){throw new jg(`too many indicies for array; expected ${e.length}, got ${n.length}`)}function nR(n){throw new jg(`index out of bounds for dimension with length ${n}`)}function rR(){throw new jg("only slices with step >= 1 are supported")}function sR(n,e){n.length>e.length&&tR(n,e)}function iR(n,e){return n=Math.trunc(n),n<0&&(n=e+n),(n>=e||n<0)&&nR(e),n}class oR{constructor({dim_sel:e,dim_len:t,dim_chunk_len:r}){x(this,"dim_sel");x(this,"dim_len");x(this,"dim_chunk_len");x(this,"nitems");e=iR(e,t),this.dim_sel=e,this.dim_len=t,this.dim_chunk_len=r,this.nitems=1}*[Symbol.iterator](){const e=Math.floor(this.dim_sel/this.dim_chunk_len),t=e*this.dim_chunk_len,r=this.dim_sel-t;yield{dim_chunk_ix:e,dim_chunk_sel:r}}}class Ey{constructor({dim_sel:e,dim_len:t,dim_chunk_len:r}){x(this,"start");x(this,"stop");x(this,"step");x(this,"dim_len");x(this,"dim_chunk_len");x(this,"nitems");x(this,"nchunks");const[s,i,o]=QC(e,t);this.start=s,this.stop=i,this.step=o,this.step<1&&rR(),this.dim_len=t,this.dim_chunk_len=r,this.nitems=Math.max(0,Math.ceil((this.stop-this.start)/this.step)),this.nchunks=Math.ceil(this.dim_len/this.dim_chunk_len)}*[Symbol.iterator](){const e=Math.floor(this.start/this.dim_chunk_len),t=Math.ceil(this.stop/this.dim_chunk_len);for(const r of GC(e,t)){const s=r*this.dim_chunk_len,i=Math.min(this.dim_len,(r+1)*this.dim_chunk_len),o=i-s;let a=0,c=0;if(this.start<s){const d=(s-this.start)%this.step;d&&(c+=this.step-d),a=Math.ceil((s-this.start)/this.step)}else c=this.start-s;const l=this.stop>i?o:this.stop-s,u=[c,l,this.step],f=Math.ceil((l-c)/this.step),h=[a,a+f,1];yield{dim_chunk_ix:r,dim_chunk_sel:u,dim_out_sel:h}}}}function aR(n,e){let t=[];return n===null?t=e.map(r=>fi(null)):Array.isArray(n)&&(t=n.map(r=>r??fi(null))),sR(t,e),t}class cR{constructor({selection:e,shape:t,chunk_shape:r}){x(this,"dim_indexers");x(this,"shape");this.dim_indexers=aR(e,t).map((s,i)=>new(typeof s=="number"?oR:Ey)({dim_sel:s,dim_len:t[i],dim_chunk_len:r[i]})),this.shape=this.dim_indexers.filter(s=>s instanceof Ey).map(s=>s.nitems)}*[Symbol.iterator](){for(const e of JC(...this.dim_indexers)){const t=e.map(s=>s.dim_chunk_ix),r=e.map(s=>"dim_out_sel"in s?{from:s.dim_chunk_sel,to:s.dim_out_sel}:{from:s.dim_chunk_sel,to:null});yield{chunk_coords:t,mapping:r}}}}function lR(n,e){return"get"in n?n.get(e):n[e]}async function uR(n,e,t,r){var c;let s=WC(n),i=new cR({selection:e,shape:n.shape,chunk_shape:n.chunks}),o=r.prepare(new s.TypedArray(i.shape.reduce((l,u)=>l*u,1)),i.shape,s.get_strides(i.shape)),a=((c=t.create_queue)==null?void 0:c.call(t))??eR();for(const{chunk_coords:l,mapping:u}of i)a.add(async()=>{let{data:f,shape:h,stride:d}=await n.getChunk(l,t.opts),m=r.prepare(f,h,d);r.set_from_chunk(o,m,u)});return await a.onIdle(),i.shape.length===0?lR(o.data,0):o}function Wg(n,e=0,t){let r=t??n.length-e;return{length:r,subarray(s,i=r){return Wg(n,e+s,i-s)},set(s,i=0){for(let o=0;o<s.length;o++)n[e+i+o]=s.get(o)},get(s){return n[e+s]}}}function kd(n){return globalThis.Array.isArray(n.data)?{data:Wg(n.data),stride:n.stride,bytes_per_element:1}:{data:new Uint8Array(n.data.buffer,n.data.byteOffset,n.data.byteLength),stride:n.stride,bytes_per_element:n.data.BYTES_PER_ELEMENT}}function fR(n){return"chars"in n?n.constructor.bind(null,n.chars):n.constructor}function hR(n,e){if(globalThis.Array.isArray(n.data))return Wg([e]);let t=fR(n.data),r=new t([e]);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}const dR={prepare(n,e,t){return{data:n,shape:e,stride:t}},set_scalar(n,e,t){let r=kd(n);Xp(r,e,hR(n,t),r.bytes_per_element)},set_from_chunk(n,e,t){let r=kd(n);Cu(r,kd(e),r.bytes_per_element,t)}};async function pR(n,e=null,t={}){return uR(n,e,t,dR)}function G1(n,e,t){return t<0&&e<n?Math.floor((n-e-1)/-t)+1:n<e?Math.floor((e-n-1)/t)+1:0}function Xp(n,e,t,r){if(e.length===0){n.data.set(t,0);return}const[s,...i]=e,[o,...a]=n.stride;if(typeof s=="number"){const h=n.data.subarray(o*s*r);Xp({data:h,stride:a},i,t,r);return}const[c,l,u]=s,f=G1(c,l,u);if(i.length===0){for(let h=0;h<f;h++)n.data.set(t,o*(c+u*h)*r);return}for(let h=0;h<f;h++){const d=n.data.subarray(o*(c+u*h)*r);Xp({data:d,stride:a},i,t,r)}}function Cu(n,e,t,r){const[s,...i]=r,[o,...a]=n.stride,[c,...l]=e.stride;if(s.from===null){if(i.length===0){n.data.set(e.data.subarray(0,t),s.to*t);return}Cu({data:n.data.subarray(o*s.to*t),stride:a},e,t,i);return}if(s.to===null){if(i.length===0){let y=s.from*t;n.data.set(e.data.subarray(y,y+t),0);return}Cu(n,{data:e.data.subarray(c*s.from*t),stride:l},t,i);return}const[u,f,h]=s.to,[d,m,p]=s.from,_=G1(u,f,h);if(i.length===0){if(h===1&&p===1&&o===1&&c===1){let y=d*t,T=_*t;n.data.set(e.data.subarray(y,y+T),u*t);return}for(let y=0;y<_;y++){let T=c*(d+p*y)*t;n.data.set(e.data.subarray(T,T+t),o*(u+h*y)*t)}return}for(let y=0;y<_;y++)Cu({data:n.data.subarray(o*(u+y*h)*t),stride:a},{data:e.data.subarray(c*(d+y*p)*t),stride:l},t,i)}function Ru(n){return n.slice(1)}function mR(n){let[e,t]=(typeof n=="string"?n:n.href).split("://");if(e==="https"||e==="http")return n;if(e==="gc")return`https://storage.googleapis.com/${t}`;if(e==="s3")return`https://s3.amazonaws.com/${t}`;throw Error(`Protocol not supported, got: ${JSON.stringify(e)}`)}function Dh(n,e,t,r={}){return e!==void 0&&t!==void 0&&(r={...r,headers:{...r.headers,Range:`bytes=${e}-${e+t-1}`}}),fetch(n,r)}function J1(n,e){return{...n,...e,headers:{...n.headers,...e.headers}}}function Ay(n,e=""){if(!n)throw new Error(e)}function Cy(n,e){const t=typeof n=="string"?new URL(n):n;t.pathname.endsWith("/")||(t.pathname+="/");const r=new URL(e.slice(1),t);return r.search=t.search,r}async function Ry(n){if(n.status!==404){if(n.status===200||n.status===206)return new Uint8Array(await n.arrayBuffer());throw new Error(`Unexpected response status ${n.status} ${n.statusText}`)}}async function gR(n,e,t,r){if(r)return fetch(n,{...t,headers:{...t.headers,Range:`bytes=-${e}`}});let s=await fetch(n,{...t,method:"HEAD"});if(!s.ok)return s;let i=s.headers.get("Content-Length"),o=Number(i);return Dh(n,o-e,o,t)}var sl,il,ol,Yp;class _R{constructor(e,t={}){Ge(this,ol);x(this,"url");Ge(this,sl);Ge(this,il);this.url=e,Be(this,sl,t.overrides??{}),Be(this,il,t.useSuffixRequest??!1)}async get(e,t={}){let r=Cy(this.url,e).href,s=await fetch(r,dt(this,ol,Yp).call(this,t));return Ry(s)}async getRange(e,t,r={}){let s=Cy(this.url,e),i=dt(this,ol,Yp).call(this,r),o;return"suffixLength"in t?o=await gR(s,t.suffixLength,i,le(this,il)):o=await Dh(s,t.offset,t.length,i),Ry(o)}}sl=new WeakMap,il=new WeakMap,ol=new WeakSet,Yp=function(e){return J1(le(this,sl),e)};function Q1(n){return n.arrayBuffer?n.arrayBuffer():new Promise((e,t)=>{const r=new FileReader;r.addEventListener("loadend",()=>{e(r.result)}),r.addEventListener("error",t),r.readAsArrayBuffer(n)})}async function yR(n){const e=await Q1(n);return new Uint8Array(e)}function e2(n){return typeof Blob<"u"&&n instanceof Blob}function wc(n){return typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}const vR=typeof process<"u"&&process.versions&&typeof process.versions.node<"u"&&typeof process.versions.electron>"u";function xR(n){return n.byteOffset===0&&n.byteLength===n.buffer.byteLength}class Iy{constructor(e){this.typedArray=e instanceof ArrayBuffer||wc(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}async getLength(){return this.typedArray.byteLength}async read(e,t){return new Uint8Array(this.typedArray.buffer,this.typedArray.byteOffset+e,t)}}let Py=class{constructor(e){this.blob=e}async getLength(){return this.blob.size}async read(e,t){const r=this.blob.slice(e,e+t),s=await Q1(r);return new Uint8Array(s)}async sliceAsBlob(e,t,r=""){return this.blob.slice(e,e+t,r)}};function bR(n,e){var t=Uint8Array;if(n[0]==3&&n[1]==0)return e||new t(0);var r=TR,s=t2,i=wR,o=n2,a=e==null;a&&(e=new t(n.length>>>2<<3));for(var c=0,l=0,u=0,f=0,h=0,d=0,m=0,p=0,_=0,y,T;c==0;){if(c=r(n,_,1),l=r(n,_+1,2),_+=3,l==0){(_&7)!=0&&(_+=8-(_&7));var b=(_>>>3)+4,w=n[b-4]|n[b-3]<<8;a&&(e=Od(e,p+w)),e.set(new t(n.buffer,n.byteOffset+b,w),p),_=b+w<<3,p+=w;continue}if(a&&(e=Od(e,p+(1<<17))),l==1&&(y=Pe.flmap,T=Pe.fdmap,d=511,m=31),l==2){u=s(n,_,5)+257,f=s(n,_+5,5)+1,h=s(n,_+10,4)+4,_+=14;for(var v=0;v<38;v+=2)Pe.itree[v]=0,Pe.itree[v+1]=0;for(var A=1,v=0;v<h;v++){var N=s(n,_+v*3,3);Pe.itree[(Pe.ordr[v]<<1)+1]=N,N>A&&(A=N)}_+=3*h,tc(Pe.itree,A),nc(Pe.itree,A,Pe.imap),y=Pe.lmap,T=Pe.dmap,_=i(Pe.imap,(1<<A)-1,u+f,n,_,Pe.ttree);var D=ky(Pe.ttree,0,u,Pe.ltree);d=(1<<D)-1;var B=ky(Pe.ttree,u,f,Pe.dtree);m=(1<<B)-1,tc(Pe.ltree,D),nc(Pe.ltree,D,y),tc(Pe.dtree,B),nc(Pe.dtree,B,T)}for(;;){var G=y[o(n,_)&d];_+=G&15;var Q=G>>>4;if(!(Q>>>8))e[p++]=Q;else{if(Q==256)break;var E=p+Q-254;if(Q>264){var J=Pe.ldef[Q-257];E=p+(J>>>3)+s(n,_,J&7),_+=J&7}var X=T[o(n,_)&m];_+=X&15;var ce=X>>>4,k=Pe.ddef[ce],z=(k>>>4)+r(n,_,k&15);for(_+=k&15,a&&(e=Od(e,p+(1<<17)));p<E;)e[p]=e[p++-z],e[p]=e[p++-z],e[p]=e[p++-z],e[p]=e[p++-z];p=E}}}return e.length==p?e:e.slice(0,p)}function Od(n,e){var t=n.length;if(e<=t)return n;var r=new Uint8Array(Math.max(t<<1,e));return r.set(n,0),r}function wR(n,e,t,r,s,i){for(var o=t2,a=n2,c=0;c<t;){var l=n[a(r,s)&e];s+=l&15;var u=l>>>4;if(u<=15)i[c]=u,c++;else{var f=0,h=0;u==16?(h=3+o(r,s,2),s+=2,f=i[c-1]):u==17?(h=3+o(r,s,3),s+=3):u==18&&(h=11+o(r,s,7),s+=7);for(var d=c+h;c<d;)i[c]=f,c++}}return s}function ky(n,e,t,r){for(var s=0,i=0,o=r.length>>>1;i<t;){var a=n[i+e];r[i<<1]=0,r[(i<<1)+1]=a,a>s&&(s=a),i++}for(;i<o;)r[i<<1]=0,r[(i<<1)+1]=0,i++;return s}function tc(n,e){for(var t=n.length,r,s,i,o,a,c=Pe.bl_count,o=0;o<=e;o++)c[o]=0;for(o=1;o<t;o+=2)c[n[o]]++;var l=Pe.next_code;for(r=0,c[0]=0,s=1;s<=e;s++)r=r+c[s-1]<<1,l[s]=r;for(i=0;i<t;i+=2)a=n[i+1],a!=0&&(n[i]=l[a],l[a]++)}function nc(n,e,t){for(var r=n.length,s=Pe.rev15,i=0;i<r;i+=2)if(n[i+1]!=0)for(var o=i>>1,a=n[i+1],c=o<<4|a,l=e-a,u=n[i]<<l,f=u+(1<<l);u!=f;){var h=s[u]>>>15-e;t[h]=c,u++}}function Oy(n,e){for(var t=Pe.rev15,r=15-e,s=0;s<n.length;s+=2){var i=n[s]<<e-n[s+1];n[s]=t[i]>>>r}}function t2(n,e,t){return(n[e>>>3]|n[(e>>>3)+1]<<8)>>>(e&7)&(1<<t)-1}function TR(n,e,t){return(n[e>>>3]|n[(e>>>3)+1]<<8|n[(e>>>3)+2]<<16)>>>(e&7)&(1<<t)-1}function n2(n,e){return(n[e>>>3]|n[(e>>>3)+1]<<8|n[(e>>>3)+2]<<16)>>>(e&7)}const Pe=function(){var n=Uint16Array,e=Uint32Array;return{next_code:new n(16),bl_count:new n(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new n(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new e(32),flmap:new n(512),fltree:[],fdmap:new n(32),fdtree:[],lmap:new n(32768),ltree:[],ttree:[],dmap:new n(32768),dtree:[],imap:new n(512),itree:[],rev15:new n(32768),lhst:new e(286),dhst:new e(30),ihst:new e(19),lits:new e(15e3),strt:new n(65536),prev:new n(32768)}}();(function(){for(var n=32768,e=0;e<n;e++){var t=e;t=(t&2863311530)>>>1|(t&1431655765)<<1,t=(t&3435973836)>>>2|(t&858993459)<<2,t=(t&4042322160)>>>4|(t&252645135)<<4,t=(t&4278255360)>>>8|(t&16711935)<<8,Pe.rev15[e]=(t>>>16|t<<16)>>>17}function r(s,i,o){for(;i--!=0;)s.push(0,o)}for(var e=0;e<32;e++)Pe.ldef[e]=Pe.of0[e]<<3|Pe.exb[e],Pe.ddef[e]=Pe.df0[e]<<4|Pe.dxb[e];r(Pe.fltree,144,8),r(Pe.fltree,112,9),r(Pe.fltree,24,7),r(Pe.fltree,8,8),tc(Pe.fltree,9),nc(Pe.fltree,9,Pe.flmap),Oy(Pe.fltree,9),r(Pe.fdtree,32,5),tc(Pe.fdtree,5),nc(Pe.fdtree,5,Pe.fdmap),Oy(Pe.fdtree,5),r(Pe.itree,19,0),r(Pe.ltree,286,0),r(Pe.dtree,30,0),r(Pe.ttree,320,0)})();(function(){for(var n=new Uint32Array(256),e=0;e<256;e++){for(var t=e,r=0;r<8;r++)t&1?t=3988292384^t>>>1:t=t>>>1;n[e]=t}return n})();function SR(n,e){return bR(n,e)}const My={numWorkers:1,workerURL:"",useWorkers:!1};let ER=0;const Iu=[];function Md(n){return new Promise((e,t)=>{const r=new Worker(n);r.onmessage=s=>{s.data==="start"?(r.onerror=void 0,r.onmessage=void 0,e(r)):t(new Error(`unexpected message: ${s.data}`))},r.onerror=t})}function AR(n,e){return n.require?n.require(e):{}}(function(){if(vR){const{Worker:n}=AR(module,"worker_threads");return{async createWorker(e){return new n(e)},addEventListener(e,t){e.on("message",r=>{t({target:e,data:r})})},async terminate(e){await e.terminate()}}}else return{async createWorker(n){try{return await Md(n)}catch{console.warn("could not load worker:",n)}let e;try{const t=await fetch(n,{mode:"cors"});if(!t.ok)throw new Error(`could not load: ${n}`);e=await t.text(),n=URL.createObjectURL(new Blob([e],{type:"application/javascript"}));const r=await Md(n);return My.workerURL=n,r}catch{console.warn("could not load worker via fetch:",n)}if(e!==void 0)try{n=`data:application/javascript;base64,${btoa(e)}`;const t=await Md(n);return My.workerURL=n,t}catch{console.warn("could not load worker via dataURI")}throw console.warn("workers will not be used"),new Error("can not start workers")},addEventListener(n,e){n.addEventListener("message",e)},async terminate(n){n.terminate()}}})();function CR(n,e,t,r){const s=new Uint8Array(e);SR(n,s),r(t?new Blob([s],{type:t}):s.buffer)}async function RR(){if(Iu.length!==0)for(;Iu.length;){const{src:n,uncompressedSize:e,type:t,resolve:r}=Iu.shift();let s=n;e2(n)&&(s=await yR(n)),CR(s,e,t,r)}}function r2(n,e,t){return new Promise((r,s)=>{Iu.push({src:n,uncompressedSize:e,type:t,resolve:r,reject:s,id:ER++}),RR()})}function IR(n,e){const t=n&31,r=(n>>5&15)-1,s=(n>>9&127)+1980,i=0,o=(e&31)*2,a=e>>5&63,c=e>>11&31;return new Date(s,r,t,c,a,o,i)}class PR{constructor(e,t){this._reader=e,this._rawEntry=t,this.name=t.name,this.nameBytes=t.nameBytes,this.size=t.uncompressedSize,this.compressedSize=t.compressedSize,this.comment=t.comment,this.commentBytes=t.commentBytes,this.compressionMethod=t.compressionMethod,this.lastModDate=IR(t.lastModFileDate,t.lastModFileTime),this.isDirectory=t.uncompressedSize===0&&t.name.endsWith("/"),this.encrypted=!!(t.generalPurposeBitFlag&1),this.externalFileAttributes=t.externalFileAttributes,this.versionMadeBy=t.versionMadeBy}async blob(e="application/octet-stream"){return await VR(this._reader,this._rawEntry,e)}async arrayBuffer(){return await $R(this._reader,this._rawEntry)}async text(){const e=await this.arrayBuffer();return rc(new Uint8Array(e))}async json(){const e=await this.text();return JSON.parse(e)}}const Nd=22,kR=65535,OR=101010256,MR=101075792;async function Ko(n,e,t){return await n.read(e,t)}async function qp(n,e,t,r){return n.sliceAsBlob?await n.sliceAsBlob(e,t,r):await n.read(e,t)}const NR={unsigned(){return 0}};function Jt(n,e){return n[e]+n[e+1]*256}function gn(n,e){return n[e]+n[e+1]*256+n[e+2]*65536+n[e+3]*16777216}function hi(n,e){return gn(n,e)+gn(n,e+4)*4294967296}const DR=new TextDecoder;function rc(n,e){return wc(n.buffer)&&(n=new Uint8Array(n)),DR.decode(n)}async function LR(n,e){const t=Math.min(Nd+kR,e),r=e-t,s=await Ko(n,r,t);for(let i=t-Nd;i>=0;--i){if(gn(s,i)!==OR)continue;const o=new Uint8Array(s.buffer,s.byteOffset+i,s.byteLength-i),a=Jt(o,4);if(a!==0)throw new Error(`multi-volume zip files are not supported. This is volume: ${a}`);const c=Jt(o,10),l=gn(o,12),u=gn(o,16),f=Jt(o,20),h=o.length-Nd;if(f!==h)throw new Error(`invalid comment length. expected: ${h}, actual: ${f}`);const d=new Uint8Array(o.buffer,o.byteOffset+22,f),m=rc(d);return c===65535||u===4294967295?await BR(n,r+i,m,d):await s2(n,u,l,c,m,d)}throw new Error("could not find end of central directory. maybe not zip file")}const FR=117853008;async function BR(n,e,t,r){const s=e-20,i=await Ko(n,s,20);if(gn(i,0)!==FR)throw new Error("invalid zip64 end of central directory locator signature");const o=hi(i,8),a=await Ko(n,o,56);if(gn(a,0)!==MR)throw new Error("invalid zip64 end of central directory record signature");const c=hi(a,32),l=hi(a,40),u=hi(a,48);return s2(n,u,l,c,t,r)}const UR=33639248;async function s2(n,e,t,r,s,i){let o=0;const a=await Ko(n,e,t),c=[];for(let u=0;u<r;++u){const f=a.subarray(o,o+46),h=gn(f,0);if(h!==UR)throw new Error(`invalid central directory file header signature: 0x${h.toString(16)}`);const d={versionMadeBy:Jt(f,4),versionNeededToExtract:Jt(f,6),generalPurposeBitFlag:Jt(f,8),compressionMethod:Jt(f,10),lastModFileTime:Jt(f,12),lastModFileDate:Jt(f,14),crc32:gn(f,16),compressedSize:gn(f,20),uncompressedSize:gn(f,24),fileNameLength:Jt(f,28),extraFieldLength:Jt(f,30),fileCommentLength:Jt(f,32),internalFileAttributes:Jt(f,36),externalFileAttributes:gn(f,38),relativeOffsetOfLocalHeader:gn(f,42)};if(d.generalPurposeBitFlag&64)throw new Error("strong encryption is not supported");o+=46;const m=a.subarray(o,o+d.fileNameLength+d.extraFieldLength+d.fileCommentLength);d.nameBytes=m.slice(0,d.fileNameLength),d.name=rc(d.nameBytes);const p=d.fileNameLength+d.extraFieldLength,_=m.slice(d.fileNameLength,p);d.extraFields=[];let y=0;for(;y<_.length-3;){const b=Jt(_,y+0),w=Jt(_,y+2),v=y+4,A=v+w;if(A>_.length)throw new Error("extra field length exceeds extra field buffer size");d.extraFields.push({id:b,data:_.slice(v,A)}),y=A}if(d.commentBytes=m.slice(p,p+d.fileCommentLength),d.comment=rc(d.commentBytes),o+=m.length,d.uncompressedSize===4294967295||d.compressedSize===4294967295||d.relativeOffsetOfLocalHeader===4294967295){const b=d.extraFields.find(A=>A.id===1);if(!b)throw new Error("expected zip64 extended information extra field");const w=b.data;let v=0;if(d.uncompressedSize===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include uncompressed size");d.uncompressedSize=hi(w,v),v+=8}if(d.compressedSize===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include compressed size");d.compressedSize=hi(w,v),v+=8}if(d.relativeOffsetOfLocalHeader===4294967295){if(v+8>w.length)throw new Error("zip64 extended information extra field does not include relative header offset");d.relativeOffsetOfLocalHeader=hi(w,v),v+=8}}const T=d.extraFields.find(b=>b.id===28789&&b.data.length>=6&&b.data[0]===1&&gn(b.data,1),NR.unsigned(d.nameBytes));if(T&&(d.fileName=rc(T.data.slice(5))),d.compressionMethod===0){let b=d.uncompressedSize;if((d.generalPurposeBitFlag&1)!==0&&(b+=12),d.compressedSize!==b)throw new Error(`compressed size mismatch for stored file: ${d.compressedSize} != ${b}`)}c.push(d)}return{zip:{comment:s,commentBytes:i},entries:c.map(u=>new PR(n,u))}}async function i2(n,e){if(e.generalPurposeBitFlag&1)throw new Error("encrypted entries not supported");const t=await Ko(n,e.relativeOffsetOfLocalHeader,30),r=await n.getLength(),s=gn(t,0);if(s!==67324752)throw new Error(`invalid local file header signature: 0x${s.toString(16)}`);const i=Jt(t,26),o=Jt(t,28),a=e.relativeOffsetOfLocalHeader+t.length+i+o;let c;if(e.compressionMethod===0)c=!1;else if(e.compressionMethod===8)c=!0;else throw new Error(`unsupported compression method: ${e.compressionMethod}`);const l=a,u=l+e.compressedSize;if(e.compressedSize!==0&&u>r)throw new Error(`file data overflows file bounds: ${l} + ${e.compressedSize} > ${r}`);return{decompress:c,fileDataStart:l}}async function $R(n,e){const{decompress:t,fileDataStart:r}=await i2(n,e);if(!t){const o=await Ko(n,r,e.compressedSize);return xR(o)?o.buffer:o.slice().buffer}const s=await qp(n,r,e.compressedSize);return await r2(s,e.uncompressedSize)}async function VR(n,e,t){const{decompress:r,fileDataStart:s}=await i2(n,e);if(!r){const a=await qp(n,s,e.compressedSize,t);return e2(a)?a:new Blob([wc(a.buffer)?new Uint8Array(a):a],{type:t})}const i=await qp(n,s,e.compressedSize);return await r2(i,e.uncompressedSize,t)}async function zR(n){let e;if(typeof Blob<"u"&&n instanceof Blob)e=new Py(n);else if(n instanceof ArrayBuffer||n&&n.buffer&&n.buffer instanceof ArrayBuffer)e=new Iy(n);else if(wc(n)||wc(n.buffer))e=new Iy(n);else if(typeof n=="string"){const r=await fetch(n);if(!r.ok)throw new Error(`failed http request ${n}, status: ${r.status}: ${r.statusText}`);const s=await r.blob();e=new Py(s)}else if(typeof n.getLength=="function"&&typeof n.read=="function")e=n;else throw new Error("unsupported source type");const t=await e.getLength();if(t>Number.MAX_SAFE_INTEGER)throw new Error(`file too large. size: ${t}. Only file sizes up 4503599627370496 bytes are supported`);return await LR(e,t)}async function jR(n){const{zip:e,entries:t}=await zR(n);return{zip:e,entries:Object.fromEntries(t.map(r=>[r.name,r]))}}function WR(n){if(!("compressionMethod"in n)||!("_rawEntry"in n))return!1;const e=n._rawEntry;return typeof n.compressionMethod=="number"&&typeof e=="object"&&e!==null&&"relativeOffsetOfLocalHeader"in e&&typeof e.relativeOffsetOfLocalHeader=="number"}class HR{constructor(e){x(this,"blob");this.blob=e}async getLength(){return this.blob.size}async read(e,t){const r=this.blob.slice(e,e+t);return new Uint8Array(await r.arrayBuffer())}}var Zo;class ZR{constructor(e,t={}){x(this,"url");x(this,"length");Ge(this,Zo);this.url=e,Be(this,Zo,t.overrides??{})}async getLength(){if(this.length===void 0){const e=await fetch(this.url,{...le(this,Zo),method:"HEAD"});if(Ay(e.ok,`failed http request ${this.url}, status: ${e.status}: ${e.statusText}`),this.length=Number(e.headers.get("content-length")),Number.isNaN(this.length))throw Error("could not get length")}return this.length}async read(e,t){if(t===0)return new Uint8Array(0);const r=await Dh(this.url,e,t,le(this,Zo));return Ay(r.ok,`failed http request ${this.url}, status: ${r.status} offset: ${e} size: ${t}: ${r.statusText}`),new Uint8Array(await r.arrayBuffer())}}Zo=new WeakMap;class Ju{constructor(e,t={}){x(this,"info");x(this,"reader");this.reader=e,this.info=jR(e).then(r=>(t.transformEntries&&(r.entries=t.transformEntries(r.entries)),r))}async getEntryDataOffset(e){const t=e._rawEntry.relativeOffsetOfLocalHeader,r=await this.reader.read(t,30),s=r[26]+r[27]*256,i=r[28]+r[29]*256;return t+30+s+i}async get(e){let t=(await this.info).entries[Ru(e)];if(t)return new Uint8Array(await t.arrayBuffer())}async getRange(e,t){const r=(await this.info).entries[Ru(e)];if(!r)return;if(!WR(r))throw new Error("ZipFileStore.getRange requires internal unzipit properties that are not available. This may indicate an incompatible version of unzipit.");if(r.compressionMethod!==0){const i=await this.get(e);return i?"suffixLength"in t?i.slice(-t.suffixLength):i.slice(t.offset,t.offset+t.length):void 0}const s=await this.getEntryDataOffset(r);if("suffixLength"in t){const i=s+r.size-t.suffixLength;return this.reader.read(i,t.suffixLength)}return this.reader.read(s+t.offset,t.length)}async has(e){return Ru(e)in(await this.info).entries}static fromUrl(e,t={}){return new Ju(new ZR(e,t),t)}static fromBlob(e,t={}){return new Ju(new HR(e),t)}}var Nn,At,Dt,Es,al,As,nt,Kp,Kn,o2,Gp,Jp,Qp,a2,em;class XR extends Map{constructor(t={}){super();Ge(this,nt);Ge(this,Nn,0);Ge(this,At,new Map);Ge(this,Dt,new Map);Ge(this,Es);Ge(this,al);Ge(this,As);if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof t.maxAge=="number"&&t.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");Be(this,Es,t.maxSize),Be(this,al,t.maxAge||Number.POSITIVE_INFINITY),Be(this,As,t.onEviction)}get __oldCache(){return le(this,Dt)}get(t){if(le(this,At).has(t)){const r=le(this,At).get(t);return dt(this,nt,Gp).call(this,t,r)}if(le(this,Dt).has(t)){const r=le(this,Dt).get(t);if(dt(this,nt,Kn).call(this,t,r)===!1)return dt(this,nt,a2).call(this,t,r),r.value}}set(t,r,{maxAge:s=le(this,al)}={}){const i=typeof s=="number"&&s!==Number.POSITIVE_INFINITY?Date.now()+s:void 0;return le(this,At).has(t)?le(this,At).set(t,{value:r,expiry:i}):dt(this,nt,Qp).call(this,t,{value:r,expiry:i}),this}has(t){return le(this,At).has(t)?!dt(this,nt,Kn).call(this,t,le(this,At).get(t)):le(this,Dt).has(t)?!dt(this,nt,Kn).call(this,t,le(this,Dt).get(t)):!1}peek(t){if(le(this,At).has(t))return dt(this,nt,Jp).call(this,t,le(this,At));if(le(this,Dt).has(t))return dt(this,nt,Jp).call(this,t,le(this,Dt))}delete(t){const r=le(this,At).delete(t);return r&&_d(this,Nn)._--,le(this,Dt).delete(t)||r}clear(){le(this,At).clear(),le(this,Dt).clear(),Be(this,Nn,0)}resize(t){if(!(t&&t>0))throw new TypeError("`maxSize` must be a number greater than 0");const r=[...dt(this,nt,em).call(this)],s=r.length-t;s<0?(Be(this,At,new Map(r)),Be(this,Dt,new Map),Be(this,Nn,r.length)):(s>0&&dt(this,nt,Kp).call(this,r.slice(0,s)),Be(this,Dt,new Map(r.slice(s))),Be(this,At,new Map),Be(this,Nn,0)),Be(this,Es,t)}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of le(this,At)){const[r,s]=t;dt(this,nt,Kn).call(this,r,s)===!1&&(yield[r,s.value])}for(const t of le(this,Dt)){const[r,s]=t;le(this,At).has(r)||dt(this,nt,Kn).call(this,r,s)===!1&&(yield[r,s.value])}}*entriesDescending(){let t=[...le(this,At)];for(let r=t.length-1;r>=0;--r){const s=t[r],[i,o]=s;dt(this,nt,Kn).call(this,i,o)===!1&&(yield[i,o.value])}t=[...le(this,Dt)];for(let r=t.length-1;r>=0;--r){const s=t[r],[i,o]=s;le(this,At).has(i)||dt(this,nt,Kn).call(this,i,o)===!1&&(yield[i,o.value])}}*entriesAscending(){for(const[t,r]of dt(this,nt,em).call(this))yield[t,r.value]}get size(){if(!le(this,Nn))return le(this,Dt).size;let t=0;for(const r of le(this,Dt).keys())le(this,At).has(r)||t++;return Math.min(le(this,Nn)+t,le(this,Es))}get maxSize(){return le(this,Es)}entries(){return this.entriesAscending()}forEach(t,r=this){for(const[s,i]of this.entriesAscending())t.call(r,i,s,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}Nn=new WeakMap,At=new WeakMap,Dt=new WeakMap,Es=new WeakMap,al=new WeakMap,As=new WeakMap,nt=new WeakSet,Kp=function(t){if(typeof le(this,As)=="function")for(const[r,s]of t)le(this,As).call(this,r,s.value)},Kn=function(t,r){return typeof r.expiry=="number"&&r.expiry<=Date.now()?(typeof le(this,As)=="function"&&le(this,As).call(this,t,r.value),this.delete(t)):!1},o2=function(t,r){if(dt(this,nt,Kn).call(this,t,r)===!1)return r.value},Gp=function(t,r){return r.expiry?dt(this,nt,o2).call(this,t,r):r.value},Jp=function(t,r){const s=r.get(t);return dt(this,nt,Gp).call(this,t,s)},Qp=function(t,r){le(this,At).set(t,r),_d(this,Nn)._++,le(this,Nn)>=le(this,Es)&&(Be(this,Nn,0),dt(this,nt,Kp).call(this,le(this,Dt)),Be(this,Dt,le(this,At)),Be(this,At,new Map))},a2=function(t,r){le(this,Dt).delete(t),dt(this,nt,Qp).call(this,t,r)},em=function*(){for(const t of le(this,Dt)){const[r,s]=t;le(this,At).has(r)||dt(this,nt,Kn).call(this,r,s)===!1&&(yield t)}for(const t of le(this,At)){const[r,s]=t;dt(this,nt,Kn).call(this,r,s)===!1&&(yield t)}};function Ny(n,e){return e?"suffixLength"in e?`${n}:-${e.suffixLength}`:`${n}:${e.offset}:${e.offset+e.length-1}`:n}function Dy(n){var e;return(e=n.split("/")[1])!=null&&e.includes(":")?`/.${n}`:n}function YR(n,e=100){const t=new XR({maxSize:e});let r=n.getRange?n.getRange.bind(n):void 0;function s(...i){const[o,a]=i,c=Ny(o),l=t.get(c);if(l)return l;const u=Dy(o),f=Promise.resolve(n.get(u,a));return t.set(c,f),f}if(r){const i=r;r=(...o)=>{const[a,c,l]=o,u=Ny(a,c),f=t.get(u);if(f)return f;const h=Dy(a),d=Promise.resolve(i==null?void 0:i(h,c,l)).catch(m=>{throw t.delete(u),m});return t.set(u,d),d}}return new Proxy(n,{get(i,o,a){return o==="get"?s:o==="getRange"&&r?r:Reflect.get(i,o,a)}})}const qR={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...qR}};const xn=globalThis.mathgl.config;function KR(n,{precision:e=xn.precision}={}){return n=GR(n),`${parseFloat(n.toPrecision(e))}`}function Ii(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Rt(n,e,t){return QR(n,r=>Math.max(e,Math.min(t,r)))}function vi(n,e,t){return Ii(n)?n.map((r,s)=>vi(r,e[s],t)):t*e+(1-t)*n}function Yr(n,e,t){const r=xn.EPSILON;try{if(n===e)return!0;if(Ii(n)&&Ii(e)){if(n.length!==e.length)return!1;for(let s=0;s<n.length;++s)if(!Yr(n[s],e[s]))return!1;return!0}return n&&n.equals?n.equals(e):e&&e.equals?e.equals(n):typeof n=="number"&&typeof e=="number"?Math.abs(n-e)<=xn.EPSILON*Math.max(1,Math.abs(n),Math.abs(e)):!1}finally{xn.EPSILON=r}}function GR(n){return Math.round(n/xn.EPSILON)*xn.EPSILON}function JR(n){return n.clone?n.clone():new Array(n.length)}function QR(n,e,t){if(Ii(n)){const r=n;t=t||JR(r);for(let s=0;s<t.length&&s<r.length;++s){const i=typeof n=="number"?n:n[s];t[s]=e(i,s,t)}return t}return e(n)}class Hg extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ii(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(xn)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+KR(this[r],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Yr(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(r===void 0)return this.lerp(this,e,t);for(let s=0;s<this.ELEMENTS;++s){const i=e[s],o=typeof t=="number"?t:t[s];this[s]=i+r*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=t[r];return this.check()}subtract(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=t[r];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(xn.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}}function eI(n,e){if(n.length!==e)return!1;for(let t=0;t<n.length;++t)if(!Number.isFinite(n[t]))return!1;return!0}function wt(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function sc(n,e,t=""){if(xn.debug&&!eI(n,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return n}function Tc(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}class c2 extends Hg{get x(){return this[0]}set x(e){this[0]=wt(e)}get y(){return this[1]}set y(e){this[1]=wt(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const s=this[r]-e[r];t+=s*s}return wt(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return wt(t)}normalize(){const e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]*=t[r];return this.check()}divide(...e){for(const t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Tc(e>=0&&e<this.ELEMENTS,"index is out of range"),wt(this[e])}setComponent(e,t){return Tc(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}const ic=1e-6;let rr=typeof Float32Array<"u"?Float32Array:Array;function tI(){const n=new rr(2);return rr!=Float32Array&&(n[0]=0,n[1]=0),n}function Qu(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function l2(n,e){return n[0]=-e[0],n[1]=-e[1],n}function u2(n,e,t,r){const s=e[0],i=e[1];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n}function nI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[3]*s+t[6],n[1]=t[1]*r+t[4]*s+t[7],n}function rI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[4]*s+t[12],n[1]=t[1]*r+t[5]*s+t[13],n}(function(){const n=tI();return function(e,t,r,s,i,o){let a,c;for(t||(t=2),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],i(n,n,o),e[a]=n[0],e[a+1]=n[1];return e}})();function sI(n,e,t){const r=e[0],s=e[1],i=t[3]*r+t[7]*s||1;return n[0]=(t[0]*r+t[4]*s)/i,n[1]=(t[1]*r+t[5]*s)/i,n}function f2(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[3]*r+t[7]*s+t[11]*i||1;return n[0]=(t[0]*r+t[4]*s+t[8]*i)/o,n[1]=(t[1]*r+t[5]*s+t[9]*i)/o,n[2]=(t[2]*r+t[6]*s+t[10]*i)/o,n}function iI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[2]*s,n[1]=t[1]*r+t[3]*s,n[2]=e[2],n}function oI(n,e,t){const r=e[0],s=e[1];return n[0]=t[0]*r+t[2]*s,n[1]=t[1]*r+t[3]*s,n[2]=e[2],n[3]=e[3],n}function h2(n,e,t){const r=e[0],s=e[1],i=e[2];return n[0]=t[0]*r+t[3]*s+t[6]*i,n[1]=t[1]*r+t[4]*s+t[7]*i,n[2]=t[2]*r+t[5]*s+t[8]*i,n[3]=e[3],n}function d2(){const n=new rr(3);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function aI(n){const e=n[0],t=n[1],r=n[2];return Math.sqrt(e*e+t*t+r*r)}function Ly(n,e,t){const r=new rr(3);return r[0]=n,r[1]=e,r[2]=t,r}function cI(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lI(n){const e=n[0],t=n[1],r=n[2];return e*e+t*t+r*r}function uI(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function fI(n,e){const t=e[0],r=e[1],s=e[2];let i=t*t+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n}function p2(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Pu(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2];return n[0]=s*c-i*a,n[1]=i*o-r*c,n[2]=r*a-s*o,n}function hI(n,e,t,r){const s=e[0],i=e[1],o=e[2];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n[2]=o+r*(t[2]-o),n}function Zg(n,e,t){const r=e[0],s=e[1],i=e[2];let o=t[3]*r+t[7]*s+t[11]*i+t[15];return o=o||1,n[0]=(t[0]*r+t[4]*s+t[8]*i+t[12])/o,n[1]=(t[1]*r+t[5]*s+t[9]*i+t[13])/o,n[2]=(t[2]*r+t[6]*s+t[10]*i+t[14])/o,n}function m2(n,e,t){const r=e[0],s=e[1],i=e[2];return n[0]=r*t[0]+s*t[3]+i*t[6],n[1]=r*t[1]+s*t[4]+i*t[7],n[2]=r*t[2]+s*t[5]+i*t[8],n}function g2(n,e,t){const r=t[0],s=t[1],i=t[2],o=t[3],a=e[0],c=e[1],l=e[2];let u=s*l-i*c,f=i*a-r*l,h=r*c-s*a,d=s*h-i*f,m=i*u-r*h,p=r*f-s*u;const _=o*2;return u*=_,f*=_,h*=_,d*=2,m*=2,p*=2,n[0]=a+u+d,n[1]=c+f+m,n[2]=l+h+p,n}function dI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function pI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function mI(n,e,t,r){const s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function gI(n,e){const t=n[0],r=n[1],s=n[2],i=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+r*r+s*s)*(i*i+o*o+a*a)),l=c&&p2(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}const _2=cI,y2=aI,Dd=lI;(function(){const n=d2();return function(e,t,r,s,i,o){let a,c;for(t||(t=3),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],n[2]=e[a+2],i(n,n,o),e[a]=n[0],e[a+1]=n[1],e[a+2]=n[2];return e}})();const Ld=[0,0,0];let Yl;class Ce extends c2{static get ZERO(){return Yl||(Yl=new Ce(0,0,0),Object.freeze(Yl)),Yl}constructor(e=0,t=0,r=0){super(-0,-0,-0),arguments.length===1&&Ii(e)?this.copy(e):(xn.debug&&(wt(e),wt(t),wt(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return xn.debug&&(wt(e.x),wt(e.y),wt(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=wt(e)}angle(e){return gI(this,e)}cross(e){return Pu(this,this,e),this.check()}rotateX({radians:e,origin:t=Ld}){return dI(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Ld}){return pI(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Ld}){return mI(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Zg(this,this,e),this.check()}transformAsVector(e){return f2(this,this,e),this.check()}transformByMatrix3(e){return m2(this,this,e),this.check()}transformByMatrix2(e){return iI(this,this,e),this.check()}transformByQuaternion(e){return g2(this,this,e),this.check()}}let ql;class Xg extends c2{static get ZERO(){return ql||(ql=new Xg(0,0,0,0),Object.freeze(ql)),ql}constructor(e=0,t=0,r=0,s=0){super(-0,-0,-0,-0),Ii(e)&&arguments.length===1?this.copy(e):(xn.debug&&(wt(e),wt(t),wt(r),wt(s)),this[0]=e,this[1]=t,this[2]=r,this[3]=s)}set(e,t,r,s){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return xn.debug&&(wt(e.x),wt(e.y),wt(e.z),wt(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=wt(e)}get w(){return this[3]}set w(e){this[3]=wt(e)}transform(e){return Zg(this,this,e),this.check()}transformByMatrix3(e){return h2(this,this,e),this.check()}transformByMatrix2(e){return oI(this,this,e),this.check()}transformByQuaternion(e){return g2(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}class v2 extends Hg{toString(){let e="[";if(xn.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=wt(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let s=0;s<this.RANK;++s)t[s]=this[r+s];return t}setColumn(e,t){const r=e*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=t[s];return this}}function _I(){const n=new rr(9);return rr!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function yI(n,e){if(n===e){const t=e[1],r=e[2],s=e[5];n[1]=e[3],n[2]=e[6],n[3]=t,n[5]=e[7],n[6]=r,n[7]=s}else n[0]=e[0],n[1]=e[3],n[2]=e[6],n[3]=e[1],n[4]=e[4],n[5]=e[7],n[6]=e[2],n[7]=e[5],n[8]=e[8];return n}function vI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=u*o-a*l,h=-u*i+a*c,d=l*i-o*c;let m=t*f+r*h+s*d;return m?(m=1/m,n[0]=f*m,n[1]=(-u*r+s*l)*m,n[2]=(a*r-s*o)*m,n[3]=h*m,n[4]=(u*t-s*c)*m,n[5]=(-a*t+s*i)*m,n[6]=d*m,n[7]=(-l*t+r*c)*m,n[8]=(o*t-r*i)*m,n):null}function xI(n){const e=n[0],t=n[1],r=n[2],s=n[3],i=n[4],o=n[5],a=n[6],c=n[7],l=n[8];return e*(l*i-o*c)+t*(-l*s+o*a)+r*(c*s-i*a)}function Fy(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=t[0],d=t[1],m=t[2],p=t[3],_=t[4],y=t[5],T=t[6],b=t[7],w=t[8];return n[0]=h*r+d*o+m*l,n[1]=h*s+d*a+m*u,n[2]=h*i+d*c+m*f,n[3]=p*r+_*o+y*l,n[4]=p*s+_*a+y*u,n[5]=p*i+_*c+y*f,n[6]=T*r+b*o+w*l,n[7]=T*s+b*a+w*u,n[8]=T*i+b*c+w*f,n}function bI(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=r,n[1]=s,n[2]=i,n[3]=o,n[4]=a,n[5]=c,n[6]=h*r+d*o+l,n[7]=h*s+d*a+u,n[8]=h*i+d*c+f,n}function wI(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=Math.sin(t),d=Math.cos(t);return n[0]=d*r+h*o,n[1]=d*s+h*a,n[2]=d*i+h*c,n[3]=d*o-h*r,n[4]=d*a-h*s,n[5]=d*c-h*i,n[6]=l,n[7]=u,n[8]=f,n}function By(n,e,t){const r=t[0],s=t[1];return n[0]=r*e[0],n[1]=r*e[1],n[2]=r*e[2],n[3]=s*e[3],n[4]=s*e[4],n[5]=s*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function TI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t+t,a=r+r,c=s+s,l=t*o,u=r*o,f=r*a,h=s*o,d=s*a,m=s*c,p=i*o,_=i*a,y=i*c;return n[0]=1-f-m,n[3]=u-y,n[6]=h+_,n[1]=u+y,n[4]=1-l-m,n[7]=d-p,n[2]=h-_,n[5]=d+p,n[8]=1-l-f,n}var tm;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL1ROW0=3]="COL1ROW0",n[n.COL1ROW1=4]="COL1ROW1",n[n.COL1ROW2=5]="COL1ROW2",n[n.COL2ROW0=6]="COL2ROW0",n[n.COL2ROW1=7]="COL2ROW1",n[n.COL2ROW2=8]="COL2ROW2"})(tm||(tm={}));const SI=Object.freeze([1,0,0,0,1,0,0,0,1]);class tn extends v2{static get IDENTITY(){return AI()}static get ZERO(){return EI()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return tm}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(SI)}fromObject(e){return this.check()}fromQuaternion(e){return TI(this,e),this.check()}set(e,t,r,s,i,o,a,c,l){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,t,r,s,i,o,a,c,l){return this[0]=e,this[1]=s,this[2]=a,this[3]=t,this[4]=i,this[5]=c,this[6]=r,this[7]=o,this[8]=l,this.check()}determinant(){return xI(this)}transpose(){return yI(this,this),this.check()}invert(){return vI(this,this),this.check()}multiplyLeft(e){return Fy(this,e,this),this.check()}multiplyRight(e){return Fy(this,this,e),this.check()}rotate(e){return wI(this,this,e),this.check()}scale(e){return Array.isArray(e)?By(this,this,e):By(this,this,[e,e]),this.check()}translate(e){return bI(this,this,e),this.check()}transform(e,t){let r;switch(e.length){case 2:r=nI(t||[-0,-0],e,this);break;case 3:r=m2(t||[-0,-0,-0],e,this);break;case 4:r=h2(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Kl,Gl=null;function EI(){return Kl||(Kl=new tn([0,0,0,0,0,0,0,0,0]),Object.freeze(Kl)),Kl}function AI(){return Gl||(Gl=new tn,Object.freeze(Gl)),Gl}function CI(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function RI(n,e){if(n===e){const t=e[1],r=e[2],s=e[3],i=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=i,n[11]=e[14],n[12]=s,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function nm(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],p=e[13],_=e[14],y=e[15],T=t*a-r*o,b=t*c-s*o,w=t*l-i*o,v=r*c-s*a,A=r*l-i*a,N=s*l-i*c,D=u*p-f*m,B=u*_-h*m,G=u*y-d*m,Q=f*_-h*p,E=f*y-d*p,J=h*y-d*_;let X=T*J-b*E+w*Q+v*G-A*B+N*D;return X?(X=1/X,n[0]=(a*J-c*E+l*Q)*X,n[1]=(s*E-r*J-i*Q)*X,n[2]=(p*N-_*A+y*v)*X,n[3]=(h*A-f*N-d*v)*X,n[4]=(c*G-o*J-l*B)*X,n[5]=(t*J-s*G+i*B)*X,n[6]=(_*w-m*N-y*b)*X,n[7]=(u*N-h*w+d*b)*X,n[8]=(o*E-a*G+l*D)*X,n[9]=(r*G-t*E-i*D)*X,n[10]=(m*A-p*w+y*T)*X,n[11]=(f*w-u*A-d*T)*X,n[12]=(a*B-o*Q-c*D)*X,n[13]=(t*Q-r*B+s*D)*X,n[14]=(p*b-m*v-_*T)*X,n[15]=(u*v-f*b+h*T)*X,n):null}function II(n){const e=n[0],t=n[1],r=n[2],s=n[3],i=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],h=n[11],d=n[12],m=n[13],p=n[14],_=n[15],y=e*o-t*i,T=e*a-r*i,b=t*a-r*o,w=l*m-u*d,v=l*p-f*d,A=u*p-f*m,N=e*A-t*v+r*w,D=i*A-o*v+a*w,B=l*b-u*T+f*y,G=d*b-m*T+p*y;return c*N-s*D+_*B-h*G}function xi(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],m=e[11],p=e[12],_=e[13],y=e[14],T=e[15];let b=t[0],w=t[1],v=t[2],A=t[3];return n[0]=b*r+w*a+v*f+A*p,n[1]=b*s+w*c+v*h+A*_,n[2]=b*i+w*l+v*d+A*y,n[3]=b*o+w*u+v*m+A*T,b=t[4],w=t[5],v=t[6],A=t[7],n[4]=b*r+w*a+v*f+A*p,n[5]=b*s+w*c+v*h+A*_,n[6]=b*i+w*l+v*d+A*y,n[7]=b*o+w*u+v*m+A*T,b=t[8],w=t[9],v=t[10],A=t[11],n[8]=b*r+w*a+v*f+A*p,n[9]=b*s+w*c+v*h+A*_,n[10]=b*i+w*l+v*d+A*y,n[11]=b*o+w*u+v*m+A*T,b=t[12],w=t[13],v=t[14],A=t[15],n[12]=b*r+w*a+v*f+A*p,n[13]=b*s+w*c+v*h+A*_,n[14]=b*i+w*l+v*d+A*y,n[15]=b*o+w*u+v*m+A*T,n}function ef(n,e,t){const r=t[0],s=t[1],i=t[2];let o,a,c,l,u,f,h,d,m,p,_,y;return e===n?(n[12]=e[0]*r+e[4]*s+e[8]*i+e[12],n[13]=e[1]*r+e[5]*s+e[9]*i+e[13],n[14]=e[2]*r+e[6]*s+e[10]*i+e[14],n[15]=e[3]*r+e[7]*s+e[11]*i+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],m=e[8],p=e[9],_=e[10],y=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=h,n[7]=d,n[8]=m,n[9]=p,n[10]=_,n[11]=y,n[12]=o*r+u*s+m*i+e[12],n[13]=a*r+f*s+p*i+e[13],n[14]=c*r+h*s+_*i+e[14],n[15]=l*r+d*s+y*i+e[15]),n}function Yg(n,e,t){const r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*s,n[5]=e[5]*s,n[6]=e[6]*s,n[7]=e[7]*s,n[8]=e[8]*i,n[9]=e[9]*i,n[10]=e[10]*i,n[11]=e[11]*i,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function PI(n,e,t,r){let s=r[0],i=r[1],o=r[2],a=Math.sqrt(s*s+i*i+o*o),c,l,u,f,h,d,m,p,_,y,T,b,w,v,A,N,D,B,G,Q,E,J,X,ce;return a<ic?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],h=e[1],d=e[2],m=e[3],p=e[4],_=e[5],y=e[6],T=e[7],b=e[8],w=e[9],v=e[10],A=e[11],N=s*s*u+c,D=i*s*u+o*l,B=o*s*u-i*l,G=s*i*u-o*l,Q=i*i*u+c,E=o*i*u+s*l,J=s*o*u+i*l,X=i*o*u-s*l,ce=o*o*u+c,n[0]=f*N+p*D+b*B,n[1]=h*N+_*D+w*B,n[2]=d*N+y*D+v*B,n[3]=m*N+T*D+A*B,n[4]=f*G+p*Q+b*E,n[5]=h*G+_*Q+w*E,n[6]=d*G+y*Q+v*E,n[7]=m*G+T*Q+A*E,n[8]=f*J+p*X+b*ce,n[9]=h*J+_*X+w*ce,n[10]=d*J+y*X+v*ce,n[11]=m*J+T*X+A*ce,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function x2(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=i*s+l*r,n[5]=o*s+u*r,n[6]=a*s+f*r,n[7]=c*s+h*r,n[8]=l*s-i*r,n[9]=u*s-o*r,n[10]=f*s-a*r,n[11]=h*s-c*r,n}function kI(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s-l*r,n[1]=o*s-u*r,n[2]=a*s-f*r,n[3]=c*s-h*r,n[8]=i*r+l*s,n[9]=o*r+u*s,n[10]=a*r+f*s,n[11]=c*r+h*s,n}function b2(n,e,t){const r=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s+l*r,n[1]=o*s+u*r,n[2]=a*s+f*r,n[3]=c*s+h*r,n[4]=l*s-i*r,n[5]=u*s-o*r,n[6]=f*s-a*r,n[7]=h*s-c*r,n}function OI(n,e){const t=e[0],r=e[1],s=e[2],i=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+r*r+s*s),n[1]=Math.sqrt(i*i+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function MI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t+t,a=r+r,c=s+s,l=t*o,u=r*o,f=r*a,h=s*o,d=s*a,m=s*c,p=i*o,_=i*a,y=i*c;return n[0]=1-f-m,n[1]=u+y,n[2]=h-_,n[3]=0,n[4]=u-y,n[5]=1-l-m,n[6]=d+p,n[7]=0,n[8]=h+_,n[9]=d-p,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function NI(n,e,t,r,s,i,o){const a=1/(t-e),c=1/(s-r),l=1/(i-o);return n[0]=i*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(s+r)*c,n[10]=(o+i)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*i*2*l,n[15]=0,n}function DI(n,e,t,r,s){const i=1/Math.tan(e/2);if(n[0]=i/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){const o=1/(r-s);n[10]=(s+r)*o,n[14]=2*s*r*o}else n[10]=-1,n[14]=-2*r;return n}const LI=DI;function FI(n,e,t,r,s,i,o){const a=1/(e-t),c=1/(r-s),l=1/(i-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(s+r)*c,n[14]=(o+i)*l,n[15]=1,n}const BI=FI;function UI(n,e,t,r){let s,i,o,a,c,l,u,f,h,d;const m=e[0],p=e[1],_=e[2],y=r[0],T=r[1],b=r[2],w=t[0],v=t[1],A=t[2];return Math.abs(m-w)<ic&&Math.abs(p-v)<ic&&Math.abs(_-A)<ic?CI(n):(f=m-w,h=p-v,d=_-A,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,i=T*d-b*h,o=b*f-y*d,a=y*h-T*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=h*a-d*o,l=d*i-f*a,u=f*o-h*i,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),n[0]=i,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=h,n[7]=0,n[8]=a,n[9]=u,n[10]=d,n[11]=0,n[12]=-(i*m+o*p+a*_),n[13]=-(c*m+l*p+u*_),n[14]=-(f*m+h*p+d*_),n[15]=1,n)}function $I(){const n=new rr(4);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function VI(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function qg(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function zI(n){const e=n[0],t=n[1],r=n[2],s=n[3];return Math.sqrt(e*e+t*t+r*r+s*s)}function jI(n){const e=n[0],t=n[1],r=n[2],s=n[3];return e*e+t*t+r*r+s*s}function WI(n,e){const t=e[0],r=e[1],s=e[2],i=e[3];let o=t*t+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=r*o,n[2]=s*o,n[3]=i*o,n}function HI(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function ZI(n,e,t,r){const s=e[0],i=e[1],o=e[2],a=e[3];return n[0]=s+r*(t[0]-s),n[1]=i+r*(t[1]-i),n[2]=o+r*(t[2]-o),n[3]=a+r*(t[3]-a),n}function pa(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3];return n[0]=t[0]*r+t[4]*s+t[8]*i+t[12]*o,n[1]=t[1]*r+t[5]*s+t[9]*i+t[13]*o,n[2]=t[2]*r+t[6]*s+t[10]*i+t[14]*o,n[3]=t[3]*r+t[7]*s+t[11]*i+t[15]*o,n}function XI(n,e,t){const r=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*r+a*i-c*s,f=l*s+c*r-o*i,h=l*i+o*s-a*r,d=-o*r-a*s-c*i;return n[0]=u*l+d*-o+f*-c-h*-a,n[1]=f*l+d*-a+h*-o-u*-c,n[2]=h*l+d*-c+u*-a-f*-o,n[3]=e[3],n}(function(){const n=$I();return function(e,t,r,s,i,o){let a,c;for(t||(t=4),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],n[2]=e[a+2],n[3]=e[a+3],i(n,n,o),e[a]=n[0],e[a+1]=n[1],e[a+2]=n[2],e[a+3]=n[3];return e}})();var rm;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(rm||(rm={}));const YI=45*Math.PI/180,qI=1,Fd=.1,Bd=500,KI=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class qe extends v2{static get IDENTITY(){return JI()}static get ZERO(){return GI()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rm}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,s,i,o,a,c,l,u,f,h,d,m,p,_){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=m,this[14]=p,this[15]=_,this.check()}setRowMajor(e,t,r,s,i,o,a,c,l,u,f,h,d,m,p,_){return this[0]=e,this[1]=i,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=u,this[7]=m,this[8]=r,this[9]=a,this[10]=f,this[11]=p,this[12]=s,this[13]=c,this[14]=h,this[15]=_,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(KI)}fromObject(e){return this.check()}fromQuaternion(e){return MI(this,e),this.check()}frustum(e){const{left:t,right:r,bottom:s,top:i,near:o=Fd,far:a=Bd}=e;return a===1/0?QI(this,t,r,s,i,o):NI(this,t,r,s,i,o,a),this.check()}lookAt(e){const{eye:t,center:r=[0,0,0],up:s=[0,1,0]}=e;return UI(this,t,r,s),this.check()}ortho(e){const{left:t,right:r,bottom:s,top:i,near:o=Fd,far:a=Bd}=e;return BI(this,t,r,s,i,o,a),this.check()}orthographic(e){const{fovy:t=YI,aspect:r=qI,focalDistance:s=1,near:i=Fd,far:o=Bd}=e;Uy(t);const a=t/2,c=s*Math.tan(a),l=c*r;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=e;return Uy(t),LI(this,t,r,s,i),this.check()}determinant(){return II(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),s=1/r[0],i=1/r[1],o=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),s=1/r[0],i=1/r[1],o=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*s,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*s,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return RI(this,this),this.check()}invert(){return nm(this,this),this.check()}multiplyLeft(e){return xi(this,e,this),this.check()}multiplyRight(e){return xi(this,this,e),this.check()}rotateX(e){return x2(this,this,e),this.check()}rotateY(e){return kI(this,this,e),this.check()}rotateZ(e){return b2(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return PI(this,this,e,t),this.check()}scale(e){return Yg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return ef(this,this,e),this.check()}transform(e,t){return e.length===4?(t=pa(t||[-0,-0,-0,-0],e,this),sc(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:r}=e;let s;switch(r){case 2:s=rI(t||[-0,-0],e,this);break;case 3:s=Zg(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(s,e.length),s}transformAsVector(e,t){let r;switch(e.length){case 2:r=sI(t||[-0,-0],e,this);break;case 3:r=f2(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return sc(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}}let Jl,Ql;function GI(){return Jl||(Jl=new qe([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jl)),Jl}function JI(){return Ql||(Ql=new qe,Object.freeze(Ql)),Ql}function Uy(n){if(n>Math.PI*2)throw Error("expected radians")}function QI(n,e,t,r,s,i){const o=2*i/(t-e),a=2*i/(s-r),c=(t+e)/(t-e),l=(s+r)/(s-r),u=-1,f=-1,h=-2*i;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=h,n[15]=0,n}function $y(){const n=new rr(4);return rr!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function eP(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function w2(n,e,t){t=t*.5;const r=Math.sin(t);return n[0]=r*e[0],n[1]=r*e[1],n[2]=r*e[2],n[3]=Math.cos(t),n}function Vy(n,e,t){const r=e[0],s=e[1],i=e[2],o=e[3],a=t[0],c=t[1],l=t[2],u=t[3];return n[0]=r*u+o*a+s*l-i*c,n[1]=s*u+o*c+i*a-r*l,n[2]=i*u+o*l+r*c-s*a,n[3]=o*u-r*a-s*c-i*l,n}function tP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c+o*a,n[1]=s*c+i*a,n[2]=i*c-s*a,n[3]=o*c-r*a,n}function nP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c-i*a,n[1]=s*c+o*a,n[2]=i*c+r*a,n[3]=o*c-s*a,n}function rP(n,e,t){t*=.5;const r=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(t),c=Math.cos(t);return n[0]=r*c+s*a,n[1]=s*c-r*a,n[2]=i*c+o*a,n[3]=o*c-i*a,n}function sP(n,e){const t=e[0],r=e[1],s=e[2];return n[0]=t,n[1]=r,n[2]=s,n[3]=Math.sqrt(Math.abs(1-t*t-r*r-s*s)),n}function ku(n,e,t,r){const s=e[0],i=e[1],o=e[2],a=e[3];let c=t[0],l=t[1],u=t[2],f=t[3],h,d,m,p,_;return h=s*c+i*l+o*u+a*f,h<0&&(h=-h,c=-c,l=-l,u=-u,f=-f),1-h>ic?(d=Math.acos(h),_=Math.sin(d),m=Math.sin((1-r)*d)/_,p=Math.sin(r*d)/_):(m=1-r,p=r),n[0]=m*s+p*c,n[1]=m*i+p*l,n[2]=m*o+p*u,n[3]=m*a+p*f,n}function iP(n,e){const t=e[0],r=e[1],s=e[2],i=e[3],o=t*t+r*r+s*s+i*i,a=o?1/o:0;return n[0]=-t*a,n[1]=-r*a,n[2]=-s*a,n[3]=i*a,n}function oP(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n}function T2(n,e){const t=e[0]+e[4]+e[8];let r;if(t>0)r=Math.sqrt(t+1),n[3]=.5*r,r=.5/r,n[0]=(e[5]-e[7])*r,n[1]=(e[6]-e[2])*r,n[2]=(e[1]-e[3])*r;else{let s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);const i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(e[s*3+s]-e[i*3+i]-e[o*3+o]+1),n[s]=.5*r,r=.5/r,n[3]=(e[i*3+o]-e[o*3+i])*r,n[i]=(e[i*3+s]+e[s*3+i])*r,n[o]=(e[o*3+s]+e[s*3+o])*r}return n}const aP=VI,cP=qg,lP=HI,uP=ZI,fP=zI,hP=jI,S2=WI,dP=function(){const n=d2(),e=Ly(1,0,0),t=Ly(0,1,0);return function(r,s,i){const o=p2(s,i);return o<-.999999?(Pu(n,e,s),y2(n)<1e-6&&Pu(n,t,s),fI(n,n),w2(r,n,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Pu(n,s,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=1+o,S2(r,r))}}();(function(){const n=$y(),e=$y();return function(t,r,s,i,o,a){return ku(n,r,o,a),ku(e,s,i,a),ku(t,n,e,2*a*(1-a)),t}})();(function(){const n=_I();return function(e,t,r,s){return n[0]=r[0],n[3]=r[1],n[6]=r[2],n[1]=s[0],n[4]=s[1],n[7]=s[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],S2(e,T2(e,n))}})();const pP=[0,0,0,1];class zy extends Hg{constructor(e=0,t=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,t,r,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,r,s){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return T2(this,e),this.check()}fromAxisRotation(e,t){return w2(this,e,t),this.check()}identity(){return eP(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=wt(e)}get y(){return this[1]}set y(e){this[1]=wt(e)}get z(){return this[2]}set z(e){this[2]=wt(e)}get w(){return this[3]}set w(e){this[3]=wt(e)}len(){return fP(this)}lengthSquared(){return hP(this)}dot(e){return lP(this,e)}rotationTo(e,t){return dP(this,e,t),this.check()}add(e){return aP(this,this,e),this.check()}calculateW(){return sP(this,this),this.check()}conjugate(){return oP(this,this),this.check()}invert(){return iP(this,this),this.check()}lerp(e,t,r){return r===void 0?this.lerp(this,e,t):(uP(this,e,t,r),this.check())}multiplyRight(e){return Vy(this,this,e),this.check()}multiplyLeft(e){return Vy(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,e===0&&(this[3]=1),this.check()}rotateX(e){return tP(this,this,e),this.check()}rotateY(e){return nP(this,this,e),this.check()}rotateZ(e){return rP(this,this,e),this.check()}scale(e){return cP(this,this,e),this.check()}slerp(e,t,r){let s,i,o;switch(arguments.length){case 1:({start:s=pP,target:i,ratio:o}=e);break;case 2:s=this,i=e,o=t;break;default:s=e,i=t,o=r}return ku(this,s,i,o),this.check()}transformVector4(e,t=new Xg){return XI(t,e,this),sc(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const mP=1e-15,gP=1e-20,bi=6,Sr={cyan:"#00FFFF",yellow:"#FFFF00",magenta:"#FF00FF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",white:"#FFFFFF"},_P=[Sr.magenta,Sr.green],yP=[Sr.red,Sr.green,Sr.blue],jy=Object.values(Sr).slice(0,bi),vP="https://ome.github.io/ome-ngff-validator/";async function xP(n){if(typeof n=="string"){let e,t="/";if(n.endsWith(".json")){const[{default:r},s]=await Promise.all([Promise.resolve().then(()=>require("./ref-B0_Wl0Bd.cjs")),fetch(n).then(i=>i.json())]);e=r.fromSpec(s)}else try{const r=Ju.fromUrl(n);await r.has("/"),e=r}catch{const r=new URL(n);t=bP(r.pathname),r.pathname="/",e=new _R(r.href)}return new Ys(YR(e),t)}return jC(n)}function bP(n){return n==="/"||n.startsWith("/")?n:`/${n}`}async function wP(n){const e=await xP(n);return en(e)}async function Ud(n,e){const t=new TextDecoder;if(e.path&&(n=n.resolve(e.path)),e.zarrVersion===3){const o=await en.v3(n).then(a=>a.attrs);return Pi(o)}const r=n.resolve(".zattrs"),s=await n.store.get(r.path),i=s?JSON.parse(t.decode(s)):{};return Pi(i)}async function Kg(n,e){const{datasets:t}=e[0]||[{path:"0"}];return Promise.all(t.map(({path:r})=>en(n.resolve(r),{kind:"array",attrs:!1})))}function Gg(n){n.startsWith("#")&&(n=n.slice(1));const e=Number.parseInt(n.slice(0,2),16),t=Number.parseInt(n.slice(2,4),16),r=Number.parseInt(n.slice(4,6),16);return[e,t,r]}function Sc(n){return Array.from({length:n},(e,t)=>t)}function TP(n,e=" "){for(;n.length>0&&e.includes(n.charAt(n.length-1));)n=n.substr(0,n.length-1);return n}function Ao(...n){return n.filter(e=>e!==void 0).map(e=>TP(e,"/")).join("/")}function SP(n,e){return(!e||e.length!==n.shape.length)&&(e=n.shape.slice(0,-2).map((r,s)=>`${s}`).concat(["y","x"])),e}function E2(n){return Sc(n).map(e=>`channel_${e}`)}function Wy(n){return n==="t"?"time":n==="c"?"channel":"space"}function Lh(n){return typeof n[0]=="object"&&n[0]&&"axes"in n[0]&&Array.isArray(n[0].axes)?n[0].axes.map(t=>{if(typeof t=="string")return{name:t,type:Wy(t)};const{name:r,type:s,unit:i}=t;return{name:r,type:s??Wy(r),unit:i}}):[{type:"channel",name:"c"},{type:"space",name:"z"},{type:"space",name:"y"},{type:"space",name:"x"}]}function hl(n){return n.map(t=>t.name)}function A2(n,e){return e||(n<=bi?e=Array(n).fill(!0):e=[...Array(bi).fill(!0),...Array(n-bi).fill(!1)]),e}function C2(n,e){let t=[];if(n===1)t=[Sr.white];else if(n===2)t=_P;else if(n===3)t=yP;else if(n<=bi)t=jy.slice(0,n);else{t=Array(n).fill(Sr.white);const r=e.flatMap((s,i)=>s?i:[]);for(const[s,i]of r.entries())t[i]=jy[s]}return t}function R2(n){const e=n[n.length-1];return e===3||e===4}function dl(n){const e=R2(n.shape),[t,r]=n.chunks.slice(e?-3:-2),s=Math.min(t,r);return 2**Math.floor(Math.log2(s))}function I2(n){const{image:e,viewport:t,padding:r,matrix:s=new qe().identity()}=n,i=[[0,0,0],[e.width,0,0],[e.width,e.height,0],[0,e.height,0]].map(h=>s.transformAsPoint(h)),o=Math.min(...i.map(h=>h[0])),a=Math.max(...i.map(h=>h[0])),c=Math.min(...i.map(h=>h[1])),l=Math.max(...i.map(h=>h[1])),u=t.width-2*r,f=t.height-2*r;return{zoom:Math.log2(Math.min(u/(a-o),f/(l-c))),target:[(o+a)/2,(c+l)/2]}}function EP(n){return Array.isArray(n)?n.length===16&&n.every(e=>typeof e=="number"):!1}function Fh(n){if(!n)return qe.IDENTITY;const e=new qe;try{const t=typeof n=="string"?JSON.parse(n):n;it(EP(t),"Invalid modelMatrix size. Must be 16."),e.setRowMajor(...t)}catch{const t=`Failed to parse modelMatrix. Got ${JSON.stringify(n)}, using identity.`;console.warn(t)}return e}async function Jg(n,e){if(n.dtype==="Uint8")return[0,255];const{data:t}=await n.getRaster({selection:e});let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let i=0;i<t.length;i++)t[i]>s&&(s=t[i]),t[i]<r&&(r=t[i]);return r===s&&(r=0,s=1),[r,s]}async function P2(n,e,t,r){const s=n.shape.map(()=>0),i=n.shape[e];return e!==-1&&it(i===t.length,"visibilities do not match number of channels"),Promise.all(t.map(async(o,a)=>{if(!o)return;const c=[...s];return e>-1&&(c[e]=a),Jg(n,c)}))}function AP(){let n,e;return{promise:new Promise((r,s)=>{n=r,e=s}),resolve:n,reject:e}}function CP(){let n=new EventTarget;return{on:(e,t)=>{n.addEventListener(e,r=>t(r.detail))},emit:(e,t)=>{n.dispatchEvent(new CustomEvent(e,{detail:t}))}}}function Pi(n){return"omero"in n&&"ome"in n?{version:typeof n.ome=="object"&&n.ome!==null&&"version"in n.ome?n.ome.version:"",multiscales:typeof n.ome=="object"&&n.ome!==null&&"multiscales"in n.ome?n.ome.multiscales:{},omero:{channels:typeof n.omero=="object"&&n.omero!==null&&"channels"in n.omero?n.omero.channels:{}}}:"ome"in n?n.ome:n}class k2 extends Error{constructor(e){super(e),this.name="AssertionError"}}class O2 extends Error{constructor(t,r){super(t);x(this,"url");this.name="RedirectError",this.url=r}}function it(n,e=""){if(!n)throw new k2(e)}async function RP(n){try{return await en.v3(n),3}catch(e){if(!(e instanceof ji))throw e;return 2}}function Hy(n){return"plate"in n}function IP(n){return"well"in n}function PP(n){return"image-label"in n&&Ec(n)}function M2(n){return"omero"in n&&Ec(n)}function Ec(n){return"multiscales"in n}function kP(n){return"bioformats2raw.layout"in n}/**
|
|
136
136
|
* Ensures an error matches expected type(s), otherwise rethrows.
|
|
137
137
|
*
|
|
138
138
|
* Unmatched errors bubble up, like Python's `except`. Narrows error types for
|
|
@@ -3456,7 +3456,7 @@ vec4 colormap(float intensity, float opacity) {
|
|
|
3456
3456
|
rgbCombo += max(0.0, min(1.0, minVals[i])) * vec3(colors[i]);
|
|
3457
3457
|
}
|
|
3458
3458
|
color = vec4(rgbCombo, 1.0);
|
|
3459
|
-
`,dW=class extends Al{constructor(n){super(n),this.rendering={_BEFORE_RENDER:uW,_RENDER:fW,_AFTER_RENDER:hW}}};dW.extensionName="MinimumIntensityProjectionExtension";const OS={AdditiveBlendExtension:kS},pW=new Map;function is(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>pW.set(t,e))}is([void 0,1],()=>Promise.resolve().then(()=>require("./raw-BB450wdT.cjs")).then(n=>n.default));is(5,()=>Promise.resolve().then(()=>require("./lzw-DnHvgKbO.cjs")).then(n=>n.default));is(6,()=>{throw new Error("old style JPEG compression is not supported.")});is(7,()=>Promise.resolve().then(()=>require("./jpeg-DFzBPcur.cjs")).then(n=>n.default));is([8,32946],()=>Promise.resolve().then(()=>require("./deflate-DzrO3E-1.cjs")).then(n=>n.default));is(32773,()=>Promise.resolve().then(()=>require("./packbits-DwdUAwAt.cjs")).then(n=>n.default));is(34887,()=>Promise.resolve().then(()=>require("./lerc-35FtXNGP.cjs")).then(async n=>(await n.zstd.init(),n)).then(n=>n.default));is(50001,()=>Promise.resolve().then(()=>require("./webimage-66a9vFf5.cjs")).then(n=>n.default));function mW(n,e){let t=n.length-e,r=0;do{for(let s=e;s>0;s--)n[r+e]+=n[r],r++;t-=e}while(t>0)}function gW(n,e,t){let r=0,s=n.length;const i=s/t;for(;s>e;){for(let a=e;a>0;--a)n[r+e]+=n[r],++r;s-=e}const o=n.slice();for(let a=0;a<i;++a)for(let c=0;c<t;++c)n[t*a+c]=o[(t-c-1)*i+a]}function _W(n,e,t,r,s,i){if(e===1)return n;for(let c=0;c<s.length;++c){if(s[c]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(s[c]!==s[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const o=s[0]/8,a=i===2?1:s.length;for(let c=0;c<r&&!(c*a*t*o>=n.byteLength);++c){let l;if(e===2){switch(s[0]){case 8:l=new Uint8Array(n,c*a*t*o,a*t*o);break;case 16:l=new Uint16Array(n,c*a*t*o,a*t*o/2);break;case 32:l=new Uint32Array(n,c*a*t*o,a*t*o/4);break;default:throw new Error(`Predictor 2 not allowed with ${s[0]} bits per sample.`)}mW(l,a)}else e===3&&(l=new Uint8Array(n,c*a*t*o,a*t*o),gW(l,a,o))}return n}class MS{async decode(e,t){const r=await this.decodeBlock(t),s=e.Predictor||1;if(s!==1){const i=!e.StripOffsets,o=i?e.TileWidth:e.ImageWidth,a=i?e.TileLength:e.RowsPerStrip||e.ImageLength;return _W(r,s,o,a,e.BitsPerSample,e.PlanarConfiguration)}return r}}var tt;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},n.find=(s,i)=>{for(const o of s)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(tt||(tt={}));var Vb;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Vb||(Vb={}));const Ee=tt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return isNaN(n)?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(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},de=tt.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 $n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let a=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof $n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}$n.create=n=>new $n(n);const Zc=(n,e)=>{let t;switch(n.code){case de.invalid_type:n.received===Ee.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case de.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,tt.jsonStringifyReplacer)}`;break;case de.unrecognized_keys:t=`Unrecognized key(s) in object: ${tt.joinValues(n.keys,", ")}`;break;case de.invalid_union:t="Invalid input";break;case de.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${tt.joinValues(n.options)}`;break;case de.invalid_enum_value:t=`Invalid enum value. Expected ${tt.joinValues(n.options)}, received '${n.received}'`;break;case de.invalid_arguments:t="Invalid function arguments";break;case de.invalid_return_type:t="Invalid function return type";break;case de.invalid_date:t="Invalid date";break;case de.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:tt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case de.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case de.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case de.custom:t="Invalid input";break;case de.invalid_intersection_types:t="Intersection results could not be merged";break;case de.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case de.not_finite:t="Number must be finite";break;default:t=e.defaultError,tt.assertNever(n)}return{message:t}};let yW=Zc;function rg(){return yW}const sg=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function we(n,e){const t=rg(),r=sg({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Zc?void 0:Zc].filter(s=>!!s)});n.common.issues.push(r)}class yn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return $e;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return yn.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return $e;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const $e=Object.freeze({status:"aborted"}),Ka=n=>({status:"dirty",value:n}),Tn=n=>({status:"valid",value:n}),zb=n=>n.status==="aborted",jb=n=>n.status==="dirty",la=n=>n.status==="valid",Vf=n=>typeof Promise<"u"&&n instanceof Promise;function zf(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function NS(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var Ie;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ie||(Ie={}));var Ga,Ja;class Cr{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Wb=(n,e)=>{if(la(e))return{success:!0,data:e.value};if(!n.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 $n(n.common.issues);return this._error=t,this._error}}};function je(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{var c,l;const{message:u}=n;return o.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(l=u??t)!==null&&l!==void 0?l:a.defaultError}},description:s}}class Ke{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yn,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Vf(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Wb(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return la(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>la(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Vf(s)?s:Promise.resolve(s));return Wb(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:de.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new ss({schema:this,typeName:Le.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:t=>this["~validate"](t)}}optional(){return Kr.create(this,this._def)}nullable(){return Vi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Er.create(this)}promise(){return Xc.create(this,this._def)}or(e){return Zf.create([this,e],this._def)}and(e){return Xf.create(this,e,this._def)}transform(e){return new ss({...je(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Jf({...je(this._def),innerType:this,defaultValue:t,typeName:Le.ZodDefault})}brand(){return new BS({typeName:Le.ZodBranded,type:this,...je(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Qf({...je(this._def),innerType:this,catchValue:t,typeName:Le.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ed.create(this,e)}readonly(){return eh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const vW=/^c[^\s-]{8,}$/i,xW=/^[0-9a-z]+$/,bW=/^[0-9A-HJKMNP-TV-Z]{26}$/i,wW=/^[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,TW=/^[a-z0-9_-]{21}$/i,SW=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,EW=/^[-+]?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)?)??$/,AW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,CW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ep;const RW=/^(?:(?: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])$/,IW=/^(?:(?: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])$/,PW=/^(([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]))$/,kW=/^(([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])$/,OW=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,MW=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DS="((\\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])))",NW=new RegExp(`^${DS}$`);function LS(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function DW(n){return new RegExp(`^${LS(n)}$`)}function LW(n){let e=`${DS}T${LS(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function FW(n,e){return!!((e==="v4"||!e)&&RW.test(n)||(e==="v6"||!e)&&PW.test(n))}function BW(n,e){if(!SW.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function UW(n,e){return!!((e==="v4"||!e)&&IW.test(n)||(e==="v6"||!e)&&kW.test(n))}class wr extends Ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ee.string){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.string,received:i.parsedType}),$e}const r=new yn;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?we(s,{code:de.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&we(s,{code:de.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")AW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"email",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ep||(Ep=new RegExp(CW,"u")),Ep.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"emoji",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")wW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"uuid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")TW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"nanoid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")vW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cuid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")xW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cuid2",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"ulid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),we(s,{validation:"url",code:de.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"regex",code:de.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?LW(i).test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?NW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?DW(i).test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?EW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"duration",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?FW(e.data,i.version)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"ip",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?BW(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"jwt",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?UW(e.data,i.version)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cidr",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?OW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"base64",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?MW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"base64url",code:de.invalid_string,message:i.message}),r.dirty()):tt.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:de.invalid_string,...Ie.errToObj(r)})}_addCheck(e){return new wr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ie.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ie.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ie.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ie.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...Ie.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ie.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ie.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ie.errToObj(t)})}nonempty(e){return this.min(1,Ie.errToObj(e))}trim(){return new wr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}wr.create=n=>{var e;return new wr({checks:[],typeName:Le.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...je(n)})};function $W(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}class Bi extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Ee.number){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.number,received:i.parsedType}),$e}let r;const s=new yn;for(const i of this._def.checks)i.kind==="int"?tt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:de.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?$W(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_finite,message:i.message}),s.dirty()):tt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,r,s){return new Bi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ie.toString(s)}]})}_addCheck(e){return new Bi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&tt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bi.create=n=>new Bi({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...je(n)});class Ui extends Ke{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 r;const s=new yn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):tt.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return we(t,{code:de.invalid_type,expected:Ee.bigint,received:t.parsedType}),$e}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,r,s){return new Ui({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ie.toString(s)}]})}_addCheck(e){return new Ui({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ui.create=n=>{var e;return new Ui({checks:[],typeName:Le.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...je(n)})};class jf extends Ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ee.boolean){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.boolean,received:r.parsedType}),$e}return Tn(e.data)}}jf.create=n=>new jf({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...je(n)});class ua extends Ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ee.date){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.date,received:i.parsedType}),$e}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_date}),$e}const r=new yn;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):tt.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ua({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ie.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ua.create=n=>new ua({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...je(n)});class ig extends Ke{_parse(e){if(this._getType(e)!==Ee.symbol){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.symbol,received:r.parsedType}),$e}return Tn(e.data)}}ig.create=n=>new ig({typeName:Le.ZodSymbol,...je(n)});class Wf extends Ke{_parse(e){if(this._getType(e)!==Ee.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.undefined,received:r.parsedType}),$e}return Tn(e.data)}}Wf.create=n=>new Wf({typeName:Le.ZodUndefined,...je(n)});class Hf extends Ke{_parse(e){if(this._getType(e)!==Ee.null){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.null,received:r.parsedType}),$e}return Tn(e.data)}}Hf.create=n=>new Hf({typeName:Le.ZodNull,...je(n)});class og extends Ke{constructor(){super(...arguments),this._any=!0}_parse(e){return Tn(e.data)}}og.create=n=>new og({typeName:Le.ZodAny,...je(n)});class zo extends Ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tn(e.data)}}zo.create=n=>new zo({typeName:Le.ZodUnknown,...je(n)});class Zs extends Ke{_parse(e){const t=this._getOrReturnCtx(e);return we(t,{code:de.invalid_type,expected:Ee.never,received:t.parsedType}),$e}}Zs.create=n=>new Zs({typeName:Le.ZodNever,...je(n)});class ag extends Ke{_parse(e){if(this._getType(e)!==Ee.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.void,received:r.parsedType}),$e}return Tn(e.data)}}ag.create=n=>new ag({typeName:Le.ZodVoid,...je(n)});class Er extends Ke{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==Ee.array)return we(t,{code:de.invalid_type,expected:Ee.array,received:t.parsedType}),$e;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(o||a)&&(we(t,{code:o?de.too_big:de.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(we(t,{code:de.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(we(t,{code:de.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new Cr(t,o,t.path,a)))).then(o=>yn.mergeArray(r,o));const i=[...t.data].map((o,a)=>s.type._parseSync(new Cr(t,o,t.path,a)));return yn.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new Er({...this._def,minLength:{value:e,message:Ie.toString(t)}})}max(e,t){return new Er({...this._def,maxLength:{value:e,message:Ie.toString(t)}})}length(e,t){return new Er({...this._def,exactLength:{value:e,message:Ie.toString(t)}})}nonempty(e){return this.min(1,e)}}Er.create=(n,e)=>new Er({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...je(e)});function To(n){if(n instanceof Ft){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Kr.create(To(r))}return new Ft({...n._def,shape:()=>e})}else return n instanceof Er?new Er({...n._def,type:To(n.element)}):n instanceof Kr?Kr.create(To(n.unwrap())):n instanceof Vi?Vi.create(To(n.unwrap())):n instanceof rs?rs.create(n.items.map(e=>To(e))):n}class Ft extends Ke{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=tt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Ee.object){const l=this._getOrReturnCtx(e);return we(l,{code:de.invalid_type,expected:Ee.object,received:l.parsedType}),$e}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Zs&&this._def.unknownKeys==="strip"))for(const l in s.data)o.includes(l)||a.push(l);const c=[];for(const l of o){const u=i[l],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Cr(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Zs){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(we(s,{code:de.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of a){const f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Cr(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const f=await u.key,h=await u.value;l.push({key:f,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>yn.mergeObjectSync(r,l)):yn.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return Ie.errToObj,new Ft({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,o,a;const c=(o=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(a=Ie.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ft({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ft({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ft({...this._def,catchall:e})}pick(e){const t={};return tt.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new Ft({...this._def,shape:()=>t})}omit(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new Ft({...this._def,shape:()=>t})}deepPartial(){return To(this)}partial(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new Ft({...this._def,shape:()=>t})}required(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Kr;)i=i._def.innerType;t[r]=i}}),new Ft({...this._def,shape:()=>t})}keyof(){return FS(tt.objectKeys(this.shape))}}Ft.create=(n,e)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});Ft.strictCreate=(n,e)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});Ft.lazycreate=(n,e)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});class Zf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new $n(a.ctx.common.issues));return we(t,{code:de.invalid_union,unionErrors:o}),$e}if(t.common.async)return Promise.all(r.map(async i=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(c=>new $n(c));return we(t,{code:de.invalid_union,unionErrors:a}),$e}}get options(){return this._def.options}}Zf.create=(n,e)=>new Zf({options:n,typeName:Le.ZodUnion,...je(e)});const $r=n=>n instanceof qf?$r(n.schema):n instanceof ss?$r(n.innerType()):n instanceof Kf?[n.value]:n instanceof $i?n.options:n instanceof Gf?tt.objectValues(n.enum):n instanceof Jf?$r(n._def.innerType):n instanceof Wf?[void 0]:n instanceof Hf?[null]:n instanceof Kr?[void 0,...$r(n.unwrap())]:n instanceof Vi?[null,...$r(n.unwrap())]:n instanceof BS||n instanceof eh?$r(n.unwrap()):n instanceof Qf?$r(n._def.innerType):[];class o_ extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.object)return we(t,{code:de.invalid_type,expected:Ee.object,received:t.parsedType}),$e;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(we(t,{code:de.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),$e)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const o=$r(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new o_({typeName:Le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...je(r)})}}function cg(n,e){const t=bs(n),r=bs(e);if(n===e)return{valid:!0,data:n};if(t===Ee.object&&r===Ee.object){const s=tt.objectKeys(e),i=tt.objectKeys(n).filter(a=>s.indexOf(a)!==-1),o={...n,...e};for(const a of i){const c=cg(n[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(t===Ee.array&&r===Ee.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const o=n[i],a=e[i],c=cg(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Ee.date&&r===Ee.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Xf extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(zb(i)||zb(o))return $e;const a=cg(i.value,o.value);return a.valid?((jb(i)||jb(o))&&t.dirty(),{status:t.value,value:a.data}):(we(r,{code:de.invalid_intersection_types}),$e)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Xf.create=(n,e,t)=>new Xf({left:n,right:e,typeName:Le.ZodIntersection,...je(t)});class rs extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.array)return we(r,{code:de.invalid_type,expected:Ee.array,received:r.parsedType}),$e;if(r.data.length<this._def.items.length)return we(r,{code:de.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$e;!this._def.rest&&r.data.length>this._def.items.length&&(we(r,{code:de.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new Cr(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>yn.mergeArray(t,o)):yn.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new rs({...this._def,rest:e})}}rs.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new rs({items:n,typeName:Le.ZodTuple,rest:null,...je(e)})};class Yf extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.object)return we(r,{code:de.invalid_type,expected:Ee.object,received:r.parsedType}),$e;const s=[],i=this._def.keyType,o=this._def.valueType;for(const a in r.data)s.push({key:i._parse(new Cr(r,a,r.path,a)),value:o._parse(new Cr(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?yn.mergeObjectAsync(t,s):yn.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Ke?new Yf({keyType:e,valueType:t,typeName:Le.ZodRecord,...je(r)}):new Yf({keyType:wr.create(),valueType:e,typeName:Le.ZodRecord,...je(t)})}}class lg extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.map)return we(r,{code:de.invalid_type,expected:Ee.map,received:r.parsedType}),$e;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new Cr(r,a,r.path,[l,"key"])),value:i._parse(new Cr(r,c,r.path,[l,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return $e;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return $e;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}}}}lg.create=(n,e,t)=>new lg({valueType:e,keyType:n,typeName:Le.ZodMap,...je(t)});class fa extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.set)return we(r,{code:de.invalid_type,expected:Ee.set,received:r.parsedType}),$e;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(we(r,{code:de.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(we(r,{code:de.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return $e;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}const a=[...r.data.values()].map((c,l)=>i._parse(new Cr(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,t){return new fa({...this._def,minSize:{value:e,message:Ie.toString(t)}})}max(e,t){return new fa({...this._def,maxSize:{value:e,message:Ie.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fa.create=(n,e)=>new fa({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...je(e)});class pc extends Ke{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.function)return we(t,{code:de.invalid_type,expected:Ee.function,received:t.parsedType}),$e;function r(a,c){return sg({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rg(),Zc].filter(l=>!!l),issueData:{code:de.invalid_arguments,argumentsError:c}})}function s(a,c){return sg({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rg(),Zc].filter(l=>!!l),issueData:{code:de.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Xc){const a=this;return Tn(async function(...c){const l=new $n([]),u=await a._def.args.parseAsync(c,i).catch(d=>{throw l.addIssue(r(c,d)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(d=>{throw l.addIssue(s(f,d)),l})})}else{const a=this;return Tn(function(...c){const l=a._def.args.safeParse(c,i);if(!l.success)throw new $n([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new $n([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pc({...this._def,args:rs.create(e).rest(zo.create())})}returns(e){return new pc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new pc({args:e||rs.create([]).rest(zo.create()),returns:t||zo.create(),typeName:Le.ZodFunction,...je(r)})}}class qf extends Ke{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})}}qf.create=(n,e)=>new qf({getter:n,typeName:Le.ZodLazy,...je(e)});class Kf extends Ke{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return we(t,{received:t.data,code:de.invalid_literal,expected:this._def.value}),$e}return{status:"valid",value:e.data}}get value(){return this._def.value}}Kf.create=(n,e)=>new Kf({value:n,typeName:Le.ZodLiteral,...je(e)});function FS(n,e){return new $i({values:n,typeName:Le.ZodEnum,...je(e)})}class $i extends Ke{constructor(){super(...arguments),Ga.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{expected:tt.joinValues(r),received:t.parsedType,code:de.invalid_type}),$e}if(zf(this,Ga)||NS(this,Ga,new Set(this._def.values)),!zf(this,Ga).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{received:t.data,code:de.invalid_enum_value,options:r}),$e}return Tn(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 $i.create(e,{...this._def,...t})}exclude(e,t=this._def){return $i.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ga=new WeakMap;$i.create=FS;class Gf extends Ke{constructor(){super(...arguments),Ja.set(this,void 0)}_parse(e){const t=tt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const s=tt.objectValues(t);return we(r,{expected:tt.joinValues(s),received:r.parsedType,code:de.invalid_type}),$e}if(zf(this,Ja)||NS(this,Ja,new Set(tt.getValidEnumValues(this._def.values))),!zf(this,Ja).has(e.data)){const s=tt.objectValues(t);return we(r,{received:r.data,code:de.invalid_enum_value,options:s}),$e}return Tn(e.data)}get enum(){return this._def.values}}Ja=new WeakMap;Gf.create=(n,e)=>new Gf({values:n,typeName:Le.ZodNativeEnum,...je(e)});class Xc extends Ke{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.promise&&t.common.async===!1)return we(t,{code:de.invalid_type,expected:Ee.promise,received:t.parsedType}),$e;const r=t.parsedType===Ee.promise?t.data:Promise.resolve(t.data);return Tn(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Xc.create=(n,e)=>new Xc({type:n,typeName:Le.ZodPromise,...je(e)});class ss extends Ke{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{we(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return $e;const c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?$e:c.status==="dirty"||t.value==="dirty"?Ka(c.value):c});{if(t.value==="aborted")return $e;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?$e:a.status==="dirty"||t.value==="dirty"?Ka(a.value):a}}if(s.type==="refinement"){const o=a=>{const c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?$e:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?$e:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!la(o))return o;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>la(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:t.value,value:a})):o);tt.assertNever(s)}}ss.create=(n,e,t)=>new ss({schema:n,typeName:Le.ZodEffects,effect:e,...je(t)});ss.createWithPreprocess=(n,e,t)=>new ss({schema:e,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...je(t)});class Kr extends Ke{_parse(e){return this._getType(e)===Ee.undefined?Tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Kr.create=(n,e)=>new Kr({innerType:n,typeName:Le.ZodOptional,...je(e)});class Vi extends Ke{_parse(e){return this._getType(e)===Ee.null?Tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Vi.create=(n,e)=>new Vi({innerType:n,typeName:Le.ZodNullable,...je(e)});class Jf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Jf.create=(n,e)=>new Jf({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...je(e)});class Qf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Vf(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $n(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Qf.create=(n,e)=>new Qf({innerType:n,typeName:Le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...je(e)});class ug extends Ke{_parse(e){if(this._getType(e)!==Ee.nan){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.nan,received:r.parsedType}),$e}return{status:"valid",value:e.data}}}ug.create=n=>new ug({typeName:Le.ZodNaN,...je(n)});class BS extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ed extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?$e:i.status==="dirty"?(t.dirty(),Ka(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?$e:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ed({in:e,out:t,typeName:Le.ZodPipeline})}}class eh extends Ke{_parse(e){const t=this._def.innerType._parse(e),r=s=>(la(s)&&(s.value=Object.freeze(s.value)),s);return Vf(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}eh.create=(n,e)=>new eh({innerType:n,typeName:Le.ZodReadonly,...je(e)});Ft.lazycreate;var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const Gr=wr.create;Bi.create;ug.create;Ui.create;jf.create;ua.create;ig.create;Wf.create;Hf.create;og.create;const VW=zo.create;Zs.create;ag.create;Er.create;const or=Ft.create;Ft.strictCreate;Zf.create;o_.create;Xf.create;rs.create;Yf.create;lg.create;fa.create;pc.create;qf.create;Kf.create;const a_=$i.create;Gf.create;Xc.create;ss.create;Kr.create;Vi.create;const fg=ss.createWithPreprocess;ed.create;const ln={string:n=>wr.create({...n,coerce:!0}),number:n=>Bi.create({...n,coerce:!0}),boolean:n=>jf.create({...n,coerce:!0}),bigint:n=>Ui.create({...n,coerce:!0}),date:n=>ua.create({...n,coerce:!0})};var zW=Object.defineProperty,jW=(n,e,t)=>e in n?zW(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,WW=(n,e,t)=>(jW(n,e+"",t),t);class HW extends MS{constructor(e){super(),WW(this,"maxUncompressedSize");const t=e.TileWidth||e.ImageWidth,r=e.TileLength||e.ImageLength,s=e.BitsPerSample[0]/8;this.maxUncompressedSize=t*r*s}async decodeBlock(e){const t=new Uint8Array(e);return(await decompress(t,this.maxUncompressedSize)).buffer}}function ZW(n){if(!Number.isInteger(n))throw Error("Not an integer.");const e=new ArrayBuffer(4);new DataView(e).setInt32(0,n,!1);const r=new Uint8Array(e);return Array.from(r)}function Yc(n){const e=n[n.length-1];return e===3||e===4}function td(n){const e=Yc(n.shape),[t,r]=n.shape.slice(e?-3:-2);return{height:t,width:r}}const US="__vivSignalAborted";function Cl({attr:n,...e}){return{...n,...e}}function hg(n){return Array.isArray(n)?n:[n]}const XW=a_(["XYZCT","XYZTC","XYCTZ","XYCZT","XYTCZ","XYTZC"]),YW=a_(["int8","int16","int32","uint8","uint16","uint32","float","bit","double","complex","double-complex"]),Ap=a_(["Ym","Zm","Em","Pm","Tm","Gm","Mm","km","hm","dam","m","dm","cm","mm","µm","nm","pm","fm","am","zm","ym","Å","thou","li","in","ft","yd","mi","ua","ly","pc","pt","pixel","reference frame"]),qW=or({}).extend({attr:or({ID:Gr(),SamplesPerPixel:ln.number().optional(),Name:Gr().optional(),Color:ln.number().transform(ZW).optional()})}).transform(Cl),KW=or({}).extend({attr:or({FileName:Gr()})}).transform(Cl),GW=or({UUID:KW.optional()}).extend({attr:or({IFD:ln.number().default(0),PlaneCount:ln.number().default(1),FirstT:ln.number().optional(),FirstC:ln.number().optional(),FirstZ:ln.number().optional()})}).transform(Cl),JW=or({Channel:fg(hg,qW.array()),TiffData:fg(hg,GW.array()).optional()}).extend({attr:or({ID:Gr(),DimensionOrder:XW,Type:YW,SizeT:ln.number(),SizeC:ln.number(),SizeZ:ln.number(),SizeY:ln.number(),SizeX:ln.number(),PhysicalSizeX:ln.number().optional(),PhysicalSizeY:ln.number().optional(),PhysicalSizeZ:ln.number().optional(),SignificantBits:ln.number().optional(),PhysicalSizeXUnit:Ap.optional().default("µm"),PhysicalSizeYUnit:Ap.optional().default("µm"),PhysicalSizeZUnit:Ap.optional().default("µm"),BigEndian:Gr().transform(n=>n.toLowerCase()==="true").optional(),Interleaved:Gr().transform(n=>n.toLowerCase()==="true").optional()})}).transform(Cl).transform(({Channel:n,...e})=>({Channels:n,...e})),QW=or({AquisitionDate:Gr().optional().default(""),Description:VW().optional().default(""),Pixels:JW}).extend({attr:or({ID:Gr(),Name:Gr().optional()})}).transform(Cl);or({Image:fg(hg,QW.array())});is(5,()=>HW);function eH(n){return[...Array(n).keys()]}function $S(n,e,t){for(let r=0;r<t;r+=1)n.push(e);return n}function c_(n){const e=Ub[n];if(!e){const t=Object.keys(Ub);throw Error(`Dtype not supported, got ${n}. Must be one of ${t}.`)}return e}function VS({contrastLimits:n=[],channelsVisible:e,domain:t,dtype:r}){const s=(t==null?void 0:t[1])||c_(r).max,i=n.map((c,l)=>e[l]?c:[s,s]),o=ES-i.length;if(o<0)throw Error(`${i.lengths} channels passed in, but only 6 are allowed.`);return $S(i,[s,s],o).reduce((c,l)=>c.concat(l),[])}function tH(n){var s;const{x:e,y:t,z:r}=((s=n==null?void 0:n.meta)==null?void 0:s.physicalSizes)??{};if(e!=null&&e.size&&(t!=null&&t.size)&&(r!=null&&r.size)){const i=Math.min(r.size,e.size,t.size),o=[e.size/i,t.size/i,r.size/i];return new qe().scale(o)}return new qe().identity()}function nH(n){const e=new W0().makeViewport({viewState:n,height:n.height,width:n.width});return[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([e.width,e.height]),e.unproject([0,e.height])]}const th=[1,2,3,4,5,10,20,25,50,100,200,250,500,1e3],rH=th[0],sH=th[th.length-1],dg=[{symbol:"Y",exponent:24},{symbol:"Z",exponent:21},{symbol:"E",exponent:18},{symbol:"P",exponent:15},{symbol:"T",exponent:12},{symbol:"G",exponent:9},{symbol:"M",exponent:6},{symbol:"k",exponent:3},{symbol:"h",exponent:2},{symbol:"da",exponent:1},{symbol:"",exponent:0},{symbol:"d",exponent:-1},{symbol:"c",exponent:-2},{symbol:"m",exponent:-3},{symbol:"µ",exponent:-6},{symbol:"n",exponent:-9},{symbol:"p",exponent:-12},{symbol:"f",exponent:-15},{symbol:"a",exponent:-18},{symbol:"z",exponent:-21},{symbol:"y",exponent:-24}];function iH(n,e){if(!e||e==="m")return n;if(e.length>1){let t=e.substring(0,e.length-1);t==="u"&&(t="µ");const r=dg.find(s=>s.symbol===t);if(r)return n*10**r.exponent}throw new Error("Received unknown unit")}function oH(n){let e=0;(n<rH||n>sH)&&(e=Math.floor(Math.log10(n)));let t=dg.find(o=>o.exponent%3===0&&o.exponent<=e),r=n/10**t.exponent;r>500&&r<=1e3&&(t=dg.find(o=>o.exponent%3===0&&o.exponent<=e+3),r=n/10**t.exponent);const s=th.find(o=>o>r);return[s*10**t.exponent,s,t.symbol]}function aH(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");const e=new Uint8Array(n.length+n.length/3);for(let t=0;t<n.length/3;t+=1)e[t*4]=n[t*3],e[t*4+1]=n[t*3+1],e[t*4+2]=n[t*3+2],e[t*4+3]=255;return e}const Xr={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},zS={...Tl.defaultProps,pickable:{type:"boolean",value:!0,compare:!0},coordinateSystem:Ue.CARTESIAN},cH=(n,e)=>{const t=e?"true":"false",r=`vec3(${(e||[0,0,0]).map(s=>String(s/255)).join(",")})`;switch(n){case Xr.RGB:return`color[3] = (${t} && (color.rgb == ${r})) ? 0.0 : color.a;`;case Xr.WhiteIsZero:return` float value = 1.0 - (color.r / 256.0);
|
|
3459
|
+
`,dW=class extends Al{constructor(n){super(n),this.rendering={_BEFORE_RENDER:uW,_RENDER:fW,_AFTER_RENDER:hW}}};dW.extensionName="MinimumIntensityProjectionExtension";const OS={AdditiveBlendExtension:kS},pW=new Map;function is(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>pW.set(t,e))}is([void 0,1],()=>Promise.resolve().then(()=>require("./raw-GJmfvqqS.cjs")).then(n=>n.default));is(5,()=>Promise.resolve().then(()=>require("./lzw-DOv7FpJp.cjs")).then(n=>n.default));is(6,()=>{throw new Error("old style JPEG compression is not supported.")});is(7,()=>Promise.resolve().then(()=>require("./jpeg-B4oirkAG.cjs")).then(n=>n.default));is([8,32946],()=>Promise.resolve().then(()=>require("./deflate-D4fVjT8X.cjs")).then(n=>n.default));is(32773,()=>Promise.resolve().then(()=>require("./packbits-YFbkocqj.cjs")).then(n=>n.default));is(34887,()=>Promise.resolve().then(()=>require("./lerc-BYe2-QJc.cjs")).then(async n=>(await n.zstd.init(),n)).then(n=>n.default));is(50001,()=>Promise.resolve().then(()=>require("./webimage-DACySx-6.cjs")).then(n=>n.default));function mW(n,e){let t=n.length-e,r=0;do{for(let s=e;s>0;s--)n[r+e]+=n[r],r++;t-=e}while(t>0)}function gW(n,e,t){let r=0,s=n.length;const i=s/t;for(;s>e;){for(let a=e;a>0;--a)n[r+e]+=n[r],++r;s-=e}const o=n.slice();for(let a=0;a<i;++a)for(let c=0;c<t;++c)n[t*a+c]=o[(t-c-1)*i+a]}function _W(n,e,t,r,s,i){if(e===1)return n;for(let c=0;c<s.length;++c){if(s[c]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(s[c]!==s[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const o=s[0]/8,a=i===2?1:s.length;for(let c=0;c<r&&!(c*a*t*o>=n.byteLength);++c){let l;if(e===2){switch(s[0]){case 8:l=new Uint8Array(n,c*a*t*o,a*t*o);break;case 16:l=new Uint16Array(n,c*a*t*o,a*t*o/2);break;case 32:l=new Uint32Array(n,c*a*t*o,a*t*o/4);break;default:throw new Error(`Predictor 2 not allowed with ${s[0]} bits per sample.`)}mW(l,a)}else e===3&&(l=new Uint8Array(n,c*a*t*o,a*t*o),gW(l,a,o))}return n}class MS{async decode(e,t){const r=await this.decodeBlock(t),s=e.Predictor||1;if(s!==1){const i=!e.StripOffsets,o=i?e.TileWidth:e.ImageWidth,a=i?e.TileLength:e.RowsPerStrip||e.ImageLength;return _W(r,s,o,a,e.BitsPerSample,e.PlanarConfiguration)}return r}}var tt;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},n.find=(s,i)=>{for(const o of s)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(tt||(tt={}));var Vb;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Vb||(Vb={}));const Ee=tt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return isNaN(n)?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(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},de=tt.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 $n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let a=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof $n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}$n.create=n=>new $n(n);const Zc=(n,e)=>{let t;switch(n.code){case de.invalid_type:n.received===Ee.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case de.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,tt.jsonStringifyReplacer)}`;break;case de.unrecognized_keys:t=`Unrecognized key(s) in object: ${tt.joinValues(n.keys,", ")}`;break;case de.invalid_union:t="Invalid input";break;case de.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${tt.joinValues(n.options)}`;break;case de.invalid_enum_value:t=`Invalid enum value. Expected ${tt.joinValues(n.options)}, received '${n.received}'`;break;case de.invalid_arguments:t="Invalid function arguments";break;case de.invalid_return_type:t="Invalid function return type";break;case de.invalid_date:t="Invalid date";break;case de.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:tt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case de.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case de.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case de.custom:t="Invalid input";break;case de.invalid_intersection_types:t="Intersection results could not be merged";break;case de.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case de.not_finite:t="Number must be finite";break;default:t=e.defaultError,tt.assertNever(n)}return{message:t}};let yW=Zc;function rg(){return yW}const sg=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function we(n,e){const t=rg(),r=sg({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Zc?void 0:Zc].filter(s=>!!s)});n.common.issues.push(r)}class yn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return $e;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return yn.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return $e;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const $e=Object.freeze({status:"aborted"}),Ka=n=>({status:"dirty",value:n}),Tn=n=>({status:"valid",value:n}),zb=n=>n.status==="aborted",jb=n=>n.status==="dirty",la=n=>n.status==="valid",Vf=n=>typeof Promise<"u"&&n instanceof Promise;function zf(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function NS(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var Ie;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ie||(Ie={}));var Ga,Ja;class Cr{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Wb=(n,e)=>{if(la(e))return{success:!0,data:e.value};if(!n.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 $n(n.common.issues);return this._error=t,this._error}}};function je(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{var c,l;const{message:u}=n;return o.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(l=u??t)!==null&&l!==void 0?l:a.defaultError}},description:s}}class Ke{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yn,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Vf(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Wb(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return la(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>la(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Vf(s)?s:Promise.resolve(s));return Wb(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:de.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new ss({schema:this,typeName:Le.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:t=>this["~validate"](t)}}optional(){return Kr.create(this,this._def)}nullable(){return Vi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Er.create(this)}promise(){return Xc.create(this,this._def)}or(e){return Zf.create([this,e],this._def)}and(e){return Xf.create(this,e,this._def)}transform(e){return new ss({...je(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Jf({...je(this._def),innerType:this,defaultValue:t,typeName:Le.ZodDefault})}brand(){return new BS({typeName:Le.ZodBranded,type:this,...je(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Qf({...je(this._def),innerType:this,catchValue:t,typeName:Le.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ed.create(this,e)}readonly(){return eh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const vW=/^c[^\s-]{8,}$/i,xW=/^[0-9a-z]+$/,bW=/^[0-9A-HJKMNP-TV-Z]{26}$/i,wW=/^[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,TW=/^[a-z0-9_-]{21}$/i,SW=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,EW=/^[-+]?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)?)??$/,AW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,CW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ep;const RW=/^(?:(?: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])$/,IW=/^(?:(?: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])$/,PW=/^(([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]))$/,kW=/^(([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])$/,OW=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,MW=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DS="((\\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])))",NW=new RegExp(`^${DS}$`);function LS(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function DW(n){return new RegExp(`^${LS(n)}$`)}function LW(n){let e=`${DS}T${LS(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function FW(n,e){return!!((e==="v4"||!e)&&RW.test(n)||(e==="v6"||!e)&&PW.test(n))}function BW(n,e){if(!SW.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function UW(n,e){return!!((e==="v4"||!e)&&IW.test(n)||(e==="v6"||!e)&&kW.test(n))}class wr extends Ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ee.string){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.string,received:i.parsedType}),$e}const r=new yn;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?we(s,{code:de.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&we(s,{code:de.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")AW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"email",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ep||(Ep=new RegExp(CW,"u")),Ep.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"emoji",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")wW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"uuid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")TW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"nanoid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")vW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cuid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")xW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cuid2",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"ulid",code:de.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),we(s,{validation:"url",code:de.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"regex",code:de.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?LW(i).test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?NW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?DW(i).test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{code:de.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?EW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"duration",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?FW(e.data,i.version)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"ip",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?BW(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"jwt",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?UW(e.data,i.version)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"cidr",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?OW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"base64",code:de.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?MW.test(e.data)||(s=this._getOrReturnCtx(e,s),we(s,{validation:"base64url",code:de.invalid_string,message:i.message}),r.dirty()):tt.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:de.invalid_string,...Ie.errToObj(r)})}_addCheck(e){return new wr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ie.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ie.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ie.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ie.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...Ie.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ie.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ie.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ie.errToObj(t)})}nonempty(e){return this.min(1,Ie.errToObj(e))}trim(){return new wr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}wr.create=n=>{var e;return new wr({checks:[],typeName:Le.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...je(n)})};function $W(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}class Bi extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Ee.number){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.number,received:i.parsedType}),$e}let r;const s=new yn;for(const i of this._def.checks)i.kind==="int"?tt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:de.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?$W(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_finite,message:i.message}),s.dirty()):tt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,r,s){return new Bi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ie.toString(s)}]})}_addCheck(e){return new Bi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&tt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bi.create=n=>new Bi({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...je(n)});class Ui extends Ke{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 r;const s=new yn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),we(r,{code:de.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):tt.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return we(t,{code:de.invalid_type,expected:Ee.bigint,received:t.parsedType}),$e}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,r,s){return new Ui({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ie.toString(s)}]})}_addCheck(e){return new Ui({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ui.create=n=>{var e;return new Ui({checks:[],typeName:Le.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...je(n)})};class jf extends Ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ee.boolean){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.boolean,received:r.parsedType}),$e}return Tn(e.data)}}jf.create=n=>new jf({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...je(n)});class ua extends Ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ee.date){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_type,expected:Ee.date,received:i.parsedType}),$e}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return we(i,{code:de.invalid_date}),$e}const r=new yn;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),we(s,{code:de.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):tt.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ua({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ie.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ua.create=n=>new ua({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...je(n)});class ig extends Ke{_parse(e){if(this._getType(e)!==Ee.symbol){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.symbol,received:r.parsedType}),$e}return Tn(e.data)}}ig.create=n=>new ig({typeName:Le.ZodSymbol,...je(n)});class Wf extends Ke{_parse(e){if(this._getType(e)!==Ee.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.undefined,received:r.parsedType}),$e}return Tn(e.data)}}Wf.create=n=>new Wf({typeName:Le.ZodUndefined,...je(n)});class Hf extends Ke{_parse(e){if(this._getType(e)!==Ee.null){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.null,received:r.parsedType}),$e}return Tn(e.data)}}Hf.create=n=>new Hf({typeName:Le.ZodNull,...je(n)});class og extends Ke{constructor(){super(...arguments),this._any=!0}_parse(e){return Tn(e.data)}}og.create=n=>new og({typeName:Le.ZodAny,...je(n)});class zo extends Ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tn(e.data)}}zo.create=n=>new zo({typeName:Le.ZodUnknown,...je(n)});class Zs extends Ke{_parse(e){const t=this._getOrReturnCtx(e);return we(t,{code:de.invalid_type,expected:Ee.never,received:t.parsedType}),$e}}Zs.create=n=>new Zs({typeName:Le.ZodNever,...je(n)});class ag extends Ke{_parse(e){if(this._getType(e)!==Ee.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.void,received:r.parsedType}),$e}return Tn(e.data)}}ag.create=n=>new ag({typeName:Le.ZodVoid,...je(n)});class Er extends Ke{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==Ee.array)return we(t,{code:de.invalid_type,expected:Ee.array,received:t.parsedType}),$e;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(o||a)&&(we(t,{code:o?de.too_big:de.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(we(t,{code:de.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(we(t,{code:de.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new Cr(t,o,t.path,a)))).then(o=>yn.mergeArray(r,o));const i=[...t.data].map((o,a)=>s.type._parseSync(new Cr(t,o,t.path,a)));return yn.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new Er({...this._def,minLength:{value:e,message:Ie.toString(t)}})}max(e,t){return new Er({...this._def,maxLength:{value:e,message:Ie.toString(t)}})}length(e,t){return new Er({...this._def,exactLength:{value:e,message:Ie.toString(t)}})}nonempty(e){return this.min(1,e)}}Er.create=(n,e)=>new Er({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...je(e)});function To(n){if(n instanceof Ft){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Kr.create(To(r))}return new Ft({...n._def,shape:()=>e})}else return n instanceof Er?new Er({...n._def,type:To(n.element)}):n instanceof Kr?Kr.create(To(n.unwrap())):n instanceof Vi?Vi.create(To(n.unwrap())):n instanceof rs?rs.create(n.items.map(e=>To(e))):n}class Ft extends Ke{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=tt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Ee.object){const l=this._getOrReturnCtx(e);return we(l,{code:de.invalid_type,expected:Ee.object,received:l.parsedType}),$e}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Zs&&this._def.unknownKeys==="strip"))for(const l in s.data)o.includes(l)||a.push(l);const c=[];for(const l of o){const u=i[l],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Cr(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Zs){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(we(s,{code:de.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of a){const f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Cr(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const f=await u.key,h=await u.value;l.push({key:f,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>yn.mergeObjectSync(r,l)):yn.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return Ie.errToObj,new Ft({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,o,a;const c=(o=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(a=Ie.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ft({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ft({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ft({...this._def,catchall:e})}pick(e){const t={};return tt.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new Ft({...this._def,shape:()=>t})}omit(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new Ft({...this._def,shape:()=>t})}deepPartial(){return To(this)}partial(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new Ft({...this._def,shape:()=>t})}required(e){const t={};return tt.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Kr;)i=i._def.innerType;t[r]=i}}),new Ft({...this._def,shape:()=>t})}keyof(){return FS(tt.objectKeys(this.shape))}}Ft.create=(n,e)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});Ft.strictCreate=(n,e)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});Ft.lazycreate=(n,e)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zs.create(),typeName:Le.ZodObject,...je(e)});class Zf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new $n(a.ctx.common.issues));return we(t,{code:de.invalid_union,unionErrors:o}),$e}if(t.common.async)return Promise.all(r.map(async i=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(c=>new $n(c));return we(t,{code:de.invalid_union,unionErrors:a}),$e}}get options(){return this._def.options}}Zf.create=(n,e)=>new Zf({options:n,typeName:Le.ZodUnion,...je(e)});const $r=n=>n instanceof qf?$r(n.schema):n instanceof ss?$r(n.innerType()):n instanceof Kf?[n.value]:n instanceof $i?n.options:n instanceof Gf?tt.objectValues(n.enum):n instanceof Jf?$r(n._def.innerType):n instanceof Wf?[void 0]:n instanceof Hf?[null]:n instanceof Kr?[void 0,...$r(n.unwrap())]:n instanceof Vi?[null,...$r(n.unwrap())]:n instanceof BS||n instanceof eh?$r(n.unwrap()):n instanceof Qf?$r(n._def.innerType):[];class o_ extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.object)return we(t,{code:de.invalid_type,expected:Ee.object,received:t.parsedType}),$e;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(we(t,{code:de.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),$e)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const o=$r(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new o_({typeName:Le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...je(r)})}}function cg(n,e){const t=bs(n),r=bs(e);if(n===e)return{valid:!0,data:n};if(t===Ee.object&&r===Ee.object){const s=tt.objectKeys(e),i=tt.objectKeys(n).filter(a=>s.indexOf(a)!==-1),o={...n,...e};for(const a of i){const c=cg(n[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(t===Ee.array&&r===Ee.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const o=n[i],a=e[i],c=cg(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Ee.date&&r===Ee.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Xf extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(zb(i)||zb(o))return $e;const a=cg(i.value,o.value);return a.valid?((jb(i)||jb(o))&&t.dirty(),{status:t.value,value:a.data}):(we(r,{code:de.invalid_intersection_types}),$e)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Xf.create=(n,e,t)=>new Xf({left:n,right:e,typeName:Le.ZodIntersection,...je(t)});class rs extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.array)return we(r,{code:de.invalid_type,expected:Ee.array,received:r.parsedType}),$e;if(r.data.length<this._def.items.length)return we(r,{code:de.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$e;!this._def.rest&&r.data.length>this._def.items.length&&(we(r,{code:de.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new Cr(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>yn.mergeArray(t,o)):yn.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new rs({...this._def,rest:e})}}rs.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new rs({items:n,typeName:Le.ZodTuple,rest:null,...je(e)})};class Yf extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.object)return we(r,{code:de.invalid_type,expected:Ee.object,received:r.parsedType}),$e;const s=[],i=this._def.keyType,o=this._def.valueType;for(const a in r.data)s.push({key:i._parse(new Cr(r,a,r.path,a)),value:o._parse(new Cr(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?yn.mergeObjectAsync(t,s):yn.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Ke?new Yf({keyType:e,valueType:t,typeName:Le.ZodRecord,...je(r)}):new Yf({keyType:wr.create(),valueType:e,typeName:Le.ZodRecord,...je(t)})}}class lg extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.map)return we(r,{code:de.invalid_type,expected:Ee.map,received:r.parsedType}),$e;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new Cr(r,a,r.path,[l,"key"])),value:i._parse(new Cr(r,c,r.path,[l,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return $e;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return $e;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}}}}lg.create=(n,e,t)=>new lg({valueType:e,keyType:n,typeName:Le.ZodMap,...je(t)});class fa extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ee.set)return we(r,{code:de.invalid_type,expected:Ee.set,received:r.parsedType}),$e;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(we(r,{code:de.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(we(r,{code:de.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return $e;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}const a=[...r.data.values()].map((c,l)=>i._parse(new Cr(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,t){return new fa({...this._def,minSize:{value:e,message:Ie.toString(t)}})}max(e,t){return new fa({...this._def,maxSize:{value:e,message:Ie.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fa.create=(n,e)=>new fa({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...je(e)});class pc extends Ke{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.function)return we(t,{code:de.invalid_type,expected:Ee.function,received:t.parsedType}),$e;function r(a,c){return sg({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rg(),Zc].filter(l=>!!l),issueData:{code:de.invalid_arguments,argumentsError:c}})}function s(a,c){return sg({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rg(),Zc].filter(l=>!!l),issueData:{code:de.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Xc){const a=this;return Tn(async function(...c){const l=new $n([]),u=await a._def.args.parseAsync(c,i).catch(d=>{throw l.addIssue(r(c,d)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(d=>{throw l.addIssue(s(f,d)),l})})}else{const a=this;return Tn(function(...c){const l=a._def.args.safeParse(c,i);if(!l.success)throw new $n([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new $n([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pc({...this._def,args:rs.create(e).rest(zo.create())})}returns(e){return new pc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new pc({args:e||rs.create([]).rest(zo.create()),returns:t||zo.create(),typeName:Le.ZodFunction,...je(r)})}}class qf extends Ke{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})}}qf.create=(n,e)=>new qf({getter:n,typeName:Le.ZodLazy,...je(e)});class Kf extends Ke{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return we(t,{received:t.data,code:de.invalid_literal,expected:this._def.value}),$e}return{status:"valid",value:e.data}}get value(){return this._def.value}}Kf.create=(n,e)=>new Kf({value:n,typeName:Le.ZodLiteral,...je(e)});function FS(n,e){return new $i({values:n,typeName:Le.ZodEnum,...je(e)})}class $i extends Ke{constructor(){super(...arguments),Ga.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{expected:tt.joinValues(r),received:t.parsedType,code:de.invalid_type}),$e}if(zf(this,Ga)||NS(this,Ga,new Set(this._def.values)),!zf(this,Ga).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{received:t.data,code:de.invalid_enum_value,options:r}),$e}return Tn(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 $i.create(e,{...this._def,...t})}exclude(e,t=this._def){return $i.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ga=new WeakMap;$i.create=FS;class Gf extends Ke{constructor(){super(...arguments),Ja.set(this,void 0)}_parse(e){const t=tt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const s=tt.objectValues(t);return we(r,{expected:tt.joinValues(s),received:r.parsedType,code:de.invalid_type}),$e}if(zf(this,Ja)||NS(this,Ja,new Set(tt.getValidEnumValues(this._def.values))),!zf(this,Ja).has(e.data)){const s=tt.objectValues(t);return we(r,{received:r.data,code:de.invalid_enum_value,options:s}),$e}return Tn(e.data)}get enum(){return this._def.values}}Ja=new WeakMap;Gf.create=(n,e)=>new Gf({values:n,typeName:Le.ZodNativeEnum,...je(e)});class Xc extends Ke{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ee.promise&&t.common.async===!1)return we(t,{code:de.invalid_type,expected:Ee.promise,received:t.parsedType}),$e;const r=t.parsedType===Ee.promise?t.data:Promise.resolve(t.data);return Tn(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Xc.create=(n,e)=>new Xc({type:n,typeName:Le.ZodPromise,...je(e)});class ss extends Ke{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{we(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return $e;const c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?$e:c.status==="dirty"||t.value==="dirty"?Ka(c.value):c});{if(t.value==="aborted")return $e;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?$e:a.status==="dirty"||t.value==="dirty"?Ka(a.value):a}}if(s.type==="refinement"){const o=a=>{const c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?$e:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?$e:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!la(o))return o;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>la(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:t.value,value:a})):o);tt.assertNever(s)}}ss.create=(n,e,t)=>new ss({schema:n,typeName:Le.ZodEffects,effect:e,...je(t)});ss.createWithPreprocess=(n,e,t)=>new ss({schema:e,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...je(t)});class Kr extends Ke{_parse(e){return this._getType(e)===Ee.undefined?Tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Kr.create=(n,e)=>new Kr({innerType:n,typeName:Le.ZodOptional,...je(e)});class Vi extends Ke{_parse(e){return this._getType(e)===Ee.null?Tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Vi.create=(n,e)=>new Vi({innerType:n,typeName:Le.ZodNullable,...je(e)});class Jf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Jf.create=(n,e)=>new Jf({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...je(e)});class Qf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Vf(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $n(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Qf.create=(n,e)=>new Qf({innerType:n,typeName:Le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...je(e)});class ug extends Ke{_parse(e){if(this._getType(e)!==Ee.nan){const r=this._getOrReturnCtx(e);return we(r,{code:de.invalid_type,expected:Ee.nan,received:r.parsedType}),$e}return{status:"valid",value:e.data}}}ug.create=n=>new ug({typeName:Le.ZodNaN,...je(n)});class BS extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ed extends Ke{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?$e:i.status==="dirty"?(t.dirty(),Ka(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?$e:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ed({in:e,out:t,typeName:Le.ZodPipeline})}}class eh extends Ke{_parse(e){const t=this._def.innerType._parse(e),r=s=>(la(s)&&(s.value=Object.freeze(s.value)),s);return Vf(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}eh.create=(n,e)=>new eh({innerType:n,typeName:Le.ZodReadonly,...je(e)});Ft.lazycreate;var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const Gr=wr.create;Bi.create;ug.create;Ui.create;jf.create;ua.create;ig.create;Wf.create;Hf.create;og.create;const VW=zo.create;Zs.create;ag.create;Er.create;const or=Ft.create;Ft.strictCreate;Zf.create;o_.create;Xf.create;rs.create;Yf.create;lg.create;fa.create;pc.create;qf.create;Kf.create;const a_=$i.create;Gf.create;Xc.create;ss.create;Kr.create;Vi.create;const fg=ss.createWithPreprocess;ed.create;const ln={string:n=>wr.create({...n,coerce:!0}),number:n=>Bi.create({...n,coerce:!0}),boolean:n=>jf.create({...n,coerce:!0}),bigint:n=>Ui.create({...n,coerce:!0}),date:n=>ua.create({...n,coerce:!0})};var zW=Object.defineProperty,jW=(n,e,t)=>e in n?zW(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,WW=(n,e,t)=>(jW(n,e+"",t),t);class HW extends MS{constructor(e){super(),WW(this,"maxUncompressedSize");const t=e.TileWidth||e.ImageWidth,r=e.TileLength||e.ImageLength,s=e.BitsPerSample[0]/8;this.maxUncompressedSize=t*r*s}async decodeBlock(e){const t=new Uint8Array(e);return(await decompress(t,this.maxUncompressedSize)).buffer}}function ZW(n){if(!Number.isInteger(n))throw Error("Not an integer.");const e=new ArrayBuffer(4);new DataView(e).setInt32(0,n,!1);const r=new Uint8Array(e);return Array.from(r)}function Yc(n){const e=n[n.length-1];return e===3||e===4}function td(n){const e=Yc(n.shape),[t,r]=n.shape.slice(e?-3:-2);return{height:t,width:r}}const US="__vivSignalAborted";function Cl({attr:n,...e}){return{...n,...e}}function hg(n){return Array.isArray(n)?n:[n]}const XW=a_(["XYZCT","XYZTC","XYCTZ","XYCZT","XYTCZ","XYTZC"]),YW=a_(["int8","int16","int32","uint8","uint16","uint32","float","bit","double","complex","double-complex"]),Ap=a_(["Ym","Zm","Em","Pm","Tm","Gm","Mm","km","hm","dam","m","dm","cm","mm","µm","nm","pm","fm","am","zm","ym","Å","thou","li","in","ft","yd","mi","ua","ly","pc","pt","pixel","reference frame"]),qW=or({}).extend({attr:or({ID:Gr(),SamplesPerPixel:ln.number().optional(),Name:Gr().optional(),Color:ln.number().transform(ZW).optional()})}).transform(Cl),KW=or({}).extend({attr:or({FileName:Gr()})}).transform(Cl),GW=or({UUID:KW.optional()}).extend({attr:or({IFD:ln.number().default(0),PlaneCount:ln.number().default(1),FirstT:ln.number().optional(),FirstC:ln.number().optional(),FirstZ:ln.number().optional()})}).transform(Cl),JW=or({Channel:fg(hg,qW.array()),TiffData:fg(hg,GW.array()).optional()}).extend({attr:or({ID:Gr(),DimensionOrder:XW,Type:YW,SizeT:ln.number(),SizeC:ln.number(),SizeZ:ln.number(),SizeY:ln.number(),SizeX:ln.number(),PhysicalSizeX:ln.number().optional(),PhysicalSizeY:ln.number().optional(),PhysicalSizeZ:ln.number().optional(),SignificantBits:ln.number().optional(),PhysicalSizeXUnit:Ap.optional().default("µm"),PhysicalSizeYUnit:Ap.optional().default("µm"),PhysicalSizeZUnit:Ap.optional().default("µm"),BigEndian:Gr().transform(n=>n.toLowerCase()==="true").optional(),Interleaved:Gr().transform(n=>n.toLowerCase()==="true").optional()})}).transform(Cl).transform(({Channel:n,...e})=>({Channels:n,...e})),QW=or({AquisitionDate:Gr().optional().default(""),Description:VW().optional().default(""),Pixels:JW}).extend({attr:or({ID:Gr(),Name:Gr().optional()})}).transform(Cl);or({Image:fg(hg,QW.array())});is(5,()=>HW);function eH(n){return[...Array(n).keys()]}function $S(n,e,t){for(let r=0;r<t;r+=1)n.push(e);return n}function c_(n){const e=Ub[n];if(!e){const t=Object.keys(Ub);throw Error(`Dtype not supported, got ${n}. Must be one of ${t}.`)}return e}function VS({contrastLimits:n=[],channelsVisible:e,domain:t,dtype:r}){const s=(t==null?void 0:t[1])||c_(r).max,i=n.map((c,l)=>e[l]?c:[s,s]),o=ES-i.length;if(o<0)throw Error(`${i.lengths} channels passed in, but only 6 are allowed.`);return $S(i,[s,s],o).reduce((c,l)=>c.concat(l),[])}function tH(n){var s;const{x:e,y:t,z:r}=((s=n==null?void 0:n.meta)==null?void 0:s.physicalSizes)??{};if(e!=null&&e.size&&(t!=null&&t.size)&&(r!=null&&r.size)){const i=Math.min(r.size,e.size,t.size),o=[e.size/i,t.size/i,r.size/i];return new qe().scale(o)}return new qe().identity()}function nH(n){const e=new W0().makeViewport({viewState:n,height:n.height,width:n.width});return[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([e.width,e.height]),e.unproject([0,e.height])]}const th=[1,2,3,4,5,10,20,25,50,100,200,250,500,1e3],rH=th[0],sH=th[th.length-1],dg=[{symbol:"Y",exponent:24},{symbol:"Z",exponent:21},{symbol:"E",exponent:18},{symbol:"P",exponent:15},{symbol:"T",exponent:12},{symbol:"G",exponent:9},{symbol:"M",exponent:6},{symbol:"k",exponent:3},{symbol:"h",exponent:2},{symbol:"da",exponent:1},{symbol:"",exponent:0},{symbol:"d",exponent:-1},{symbol:"c",exponent:-2},{symbol:"m",exponent:-3},{symbol:"µ",exponent:-6},{symbol:"n",exponent:-9},{symbol:"p",exponent:-12},{symbol:"f",exponent:-15},{symbol:"a",exponent:-18},{symbol:"z",exponent:-21},{symbol:"y",exponent:-24}];function iH(n,e){if(!e||e==="m")return n;if(e.length>1){let t=e.substring(0,e.length-1);t==="u"&&(t="µ");const r=dg.find(s=>s.symbol===t);if(r)return n*10**r.exponent}throw new Error("Received unknown unit")}function oH(n){let e=0;(n<rH||n>sH)&&(e=Math.floor(Math.log10(n)));let t=dg.find(o=>o.exponent%3===0&&o.exponent<=e),r=n/10**t.exponent;r>500&&r<=1e3&&(t=dg.find(o=>o.exponent%3===0&&o.exponent<=e+3),r=n/10**t.exponent);const s=th.find(o=>o>r);return[s*10**t.exponent,s,t.symbol]}function aH(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");const e=new Uint8Array(n.length+n.length/3);for(let t=0;t<n.length/3;t+=1)e[t*4]=n[t*3],e[t*4+1]=n[t*3+1],e[t*4+2]=n[t*3+2],e[t*4+3]=255;return e}const Xr={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},zS={...Tl.defaultProps,pickable:{type:"boolean",value:!0,compare:!0},coordinateSystem:Ue.CARTESIAN},cH=(n,e)=>{const t=e?"true":"false",r=`vec3(${(e||[0,0,0]).map(s=>String(s/255)).join(",")})`;switch(n){case Xr.RGB:return`color[3] = (${t} && (color.rgb == ${r})) ? 0.0 : color.a;`;case Xr.WhiteIsZero:return` float value = 1.0 - (color.r / 256.0);
|
|
3460
3460
|
color = vec4(value, value, value, (${t} && vec3(value, value, value) == ${r}) ? 0.0 : color.a);
|
|
3461
3461
|
`;case Xr.BlackIsZero:return` float value = (color.r / 256.0);
|
|
3462
3462
|
color = vec4(value, value, value, (${t} && vec3(value, value, value) == ${r}) ? 0.0 : color.a);
|