experimental-ash 0.24.1 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/src/chunks/authored-module-loader-DcCfCiBm.js +4 -0
- package/dist/src/chunks/client-DLHAGI2g.js +4 -0
- package/dist/src/chunks/dev-authored-source-watcher-CBID_Dwh.js +1 -0
- package/dist/src/chunks/{errors-DsO9xmQL.js → errors-HYWjHxV6.js} +1 -1
- package/dist/src/chunks/{gray-matter-BxS7ZG-J.js → gray-matter-D-9jHwOT.js} +4 -4
- package/dist/src/chunks/host-zBy9FyyX.js +70 -0
- package/dist/src/chunks/{jsdist-M7JFZoA4.js → jsdist-BkeWZ7EZ.js} +61 -61
- package/dist/src/chunks/package-HUaeub_D.js +1 -0
- package/dist/src/chunks/{paths-jcVjBqc3.js → paths-CebY5GCi.js} +2 -2
- package/dist/src/chunks/{picocolors-Bq-tZK9u.js → picocolors-aAkqW4On.js} +1 -1
- package/dist/src/chunks/token-D98SQdvs.js +1 -0
- package/dist/src/chunks/{url-BVRhVE2O.js → url-JdCGA634.js} +1 -1
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +16 -2
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/input-requests.js +1 -1
- package/dist/src/cli/dev/repl.js +3 -3
- package/dist/src/cli/dev/url.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/cli/ui/output.js +1 -1
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/index.js +1 -0
- package/dist/src/compiled/.vendor-stamp.json +7 -6
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/google/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
- package/dist/src/compiled/@chat-adapter/slack/_slack-web-api.d.ts +7 -0
- package/dist/src/compiled/@chat-adapter/slack/index.d.ts +418 -109
- package/dist/src/compiled/@chat-adapter/slack/index.js +31 -27
- package/dist/src/compiled/@chat-adapter/slack/package.json +1 -1
- package/dist/src/compiled/@chat-adapter/state-memory/index.d.ts +8 -2
- package/dist/src/compiled/@chat-adapter/state-memory/index.js +1 -1
- package/dist/src/compiled/@chat-adapter/state-memory/package.json +1 -1
- package/dist/src/compiled/@opentelemetry/api/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +19 -17
- package/dist/src/compiled/@vercel/sandbox/package.json +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime.js +22 -22
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/_chunks/node/auth-ZhCJAHxl.js +2 -0
- package/dist/src/compiled/_chunks/node/{dist-BdWHjlRQ.js → dist-BQYUcBqu.js} +31 -31
- package/dist/src/compiled/_chunks/node/{chunk-Dd2tEFlW.js → dist-BdTs18CF.js} +1 -1
- package/dist/src/compiled/_chunks/node/retry-DkR2H1Y0.js +1 -0
- package/dist/src/compiled/_chunks/node/token-CoIbMZkq.js +1 -0
- package/dist/src/compiled/_chunks/node/{version-BMyZn3Y2.js → version-D4IYmfaS.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/coerce-BhzIW-Hm.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{compat-CIROS3w4.js → compat-DcEvieoj.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{core-DOVmxHH8.js → core-XWIi7wKc.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{dist-C7wPwOI9.js → dist-DO14ZaQj.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-CpUQh3NH.js → dist-DZZY3Zyp.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-DOMbNs-S.js +51 -0
- package/dist/src/compiled/_chunks/workflow/{schemas-DFZoEyCn.js → schemas-DmgDnhW3.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CRjce49s.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{src-ClRYdO4-.js → src-B54rYDvB.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/symbols-D8paKc8P.js +9 -0
- package/dist/src/compiled/_chunks/workflow/{token-CsNmv7KW.js → token-D9z1dMB6.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{token-j5Cl4rrs.js → token-DV7rQw_t.js} +1 -1
- package/dist/src/compiled/chat/index.d.ts +6 -3143
- package/dist/src/compiled/chat/index.js +1 -1
- package/dist/src/compiled/chat/{jsx-runtime-DxGwoLu2.d.ts → jsx-runtime-CFq1K_Ve.d.ts} +1 -1
- package/dist/src/compiled/chat/package.json +1 -1
- package/dist/src/compiled/jose/index.js +2 -2
- package/dist/src/compiled/jsonc-parser/LICENSE.md +21 -0
- package/dist/src/compiled/jsonc-parser/index.d.ts +13 -0
- package/dist/src/compiled/jsonc-parser/index.js +15 -0
- package/dist/src/compiled/jsonc-parser/package.json +7 -0
- package/dist/src/compiled/just-bash/index.js +773 -773
- package/dist/src/compiled/just-bash/package.json +1 -1
- package/dist/src/compiled/turndown/index.js +1 -1
- package/dist/src/compiled/zod/index.js +1 -1
- package/dist/src/compiled/zod-validation-error/index.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/loaders/yaml.js +1 -1
- package/dist/src/evals/runner/discover.js +1 -1
- package/dist/src/evals/runner/execute-suite.js +1 -1
- package/dist/src/evals/runner/reporters/console.js +1 -1
- package/dist/src/evals/scorers/autoevals-client.js +1 -1
- package/dist/src/evals/scorers/autoevals.js +1 -1
- package/dist/src/evals/scorers/json.js +1 -1
- package/dist/src/evals/scorers/run.js +1 -1
- package/dist/src/evals/scorers/sql.js +1 -1
- package/dist/src/evals/scorers/text.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-asset-import-plugin.d.ts +5 -0
- package/dist/src/internal/authored-asset-import-plugin.js +141 -0
- package/dist/src/internal/authored-module-bundle.d.ts +4 -0
- package/dist/src/internal/authored-module-bundle.js +19 -0
- package/dist/src/internal/authored-module-loader.d.ts +6 -0
- package/dist/src/internal/authored-module-loader.js +114 -125
- package/dist/src/internal/authored-package-tsconfig-paths.d.ts +9 -0
- package/dist/src/internal/authored-package-tsconfig-paths.js +209 -0
- package/dist/src/internal/nitro/host/channel-routes.d.ts +9 -2
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +12 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +19 -3
- package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +7 -3
- package/dist/src/internal/nitro/host/start-development-server.js +2 -0
- package/package.json +17 -17
- package/dist/src/chunks/authored-module-loader-XcFLnl49.js +0 -2
- package/dist/src/chunks/client-nshDsWNF.js +0 -4
- package/dist/src/chunks/dev-authored-source-watcher-CApkYfee.js +0 -7
- package/dist/src/chunks/host-3sfHdmXL.js +0 -65
- package/dist/src/chunks/package-DmsQgn4v.js +0 -1
- package/dist/src/chunks/prewarm-DslujbK5.js +0 -6
- package/dist/src/chunks/token-DtoyQZy2.js +0 -1
- package/dist/src/chunks/token-util-CHjOk3A7.js +0 -1
- package/dist/src/compiled/_chunks/node/auth-vbe4XEEK.js +0 -2
- package/dist/src/compiled/_chunks/node/dist-DMSq2ehP.js +0 -1
- package/dist/src/compiled/_chunks/node/retry-BOcy5BbJ.js +0 -1
- package/dist/src/compiled/_chunks/node/token-D-BTJHoU.js +0 -1
- package/dist/src/compiled/_chunks/workflow/coerce-Dh0wa7P9.js +0 -1
- package/dist/src/compiled/_chunks/workflow/context-errors-Bbvvp-li.js +0 -6
- package/dist/src/compiled/_chunks/workflow/dist-C_oiE-l7.js +0 -40
- package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +0 -12
- package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +0 -1
- package/dist/src/compiled/_chunks/workflow/symbols-QezhMuLg.js +0 -4
- package/dist/src/compiled/chat/_workflow-serde.d.ts +0 -5
- /package/dist/src/chunks/{chunk-8L7ocgPr.js → chunk-DSjMdhoD.js} +0 -0
- /package/dist/src/chunks/{guards-CjJ3lmju.js → guards-26p6sOw3.js} +0 -0
- /package/dist/src/chunks/{input-requests-BsBi7_5K.js → input-requests-DJiy6dG9.js} +0 -0
- /package/dist/src/chunks/{runtime-model-BWu6M_hq.js → runtime-model-Dh0Nz64z.js} +0 -0
- /package/dist/src/chunks/{types-MZUhN0Zy.js → types-DDA2QUED.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{chunk-DHhdAPOb.js → chunk-DSjMdhoD.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{i as e,t}from"./chunk-8L7ocgPr.js";function n(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let i=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return i=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function a(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const o=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var s=class extends Error{},c=class e extends s{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new u({message:r,cause:o(n)});let a=n?.error;return t===400?new f(t,a,r,i):t===401?new p(t,a,r,i):t===403?new m(t,a,r,i):t===404?new h(t,a,r,i):t===409?new g(t,a,r,i):t===422?new _(t,a,r,i):t===429?new v(t,a,r,i):t>=500?new y(t,a,r,i):new e(t,a,r,i)}},l=class extends c{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},u=class extends c{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},d=class extends u{constructor({message:e}={}){super({message:e??`Request timed out.`})}},f=class extends c{},p=class extends c{},m=class extends c{},h=class extends c{},g=class extends c{},_=class extends c{},v=class extends c{},y=class extends c{},b=class extends s{constructor(){super(`Could not parse response content as the length limit was reached`)}},x=class extends s{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},S=class extends Error{constructor(e){super(e)}},C=class extends c{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},w=class extends s{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const T=/^[a-z][a-z0-9+.-]*:/i,E=e=>T.test(e);let D=e=>(D=Array.isArray,D(e)),O=D;function k(e){return typeof e==`object`?e??{}:{}}function A(e){if(!e)return!0;for(let t in e)return!1;return!0}function ee(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function te(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ne=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new s(`${e} must be an integer`);if(t<0)throw new s(`${e} must be a positive integer`);return t},re=e=>{try{return JSON.parse(e)}catch{return}},ie=e=>new Promise(t=>setTimeout(t,e)),ae=`6.36.0`,oe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}const j=()=>{let e=se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":ue(Deno.build.os),"X-Stainless-Arch":le(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":ue(globalThis.process.platform??`unknown`),"X-Stainless-Arch":le(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=ce();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function ce(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}const le=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ue=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`);let de;const fe=()=>de??=j();function M(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pe(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function me(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pe({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function he(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function ge(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}const _e=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),ve=`RFC3986`,ye=e=>String(e),be={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:ye};let xe=(e,t)=>(xe=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),xe(e,t));const Se=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),Ce=1024,we=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=Ce){let t=a.length>=Ce?a.slice(e,e+Ce):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=Se[r];continue}if(r<2048){n[n.length]=Se[192|r>>6]+Se[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=Se[224|r>>12]+Se[128|r>>6&63]+Se[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=Se[240|r>>18]+Se[128|r>>12&63]+Se[128|r>>6&63]+Se[128|r&63]}o+=n.join(``)}return o};function Te(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Ee(e,t){if(D(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}const De={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},Oe=function(e,t){Array.prototype.push.apply(e,D(t)?t:[t])};let ke;const Ae={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:we,encodeValuesOnly:!1,format:ve,formatter:ye,indices:!1,serializeDate(e){return(ke??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function je(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}const Me={};function Ne(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e,y=_,b=0,x=!1;for(;(y=y.get(Me))!==void 0&&!x;){let t=y.get(e);if(b+=1,t!==void 0){if(t===b)throw RangeError(`Cyclic object value`);x=!0}y.get(Me)===void 0&&(b=0)}if(typeof l==`function`?v=l(t,v):v instanceof Date?v=f?.(v):n===`comma`&&D(v)&&(v=Ee(v,function(e){return e instanceof Date?f?.(e):e})),v===null){if(a)return c&&!h?c(t,Ae.encoder,g,`key`,p):t;v=``}if(je(v)||Te(v)){if(c){let e=h?t:c(t,Ae.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(v,Ae.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(v))]}let S=[];if(v===void 0)return S;let C;if(n===`comma`&&D(v))h&&c&&(v=Ee(v,c)),C=[{value:v.length>0?v.join(`,`)||null:void 0}];else if(D(l))C=l;else{let e=Object.keys(v);C=u?e.sort(u):e}let w=s?String(t).replace(/\./g,`%2E`):String(t),T=r&&D(v)&&v.length===1?w+`[]`:w;if(i&&D(v)&&v.length===0)return T+`[]`;for(let t=0;t<C.length;++t){let y=C[t],x=typeof y==`object`&&y.value!==void 0?y.value:v[y];if(o&&x===null)continue;let w=d&&s?y.replace(/\./g,`%2E`):y,E=D(v)?typeof n==`function`?n(T,w):T:T+(d?`.`+w:`[`+w+`]`);_.set(e,b);let O=new WeakMap;O.set(Me,_),Oe(S,Ne(x,E,n,r,i,a,o,s,n===`comma`&&h&&D(v)?null:c,l,u,d,f,p,m,h,g,O))}return S}function Pe(e=Ae){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||Ae.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=ve;if(e.format!==void 0){if(!xe(be,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=be[n],i=Ae.filter;(typeof e.filter==`function`||D(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in De?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:Ae.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:Ae.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:Ae.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:Ae.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:Ae.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?Ae.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:Ae.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:Ae.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:Ae.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:Ae.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:Ae.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:Ae.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:Ae.strictNullHandling}}function Fe(e,t={}){let n=e,r=Pe(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):D(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=De[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||=Object.keys(n),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||Oe(o,Ne(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}function Ie(e){return Fe(e,{arrayFormat:`brackets`})}function Le(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let Re;function ze(e){let t;return(Re??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Be;function Ve(e){let t;return(Be??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var He,Ue,We=class{constructor(){He.set(this,void 0),Ue.set(this,void 0),n(this,He,new Uint8Array,`f`),n(this,Ue,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?ze(e):e;n(this,He,Le([r(this,He,`f`),t]),`f`);let i=[],a;for(;(a=Ge(r(this,He,`f`),r(this,Ue,`f`)))!=null;){if(a.carriage&&r(this,Ue,`f`)==null){n(this,Ue,a.index,`f`);continue}if(r(this,Ue,`f`)!=null&&(a.index!==r(this,Ue,`f`)+1||a.carriage)){i.push(Ve(r(this,He,`f`).subarray(0,r(this,Ue,`f`)-1))),n(this,He,r(this,He,`f`).subarray(r(this,Ue,`f`)),`f`),n(this,Ue,null,`f`);continue}let e=r(this,Ue,`f`)===null?a.preceding:a.preceding-1,t=Ve(r(this,He,`f`).subarray(0,e));i.push(t),n(this,He,r(this,He,`f`).subarray(a.index),`f`),n(this,Ue,null,`f`)}return i}flush(){return r(this,He,`f`).length?this.decode(`
|
|
1
|
+
import{i as e,t}from"./chunk-DSjMdhoD.js";function n(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let i=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return i=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function a(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const o=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var s=class extends Error{},c=class e extends s{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new u({message:r,cause:o(n)});let a=n?.error;return t===400?new f(t,a,r,i):t===401?new p(t,a,r,i):t===403?new m(t,a,r,i):t===404?new h(t,a,r,i):t===409?new g(t,a,r,i):t===422?new _(t,a,r,i):t===429?new v(t,a,r,i):t>=500?new y(t,a,r,i):new e(t,a,r,i)}},l=class extends c{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},u=class extends c{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},d=class extends u{constructor({message:e}={}){super({message:e??`Request timed out.`})}},f=class extends c{},p=class extends c{},m=class extends c{},h=class extends c{},g=class extends c{},_=class extends c{},v=class extends c{},y=class extends c{},b=class extends s{constructor(){super(`Could not parse response content as the length limit was reached`)}},x=class extends s{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},S=class extends Error{constructor(e){super(e)}},C=class extends c{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},w=class extends s{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const T=/^[a-z][a-z0-9+.-]*:/i,E=e=>T.test(e);let D=e=>(D=Array.isArray,D(e)),O=D;function k(e){return typeof e==`object`?e??{}:{}}function A(e){if(!e)return!0;for(let t in e)return!1;return!0}function ee(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function te(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ne=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new s(`${e} must be an integer`);if(t<0)throw new s(`${e} must be a positive integer`);return t},re=e=>{try{return JSON.parse(e)}catch{return}},ie=e=>new Promise(t=>setTimeout(t,e)),ae=`6.39.0`,oe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}const j=()=>{let e=se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":ue(Deno.build.os),"X-Stainless-Arch":le(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":ue(globalThis.process.platform??`unknown`),"X-Stainless-Arch":le(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=ce();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ae,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function ce(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}const le=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ue=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`);let de;const fe=()=>de??=j();function M(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pe(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function me(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pe({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function he(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function ge(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}const _e=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),ve=`RFC3986`,ye=e=>String(e),be={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:ye};let xe=(e,t)=>(xe=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),xe(e,t));const Se=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),Ce=1024,we=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=Ce){let t=a.length>=Ce?a.slice(e,e+Ce):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=Se[r];continue}if(r<2048){n[n.length]=Se[192|r>>6]+Se[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=Se[224|r>>12]+Se[128|r>>6&63]+Se[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=Se[240|r>>18]+Se[128|r>>12&63]+Se[128|r>>6&63]+Se[128|r&63]}o+=n.join(``)}return o};function Te(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Ee(e,t){if(D(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}const De={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},Oe=function(e,t){Array.prototype.push.apply(e,D(t)?t:[t])};let ke;const Ae={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:we,encodeValuesOnly:!1,format:ve,formatter:ye,indices:!1,serializeDate(e){return(ke??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function je(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}const Me={};function Ne(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e,y=_,b=0,x=!1;for(;(y=y.get(Me))!==void 0&&!x;){let t=y.get(e);if(b+=1,t!==void 0){if(t===b)throw RangeError(`Cyclic object value`);x=!0}y.get(Me)===void 0&&(b=0)}if(typeof l==`function`?v=l(t,v):v instanceof Date?v=f?.(v):n===`comma`&&D(v)&&(v=Ee(v,function(e){return e instanceof Date?f?.(e):e})),v===null){if(a)return c&&!h?c(t,Ae.encoder,g,`key`,p):t;v=``}if(je(v)||Te(v)){if(c){let e=h?t:c(t,Ae.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(v,Ae.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(v))]}let S=[];if(v===void 0)return S;let C;if(n===`comma`&&D(v))h&&c&&(v=Ee(v,c)),C=[{value:v.length>0?v.join(`,`)||null:void 0}];else if(D(l))C=l;else{let e=Object.keys(v);C=u?e.sort(u):e}let w=s?String(t).replace(/\./g,`%2E`):String(t),T=r&&D(v)&&v.length===1?w+`[]`:w;if(i&&D(v)&&v.length===0)return T+`[]`;for(let t=0;t<C.length;++t){let y=C[t],x=typeof y==`object`&&y.value!==void 0?y.value:v[y];if(o&&x===null)continue;let w=d&&s?y.replace(/\./g,`%2E`):y,E=D(v)?typeof n==`function`?n(T,w):T:T+(d?`.`+w:`[`+w+`]`);_.set(e,b);let O=new WeakMap;O.set(Me,_),Oe(S,Ne(x,E,n,r,i,a,o,s,n===`comma`&&h&&D(v)?null:c,l,u,d,f,p,m,h,g,O))}return S}function Pe(e=Ae){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||Ae.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=ve;if(e.format!==void 0){if(!xe(be,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=be[n],i=Ae.filter;(typeof e.filter==`function`||D(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in De?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:Ae.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:Ae.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:Ae.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:Ae.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:Ae.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?Ae.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:Ae.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:Ae.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:Ae.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:Ae.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:Ae.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:Ae.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:Ae.strictNullHandling}}function Fe(e,t={}){let n=e,r=Pe(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):D(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=De[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||=Object.keys(n),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||Oe(o,Ne(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}function Ie(e){return Fe(e,{arrayFormat:`brackets`})}function Le(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let Re;function ze(e){let t;return(Re??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Be;function Ve(e){let t;return(Be??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var He,Ue,We=class{constructor(){He.set(this,void 0),Ue.set(this,void 0),n(this,He,new Uint8Array,`f`),n(this,Ue,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?ze(e):e;n(this,He,Le([r(this,He,`f`),t]),`f`);let i=[],a;for(;(a=Ge(r(this,He,`f`),r(this,Ue,`f`)))!=null;){if(a.carriage&&r(this,Ue,`f`)==null){n(this,Ue,a.index,`f`);continue}if(r(this,Ue,`f`)!=null&&(a.index!==r(this,Ue,`f`)+1||a.carriage)){i.push(Ve(r(this,He,`f`).subarray(0,r(this,Ue,`f`)-1))),n(this,He,r(this,He,`f`).subarray(r(this,Ue,`f`)),`f`),n(this,Ue,null,`f`);continue}let e=r(this,Ue,`f`)===null?a.preceding:a.preceding-1,t=Ve(r(this,He,`f`).subarray(0,e));i.push(t),n(this,He,r(this,He,`f`).subarray(a.index),`f`),n(this,Ue,null,`f`)}return i}flush(){return r(this,He,`f`).length?this.decode(`
|
|
2
2
|
`):[]}};He=new WeakMap,Ue=new WeakMap,We.NEWLINE_CHARS=new Set([`
|
|
3
|
-
`,`\r`]),We.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ge(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Ke(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}const qe={off:0,error:200,warn:300,info:400,debug:500},Je=(e,t,n)=>{if(e){if(ee(qe,e))return e;$e(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qe))}`)}};function Ye(){}function Xe(e,t,n){return!t||qe[e]>qe[n]?Ye:t[e].bind(t)}const Ze={error:Ye,warn:Ye,info:Ye,debug:Ye};let Qe=new WeakMap;function $e(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ze;let r=Qe.get(t);if(r&&r[0]===n)return r[1];let i={error:Xe(`error`,t,n),warn:Xe(`warn`,t,n),info:Xe(`info`,t,n),debug:Xe(`debug`,t,n)};return Qe.set(t,[n,i]),i}const et=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var tt,nt=class e{constructor(e,t,r){this.iterator=e,tt.set(this,void 0),this.controller=t,n(this,tt,r,`f`)}static fromSSEResponse(t,n,r,i){let o=!1,l=r?$e(r):console;async function*u(){if(o)throw new s("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let e=!1;try{for await(let r of rt(t,n))if(!e){if(r.data.startsWith(`[DONE]`)){e=!0;continue}if(r.event===null||!r.event.startsWith(`thread.`)){let e;try{e=JSON.parse(r.data)}catch(e){throw l.error(`Could not parse message into JSON:`,r.data),l.error(`From chunk:`,r.raw),e}if(e&&e.error)throw new c(void 0,e.error,void 0,t.headers);yield i?{event:r.event,data:e}:e}else{let e;try{e=JSON.parse(r.data)}catch(e){throw console.error(`Could not parse message into JSON:`,r.data),console.error(`From chunk:`,r.raw),e}if(r.event==`error`)throw new c(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}}e=!0}catch(e){if(a(e))return;throw e}finally{e||n.abort()}}return new e(u,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*o(){let e=new We,n=he(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*c(){if(i)throw new s("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of o())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(a(e))return;throw e}finally{e||n.abort()}}return new e(c,n,r)}[(tt=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],i=this.iterator(),a=e=>({next:()=>{if(e.length===0){let e=i.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>a(t),this.controller,r(this,tt,`f`)),new e(()=>a(n),this.controller,r(this,tt,`f`))]}toReadableStream(){let e=this,t;return pe({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=ze(JSON.stringify(n)+`
|
|
3
|
+
`,`\r`]),We.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ge(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Ke(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}const qe={off:0,error:200,warn:300,info:400,debug:500},Je=(e,t,n)=>{if(e){if(ee(qe,e))return e;$e(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qe))}`)}};function Ye(){}function Xe(e,t,n){return!t||qe[e]>qe[n]?Ye:t[e].bind(t)}const Ze={error:Ye,warn:Ye,info:Ye,debug:Ye};let Qe=new WeakMap;function $e(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ze;let r=Qe.get(t);if(r&&r[0]===n)return r[1];let i={error:Xe(`error`,t,n),warn:Xe(`warn`,t,n),info:Xe(`info`,t,n),debug:Xe(`debug`,t,n)};return Qe.set(t,[n,i]),i}const et=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var tt,nt=class e{constructor(e,t,r){this.iterator=e,tt.set(this,void 0),this.controller=t,n(this,tt,r,`f`)}static fromSSEResponse(t,n,r,i){let o=!1,l=r?$e(r):console;async function*u(){if(o)throw new s("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let e=!1;try{for await(let r of rt(t,n))if(!e){if(r.data.startsWith(`[DONE]`)){e=!0;continue}if(r.event===null||!r.event.startsWith(`thread.`)){let e;try{e=JSON.parse(r.data)}catch(e){throw l.error(`Could not parse message into JSON:`,r.data),l.error(`From chunk:`,r.raw),e}if(e&&e.error)throw new c(void 0,e.error,void 0,t.headers);yield i?{event:r.event,data:e}:e}else{let e;try{e=JSON.parse(r.data)}catch(e){throw console.error(`Could not parse message into JSON:`,r.data),console.error(`From chunk:`,r.raw),e}if(r.event==`error`)throw new c(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}}e=!0}catch(e){if(a(e))return;throw e}finally{e||n.abort()}}return new e(u,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*o(){let e=new We,n=he(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*c(){if(i)throw new s("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of o())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(a(e))return;throw e}finally{e||n.abort()}}return new e(c,n,r)}[(tt=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],i=this.iterator(),a=e=>({next:()=>{if(e.length===0){let e=i.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>a(t),this.controller,r(this,tt,`f`)),new e(()=>a(n),this.controller,r(this,tt,`f`))]}toReadableStream(){let e=this,t;return pe({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=ze(JSON.stringify(n)+`
|
|
4
4
|
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*rt(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new s(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new s(`Attempted to iterate over a response with no body`);let n=new at,r=new We,i=he(e.body);for await(let e of it(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*it(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?ze(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=Ke(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var at=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
|
|
5
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=ot(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function ot(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}async function st(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return $e(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):nt.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:ct(await n.json(),n):await n.text()})();return $e(e).debug(`[${r}] response parsed`,et({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function ct(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperty(e,`_request_id`,{value:t.headers.get(`x-request-id`),enumerable:!1})}var lt,ut=class e extends Promise{constructor(e,t,r=st){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=r,lt.set(this,void 0),n(this,lt,e,`f`)}_thenUnwrap(t){return new e(r(this,lt,`f`),this.responsePromise,async(e,n)=>ct(t(await this.parseResponse(e,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get(`x-request-id`)}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(r(this,lt,`f`),e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};lt=new WeakMap;var dt,ft=class{constructor(e,t,r,i){dt.set(this,void 0),n(this,dt,e,`f`),this.options=i,this.response=t,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new s("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await r(this,dt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(dt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},pt=class extends ut{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await st(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},mt=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},ht=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...k(this.options.query),after:t}}:null}},gt=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||``}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...k(this.options.query),after:e}}:null}},_t=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.next=n.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.next;return e?{...this.options,query:{...k(this.options.query),after:e}}:null}};const vt={jwt:`urn:ietf:params:oauth:token-type:jwt`,id:`urn:ietf:params:oauth:token-type:id_token`};var yt=class{constructor(e,t){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl=`https://auth.openai.com/oauth/token`,this.config=e,this.fetch=t??M()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let e=await this.config.provider.getToken(),t=await this.fetch(this.tokenExchangeUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,client_id:this.config.clientId,subject_token:e,subject_token_type:vt[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId})});if(!t.ok){let e=await t.text(),n;try{n=JSON.parse(e)}catch{}throw t.status===400||t.status===401||t.status===403?new C(t.status,n,t.headers):c.generate(t.status,n,`Token exchange failed with status ${t.status}`,t.headers)}let n=await t.json(),r=n.expires_in||3600,i=Date.now()+r*1e3;return this.cachedToken={token:n.access_token,expiresAt:i},n.access_token}isTokenExpired(e){return Date.now()>=e.expiresAt}needsRefresh(e){let t=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=e.expiresAt-t}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};const bt=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function xt(e,t,n){return bt(),new File(e,t??`unknown_file`,n)}function St(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}const Ct=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,wt=async(e,t)=>jt(e.body)?{...e,body:await Ot(e.body,t)}:e,Tt=async(e,t)=>({...e,body:await Ot(e.body,t)}),Et=new WeakMap;function Dt(e){let t=typeof e==`function`?e:e.fetch,n=Et.get(t);if(n)return n;let r=(async()=>{try{let e=`Response`in t?t.Response:(await t(`data:,`)).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return Et.set(t,r),r}const Ot=async(e,t)=>{if(!await Dt(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Mt(n,e,t))),n},kt=e=>e instanceof Blob&&`name`in e,At=e=>typeof e==`object`&&!!e&&(e instanceof Response||Ct(e)||kt(e)),jt=e=>{if(At(e))return!0;if(Array.isArray(e))return e.some(jt);if(e&&typeof e==`object`){for(let t in e)if(jt(e[t]))return!0}return!1},Mt=async(e,t,n)=>{if(n!==void 0){if(n==null)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)e.append(t,String(n));else if(n instanceof Response)e.append(t,xt([await n.blob()],St(n)));else if(Ct(n))e.append(t,xt([await new Response(me(n)).blob()],St(n)));else if(kt(n))e.append(t,n,St(n));else if(Array.isArray(n))await Promise.all(n.map(n=>Mt(e,t+`[]`,n)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,r])=>Mt(e,`${t}[${n}]`,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},Nt=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,Pt=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&Nt(e),Ft=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function It(e,t,n){if(bt(),e=await e,Pt(e))return e instanceof File?e:xt([await e.arrayBuffer()],e.name);if(Ft(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),xt(await Lt(r),t,n)}let r=await Lt(e);if(t||=St(e),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return xt(r,t,n)}async function Lt(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(Nt(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Ct(e))for await(let n of e)t.push(...await Lt(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${Rt(e)}`)}return t}function Rt(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var N=class{constructor(e){this._client=e}};function zt(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Bt=Object.freeze(Object.create(null)),P=((e=zt)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Bt)??Bt)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,l;for(;(l=c.exec(o))!==null;)i.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new s(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
|
|
5
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=ot(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function ot(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}async function st(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return $e(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):nt.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:ct(await n.json(),n):await n.text()})();return $e(e).debug(`[${r}] response parsed`,et({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function ct(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get(`x-request-id`),enumerable:!1})}var lt,ut=class e extends Promise{constructor(e,t,r=st){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=r,lt.set(this,void 0),n(this,lt,e,`f`)}_thenUnwrap(t){return new e(r(this,lt,`f`),this.responsePromise,async(e,n)=>ct(t(await this.parseResponse(e,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get(`x-request-id`)}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(r(this,lt,`f`),e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};lt=new WeakMap;var dt,ft=class{constructor(e,t,r,i){dt.set(this,void 0),n(this,dt,e,`f`),this.options=i,this.response=t,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new s("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await r(this,dt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(dt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},pt=class extends ut{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await st(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},mt=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},ht=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...k(this.options.query),after:t}}:null}},gt=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||``}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...k(this.options.query),after:e}}:null}},_t=class extends ft{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.next=n.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.next;return e?{...this.options,query:{...k(this.options.query),after:e}}:null}};const vt={jwt:`urn:ietf:params:oauth:token-type:jwt`,id:`urn:ietf:params:oauth:token-type:id_token`};var yt=class{constructor(e,t){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl=`https://auth.openai.com/oauth/token`,this.config=e,this.fetch=t??M()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let e={grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:await this.config.provider.getToken(),subject_token_type:vt[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId};this.config.clientId&&(e.client_id=this.config.clientId);let t=await this.fetch(this.tokenExchangeUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.text(),n;try{n=JSON.parse(e)}catch{}throw t.status===400||t.status===401||t.status===403?new C(t.status,n,t.headers):c.generate(t.status,n,`Token exchange failed with status ${t.status}`,t.headers)}let n=await t.json(),r=n.expires_in||3600,i=Date.now()+r*1e3;return this.cachedToken={token:n.access_token,expiresAt:i},n.access_token}isTokenExpired(e){return Date.now()>=e.expiresAt}needsRefresh(e){let t=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=e.expiresAt-t}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};const bt=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function xt(e,t,n){return bt(),new File(e,t??`unknown_file`,n)}function St(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}const Ct=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,wt=async(e,t)=>jt(e.body)?{...e,body:await Ot(e.body,t)}:e,Tt=async(e,t)=>({...e,body:await Ot(e.body,t)}),Et=new WeakMap;function Dt(e){let t=typeof e==`function`?e:e.fetch,n=Et.get(t);if(n)return n;let r=(async()=>{try{let e=`Response`in t?t.Response:(await t(`data:,`)).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return Et.set(t,r),r}const Ot=async(e,t)=>{if(!await Dt(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Mt(n,e,t))),n},kt=e=>e instanceof Blob&&`name`in e,At=e=>typeof e==`object`&&!!e&&(e instanceof Response||Ct(e)||kt(e)),jt=e=>{if(At(e))return!0;if(Array.isArray(e))return e.some(jt);if(e&&typeof e==`object`){for(let t in e)if(jt(e[t]))return!0}return!1},Mt=async(e,t,n)=>{if(n!==void 0){if(n==null)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)e.append(t,String(n));else if(n instanceof Response)e.append(t,xt([await n.blob()],St(n)));else if(Ct(n))e.append(t,xt([await new Response(me(n)).blob()],St(n)));else if(kt(n))e.append(t,n,St(n));else if(Array.isArray(n))await Promise.all(n.map(n=>Mt(e,t+`[]`,n)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,r])=>Mt(e,`${t}[${n}]`,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},Nt=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,Pt=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&Nt(e),Ft=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function It(e,t,n){if(bt(),e=await e,Pt(e))return e instanceof File?e:xt([await e.arrayBuffer()],e.name);if(Ft(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),xt(await Lt(r),t,n)}let r=await Lt(e);if(t||=St(e),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return xt(r,t,n)}async function Lt(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(Nt(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Ct(e))for await(let n of e)t.push(...await Lt(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${Rt(e)}`)}return t}function Rt(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var N=class{constructor(e){this._client=e}};function zt(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Bt=Object.freeze(Object.create(null)),P=((e=zt)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Bt)??Bt)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,l;for(;(l=c.exec(o))!==null;)i.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new s(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
|
|
6
6
|
`)}\n${a}\n${t}`)}return a})(zt);var Vt=class extends N{list(e,t={},n){return this._client.getAPIList(P`/chat/completions/${e}/messages`,ht,{query:t,...n,__security:{bearerAuth:!0}})}};function Ht(e){return e!==void 0&&`function`in e&&e.function!==void 0}function Ut(e){return e?.$brand===`auto-parseable-response-format`}function Wt(e){return e?.$brand===`auto-parseable-tool`}function Gt(e,t){return!t||!Xt(t)?{...e,choices:e.choices.map(e=>(Zt(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}:Kt(e,t)}function Kt(e,t){let n=e.choices.map(e=>{if(e.finish_reason===`length`)throw new b;if(e.finish_reason===`content_filter`)throw new x;return Zt(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>Jt(t,e))??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?qt(t,e.message.content):null}}});return{...e,choices:n}}function qt(e,t){return e.response_format?.type===`json_schema`&&e.response_format?.type===`json_schema`?`$parseRaw`in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}function Jt(e,t){let n=e.tools?.find(e=>Ht(e)&&e.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:Wt(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}function Yt(e,t){if(!e||!(`tools`in e)||!e.tools)return!1;let n=e.tools?.find(e=>Ht(e)&&e.function?.name===t.function.name);return Ht(n)&&(Wt(n)||n?.function.strict||!1)}function Xt(e){return Ut(e.response_format)?!0:e.tools?.some(e=>Wt(e)||e.type===`function`&&e.function.strict===!0)??!1}function Zt(e){for(let t of e||[])if(t.type!==`function`)throw new s(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}function Qt(e){for(let t of e??[]){if(t.type!==`function`)throw new s(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new s(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}const $t=e=>e?.role===`assistant`,en=e=>e?.role===`tool`;var tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn=class{constructor(){tn.add(this),this.controller=new AbortController,nn.set(this,void 0),rn.set(this,()=>{}),an.set(this,()=>{}),on.set(this,void 0),sn.set(this,()=>{}),cn.set(this,()=>{}),ln.set(this,{}),un.set(this,!1),dn.set(this,!1),fn.set(this,!1),pn.set(this,!1),n(this,nn,new Promise((e,t)=>{n(this,rn,e,`f`),n(this,an,t,`f`)}),`f`),n(this,on,new Promise((e,t)=>{n(this,sn,e,`f`),n(this,cn,t,`f`)}),`f`),r(this,nn,`f`).catch(()=>{}),r(this,on,`f`).catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit(`end`)},r(this,tn,`m`,mn).bind(this))},0)}_connected(){this.ended||(r(this,rn,`f`).call(this),this._emit(`connect`))}get ended(){return r(this,un,`f`)}get errored(){return r(this,dn,`f`)}get aborted(){return r(this,fn,`f`)}abort(){this.controller.abort()}on(e,t){return(r(this,ln,`f`)[e]||(r(this,ln,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=r(this,ln,`f`)[e];if(!n)return this;let i=n.findIndex(e=>e.listener===t);return i>=0&&n.splice(i,1),this}once(e,t){return(r(this,ln,`f`)[e]||(r(this,ln,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{n(this,pn,!0,`f`),e!==`error`&&this.once(`error`,r),this.once(e,t)})}async done(){n(this,pn,!0,`f`),await r(this,on,`f`)}_emit(e,...t){if(r(this,un,`f`))return;e===`end`&&(n(this,un,!0,`f`),r(this,sn,`f`).call(this));let i=r(this,ln,`f`)[e];if(i&&(r(this,ln,`f`)[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!r(this,pn,`f`)&&!i?.length&&Promise.reject(e),r(this,an,`f`).call(this,e),r(this,cn,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!r(this,pn,`f`)&&!i?.length&&Promise.reject(e),r(this,an,`f`).call(this,e),r(this,cn,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){}};nn=new WeakMap,rn=new WeakMap,an=new WeakMap,on=new WeakMap,sn=new WeakMap,cn=new WeakMap,ln=new WeakMap,un=new WeakMap,dn=new WeakMap,fn=new WeakMap,pn=new WeakMap,tn=new WeakSet,mn=function(e){if(n(this,dn,!0,`f`),e instanceof Error&&e.name===`AbortError`&&(e=new l),e instanceof l)return n(this,fn,!0,`f`),this._emit(`abort`,e);if(e instanceof s)return this._emit(`error`,e);if(e instanceof Error){let t=new s(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new s(String(e)))};function gn(e){return typeof e.parse==`function`}var _n,vn,yn,bn,xn,Sn,Cn,wn,Tn=class extends hn{constructor(){super(...arguments),_n.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit(`chatCompletion`,e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if(`content`in e||(e.content=null),this.messages.push(e),t){if(this._emit(`message`,e),en(e)&&e.content)this._emit(`functionToolCallResult`,e.content);else if($t(e)&&e.tool_calls)for(let t of e.tool_calls)t.type===`function`&&this._emit(`functionToolCall`,t.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new s(`stream ended without producing a ChatCompletion`);return e}async finalContent(){return await this.done(),r(this,_n,`m`,vn).call(this)}async finalMessage(){return await this.done(),r(this,_n,`m`,yn).call(this)}async finalFunctionToolCall(){return await this.done(),r(this,_n,`m`,bn).call(this)}async finalFunctionToolCallResult(){return await this.done(),r(this,_n,`m`,xn).call(this)}async totalUsage(){return await this.done(),r(this,_n,`m`,Sn).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit(`finalChatCompletion`,e);let t=r(this,_n,`m`,yn).call(this);t&&this._emit(`finalMessage`,t);let n=r(this,_n,`m`,vn).call(this);n&&this._emit(`finalContent`,n);let i=r(this,_n,`m`,bn).call(this);i&&this._emit(`finalFunctionToolCall`,i);let a=r(this,_n,`m`,xn).call(this);a!=null&&this._emit(`finalFunctionToolCallResult`,a),this._chatCompletions.some(e=>e.usage)&&this._emit(`totalUsage`,r(this,_n,`m`,Sn).call(this))}async _createChatCompletion(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),r(this,_n,`m`,Cn).call(this,t);let a=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Kt(a,t))}async _runChatCompletion(e,t,n){for(let e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,n)}async _runTools(e,t,n){let i=`tool`,{tool_choice:a=`auto`,stream:o,...c}=t,l=typeof a!=`string`&&a.type===`function`&&a?.function?.name,{maxChatCompletions:u=10}=n||{},d=t.tools.map(e=>{if(Wt(e)){if(!e.$callback)throw new s("Tool given to `.runTools()` that does not have an associated function");return{type:`function`,function:{function:e.$callback,name:e.function.name,description:e.function.description||``,parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),f={};for(let e of d)e.type===`function`&&(f[e.function.name||e.function.function.name]=e.function);let p=`tools`in t?d.map(e=>e.type===`function`?{type:`function`,function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(let e of t.messages)this._addMessage(e,!1);for(let t=0;t<u;++t){let t=(await this._createChatCompletion(e,{...c,tool_choice:a,tools:p,messages:[...this.messages]},n)).choices[0]?.message;if(!t)throw new s(`missing message in ChatCompletion response`);if(!t.tool_calls?.length)return;for(let e of t.tool_calls){if(e.type!==`function`)continue;let t=e.id,{name:n,arguments:a}=e.function,o=f[n];if(!o){let e=`Invalid tool_call: ${JSON.stringify(n)}. Available options are: ${Object.keys(f).map(e=>JSON.stringify(e)).join(`, `)}. Please try again`;this._addMessage({role:i,tool_call_id:t,content:e});continue}else if(l&&l!==n){let e=`Invalid tool_call: ${JSON.stringify(n)}. ${JSON.stringify(l)} requested. Please try again`;this._addMessage({role:i,tool_call_id:t,content:e});continue}let s;try{s=gn(o)?await o.parse(a):a}catch(e){let n=e instanceof Error?e.message:String(e);this._addMessage({role:i,tool_call_id:t,content:n});continue}let c=await o.function(s,this),u=r(this,_n,`m`,wn).call(this,c);if(this._addMessage({role:i,tool_call_id:t,content:u}),l)return}}}};_n=new WeakSet,vn=function(){return r(this,_n,`m`,yn).call(this).content??null},yn=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if($t(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new s(`stream ended without producing a ChatCompletionMessage with role=assistant`)},bn=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if($t(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>e.type===`function`).at(-1)?.function}},xn=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(en(t)&&t.content!=null&&typeof t.content==`string`&&this.messages.some(e=>e.role===`assistant`&&e.tool_calls?.some(e=>e.type===`function`&&e.id===t.tool_call_id)))return t.content}},Sn=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},Cn=function(e){if(e.n!=null&&e.n>1)throw new s(`ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.`)},wn=function(e){return typeof e==`string`?e:e===void 0?`undefined`:JSON.stringify(e)};var En=class e extends Tn{static runTools(t,n,r){let i=new e,a={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`runTools`}};return i._run(()=>i._runTools(t,n,a)),i}_addMessage(e,t=!0){super._addMessage(e,t),$t(e)&&e.content&&this._emit(`content`,e.content)}};const Dn={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};var On=class extends Error{},kn=class extends Error{};function An(e,t=Dn.ALL){if(typeof e!=`string`)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return jn(e.trim(),t)}const jn=(e,t)=>{let n=e.length,r=0,i=e=>{throw new On(`${e} at position ${r}`)},a=e=>{throw new kn(`${e} at position ${r}`)},o=()=>(d(),r>=n&&i(`Unexpected end of input`),e[r]===`"`?s():e[r]===`{`?c():e[r]===`[`?l():e.substring(r,r+4)===`null`||Dn.NULL&t&&n-r<4&&`null`.startsWith(e.substring(r))?(r+=4,null):e.substring(r,r+4)===`true`||Dn.BOOL&t&&n-r<4&&`true`.startsWith(e.substring(r))?(r+=4,!0):e.substring(r,r+5)===`false`||Dn.BOOL&t&&n-r<5&&`false`.startsWith(e.substring(r))?(r+=5,!1):e.substring(r,r+8)===`Infinity`||Dn.INFINITY&t&&n-r<8&&`Infinity`.startsWith(e.substring(r))?(r+=8,1/0):e.substring(r,r+9)===`-Infinity`||Dn.MINUS_INFINITY&t&&1<n-r&&n-r<9&&`-Infinity`.startsWith(e.substring(r))?(r+=9,-1/0):e.substring(r,r+3)===`NaN`||Dn.NAN&t&&n-r<3&&`NaN`.startsWith(e.substring(r))?(r+=3,NaN):u()),s=()=>{let o=r,s=!1;for(r++;r<n&&(e[r]!==`"`||s&&e[r-1]===`\\`);)s=e[r]===`\\`?!s:!1,r++;if(e.charAt(r)==`"`)try{return JSON.parse(e.substring(o,++r-Number(s)))}catch(e){a(String(e))}else if(Dn.STR&t)try{return JSON.parse(e.substring(o,r-Number(s))+`"`)}catch{return JSON.parse(e.substring(o,e.lastIndexOf(`\\`))+`"`)}i(`Unterminated string literal`)},c=()=>{r++,d();let a={};try{for(;e[r]!==`}`;){if(d(),r>=n&&Dn.OBJ&t)return a;let i=s();d(),r++;try{let e=o();Object.defineProperty(a,i,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(Dn.OBJ&t)return a;throw e}d(),e[r]===`,`&&r++}}catch{if(Dn.OBJ&t)return a;i(`Expected '}' at end of object`)}return r++,a},l=()=>{r++;let n=[];try{for(;e[r]!==`]`;)n.push(o()),d(),e[r]===`,`&&r++}catch{if(Dn.ARR&t)return n;i(`Expected ']' at end of array`)}return r++,n},u=()=>{if(r===0){e===`-`&&Dn.NUM&t&&i(`Not sure what '-' is`);try{return JSON.parse(e)}catch(n){if(Dn.NUM&t)try{return e[e.length-1]===`.`?JSON.parse(e.substring(0,e.lastIndexOf(`.`))):JSON.parse(e.substring(0,e.lastIndexOf(`e`)))}catch{}a(String(n))}}let o=r;for(e[r]===`-`&&r++;e[r]&&!`,]}`.includes(e[r]);)r++;r==n&&!(Dn.NUM&t)&&i(`Unterminated number literal`);try{return JSON.parse(e.substring(o,r))}catch{e.substring(o,r)===`-`&&Dn.NUM&t&&i(`Not sure what '-' is`);try{return JSON.parse(e.substring(o,e.lastIndexOf(`e`)))}catch(e){a(String(e))}}},d=()=>{for(;r<n&&`
|
|
7
|
-
\r `.includes(e[r]);)r++};return o()},Mn=e=>An(e,Dn.ALL^Dn.NUM);var Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn=class e extends Tn{constructor(e){super(),Nn.add(this),Pn.set(this,void 0),Fn.set(this,void 0),In.set(this,void 0),n(this,Pn,e,`f`),n(this,Fn,[],`f`)}get currentChatCompletionSnapshot(){return r(this,In,`f`)}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,r){let i=new e(n);return i._run(()=>i._runChatCompletion(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createChatCompletion(e,t,n){super._createChatCompletion;let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),r(this,Nn,`m`,Ln).call(this);let a=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let e of a)r(this,Nn,`m`,zn).call(this,e);if(a.controller.signal?.aborted)throw new l;return this._addChatCompletion(r(this,Nn,`m`,Hn).call(this))}async _fromReadableStream(e,t){let n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener(`abort`,()=>this.controller.abort())),r(this,Nn,`m`,Ln).call(this),this._connected();let i=nt.fromReadableStream(e,this.controller),a;for await(let e of i)a&&a!==e.id&&this._addChatCompletion(r(this,Nn,`m`,Hn).call(this)),r(this,Nn,`m`,zn).call(this,e),a=e.id;if(i.controller.signal?.aborted)throw new l;return this._addChatCompletion(r(this,Nn,`m`,Hn).call(this))}[(Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Nn=new WeakSet,Ln=function(){this.ended||n(this,In,void 0,`f`)},Rn=function(e){let t=r(this,Fn,`f`)[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},r(this,Fn,`f`)[e.index]=t,t)},zn=function(e){if(this.ended)return;let t=r(this,Nn,`m`,Wn).call(this,e);this._emit(`chunk`,e,t);for(let n of e.choices){let e=t.choices[n.index];n.delta.content!=null&&e.message?.role===`assistant`&&e.message?.content&&(this._emit(`content`,n.delta.content,e.message.content),this._emit(`content.delta`,{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),n.delta.refusal!=null&&e.message?.role===`assistant`&&e.message?.refusal&&this._emit(`refusal.delta`,{delta:n.delta.refusal,snapshot:e.message.refusal}),n.logprobs?.content!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.content.delta`,{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),n.logprobs?.refusal!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.refusal.delta`,{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let i=r(this,Nn,`m`,Rn).call(this,e);e.finish_reason&&(r(this,Nn,`m`,Vn).call(this,e),i.current_tool_call_index!=null&&r(this,Nn,`m`,Bn).call(this,e,i.current_tool_call_index));for(let t of n.delta.tool_calls??[])i.current_tool_call_index!==t.index&&(r(this,Nn,`m`,Vn).call(this,e),i.current_tool_call_index!=null&&r(this,Nn,`m`,Bn).call(this,e,i.current_tool_call_index)),i.current_tool_call_index=t.index;for(let t of n.delta.tool_calls??[]){let n=e.message.tool_calls?.[t.index];n?.type&&(n?.type===`function`?this._emit(`tool_calls.function.arguments.delta`,{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??``}):n?.type)}}},Bn=function(e,t){if(r(this,Nn,`m`,Rn).call(this,e).done_tool_calls.has(t))return;let n=e.message.tool_calls?.[t];if(!n)throw Error(`no tool call snapshot`);if(!n.type)throw Error("tool call snapshot missing `type`");if(n.type===`function`){let e=r(this,Pn,`f`)?.tools?.find(e=>Ht(e)&&e.function.name===n.function.name);this._emit(`tool_calls.function.arguments.done`,{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:Wt(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else n.type},Vn=function(e){let t=r(this,Nn,`m`,Rn).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let n=r(this,Nn,`m`,Un).call(this);this._emit(`content.done`,{content:e.message.content,parsed:n?n.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit(`refusal.done`,{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit(`logprobs.content.done`,{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit(`logprobs.refusal.done`,{refusal:e.logprobs.refusal}))},Hn=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);let e=r(this,In,`f`);if(!e)throw new s(`request ended without sending any chunks`);return n(this,In,void 0,`f`),n(this,Fn,[],`f`),Kn(e,r(this,Pn,`f`))},Un=function(){let e=r(this,Pn,`f`)?.response_format;return Ut(e)?e:null},Wn=function(e){var t,i,a,o;let s=r(this,In,`f`),{choices:c,...l}=e;s?Object.assign(s,l):s=n(this,In,{...l,choices:[]},`f`);for(let{delta:n,finish_reason:c,index:l,logprobs:u=null,...d}of e.choices){let e=s.choices[l];if(e||=s.choices[l]={finish_reason:c,index:l,message:{},logprobs:u,...d},u)if(!e.logprobs)e.logprobs=Object.assign({},u);else{let{content:n,refusal:r,...a}=u;Object.assign(e.logprobs,a),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),r&&((i=e.logprobs).refusal??(i.refusal=[]),e.logprobs.refusal.push(...r))}if(c&&(e.finish_reason=c,r(this,Pn,`f`)&&Xt(r(this,Pn,`f`)))){if(c===`length`)throw new b;if(c===`content_filter`)throw new x}if(Object.assign(e,d),!n)continue;let{content:f,refusal:p,function_call:m,role:h,tool_calls:g,..._}=n;if(Object.assign(e.message,_),p&&(e.message.refusal=(e.message.refusal||``)+p),h&&(e.message.role=h),m&&(e.message.function_call?(m.name&&(e.message.function_call.name=m.name),m.arguments&&((a=e.message.function_call).arguments??(a.arguments=``),e.message.function_call.arguments+=m.arguments)):e.message.function_call=m),f&&(e.message.content=(e.message.content||``)+f,!e.message.refusal&&r(this,Nn,`m`,Un).call(this)&&(e.message.parsed=Mn(e.message.content))),g){e.message.tool_calls||(e.message.tool_calls=[]);for(let{index:t,id:n,type:i,function:a,...s}of g){let c=(o=e.message.tool_calls)[t]??(o[t]={});Object.assign(c,s),n&&(c.id=n),i&&(c.type=i),a&&(c.function??={name:a.name??``,arguments:``}),a?.name&&(c.function.name=a.name),a?.arguments&&(c.function.arguments+=a.arguments,Yt(r(this,Pn,`f`),c)&&(c.function.parsed_arguments=Mn(c.function.arguments)))}}}return s},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`chunk`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new nt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function Kn(e,t){let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...c}=e;return Gt({...c,id:n,choices:r.map(({message:t,finish_reason:n,index:r,logprobs:i,...a})=>{if(!n)throw new s(`missing finish_reason for choice ${r}`);let{content:o=null,function_call:c,tool_calls:l,...u}=t,d=t.role;if(!d)throw new s(`missing role for choice ${r}`);if(c){let{arguments:e,name:l}=c;if(e==null)throw new s(`missing function_call.arguments for choice ${r}`);if(!l)throw new s(`missing function_call.name for choice ${r}`);return{...a,message:{content:o,function_call:{arguments:e,name:l},role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}return l?{...a,index:r,finish_reason:n,logprobs:i,message:{...u,role:d,content:o,refusal:t.refusal??null,tool_calls:l.map((t,n)=>{let{function:i,type:a,id:o,...c}=t,{arguments:l,name:u,...d}=i||{};if(o==null)throw new s(`missing choices[${r}].tool_calls[${n}].id\n${qn(e)}`);if(a==null)throw new s(`missing choices[${r}].tool_calls[${n}].type\n${qn(e)}`);if(u==null)throw new s(`missing choices[${r}].tool_calls[${n}].function.name\n${qn(e)}`);if(l==null)throw new s(`missing choices[${r}].tool_calls[${n}].function.arguments\n${qn(e)}`);return{...c,id:o,type:a,function:{...d,name:u,arguments:l}}})}}:{...a,message:{...u,content:o,role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}),created:i,model:a,object:`chat.completion`,...o?{system_fingerprint:o}:{}},t)}function qn(e){return JSON.stringify(e)}var Jn=class e extends Gn{static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,r){let i=new e(n),a={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`runTools`}};return i._run(()=>i._runTools(t,n,a)),i}},Yn=class extends N{constructor(){super(...arguments),this.messages=new Vt(this._client)}create(e,t){return this._client.post(`/chat/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/chat/completions/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chat/completions`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}parse(e,t){return Qt(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":`chat.completions.parse`}})._thenUnwrap(t=>Kt(t,e))}runTools(e,t){return e.stream?Jn.runTools(this._client,e,t):En.runTools(this._client,e,t)}stream(e,t){return Gn.createChatCompletion(this._client,e,t)}};Yn.Messages=Vt;var Xn=class extends N{constructor(){super(...arguments),this.completions=new Yn(this._client)}};Xn.Completions=Yn;var Zn=class extends N{create(e,t){return this._client.post(`/organization/admin_api_keys`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/admin_api_keys`,ht,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},Qn=class extends N{list(e={},t){return this._client.getAPIList(`/organization/audit_logs`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}},$n=class extends N{create(e,t){return this._client.post(`/organization/certificates`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(P`/organization/certificates/${e}`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/certificates/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/certificates`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/certificates/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}activate(e,t){return this._client.getAPIList(`/organization/certificates/activate`,mt,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t){return this._client.getAPIList(`/organization/certificates/deactivate`,mt,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}},er=class extends N{create(e,t){return this._client.post(`/organization/invites`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/invites`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},tr=class extends N{create(e,t){return this._client.post(`/organization/roles`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/roles/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/roles`,_t,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},nr=class extends N{audioSpeeches(e,t){return this._client.get(`/organization/usage/audio_speeches`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions(e,t){return this._client.get(`/organization/usage/audio_transcriptions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions(e,t){return this._client.get(`/organization/usage/code_interpreter_sessions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}completions(e,t){return this._client.get(`/organization/usage/completions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}costs(e,t){return this._client.get(`/organization/costs`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}embeddings(e,t){return this._client.get(`/organization/usage/embeddings`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}images(e,t){return this._client.get(`/organization/usage/images`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}moderations(e,t){return this._client.get(`/organization/usage/moderations`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}vectorStores(e,t){return this._client.get(`/organization/usage/vector_stores`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}},rr=class extends N{create(e,t,n){return this._client.post(P`/organization/groups/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/groups/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(P`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},ir=class extends N{create(e,t,n){return this._client.post(P`/organization/groups/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/groups/${e}/users`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(P`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},ar=class extends N{constructor(){super(...arguments),this.users=new ir(this._client),this.roles=new rr(this._client)}create(e,t){return this._client.post(`/organization/groups`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/groups/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/groups`,_t,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}};ar.Users=ir,ar.Roles=rr;var or=class extends N{retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/api_keys`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},sr=class extends N{list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/certificates`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}activate(e,t,n){return this._client.getAPIList(P`/organization/projects/${e}/certificates/activate`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t,n){return this._client.getAPIList(P`/organization/projects/${e}/certificates/deactivate`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}},cr=class extends N{listRateLimits(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/rate_limits`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}updateRateLimit(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/rate_limits/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}},lr=class extends N{create(e,t,n){return this._client.post(P`/projects/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/roles/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/projects/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},ur=class extends N{create(e,t,n){return this._client.post(P`/organization/projects/${e}/service_accounts`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/service_accounts`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},dr=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/groups/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(P`/projects/${r}/groups/${e}/roles`,_t,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,group_id:i}=t;return this._client.delete(P`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},fr=class extends N{constructor(){super(...arguments),this.roles=new dr(this._client)}create(e,t,n){return this._client.post(P`/organization/projects/${e}/groups`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/groups`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/groups/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}};fr.Roles=dr;var pr=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/users/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(P`/projects/${r}/users/${e}/roles`,_t,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,user_id:i}=t;return this._client.delete(P`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},mr=class extends N{constructor(){super(...arguments),this.roles=new pr(this._client)}create(e,t,n){return this._client.post(P`/organization/projects/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/users/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/users`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}};mr.Roles=pr;var hr=class extends N{constructor(){super(...arguments),this.users=new mr(this._client),this.serviceAccounts=new ur(this._client),this.apiKeys=new or(this._client),this.rateLimits=new cr(this._client),this.groups=new fr(this._client),this.roles=new lr(this._client),this.certificates=new sr(this._client)}create(e,t){return this._client.post(`/organization/projects`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/projects/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/projects/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/projects`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}archive(e,t){return this._client.post(P`/organization/projects/${e}/archive`,{...t,__security:{adminAPIKeyAuth:!0}})}};hr.Users=mr,hr.ServiceAccounts=ur,hr.APIKeys=or,hr.RateLimits=cr,hr.Groups=fr,hr.Roles=lr,hr.Certificates=sr;var gr=class extends N{create(e,t,n){return this._client.post(P`/organization/users/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/users/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{user_id:r}=t;return this._client.delete(P`/organization/users/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},_r=class extends N{constructor(){super(...arguments),this.roles=new gr(this._client)}retrieve(e,t){return this._client.get(P`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/users/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/users`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}};_r.Roles=gr;var vr=class extends N{constructor(){super(...arguments),this.auditLogs=new Qn(this._client),this.adminAPIKeys=new Zn(this._client),this.usage=new nr(this._client),this.invites=new er(this._client),this.users=new _r(this._client),this.groups=new ar(this._client),this.roles=new tr(this._client),this.certificates=new $n(this._client),this.projects=new hr(this._client)}};vr.AuditLogs=Qn,vr.AdminAPIKeys=Zn,vr.Usage=nr,vr.Invites=er,vr.Users=_r,vr.Groups=ar,vr.Roles=tr,vr.Certificates=$n,vr.Projects=hr;var yr=class extends N{constructor(){super(...arguments),this.organization=new vr(this._client)}};yr.Organization=vr;const br=Symbol(`brand.privateNullableHeaders`);function*xr(e){if(!e)return;if(br in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():O(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=O(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}const F=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of xr(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[br]:!0,values:t,nulls:n}};var Sr=class extends N{create(e,t){return this._client.post(`/audio/speech`,{body:e,...t,headers:F([{Accept:`application/octet-stream`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},Cr=class extends N{create(e,t){return this._client.post(`/audio/transcriptions`,Tt({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}},wr=class extends N{create(e,t){return this._client.post(`/audio/translations`,Tt({body:e,...t,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}},Tr=class extends N{constructor(){super(...arguments),this.transcriptions=new Cr(this._client),this.translations=new wr(this._client),this.speech=new Sr(this._client)}};Tr.Transcriptions=Cr,Tr.Translations=wr,Tr.Speech=Sr;var Er=class extends N{create(e,t){return this._client.post(`/batches`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/batches/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/batches`,ht,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/batches/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}},Dr=class extends N{create(e,t){return this._client.post(`/assistants`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/assistants/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/assistants/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/assistants`,ht,{query:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/assistants/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},Or=class extends N{create(e,t){return this._client.post(`/realtime/sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},kr=class extends N{create(e,t){return this._client.post(`/realtime/transcription_sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},Ar=class extends N{constructor(){super(...arguments),this.sessions=new Or(this._client),this.transcriptionSessions=new kr(this._client)}};Ar.Sessions=Or,Ar.TranscriptionSessions=kr;var jr=class extends N{create(e,t){return this._client.post(`/chatkit/sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/chatkit/sessions/${e}/cancel`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}},Mr=class extends N{retrieve(e,t){return this._client.get(P`/chatkit/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chatkit/threads`,gt,{query:e,...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/chatkit/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}listItems(e,t={},n){return this._client.getAPIList(P`/chatkit/threads/${e}/items`,gt,{query:t,...n,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},n?.headers]),__security:{bearerAuth:!0}})}},Nr=class extends N{constructor(){super(...arguments),this.sessions=new jr(this._client),this.threads=new Mr(this._client)}};Nr.Sessions=jr,Nr.Threads=Mr;var Pr=class extends N{create(e,t,n){return this._client.post(P`/threads/${e}/messages`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(P`/threads/${r}/messages/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/messages/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/threads/${e}/messages`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{thread_id:r}=t;return this._client.delete(P`/threads/${r}/messages/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}},Fr=class extends N{retrieve(e,t,n){let{thread_id:r,run_id:i,...a}=t;return this._client.get(P`/threads/${r}/runs/${i}/steps/${e}`,{query:a,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t,n){let{thread_id:r,...i}=t;return this._client.getAPIList(P`/threads/${r}/runs/${e}/steps`,ht,{query:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}};const Ir=e=>{if(typeof Buffer<`u`){let t=Buffer.from(e,`base64`);return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return Array.from(new Float32Array(r.buffer))}},Lr=e=>{if(globalThis.process!==void 0)return globalThis.process.env?.[e]?.trim()||void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()||void 0};var Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si=class extends hn{constructor(){super(...arguments),Rr.add(this),Br.set(this,[]),Vr.set(this,{}),Hr.set(this,{}),Ur.set(this,void 0),Wr.set(this,void 0),Gr.set(this,void 0),Kr.set(this,void 0),qr.set(this,void 0),Jr.set(this,void 0),Yr.set(this,void 0),Xr.set(this,void 0),Zr.set(this,void 0)}[(Br=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,Rr=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new zr;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener(`abort`,()=>this.controller.abort())),this._connected();let i=nt.fromReadableStream(e,this.controller);for await(let e of i)r(this,Rr,`m`,Qr).call(this,e);if(i.controller.signal?.aborted)throw new l;return this._addRun(r(this,Rr,`m`,$r).call(this))}toReadableStream(){return new nt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,r){let i=new zr;return i._run(()=>i._runToolAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createToolAssistantStream(e,t,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...n,stream:!0},s=await e.submitToolOutputs(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)r(this,Rr,`m`,Qr).call(this,e);if(s.controller.signal?.aborted)throw new l;return this._addRun(r(this,Rr,`m`,$r).call(this))}static createThreadAssistantStream(e,t,n){let r=new zr;return r._run(()=>r._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":`stream`}})),r}static createAssistantStream(e,t,n,r){let i=new zr;return i._run(()=>i._runAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}currentEvent(){return r(this,Yr,`f`)}currentRun(){return r(this,Xr,`f`)}currentMessageSnapshot(){return r(this,Ur,`f`)}currentRunStepSnapshot(){return r(this,Zr,`f`)}async finalRunSteps(){return await this.done(),Object.values(r(this,Vr,`f`))}async finalMessages(){return await this.done(),Object.values(r(this,Hr,`f`))}async finalRun(){if(await this.done(),!r(this,Wr,`f`))throw Error(`Final run was not received.`);return r(this,Wr,`f`)}async _createThreadAssistantStream(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort()));let a={...t,stream:!0},o=await e.createAndRun(a,{...n,signal:this.controller.signal});this._connected();for await(let e of o)r(this,Rr,`m`,Qr).call(this,e);if(o.controller.signal?.aborted)throw new l;return this._addRun(r(this,Rr,`m`,$r).call(this))}async _createAssistantStream(e,t,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...n,stream:!0},s=await e.create(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)r(this,Rr,`m`,Qr).call(this,e);if(s.controller.signal?.aborted)throw new l;return this._addRun(r(this,Rr,`m`,$r).call(this))}static accumulateDelta(e,t){for(let[n,r]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=r;continue}let t=e[n];if(t==null){e[n]=r;continue}if(n===`index`||n===`type`){e[n]=r;continue}if(typeof t==`string`&&typeof r==`string`)t+=r;else if(typeof t==`number`&&typeof r==`number`)t+=r;else if(te(t)&&te(r))t=this.accumulateDelta(t,r);else if(Array.isArray(t)&&Array.isArray(r)){if(t.every(e=>typeof e==`string`||typeof e==`number`)){t.push(...r);continue}for(let e of r){if(!te(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let n=e.index;if(n==null)throw console.error(e),Error("Expected array delta entry to have an `index` property");if(typeof n!=`number`)throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);let r=t[n];r==null?t.push(e):t[n]=this.accumulateDelta(r,e)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${r}, accValue: ${t}`);e[n]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,r){return await this._createAssistantStream(t,e,n,r)}async _runToolAssistantStream(e,t,n,r){return await this._createToolAssistantStream(t,e,n,r)}};zr=si,Qr=function(e){if(!this.ended)switch(n(this,Yr,e,`f`),r(this,Rr,`m`,ni).call(this,e),e.event){case`thread.created`:break;case`thread.run.created`:case`thread.run.queued`:case`thread.run.in_progress`:case`thread.run.requires_action`:case`thread.run.completed`:case`thread.run.incomplete`:case`thread.run.failed`:case`thread.run.cancelling`:case`thread.run.cancelled`:case`thread.run.expired`:r(this,Rr,`m`,oi).call(this,e);break;case`thread.run.step.created`:case`thread.run.step.in_progress`:case`thread.run.step.delta`:case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:r(this,Rr,`m`,ti).call(this,e);break;case`thread.message.created`:case`thread.message.in_progress`:case`thread.message.delta`:case`thread.message.completed`:case`thread.message.incomplete`:r(this,Rr,`m`,ei).call(this,e);break;case`error`:throw Error(`Encountered an error event in event processing - errors should be processed earlier`);default:}},$r=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);if(!r(this,Wr,`f`))throw Error(`Final run has not been received`);return r(this,Wr,`f`)},ei=function(e){let[t,i]=r(this,Rr,`m`,ii).call(this,e,r(this,Ur,`f`));n(this,Ur,t,`f`),r(this,Hr,`f`)[t.id]=t;for(let e of i){let n=t.content[e.index];n?.type==`text`&&this._emit(`textCreated`,n.text)}switch(e.event){case`thread.message.created`:this._emit(`messageCreated`,e.data);break;case`thread.message.in_progress`:break;case`thread.message.delta`:if(this._emit(`messageDelta`,e.data.delta,t),e.data.delta.content)for(let i of e.data.delta.content){if(i.type==`text`&&i.text){let e=i.text,n=t.content[i.index];if(n&&n.type==`text`)this._emit(`textDelta`,e,n.text);else throw Error(`The snapshot associated with this text delta is not text or missing`)}if(i.index!=r(this,Gr,`f`)){if(r(this,Kr,`f`))switch(r(this,Kr,`f`).type){case`text`:this._emit(`textDone`,r(this,Kr,`f`).text,r(this,Ur,`f`));break;case`image_file`:this._emit(`imageFileDone`,r(this,Kr,`f`).image_file,r(this,Ur,`f`));break}n(this,Gr,i.index,`f`)}n(this,Kr,t.content[i.index],`f`)}break;case`thread.message.completed`:case`thread.message.incomplete`:if(r(this,Gr,`f`)!==void 0){let t=e.data.content[r(this,Gr,`f`)];if(t)switch(t.type){case`image_file`:this._emit(`imageFileDone`,t.image_file,r(this,Ur,`f`));break;case`text`:this._emit(`textDone`,t.text,r(this,Ur,`f`));break}}r(this,Ur,`f`)&&this._emit(`messageDone`,e.data),n(this,Ur,void 0,`f`)}},ti=function(e){let t=r(this,Rr,`m`,ri).call(this,e);switch(n(this,Zr,t,`f`),e.event){case`thread.run.step.created`:this._emit(`runStepCreated`,e.data);break;case`thread.run.step.delta`:let i=e.data.delta;if(i.step_details&&i.step_details.type==`tool_calls`&&i.step_details.tool_calls&&t.step_details.type==`tool_calls`)for(let e of i.step_details.tool_calls)e.index==r(this,qr,`f`)?this._emit(`toolCallDelta`,e,t.step_details.tool_calls[e.index]):(r(this,Jr,`f`)&&this._emit(`toolCallDone`,r(this,Jr,`f`)),n(this,qr,e.index,`f`),n(this,Jr,t.step_details.tool_calls[e.index],`f`),r(this,Jr,`f`)&&this._emit(`toolCallCreated`,r(this,Jr,`f`)));this._emit(`runStepDelta`,e.data.delta,t);break;case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:n(this,Zr,void 0,`f`),e.data.step_details.type==`tool_calls`&&r(this,Jr,`f`)&&(this._emit(`toolCallDone`,r(this,Jr,`f`)),n(this,Jr,void 0,`f`)),this._emit(`runStepDone`,e.data,t);break;case`thread.run.step.in_progress`:break}},ni=function(e){r(this,Br,`f`).push(e),this._emit(`event`,e)},ri=function(e){switch(e.event){case`thread.run.step.created`:return r(this,Vr,`f`)[e.data.id]=e.data,e.data;case`thread.run.step.delta`:let t=r(this,Vr,`f`)[e.data.id];if(!t)throw Error(`Received a RunStepDelta before creation of a snapshot`);let n=e.data;if(n.delta){let i=zr.accumulateDelta(t,n.delta);r(this,Vr,`f`)[e.data.id]=i}return r(this,Vr,`f`)[e.data.id];case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:case`thread.run.step.in_progress`:r(this,Vr,`f`)[e.data.id]=e.data;break}if(r(this,Vr,`f`)[e.data.id])return r(this,Vr,`f`)[e.data.id];throw Error(`No snapshot available`)},ii=function(e,t){let n=[];switch(e.event){case`thread.message.created`:return[e.data,n];case`thread.message.delta`:if(!t)throw Error(`Received a delta with no existing snapshot (there should be one from message creation)`);let i=e.data;if(i.delta.content)for(let e of i.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=r(this,Rr,`m`,ai).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case`thread.message.in_progress`:case`thread.message.completed`:case`thread.message.incomplete`:if(t)return[t,n];throw Error(`Received thread message event with no existing snapshot`)}throw Error(`Tried to accumulate a non-message event`)},ai=function(e,t){return zr.accumulateDelta(t,e)},oi=function(e){switch(n(this,Xr,e.data,`f`),e.event){case`thread.run.created`:break;case`thread.run.queued`:break;case`thread.run.in_progress`:break;case`thread.run.requires_action`:case`thread.run.cancelled`:case`thread.run.failed`:case`thread.run.completed`:case`thread.run.expired`:case`thread.run.incomplete`:n(this,Wr,e.data,`f`),r(this,Jr,`f`)&&(this._emit(`toolCallDone`,r(this,Jr,`f`)),n(this,Jr,void 0,`f`));break;case`thread.run.cancelling`:break}};var ci=class extends N{constructor(){super(...arguments),this.steps=new Fr(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(P`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(P`/threads/${r}/runs/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/runs/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/threads/${e}/runs`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(P`/threads/${r}/runs/${e}/cancel`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(r.id,{thread_id:e},n)}createAndStream(e,t,n){return si.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...r}}).withResponse();switch(i.status){case`queued`:case`in_progress`:case`cancelling`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`requires_action`:case`incomplete`:case`cancelled`:case`completed`:case`failed`:case`expired`:return i}}}stream(e,t,n){return si.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async submitToolOutputsAndPoll(e,t,n){let r=await this.submitToolOutputs(e,t,n);return await this.poll(r.id,t,n)}submitToolOutputsStream(e,t,n){return si.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}};ci.Steps=Fr;var li=class extends N{constructor(){super(...arguments),this.runs=new ci(this._client),this.messages=new Pr(this._client)}create(e={},t){return this._client.post(`/threads`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/threads/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}createAndRun(e,t){return this._client.post(`/threads/runs`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async createAndRunPoll(e,t){let n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return si.createThreadAssistantStream(e,this._client.beta.threads,t)}};li.Runs=ci,li.Messages=Pr;var ui=class extends N{constructor(){super(...arguments),this.realtime=new Ar(this._client),this.chatkit=new Nr(this._client),this.assistants=new Dr(this._client),this.threads=new li(this._client)}};ui.Realtime=Ar,ui.ChatKit=Nr,ui.Assistants=Dr,ui.Threads=li;var di=class extends N{create(e,t){return this._client.post(`/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}},fi=class extends N{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(P`/containers/${r}/files/${e}/content`,{...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},pi=class extends N{constructor(){super(...arguments),this.content=new fi(this._client)}create(e,t,n){return this._client.post(P`/containers/${e}/files`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(P`/containers/${r}/files/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/containers/${e}/files`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(P`/containers/${r}/files/${e}`,{...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}};pi.Content=fi;var mi=class extends N{constructor(){super(...arguments),this.files=new pi(this._client)}create(e,t){return this._client.post(`/containers`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/containers/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/containers`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/containers/${e}`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}};mi.Files=pi;var hi=class extends N{create(e,t,n){let{include:r,...i}=t;return this._client.post(P`/conversations/${e}/items`,{query:{include:r},body:i,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{conversation_id:r,...i}=t;return this._client.get(P`/conversations/${r}/items/${e}`,{query:i,...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/conversations/${e}/items`,gt,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{conversation_id:r}=t;return this._client.delete(P`/conversations/${r}/items/${e}`,{...n,__security:{bearerAuth:!0}})}},gi=class extends N{constructor(){super(...arguments),this.items=new hi(this._client)}create(e={},t){return this._client.post(`/conversations`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/conversations/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}};gi.Items=hi;var _i=class extends N{create(e,t){let n=!!e.encoding_format,r=n?e.encoding_format:`base64`;n&&$e(this._client).debug(`embeddings/user defined encoding_format:`,e.encoding_format);let i=this._client.post(`/embeddings`,{body:{...e,encoding_format:r},...t,__security:{bearerAuth:!0}});return n?i:($e(this._client).debug(`embeddings/decoding base64 embeddings from base64`),i._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=Ir(t)}),e)))}},vi=class extends N{retrieve(e,t,n){let{eval_id:r,run_id:i}=t;return this._client.get(P`/evals/${r}/runs/${i}/output_items/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t,n){let{eval_id:r,...i}=t;return this._client.getAPIList(P`/evals/${r}/runs/${e}/output_items`,ht,{query:i,...n,__security:{bearerAuth:!0}})}},yi=class extends N{constructor(){super(...arguments),this.outputItems=new vi(this._client)}create(e,t,n){return this._client.post(P`/evals/${e}/runs`,{body:t,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{eval_id:r}=t;return this._client.get(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/evals/${e}/runs`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{eval_id:r}=t;return this._client.delete(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}cancel(e,t,n){let{eval_id:r}=t;return this._client.post(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}};yi.OutputItems=vi;var bi=class extends N{constructor(){super(...arguments),this.runs=new yi(this._client)}create(e,t){return this._client.post(`/evals`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/evals/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/evals`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}};bi.Runs=yi;var xi=class extends N{create(e,t){return this._client.post(`/files`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/files/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/files`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/files/${e}`,{...t,__security:{bearerAuth:!0}})}content(e,t){return this._client.get(P`/files/${e}/content`,{...t,headers:F([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=1800*1e3}={}){let r=new Set([`processed`,`error`,`deleted`]),i=Date.now(),a=await this.retrieve(e);for(;!a.status||!r.has(a.status);)if(await ie(t),a=await this.retrieve(e),Date.now()-i>n)throw new d({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return a}},Si=class extends N{},Ci=class extends N{run(e,t){return this._client.post(`/fine_tuning/alpha/graders/run`,{body:e,...t,__security:{bearerAuth:!0}})}validate(e,t){return this._client.post(`/fine_tuning/alpha/graders/validate`,{body:e,...t,__security:{bearerAuth:!0}})}},wi=class extends N{constructor(){super(...arguments),this.graders=new Ci(this._client)}};wi.Graders=Ci;var Ti=class extends N{create(e,t,n){return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(P`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{fine_tuned_model_checkpoint:r}=t;return this._client.delete(P`/fine_tuning/checkpoints/${r}/permissions/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Ei=class extends N{constructor(){super(...arguments),this.permissions=new Ti(this._client)}};Ei.Permissions=Ti;var Di=class extends N{list(e,t={},n){return this._client.getAPIList(P`/fine_tuning/jobs/${e}/checkpoints`,ht,{query:t,...n,__security:{bearerAuth:!0}})}},Oi=class extends N{constructor(){super(...arguments),this.checkpoints=new Di(this._client)}create(e,t){return this._client.post(`/fine_tuning/jobs`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/fine_tuning/jobs/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/fine_tuning/jobs`,ht,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}listEvents(e,t={},n){return this._client.getAPIList(P`/fine_tuning/jobs/${e}/events`,ht,{query:t,...n,__security:{bearerAuth:!0}})}pause(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/pause`,{...t,__security:{bearerAuth:!0}})}resume(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/resume`,{...t,__security:{bearerAuth:!0}})}};Oi.Checkpoints=Di;var ki=class extends N{constructor(){super(...arguments),this.methods=new Si(this._client),this.jobs=new Oi(this._client),this.checkpoints=new Ei(this._client),this.alpha=new wi(this._client)}};ki.Methods=Si,ki.Jobs=Oi,ki.Checkpoints=Ei,ki.Alpha=wi;var Ai=class extends N{},ji=class extends N{constructor(){super(...arguments),this.graderModels=new Ai(this._client)}};ji.GraderModels=Ai;var Mi=class extends N{createVariation(e,t){return this._client.post(`/images/variations`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}edit(e,t){return this._client.post(`/images/edits`,Tt({body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}},this._client))}generate(e,t){return this._client.post(`/images/generations`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}},Ni=class extends N{retrieve(e,t){return this._client.get(P`/models/${e}`,{...t,__security:{bearerAuth:!0}})}list(e){return this._client.getAPIList(`/models`,mt,{...e,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/models/${e}`,{...t,__security:{bearerAuth:!0}})}},Pi=class extends N{create(e,t){return this._client.post(`/moderations`,{body:e,...t,__security:{bearerAuth:!0}})}},Fi=class extends N{accept(e,t,n){return this._client.post(P`/realtime/calls/${e}/accept`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}hangup(e,t){return this._client.post(P`/realtime/calls/${e}/hangup`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}refer(e,t,n){return this._client.post(P`/realtime/calls/${e}/refer`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}reject(e,t={},n){return this._client.post(P`/realtime/calls/${e}/reject`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}},Ii=class extends N{create(e,t){return this._client.post(`/realtime/client_secrets`,{body:e,...t,__security:{bearerAuth:!0}})}},Li=class extends N{constructor(){super(...arguments),this.clientSecrets=new Ii(this._client),this.calls=new Fi(this._client)}};Li.ClientSecrets=Ii,Li.Calls=Fi;function Ri(e,t){return!t||!Vi(t)?{...e,output_parsed:null,output:e.output.map(e=>e.type===`function_call`?{...e,parsed_arguments:null}:e.type===`message`?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}:zi(e,t)}function zi(e,t){let n=e.output.map(e=>{if(e.type===`function_call`)return{...e,parsed_arguments:Wi(t,e)};if(e.type===`message`){let n=e.content.map(e=>e.type===`output_text`?{...e,parsed:Bi(t,e.text)}:e);return{...e,content:n}}return e}),r=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,`output_text`)||Gi(r),Object.defineProperty(r,`output_parsed`,{enumerable:!0,get(){for(let e of r.output)if(e.type===`message`){for(let t of e.content)if(t.type===`output_text`&&t.parsed!==null)return t.parsed}return null}}),r}function Bi(e,t){return e.text?.format?.type===`json_schema`?`$parseRaw`in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t):null}function Vi(e){return!!Ut(e.text?.format)}function Hi(e){return e?.$brand===`auto-parseable-tool`}function Ui(e,t){return e.find(e=>e.type===`function`&&e.name===t)}function Wi(e,t){let n=Ui(e.tools??[],t.name);return{...t,...t,parsed_arguments:Hi(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function Gi(e){let t=[];for(let n of e.output)if(n.type===`message`)for(let e of n.content)e.type===`output_text`&&t.push(e.text);e.output_text=t.join(``)}var Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea=class e extends hn{constructor(e){super(),Ki.add(this),qi.set(this,void 0),Ji.set(this,void 0),Yi.set(this,void 0),n(this,qi,e,`f`)}static createResponse(t,n,r){let i=new e(n);return i._run(()=>i._createOrRetrieveResponse(t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createOrRetrieveResponse(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),r(this,Ki,`m`,Xi).call(this);let a,o=null;`response_id`in t?(a=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),o=t.starting_after??null):a=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let e of a)r(this,Ki,`m`,Zi).call(this,e,o);if(a.controller.signal?.aborted)throw new l;return r(this,Ki,`m`,Qi).call(this)}[(qi=new WeakMap,Ji=new WeakMap,Yi=new WeakMap,Ki=new WeakSet,Xi=function(){this.ended||n(this,Ji,void 0,`f`)},Zi=function(e,t){if(this.ended)return;let n=(e,n)=>{(t==null||n.sequence_number>t)&&this._emit(e,n)},i=r(this,Ki,`m`,$i).call(this,e);switch(n(`event`,e),e.type){case`response.output_text.delta`:{let t=i.output[e.output_index];if(!t)throw new s(`missing output at index ${e.output_index}`);if(t.type===`message`){let r=t.content[e.content_index];if(!r)throw new s(`missing content at index ${e.content_index}`);if(r.type!==`output_text`)throw new s(`expected content to be 'output_text', got ${r.type}`);n(`response.output_text.delta`,{...e,snapshot:r.text})}break}case`response.function_call_arguments.delta`:{let t=i.output[e.output_index];if(!t)throw new s(`missing output at index ${e.output_index}`);t.type===`function_call`&&n(`response.function_call_arguments.delta`,{...e,snapshot:t.arguments});break}default:n(e.type,e);break}},Qi=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);let e=r(this,Ji,`f`);if(!e)throw new s(`request ended without sending any events`);n(this,Ji,void 0,`f`);let t=ta(e,r(this,qi,`f`));return n(this,Yi,t,`f`),t},$i=function(e){let t=r(this,Ji,`f`);if(!t){if(e.type!==`response.created`)throw new s(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return t=n(this,Ji,e.response,`f`),t}switch(e.type){case`response.output_item.added`:t.output.push(e.item);break;case`response.content_part.added`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);let r=n.type,i=e.part;r===`message`&&i.type!==`reasoning_text`?n.content.push(i):r===`reasoning`&&i.type===`reasoning_text`&&(n.content||=[],n.content.push(i));break}case`response.output_text.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);if(n.type===`message`){let t=n.content[e.content_index];if(!t)throw new s(`missing content at index ${e.content_index}`);if(t.type!==`output_text`)throw new s(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case`response.function_call_arguments.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);n.type===`function_call`&&(n.arguments+=e.delta);break}case`response.reasoning_text.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);if(n.type===`reasoning`){let t=n.content?.[e.content_index];if(!t)throw new s(`missing content at index ${e.content_index}`);if(t.type!==`reasoning_text`)throw new s(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case`response.completed`:n(this,Ji,e.response,`f`);break}return t},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=r(this,Yi,`f`);if(!e)throw new s(`stream ended without producing a ChatCompletion`);return e}};function ta(e,t){return Ri(e,t)}var na=class extends N{list(e,t={},n){return this._client.getAPIList(P`/responses/${e}/input_items`,ht,{query:t,...n,__security:{bearerAuth:!0}})}},ra=class extends N{count(e={},t){return this._client.post(`/responses/input_tokens`,{body:e,...t,__security:{bearerAuth:!0}})}},ia=class extends N{constructor(){super(...arguments),this.inputItems=new na(this._client),this.inputTokens=new ra(this._client)}create(e,t){return this._client.post(`/responses`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&Gi(e),e))}retrieve(e,t={},n){return this._client.get(P`/responses/${e}`,{query:t,...n,stream:t?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&Gi(e),e))}delete(e,t){return this._client.delete(P`/responses/${e}`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>zi(t,e))}stream(e,t){return ea.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(P`/responses/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}compact(e,t){return this._client.post(`/responses/compact`,{body:e,...t,__security:{bearerAuth:!0}})}};ia.InputItems=na,ia.InputTokens=ra;var aa=class extends N{retrieve(e,t){return this._client.get(P`/skills/${e}/content`,{...t,headers:F([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},oa=class extends N{retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(P`/skills/${r}/versions/${e}/content`,{...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},sa=class extends N{constructor(){super(...arguments),this.content=new oa(this._client)}create(e,t={},n){return this._client.post(P`/skills/${e}/versions`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(P`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/skills/${e}/versions`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{skill_id:r}=t;return this._client.delete(P`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}};sa.Content=oa;var ca=class extends N{constructor(){super(...arguments),this.content=new aa(this._client),this.versions=new sa(this._client)}create(e={},t){return this._client.post(`/skills`,wt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/skills/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/skills`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}};ca.Content=aa,ca.Versions=sa;var la=class extends N{create(e,t,n){return this._client.post(P`/uploads/${e}/parts`,Tt({body:t,...n,__security:{bearerAuth:!0}},this._client))}},ua=class extends N{constructor(){super(...arguments),this.parts=new la(this._client)}create(e,t){return this._client.post(`/uploads`,{body:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/uploads/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}complete(e,t,n){return this._client.post(P`/uploads/${e}/complete`,{body:t,...n,__security:{bearerAuth:!0}})}};ua.Parts=la;const da=async e=>{let t=await Promise.allSettled(e),n=t.filter(e=>e.status===`rejected`);if(n.length){for(let e of n)console.error(e.reason);throw Error(`${n.length} promise(s) failed - see the above errors`)}let r=[];for(let e of t)e.status===`fulfilled`&&r.push(e.value);return r};var fa=class extends N{create(e,t,n){return this._client.post(P`/vector_stores/${e}/file_batches`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(P`/vector_stores/${r}/file_batches/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{vector_store_id:r}=t;return this._client.post(P`/vector_stores/${r}/file_batches/${e}/cancel`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t);return await this.poll(e,r.id,n)}listFiles(e,t,n){let{vector_store_id:r,...i}=t;return this._client.getAPIList(P`/vector_stores/${r}/file_batches/${e}/files`,ht,{query:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse();switch(i.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`failed`:case`cancelled`:case`completed`:return i}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},r){if(t==null||t.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=r?.maxConcurrency??5,a=Math.min(i,t.length),o=this._client,s=t.values(),c=[...n];async function l(e){for(let t of e){let e=await o.files.create({file:t,purpose:`assistants`},r);c.push(e.id)}}return await da(Array(a).fill(s).map(l)),await this.createAndPoll(e,{file_ids:c})}},pa=class extends N{create(e,t,n){return this._client.post(P`/vector_stores/${e}/files`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(P`/vector_stores/${r}/files/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{vector_store_id:r,...i}=t;return this._client.post(P`/vector_stores/${r}/files/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/vector_stores/${e}/files`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{vector_store_id:r}=t;return this._client.delete(P`/vector_stores/${r}/files/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(e,r.id,n)}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let i=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse(),a=i.data;switch(a.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=i.response.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`failed`:case`completed`:return a}}}async upload(e,t,n){let r=await this._client.files.create({file:t,purpose:`assistants`},n);return this.create(e,{file_id:r.id},n)}async uploadAndPoll(e,t,n){let r=await this.upload(e,t,n);return await this.poll(e,r.id,n)}content(e,t,n){let{vector_store_id:r}=t;return this._client.getAPIList(P`/vector_stores/${r}/files/${e}/content`,mt,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}},ma=class extends N{constructor(){super(...arguments),this.files=new pa(this._client),this.fileBatches=new fa(this._client)}create(e,t){return this._client.post(`/vector_stores`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/vector_stores/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/vector_stores/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/vector_stores`,ht,{query:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/vector_stores/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}search(e,t,n){return this._client.getAPIList(P`/vector_stores/${e}/search`,mt,{body:t,method:`post`,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}};ma.Files=pa,ma.FileBatches=fa;var ha=class extends N{create(e,t){return this._client.post(`/videos`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/videos`,gt,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}createCharacter(e,t){return this._client.post(`/videos/characters`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}downloadContent(e,t={},n){return this._client.get(P`/videos/${e}/content`,{query:t,...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit(e,t){return this._client.post(`/videos/edits`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}extend(e,t){return this._client.post(`/videos/extensions`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}getCharacter(e,t){return this._client.get(P`/videos/characters/${e}`,{...t,__security:{bearerAuth:!0}})}remix(e,t,n){return this._client.post(P`/videos/${e}/remix`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}},ga,_a,va,ya=class extends N{constructor(){super(...arguments),ga.add(this)}async unwrap(e,t,n=this._client.webhookSecret,r=300){return await this.verifySignature(e,t,n,r),JSON.parse(e)}async verifySignature(e,t,n=this._client.webhookSecret,i=300){if(typeof crypto>`u`||typeof crypto.subtle.importKey!=`function`||typeof crypto.subtle.verify!=`function`)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");r(this,ga,`m`,_a).call(this,n);let a=F([t]).values,o=r(this,ga,`m`,va).call(this,a,`webhook-signature`),s=r(this,ga,`m`,va).call(this,a,`webhook-timestamp`),c=r(this,ga,`m`,va).call(this,a,`webhook-id`),l=parseInt(s,10);if(isNaN(l))throw new S(`Invalid webhook timestamp format`);let u=Math.floor(Date.now()/1e3);if(u-l>i)throw new S(`Webhook timestamp is too old`);if(l>u+i)throw new S(`Webhook timestamp is too new`);let d=o.split(` `).map(e=>e.startsWith(`v1,`)?e.substring(3):e),f=n.startsWith(`whsec_`)?Buffer.from(n.replace(`whsec_`,``),`base64`):Buffer.from(n,`utf-8`),p=c?`${c}.${s}.${e}`:`${s}.${e}`,m=await crypto.subtle.importKey(`raw`,f,{name:`HMAC`,hash:`SHA-256`},!1,[`verify`]);for(let e of d)try{let t=Buffer.from(e,`base64`);if(await crypto.subtle.verify(`HMAC`,m,t,new TextEncoder().encode(p)))return}catch{continue}throw new S(`The given webhook signature does not match the expected signature`)}};ga=new WeakSet,_a=function(e){if(typeof e!=`string`||e.length===0)throw Error(`The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function`)},va=function(e,t){if(!e)throw Error(`Headers are required`);let n=e.get(t);if(n==null)throw Error(`Missing required header: ${t}`);return n};var ba,xa,Sa,Ca,I=class{constructor({baseURL:e=Lr(`OPENAI_BASE_URL`),apiKey:t=Lr(`OPENAI_API_KEY`)??null,adminAPIKey:r=Lr(`OPENAI_ADMIN_KEY`)??null,organization:i=Lr(`OPENAI_ORG_ID`)??null,project:a=Lr(`OPENAI_PROJECT_ID`)??null,webhookSecret:o=Lr(`OPENAI_WEBHOOK_SECRET`)??null,workloadIdentity:c,...l}={}){ba.add(this),Sa.set(this,void 0),this.completions=new di(this),this.chat=new Xn(this),this.embeddings=new _i(this),this.files=new xi(this),this.images=new Mi(this),this.audio=new Tr(this),this.moderations=new Pi(this),this.models=new Ni(this),this.fineTuning=new ki(this),this.graders=new ji(this),this.vectorStores=new ma(this),this.webhooks=new ya(this),this.beta=new ui(this),this.batches=new Er(this),this.uploads=new ua(this),this.admin=new yr(this),this.responses=new ia(this),this.realtime=new Li(this),this.conversations=new gi(this),this.evals=new bi(this),this.containers=new mi(this),this.skills=new ca(this),this.videos=new ha(this);let u={apiKey:t,adminAPIKey:r,organization:i,project:a,webhookSecret:o,workloadIdentity:c,...l,baseURL:e||`https://api.openai.com/v1`};if(t&&c)throw new s("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!t&&!r&&!c)throw new s("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!u.dangerouslyAllowBrowser&&oe())throw new s(`It looks like you're running in a browser-like environment.
|
|
7
|
+
\r `.includes(e[r]);)r++};return o()},Mn=e=>An(e,Dn.ALL^Dn.NUM);var Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn=class e extends Tn{constructor(e){super(),Nn.add(this),Pn.set(this,void 0),Fn.set(this,void 0),In.set(this,void 0),n(this,Pn,e,`f`),n(this,Fn,[],`f`)}get currentChatCompletionSnapshot(){return r(this,In,`f`)}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,r){let i=new e(n);return i._run(()=>i._runChatCompletion(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createChatCompletion(e,t,n){super._createChatCompletion;let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),r(this,Nn,`m`,Ln).call(this);let a=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let e of a)r(this,Nn,`m`,zn).call(this,e);if(a.controller.signal?.aborted)throw new l;return this._addChatCompletion(r(this,Nn,`m`,Hn).call(this))}async _fromReadableStream(e,t){let n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener(`abort`,()=>this.controller.abort())),r(this,Nn,`m`,Ln).call(this),this._connected();let i=nt.fromReadableStream(e,this.controller),a;for await(let e of i)a&&a!==e.id&&this._addChatCompletion(r(this,Nn,`m`,Hn).call(this)),r(this,Nn,`m`,zn).call(this,e),a=e.id;if(i.controller.signal?.aborted)throw new l;return this._addChatCompletion(r(this,Nn,`m`,Hn).call(this))}[(Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Nn=new WeakSet,Ln=function(){this.ended||n(this,In,void 0,`f`)},Rn=function(e){let t=r(this,Fn,`f`)[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},r(this,Fn,`f`)[e.index]=t,t)},zn=function(e){if(this.ended)return;let t=r(this,Nn,`m`,Wn).call(this,e);this._emit(`chunk`,e,t);for(let n of e.choices){let e=t.choices[n.index];n.delta.content!=null&&e.message?.role===`assistant`&&e.message?.content&&(this._emit(`content`,n.delta.content,e.message.content),this._emit(`content.delta`,{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),n.delta.refusal!=null&&e.message?.role===`assistant`&&e.message?.refusal&&this._emit(`refusal.delta`,{delta:n.delta.refusal,snapshot:e.message.refusal}),n.logprobs?.content!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.content.delta`,{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),n.logprobs?.refusal!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.refusal.delta`,{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let i=r(this,Nn,`m`,Rn).call(this,e);e.finish_reason&&(r(this,Nn,`m`,Vn).call(this,e),i.current_tool_call_index!=null&&r(this,Nn,`m`,Bn).call(this,e,i.current_tool_call_index));for(let t of n.delta.tool_calls??[])i.current_tool_call_index!==t.index&&(r(this,Nn,`m`,Vn).call(this,e),i.current_tool_call_index!=null&&r(this,Nn,`m`,Bn).call(this,e,i.current_tool_call_index)),i.current_tool_call_index=t.index;for(let t of n.delta.tool_calls??[]){let n=e.message.tool_calls?.[t.index];n?.type&&(n?.type===`function`?this._emit(`tool_calls.function.arguments.delta`,{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??``}):n?.type)}}},Bn=function(e,t){if(r(this,Nn,`m`,Rn).call(this,e).done_tool_calls.has(t))return;let n=e.message.tool_calls?.[t];if(!n)throw Error(`no tool call snapshot`);if(!n.type)throw Error("tool call snapshot missing `type`");if(n.type===`function`){let e=r(this,Pn,`f`)?.tools?.find(e=>Ht(e)&&e.function.name===n.function.name);this._emit(`tool_calls.function.arguments.done`,{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:Wt(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else n.type},Vn=function(e){let t=r(this,Nn,`m`,Rn).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let n=r(this,Nn,`m`,Un).call(this);this._emit(`content.done`,{content:e.message.content,parsed:n?n.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit(`refusal.done`,{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit(`logprobs.content.done`,{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit(`logprobs.refusal.done`,{refusal:e.logprobs.refusal}))},Hn=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);let e=r(this,In,`f`);if(!e)throw new s(`request ended without sending any chunks`);return n(this,In,void 0,`f`),n(this,Fn,[],`f`),Kn(e,r(this,Pn,`f`))},Un=function(){let e=r(this,Pn,`f`)?.response_format;return Ut(e)?e:null},Wn=function(e){var t,i,a,o;let s=r(this,In,`f`),{choices:c,...l}=e;s?Object.assign(s,l):s=n(this,In,{...l,choices:[]},`f`);for(let{delta:n,finish_reason:c,index:l,logprobs:u=null,...d}of e.choices){let e=s.choices[l];if(e||=s.choices[l]={finish_reason:c,index:l,message:{},logprobs:u,...d},u)if(!e.logprobs)e.logprobs=Object.assign({},u);else{let{content:n,refusal:r,...a}=u;Object.assign(e.logprobs,a),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),r&&((i=e.logprobs).refusal??(i.refusal=[]),e.logprobs.refusal.push(...r))}if(c&&(e.finish_reason=c,r(this,Pn,`f`)&&Xt(r(this,Pn,`f`)))){if(c===`length`)throw new b;if(c===`content_filter`)throw new x}if(Object.assign(e,d),!n)continue;let{content:f,refusal:p,function_call:m,role:h,tool_calls:g,..._}=n;if(Object.assign(e.message,_),p&&(e.message.refusal=(e.message.refusal||``)+p),h&&(e.message.role=h),m&&(e.message.function_call?(m.name&&(e.message.function_call.name=m.name),m.arguments&&((a=e.message.function_call).arguments??(a.arguments=``),e.message.function_call.arguments+=m.arguments)):e.message.function_call=m),f&&(e.message.content=(e.message.content||``)+f,!e.message.refusal&&r(this,Nn,`m`,Un).call(this)&&(e.message.parsed=Mn(e.message.content))),g){e.message.tool_calls||(e.message.tool_calls=[]);for(let{index:t,id:n,type:i,function:a,...s}of g){let c=(o=e.message.tool_calls)[t]??(o[t]={});Object.assign(c,s),n&&(c.id=n),i&&(c.type=i),a&&(c.function??={name:a.name??``,arguments:``}),a?.name&&(c.function.name=a.name),a?.arguments&&(c.function.arguments+=a.arguments,Yt(r(this,Pn,`f`),c)&&(c.function.parsed_arguments=Mn(c.function.arguments)))}}}return s},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`chunk`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new nt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function Kn(e,t){let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...c}=e;return Gt({...c,id:n,choices:r.map(({message:t,finish_reason:n,index:r,logprobs:i,...a})=>{if(!n)throw new s(`missing finish_reason for choice ${r}`);let{content:o=null,function_call:c,tool_calls:l,...u}=t,d=t.role;if(!d)throw new s(`missing role for choice ${r}`);if(c){let{arguments:e,name:l}=c;if(e==null)throw new s(`missing function_call.arguments for choice ${r}`);if(!l)throw new s(`missing function_call.name for choice ${r}`);return{...a,message:{content:o,function_call:{arguments:e,name:l},role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}return l?{...a,index:r,finish_reason:n,logprobs:i,message:{...u,role:d,content:o,refusal:t.refusal??null,tool_calls:l.map((t,n)=>{let{function:i,type:a,id:o,...c}=t,{arguments:l,name:u,...d}=i||{};if(o==null)throw new s(`missing choices[${r}].tool_calls[${n}].id\n${qn(e)}`);if(a==null)throw new s(`missing choices[${r}].tool_calls[${n}].type\n${qn(e)}`);if(u==null)throw new s(`missing choices[${r}].tool_calls[${n}].function.name\n${qn(e)}`);if(l==null)throw new s(`missing choices[${r}].tool_calls[${n}].function.arguments\n${qn(e)}`);return{...c,id:o,type:a,function:{...d,name:u,arguments:l}}})}}:{...a,message:{...u,content:o,role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}),created:i,model:a,object:`chat.completion`,...o?{system_fingerprint:o}:{}},t)}function qn(e){return JSON.stringify(e)}var Jn=class e extends Gn{static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,r){let i=new e(n),a={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`runTools`}};return i._run(()=>i._runTools(t,n,a)),i}},Yn=class extends N{constructor(){super(...arguments),this.messages=new Vt(this._client)}create(e,t){return this._client.post(`/chat/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/chat/completions/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chat/completions`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}parse(e,t){return Qt(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":`chat.completions.parse`}})._thenUnwrap(t=>Kt(t,e))}runTools(e,t){return e.stream?Jn.runTools(this._client,e,t):En.runTools(this._client,e,t)}stream(e,t){return Gn.createChatCompletion(this._client,e,t)}};Yn.Messages=Vt;var Xn=class extends N{constructor(){super(...arguments),this.completions=new Yn(this._client)}};Xn.Completions=Yn;var Zn=class extends N{create(e,t){return this._client.post(`/organization/admin_api_keys`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/admin_api_keys`,ht,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},Qn=class extends N{list(e={},t){return this._client.getAPIList(`/organization/audit_logs`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}},$n=class extends N{create(e,t){return this._client.post(`/organization/certificates`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(P`/organization/certificates/${e}`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/certificates/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/certificates`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/certificates/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}activate(e,t){return this._client.getAPIList(`/organization/certificates/activate`,mt,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t){return this._client.getAPIList(`/organization/certificates/deactivate`,mt,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}},er=class extends N{retrieve(e){return this._client.get(`/organization/data_retention`,{...e,__security:{adminAPIKeyAuth:!0}})}update(e,t){return this._client.post(`/organization/data_retention`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}},tr=class extends N{create(e,t){return this._client.post(`/organization/invites`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/invites`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},nr=class extends N{create(e,t){return this._client.post(`/organization/roles`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/roles/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/roles`,_t,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},rr=class extends N{create(e,t){return this._client.post(`/organization/spend_alerts`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/spend_alerts/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/spend_alerts`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/spend_alerts/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},ir=class extends N{audioSpeeches(e,t){return this._client.get(`/organization/usage/audio_speeches`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions(e,t){return this._client.get(`/organization/usage/audio_transcriptions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions(e,t){return this._client.get(`/organization/usage/code_interpreter_sessions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}completions(e,t){return this._client.get(`/organization/usage/completions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}costs(e,t){return this._client.get(`/organization/costs`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}embeddings(e,t){return this._client.get(`/organization/usage/embeddings`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}fileSearchCalls(e,t){return this._client.get(`/organization/usage/file_search_calls`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}images(e,t){return this._client.get(`/organization/usage/images`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}moderations(e,t){return this._client.get(`/organization/usage/moderations`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}vectorStores(e,t){return this._client.get(`/organization/usage/vector_stores`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}webSearchCalls(e,t){return this._client.get(`/organization/usage/web_search_calls`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}},ar=class extends N{create(e,t,n){return this._client.post(P`/organization/groups/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{group_id:r}=t;return this._client.get(P`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/groups/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(P`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},or=class extends N{create(e,t,n){return this._client.post(P`/organization/groups/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{group_id:r}=t;return this._client.get(P`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/groups/${e}/users`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(P`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},sr=class extends N{constructor(){super(...arguments),this.users=new or(this._client),this.roles=new ar(this._client)}create(e,t){return this._client.post(`/organization/groups`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/groups/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/groups`,_t,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}};sr.Users=or,sr.Roles=ar;var cr=class extends N{retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/api_keys`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},lr=class extends N{list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/certificates`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}activate(e,t,n){return this._client.getAPIList(P`/organization/projects/${e}/certificates/activate`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t,n){return this._client.getAPIList(P`/organization/projects/${e}/certificates/deactivate`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}},ur=class extends N{retrieve(e,t){return this._client.get(P`/organization/projects/${e}/data_retention`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/projects/${e}/data_retention`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}},dr=class extends N{retrieve(e,t){return this._client.get(P`/organization/projects/${e}/hosted_tool_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/projects/${e}/hosted_tool_permissions`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}},fr=class extends N{retrieve(e,t){return this._client.get(P`/organization/projects/${e}/model_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/projects/${e}/model_permissions`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/projects/${e}/model_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}},pr=class extends N{listRateLimits(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/rate_limits`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}updateRateLimit(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/rate_limits/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}},mr=class extends N{create(e,t,n){return this._client.post(P`/projects/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/roles/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/projects/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},hr=class extends N{create(e,t,n){return this._client.post(P`/organization/projects/${e}/service_accounts`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/service_accounts/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/service_accounts`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},gr=class extends N{create(e,t,n){return this._client.post(P`/organization/projects/${e}/spend_alerts`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/spend_alerts/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/spend_alerts`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/spend_alerts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},_r=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/groups/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,group_id:i}=t;return this._client.get(P`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(P`/projects/${r}/groups/${e}/roles`,_t,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,group_id:i}=t;return this._client.delete(P`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},vr=class extends N{constructor(){super(...arguments),this.roles=new _r(this._client)}create(e,t,n){return this._client.post(P`/organization/projects/${e}/groups`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,...i}=t;return this._client.get(P`/organization/projects/${r}/groups/${e}`,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/groups`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/groups/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}};vr.Roles=_r;var yr=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/projects/${r}/users/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,user_id:i}=t;return this._client.get(P`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(P`/projects/${r}/users/${e}/roles`,_t,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,user_id:i}=t;return this._client.delete(P`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},br=class extends N{constructor(){super(...arguments),this.roles=new yr(this._client)}create(e,t,n){return this._client.post(P`/organization/projects/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(P`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(P`/organization/projects/${r}/users/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/projects/${e}/users`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(P`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}};br.Roles=yr;var xr=class extends N{constructor(){super(...arguments),this.users=new br(this._client),this.serviceAccounts=new hr(this._client),this.apiKeys=new cr(this._client),this.rateLimits=new pr(this._client),this.modelPermissions=new fr(this._client),this.hostedToolPermissions=new dr(this._client),this.groups=new vr(this._client),this.roles=new mr(this._client),this.dataRetention=new ur(this._client),this.spendAlerts=new gr(this._client),this.certificates=new lr(this._client)}create(e,t){return this._client.post(`/organization/projects`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(P`/organization/projects/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/projects/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/projects`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}archive(e,t){return this._client.post(P`/organization/projects/${e}/archive`,{...t,__security:{adminAPIKeyAuth:!0}})}};xr.Users=br,xr.ServiceAccounts=hr,xr.APIKeys=cr,xr.RateLimits=pr,xr.ModelPermissions=fr,xr.HostedToolPermissions=dr,xr.Groups=vr,xr.Roles=mr,xr.DataRetention=ur,xr.SpendAlerts=gr,xr.Certificates=lr;var Sr=class extends N{create(e,t,n){return this._client.post(P`/organization/users/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{user_id:r}=t;return this._client.get(P`/organization/users/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/organization/users/${e}/roles`,_t,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{user_id:r}=t;return this._client.delete(P`/organization/users/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Cr=class extends N{constructor(){super(...arguments),this.roles=new Sr(this._client)}retrieve(e,t){return this._client.get(P`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(P`/organization/users/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/users`,gt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(P`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}};Cr.Roles=Sr;var wr=class extends N{constructor(){super(...arguments),this.auditLogs=new Qn(this._client),this.adminAPIKeys=new Zn(this._client),this.usage=new ir(this._client),this.invites=new tr(this._client),this.users=new Cr(this._client),this.groups=new sr(this._client),this.roles=new nr(this._client),this.dataRetention=new er(this._client),this.spendAlerts=new rr(this._client),this.certificates=new $n(this._client),this.projects=new xr(this._client)}};wr.AuditLogs=Qn,wr.AdminAPIKeys=Zn,wr.Usage=ir,wr.Invites=tr,wr.Users=Cr,wr.Groups=sr,wr.Roles=nr,wr.DataRetention=er,wr.SpendAlerts=rr,wr.Certificates=$n,wr.Projects=xr;var Tr=class extends N{constructor(){super(...arguments),this.organization=new wr(this._client)}};Tr.Organization=wr;const Er=Symbol(`brand.privateNullableHeaders`);function*Dr(e){if(!e)return;if(Er in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():O(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=O(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}const F=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Dr(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[Er]:!0,values:t,nulls:n}};var Or=class extends N{create(e,t){return this._client.post(`/audio/speech`,{body:e,...t,headers:F([{Accept:`application/octet-stream`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},kr=class extends N{create(e,t){return this._client.post(`/audio/transcriptions`,Tt({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}},Ar=class extends N{create(e,t){return this._client.post(`/audio/translations`,Tt({body:e,...t,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}},jr=class extends N{constructor(){super(...arguments),this.transcriptions=new kr(this._client),this.translations=new Ar(this._client),this.speech=new Or(this._client)}};jr.Transcriptions=kr,jr.Translations=Ar,jr.Speech=Or;var Mr=class extends N{create(e,t){return this._client.post(`/batches`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/batches/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/batches`,ht,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/batches/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}},Nr=class extends N{create(e,t){return this._client.post(`/assistants`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/assistants/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/assistants/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/assistants`,ht,{query:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/assistants/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},Pr=class extends N{create(e,t){return this._client.post(`/realtime/sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},Fr=class extends N{create(e,t){return this._client.post(`/realtime/transcription_sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}},Ir=class extends N{constructor(){super(...arguments),this.sessions=new Pr(this._client),this.transcriptionSessions=new Fr(this._client)}};Ir.Sessions=Pr,Ir.TranscriptionSessions=Fr;var Lr=class extends N{create(e,t){return this._client.post(`/chatkit/sessions`,{body:e,...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/chatkit/sessions/${e}/cancel`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}},Rr=class extends N{retrieve(e,t){return this._client.get(P`/chatkit/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chatkit/threads`,gt,{query:e,...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/chatkit/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}listItems(e,t={},n){return this._client.getAPIList(P`/chatkit/threads/${e}/items`,gt,{query:t,...n,headers:F([{"OpenAI-Beta":`chatkit_beta=v1`},n?.headers]),__security:{bearerAuth:!0}})}},zr=class extends N{constructor(){super(...arguments),this.sessions=new Lr(this._client),this.threads=new Rr(this._client)}};zr.Sessions=Lr,zr.Threads=Rr;var Br=class extends N{create(e,t,n){return this._client.post(P`/threads/${e}/messages`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(P`/threads/${r}/messages/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/messages/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/threads/${e}/messages`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{thread_id:r}=t;return this._client.delete(P`/threads/${r}/messages/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}},Vr=class extends N{retrieve(e,t,n){let{thread_id:r,run_id:i,...a}=t;return this._client.get(P`/threads/${r}/runs/${i}/steps/${e}`,{query:a,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t,n){let{thread_id:r,...i}=t;return this._client.getAPIList(P`/threads/${r}/runs/${e}/steps`,ht,{query:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}};const Hr=e=>{if(typeof Buffer<`u`){let t=Buffer.from(e,`base64`);return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return Array.from(new Float32Array(r.buffer))}},Ur=e=>{if(globalThis.process!==void 0)return globalThis.process.env?.[e]?.trim()||void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()||void 0};var Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi=class extends hn{constructor(){super(...arguments),Wr.add(this),Kr.set(this,[]),qr.set(this,{}),Jr.set(this,{}),Yr.set(this,void 0),Xr.set(this,void 0),Zr.set(this,void 0),Qr.set(this,void 0),$r.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),ni.set(this,void 0),ri.set(this,void 0)}[(Kr=new WeakMap,qr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,$r=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,ri=new WeakMap,Wr=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new Gr;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener(`abort`,()=>this.controller.abort())),this._connected();let i=nt.fromReadableStream(e,this.controller);for await(let e of i)r(this,Wr,`m`,ii).call(this,e);if(i.controller.signal?.aborted)throw new l;return this._addRun(r(this,Wr,`m`,ai).call(this))}toReadableStream(){return new nt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,r){let i=new Gr;return i._run(()=>i._runToolAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createToolAssistantStream(e,t,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...n,stream:!0},s=await e.submitToolOutputs(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)r(this,Wr,`m`,ii).call(this,e);if(s.controller.signal?.aborted)throw new l;return this._addRun(r(this,Wr,`m`,ai).call(this))}static createThreadAssistantStream(e,t,n){let r=new Gr;return r._run(()=>r._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":`stream`}})),r}static createAssistantStream(e,t,n,r){let i=new Gr;return i._run(()=>i._runAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}currentEvent(){return r(this,ti,`f`)}currentRun(){return r(this,ni,`f`)}currentMessageSnapshot(){return r(this,Yr,`f`)}currentRunStepSnapshot(){return r(this,ri,`f`)}async finalRunSteps(){return await this.done(),Object.values(r(this,qr,`f`))}async finalMessages(){return await this.done(),Object.values(r(this,Jr,`f`))}async finalRun(){if(await this.done(),!r(this,Xr,`f`))throw Error(`Final run was not received.`);return r(this,Xr,`f`)}async _createThreadAssistantStream(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort()));let a={...t,stream:!0},o=await e.createAndRun(a,{...n,signal:this.controller.signal});this._connected();for await(let e of o)r(this,Wr,`m`,ii).call(this,e);if(o.controller.signal?.aborted)throw new l;return this._addRun(r(this,Wr,`m`,ai).call(this))}async _createAssistantStream(e,t,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...n,stream:!0},s=await e.create(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)r(this,Wr,`m`,ii).call(this,e);if(s.controller.signal?.aborted)throw new l;return this._addRun(r(this,Wr,`m`,ai).call(this))}static accumulateDelta(e,t){for(let[n,r]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=r;continue}let t=e[n];if(t==null){e[n]=r;continue}if(n===`index`||n===`type`){e[n]=r;continue}if(typeof t==`string`&&typeof r==`string`)t+=r;else if(typeof t==`number`&&typeof r==`number`)t+=r;else if(te(t)&&te(r))t=this.accumulateDelta(t,r);else if(Array.isArray(t)&&Array.isArray(r)){if(t.every(e=>typeof e==`string`||typeof e==`number`)){t.push(...r);continue}for(let e of r){if(!te(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let n=e.index;if(n==null)throw console.error(e),Error("Expected array delta entry to have an `index` property");if(typeof n!=`number`)throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);let r=t[n];r==null?t.push(e):t[n]=this.accumulateDelta(r,e)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${r}, accValue: ${t}`);e[n]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,r){return await this._createAssistantStream(t,e,n,r)}async _runToolAssistantStream(e,t,n,r){return await this._createToolAssistantStream(t,e,n,r)}};Gr=pi,ii=function(e){if(!this.ended)switch(n(this,ti,e,`f`),r(this,Wr,`m`,ci).call(this,e),e.event){case`thread.created`:break;case`thread.run.created`:case`thread.run.queued`:case`thread.run.in_progress`:case`thread.run.requires_action`:case`thread.run.completed`:case`thread.run.incomplete`:case`thread.run.failed`:case`thread.run.cancelling`:case`thread.run.cancelled`:case`thread.run.expired`:r(this,Wr,`m`,fi).call(this,e);break;case`thread.run.step.created`:case`thread.run.step.in_progress`:case`thread.run.step.delta`:case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:r(this,Wr,`m`,si).call(this,e);break;case`thread.message.created`:case`thread.message.in_progress`:case`thread.message.delta`:case`thread.message.completed`:case`thread.message.incomplete`:r(this,Wr,`m`,oi).call(this,e);break;case`error`:throw Error(`Encountered an error event in event processing - errors should be processed earlier`);default:}},ai=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);if(!r(this,Xr,`f`))throw Error(`Final run has not been received`);return r(this,Xr,`f`)},oi=function(e){let[t,i]=r(this,Wr,`m`,ui).call(this,e,r(this,Yr,`f`));n(this,Yr,t,`f`),r(this,Jr,`f`)[t.id]=t;for(let e of i){let n=t.content[e.index];n?.type==`text`&&this._emit(`textCreated`,n.text)}switch(e.event){case`thread.message.created`:this._emit(`messageCreated`,e.data);break;case`thread.message.in_progress`:break;case`thread.message.delta`:if(this._emit(`messageDelta`,e.data.delta,t),e.data.delta.content)for(let i of e.data.delta.content){if(i.type==`text`&&i.text){let e=i.text,n=t.content[i.index];if(n&&n.type==`text`)this._emit(`textDelta`,e,n.text);else throw Error(`The snapshot associated with this text delta is not text or missing`)}if(i.index!=r(this,Zr,`f`)){if(r(this,Qr,`f`))switch(r(this,Qr,`f`).type){case`text`:this._emit(`textDone`,r(this,Qr,`f`).text,r(this,Yr,`f`));break;case`image_file`:this._emit(`imageFileDone`,r(this,Qr,`f`).image_file,r(this,Yr,`f`));break}n(this,Zr,i.index,`f`)}n(this,Qr,t.content[i.index],`f`)}break;case`thread.message.completed`:case`thread.message.incomplete`:if(r(this,Zr,`f`)!==void 0){let t=e.data.content[r(this,Zr,`f`)];if(t)switch(t.type){case`image_file`:this._emit(`imageFileDone`,t.image_file,r(this,Yr,`f`));break;case`text`:this._emit(`textDone`,t.text,r(this,Yr,`f`));break}}r(this,Yr,`f`)&&this._emit(`messageDone`,e.data),n(this,Yr,void 0,`f`)}},si=function(e){let t=r(this,Wr,`m`,li).call(this,e);switch(n(this,ri,t,`f`),e.event){case`thread.run.step.created`:this._emit(`runStepCreated`,e.data);break;case`thread.run.step.delta`:let i=e.data.delta;if(i.step_details&&i.step_details.type==`tool_calls`&&i.step_details.tool_calls&&t.step_details.type==`tool_calls`)for(let e of i.step_details.tool_calls)e.index==r(this,$r,`f`)?this._emit(`toolCallDelta`,e,t.step_details.tool_calls[e.index]):(r(this,ei,`f`)&&this._emit(`toolCallDone`,r(this,ei,`f`)),n(this,$r,e.index,`f`),n(this,ei,t.step_details.tool_calls[e.index],`f`),r(this,ei,`f`)&&this._emit(`toolCallCreated`,r(this,ei,`f`)));this._emit(`runStepDelta`,e.data.delta,t);break;case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:n(this,ri,void 0,`f`),e.data.step_details.type==`tool_calls`&&r(this,ei,`f`)&&(this._emit(`toolCallDone`,r(this,ei,`f`)),n(this,ei,void 0,`f`)),this._emit(`runStepDone`,e.data,t);break;case`thread.run.step.in_progress`:break}},ci=function(e){r(this,Kr,`f`).push(e),this._emit(`event`,e)},li=function(e){switch(e.event){case`thread.run.step.created`:return r(this,qr,`f`)[e.data.id]=e.data,e.data;case`thread.run.step.delta`:let t=r(this,qr,`f`)[e.data.id];if(!t)throw Error(`Received a RunStepDelta before creation of a snapshot`);let n=e.data;if(n.delta){let i=Gr.accumulateDelta(t,n.delta);r(this,qr,`f`)[e.data.id]=i}return r(this,qr,`f`)[e.data.id];case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:case`thread.run.step.in_progress`:r(this,qr,`f`)[e.data.id]=e.data;break}if(r(this,qr,`f`)[e.data.id])return r(this,qr,`f`)[e.data.id];throw Error(`No snapshot available`)},ui=function(e,t){let n=[];switch(e.event){case`thread.message.created`:return[e.data,n];case`thread.message.delta`:if(!t)throw Error(`Received a delta with no existing snapshot (there should be one from message creation)`);let i=e.data;if(i.delta.content)for(let e of i.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=r(this,Wr,`m`,di).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case`thread.message.in_progress`:case`thread.message.completed`:case`thread.message.incomplete`:if(t)return[t,n];throw Error(`Received thread message event with no existing snapshot`)}throw Error(`Tried to accumulate a non-message event`)},di=function(e,t){return Gr.accumulateDelta(t,e)},fi=function(e){switch(n(this,ni,e.data,`f`),e.event){case`thread.run.created`:break;case`thread.run.queued`:break;case`thread.run.in_progress`:break;case`thread.run.requires_action`:case`thread.run.cancelled`:case`thread.run.failed`:case`thread.run.completed`:case`thread.run.expired`:case`thread.run.incomplete`:n(this,Xr,e.data,`f`),r(this,ei,`f`)&&(this._emit(`toolCallDone`,r(this,ei,`f`)),n(this,ei,void 0,`f`));break;case`thread.run.cancelling`:break}};var mi=class extends N{constructor(){super(...arguments),this.steps=new Vr(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(P`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(P`/threads/${r}/runs/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/runs/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/threads/${e}/runs`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(P`/threads/${r}/runs/${e}/cancel`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(r.id,{thread_id:e},n)}createAndStream(e,t,n){return pi.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...r}}).withResponse();switch(i.status){case`queued`:case`in_progress`:case`cancelling`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`requires_action`:case`incomplete`:case`cancelled`:case`completed`:case`failed`:case`expired`:return i}}}stream(e,t,n){return pi.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(P`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async submitToolOutputsAndPoll(e,t,n){let r=await this.submitToolOutputs(e,t,n);return await this.poll(r.id,t,n)}submitToolOutputsStream(e,t,n){return pi.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}};mi.Steps=Vr;var hi=class extends N{constructor(){super(...arguments),this.runs=new mi(this._client),this.messages=new Br(this._client)}create(e={},t){return this._client.post(`/threads`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/threads/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/threads/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}createAndRun(e,t){return this._client.post(`/threads/runs`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async createAndRunPoll(e,t){let n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return pi.createThreadAssistantStream(e,this._client.beta.threads,t)}};hi.Runs=mi,hi.Messages=Br;var gi=class extends N{constructor(){super(...arguments),this.realtime=new Ir(this._client),this.chatkit=new zr(this._client),this.assistants=new Nr(this._client),this.threads=new hi(this._client)}};gi.Realtime=Ir,gi.ChatKit=zr,gi.Assistants=Nr,gi.Threads=hi;var _i=class extends N{create(e,t){return this._client.post(`/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}},vi=class extends N{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(P`/containers/${r}/files/${e}/content`,{...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},yi=class extends N{constructor(){super(...arguments),this.content=new vi(this._client)}create(e,t,n){return this._client.post(P`/containers/${e}/files`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(P`/containers/${r}/files/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/containers/${e}/files`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(P`/containers/${r}/files/${e}`,{...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}};yi.Content=vi;var bi=class extends N{constructor(){super(...arguments),this.files=new yi(this._client)}create(e,t){return this._client.post(`/containers`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/containers/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/containers`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/containers/${e}`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}};bi.Files=yi;var xi=class extends N{create(e,t,n){let{include:r,...i}=t;return this._client.post(P`/conversations/${e}/items`,{query:{include:r},body:i,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{conversation_id:r,...i}=t;return this._client.get(P`/conversations/${r}/items/${e}`,{query:i,...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/conversations/${e}/items`,gt,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{conversation_id:r}=t;return this._client.delete(P`/conversations/${r}/items/${e}`,{...n,__security:{bearerAuth:!0}})}},Si=class extends N{constructor(){super(...arguments),this.items=new xi(this._client)}create(e={},t){return this._client.post(`/conversations`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/conversations/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}};Si.Items=xi;var Ci=class extends N{create(e,t){let n=!!e.encoding_format,r=n?e.encoding_format:`base64`;n&&$e(this._client).debug(`embeddings/user defined encoding_format:`,e.encoding_format);let i=this._client.post(`/embeddings`,{body:{...e,encoding_format:r},...t,__security:{bearerAuth:!0}});return n?i:($e(this._client).debug(`embeddings/decoding base64 embeddings from base64`),i._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=Hr(t)}),e)))}},wi=class extends N{retrieve(e,t,n){let{eval_id:r,run_id:i}=t;return this._client.get(P`/evals/${r}/runs/${i}/output_items/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t,n){let{eval_id:r,...i}=t;return this._client.getAPIList(P`/evals/${r}/runs/${e}/output_items`,ht,{query:i,...n,__security:{bearerAuth:!0}})}},Ti=class extends N{constructor(){super(...arguments),this.outputItems=new wi(this._client)}create(e,t,n){return this._client.post(P`/evals/${e}/runs`,{body:t,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{eval_id:r}=t;return this._client.get(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/evals/${e}/runs`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{eval_id:r}=t;return this._client.delete(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}cancel(e,t,n){let{eval_id:r}=t;return this._client.post(P`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}};Ti.OutputItems=wi;var Ei=class extends N{constructor(){super(...arguments),this.runs=new Ti(this._client)}create(e,t){return this._client.post(`/evals`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/evals/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/evals`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}};Ei.Runs=Ti;var Di=class extends N{create(e,t){return this._client.post(`/files`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/files/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/files`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/files/${e}`,{...t,__security:{bearerAuth:!0}})}content(e,t){return this._client.get(P`/files/${e}/content`,{...t,headers:F([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=1800*1e3}={}){let r=new Set([`processed`,`error`,`deleted`]),i=Date.now(),a=await this.retrieve(e);for(;!a.status||!r.has(a.status);)if(await ie(t),a=await this.retrieve(e),Date.now()-i>n)throw new d({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return a}},Oi=class extends N{},ki=class extends N{run(e,t){return this._client.post(`/fine_tuning/alpha/graders/run`,{body:e,...t,__security:{bearerAuth:!0}})}validate(e,t){return this._client.post(`/fine_tuning/alpha/graders/validate`,{body:e,...t,__security:{bearerAuth:!0}})}},Ai=class extends N{constructor(){super(...arguments),this.graders=new ki(this._client)}};Ai.Graders=ki;var ji=class extends N{create(e,t,n){return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`,mt,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(P`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`,gt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{fine_tuned_model_checkpoint:r}=t;return this._client.delete(P`/fine_tuning/checkpoints/${r}/permissions/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Mi=class extends N{constructor(){super(...arguments),this.permissions=new ji(this._client)}};Mi.Permissions=ji;var Ni=class extends N{list(e,t={},n){return this._client.getAPIList(P`/fine_tuning/jobs/${e}/checkpoints`,ht,{query:t,...n,__security:{bearerAuth:!0}})}},Pi=class extends N{constructor(){super(...arguments),this.checkpoints=new Ni(this._client)}create(e,t){return this._client.post(`/fine_tuning/jobs`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/fine_tuning/jobs/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/fine_tuning/jobs`,ht,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}listEvents(e,t={},n){return this._client.getAPIList(P`/fine_tuning/jobs/${e}/events`,ht,{query:t,...n,__security:{bearerAuth:!0}})}pause(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/pause`,{...t,__security:{bearerAuth:!0}})}resume(e,t){return this._client.post(P`/fine_tuning/jobs/${e}/resume`,{...t,__security:{bearerAuth:!0}})}};Pi.Checkpoints=Ni;var Fi=class extends N{constructor(){super(...arguments),this.methods=new Oi(this._client),this.jobs=new Pi(this._client),this.checkpoints=new Mi(this._client),this.alpha=new Ai(this._client)}};Fi.Methods=Oi,Fi.Jobs=Pi,Fi.Checkpoints=Mi,Fi.Alpha=Ai;var Ii=class extends N{},Li=class extends N{constructor(){super(...arguments),this.graderModels=new Ii(this._client)}};Li.GraderModels=Ii;var Ri=class extends N{createVariation(e,t){return this._client.post(`/images/variations`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}edit(e,t){return this._client.post(`/images/edits`,Tt({body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}},this._client))}generate(e,t){return this._client.post(`/images/generations`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}},zi=class extends N{retrieve(e,t){return this._client.get(P`/models/${e}`,{...t,__security:{bearerAuth:!0}})}list(e){return this._client.getAPIList(`/models`,mt,{...e,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/models/${e}`,{...t,__security:{bearerAuth:!0}})}},Bi=class extends N{create(e,t){return this._client.post(`/moderations`,{body:e,...t,__security:{bearerAuth:!0}})}},Vi=class extends N{accept(e,t,n){return this._client.post(P`/realtime/calls/${e}/accept`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}hangup(e,t){return this._client.post(P`/realtime/calls/${e}/hangup`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}refer(e,t,n){return this._client.post(P`/realtime/calls/${e}/refer`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}reject(e,t={},n){return this._client.post(P`/realtime/calls/${e}/reject`,{body:t,...n,headers:F([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}},Hi=class extends N{create(e,t){return this._client.post(`/realtime/client_secrets`,{body:e,...t,__security:{bearerAuth:!0}})}},Ui=class extends N{constructor(){super(...arguments),this.clientSecrets=new Hi(this._client),this.calls=new Vi(this._client)}};Ui.ClientSecrets=Hi,Ui.Calls=Vi;function Wi(e,t){return!t||!qi(t)?{...e,output_parsed:null,output:e.output.map(e=>e.type===`function_call`?{...e,parsed_arguments:null}:e.type===`message`?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}:Gi(e,t)}function Gi(e,t){let n=e.output.map(e=>{if(e.type===`function_call`)return{...e,parsed_arguments:Xi(t,e)};if(e.type===`message`){let n=e.content.map(e=>e.type===`output_text`?{...e,parsed:Ki(t,e.text)}:e);return{...e,content:n}}return e}),r=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,`output_text`)||Zi(r),Object.defineProperty(r,"output_parsed",{enumerable:!0,get(){for(let e of r.output)if(e.type===`message`){for(let t of e.content)if(t.type===`output_text`&&t.parsed!==null)return t.parsed}return null}}),r}function Ki(e,t){return e.text?.format?.type===`json_schema`?`$parseRaw`in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t):null}function qi(e){return!!Ut(e.text?.format)}function Ji(e){return e?.$brand===`auto-parseable-tool`}function Yi(e,t){return e.find(e=>e.type===`function`&&e.name===t)}function Xi(e,t){let n=Yi(e.tools??[],t.name);return{...t,...t,parsed_arguments:Ji(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function Zi(e){let t=[];for(let n of e.output)if(n.type===`message`)for(let e of n.content)e.type===`output_text`&&t.push(e.text);e.output_text=t.join(``)}var Qi,$i,ea,ta,na,ra,ia,aa,oa=class e extends hn{constructor(e){super(),Qi.add(this),$i.set(this,void 0),ea.set(this,void 0),ta.set(this,void 0),n(this,$i,e,`f`)}static createResponse(t,n,r){let i=new e(n);return i._run(()=>i._createOrRetrieveResponse(t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createOrRetrieveResponse(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),r(this,Qi,`m`,na).call(this);let a,o=null;`response_id`in t?(a=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),o=t.starting_after??null):a=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let e of a)r(this,Qi,`m`,ra).call(this,e,o);if(a.controller.signal?.aborted)throw new l;return r(this,Qi,`m`,ia).call(this)}[($i=new WeakMap,ea=new WeakMap,ta=new WeakMap,Qi=new WeakSet,na=function(){this.ended||n(this,ea,void 0,`f`)},ra=function(e,t){if(this.ended)return;let n=(e,n)=>{(t==null||n.sequence_number>t)&&this._emit(e,n)},i=r(this,Qi,`m`,aa).call(this,e);switch(n(`event`,e),e.type){case`response.output_text.delta`:{let t=i.output[e.output_index];if(!t)throw new s(`missing output at index ${e.output_index}`);if(t.type===`message`){let r=t.content[e.content_index];if(!r)throw new s(`missing content at index ${e.content_index}`);if(r.type!==`output_text`)throw new s(`expected content to be 'output_text', got ${r.type}`);n(`response.output_text.delta`,{...e,snapshot:r.text})}break}case`response.function_call_arguments.delta`:{let t=i.output[e.output_index];if(!t)throw new s(`missing output at index ${e.output_index}`);t.type===`function_call`&&n(`response.function_call_arguments.delta`,{...e,snapshot:t.arguments});break}default:n(e.type,e);break}},ia=function(){if(this.ended)throw new s(`stream has ended, this shouldn't happen`);let e=r(this,ea,`f`);if(!e)throw new s(`request ended without sending any events`);n(this,ea,void 0,`f`);let t=sa(e,r(this,$i,`f`));return n(this,ta,t,`f`),t},aa=function(e){let t=r(this,ea,`f`);if(!t){if(e.type!==`response.created`)throw new s(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return t=n(this,ea,e.response,`f`),t}switch(e.type){case`response.output_item.added`:t.output.push(e.item);break;case`response.content_part.added`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);let r=n.type,i=e.part;r===`message`&&i.type!==`reasoning_text`?n.content.push(i):r===`reasoning`&&i.type===`reasoning_text`&&(n.content||=[],n.content.push(i));break}case`response.output_text.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);if(n.type===`message`){let t=n.content[e.content_index];if(!t)throw new s(`missing content at index ${e.content_index}`);if(t.type!==`output_text`)throw new s(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case`response.function_call_arguments.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);n.type===`function_call`&&(n.arguments+=e.delta);break}case`response.reasoning_text.delta`:{let n=t.output[e.output_index];if(!n)throw new s(`missing output at index ${e.output_index}`);if(n.type===`reasoning`){let t=n.content?.[e.content_index];if(!t)throw new s(`missing content at index ${e.content_index}`);if(t.type!==`reasoning_text`)throw new s(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case`response.completed`:n(this,ea,e.response,`f`);break}return t},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=r(this,ta,`f`);if(!e)throw new s(`stream ended without producing a ChatCompletion`);return e}};function sa(e,t){return Wi(e,t)}var ca=class extends N{list(e,t={},n){return this._client.getAPIList(P`/responses/${e}/input_items`,ht,{query:t,...n,__security:{bearerAuth:!0}})}},la=class extends N{count(e={},t){return this._client.post(`/responses/input_tokens`,{body:e,...t,__security:{bearerAuth:!0}})}},ua=class extends N{constructor(){super(...arguments),this.inputItems=new ca(this._client),this.inputTokens=new la(this._client)}create(e,t){return this._client.post(`/responses`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&Zi(e),e))}retrieve(e,t={},n){return this._client.get(P`/responses/${e}`,{query:t,...n,stream:t?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&Zi(e),e))}delete(e,t){return this._client.delete(P`/responses/${e}`,{...t,headers:F([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>Gi(t,e))}stream(e,t){return oa.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(P`/responses/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}compact(e,t){return this._client.post(`/responses/compact`,{body:e,...t,__security:{bearerAuth:!0}})}};ua.InputItems=ca,ua.InputTokens=la;var da=class extends N{retrieve(e,t){return this._client.get(P`/skills/${e}/content`,{...t,headers:F([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},fa=class extends N{retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(P`/skills/${r}/versions/${e}/content`,{...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},pa=class extends N{constructor(){super(...arguments),this.content=new fa(this._client)}create(e,t={},n){return this._client.post(P`/skills/${e}/versions`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(P`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/skills/${e}/versions`,ht,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{skill_id:r}=t;return this._client.delete(P`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}};pa.Content=fa;var ma=class extends N{constructor(){super(...arguments),this.content=new da(this._client),this.versions=new pa(this._client)}create(e={},t){return this._client.post(`/skills`,wt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/skills/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/skills`,ht,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}};ma.Content=da,ma.Versions=pa;var ha=class extends N{create(e,t,n){return this._client.post(P`/uploads/${e}/parts`,Tt({body:t,...n,__security:{bearerAuth:!0}},this._client))}},ga=class extends N{constructor(){super(...arguments),this.parts=new ha(this._client)}create(e,t){return this._client.post(`/uploads`,{body:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(P`/uploads/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}complete(e,t,n){return this._client.post(P`/uploads/${e}/complete`,{body:t,...n,__security:{bearerAuth:!0}})}};ga.Parts=ha;const _a=async e=>{let t=await Promise.allSettled(e),n=t.filter(e=>e.status===`rejected`);if(n.length){for(let e of n)console.error(e.reason);throw Error(`${n.length} promise(s) failed - see the above errors`)}let r=[];for(let e of t)e.status===`fulfilled`&&r.push(e.value);return r};var va=class extends N{create(e,t,n){return this._client.post(P`/vector_stores/${e}/file_batches`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(P`/vector_stores/${r}/file_batches/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{vector_store_id:r}=t;return this._client.post(P`/vector_stores/${r}/file_batches/${e}/cancel`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t);return await this.poll(e,r.id,n)}listFiles(e,t,n){let{vector_store_id:r,...i}=t;return this._client.getAPIList(P`/vector_stores/${r}/file_batches/${e}/files`,ht,{query:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse();switch(i.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`failed`:case`cancelled`:case`completed`:return i}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},r){if(t==null||t.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=r?.maxConcurrency??5,a=Math.min(i,t.length),o=this._client,s=t.values(),c=[...n];async function l(e){for(let t of e){let e=await o.files.create({file:t,purpose:`assistants`},r);c.push(e.id)}}return await _a(Array(a).fill(s).map(l)),await this.createAndPoll(e,{file_ids:c})}},ya=class extends N{create(e,t,n){return this._client.post(P`/vector_stores/${e}/files`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(P`/vector_stores/${r}/files/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{vector_store_id:r,...i}=t;return this._client.post(P`/vector_stores/${r}/files/${e}`,{body:i,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(P`/vector_stores/${e}/files`,ht,{query:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{vector_store_id:r}=t;return this._client.delete(P`/vector_stores/${r}/files/${e}`,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(e,r.id,n)}async poll(e,t,n){let r=F([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let i=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse(),a=i.data;switch(a.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=i.response.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await ie(e);break;case`failed`:case`completed`:return a}}}async upload(e,t,n){let r=await this._client.files.create({file:t,purpose:`assistants`},n);return this.create(e,{file_id:r.id},n)}async uploadAndPoll(e,t,n){let r=await this.upload(e,t,n);return await this.poll(e,r.id,n)}content(e,t,n){let{vector_store_id:r}=t;return this._client.getAPIList(P`/vector_stores/${r}/files/${e}/content`,mt,{...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}},ba=class extends N{constructor(){super(...arguments),this.files=new ya(this._client),this.fileBatches=new va(this._client)}create(e,t){return this._client.post(`/vector_stores`,{body:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(P`/vector_stores/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(P`/vector_stores/${e}`,{body:t,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/vector_stores`,ht,{query:e,...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/vector_stores/${e}`,{...t,headers:F([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}search(e,t,n){return this._client.getAPIList(P`/vector_stores/${e}/search`,mt,{body:t,method:`post`,...n,headers:F([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}};ba.Files=ya,ba.FileBatches=va;var xa=class extends N{create(e,t){return this._client.post(`/videos`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(P`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/videos`,gt,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(P`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}createCharacter(e,t){return this._client.post(`/videos/characters`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}downloadContent(e,t={},n){return this._client.get(P`/videos/${e}/content`,{query:t,...n,headers:F([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit(e,t){return this._client.post(`/videos/edits`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}extend(e,t){return this._client.post(`/videos/extensions`,Tt({body:e,...t,__security:{bearerAuth:!0}},this._client))}getCharacter(e,t){return this._client.get(P`/videos/characters/${e}`,{...t,__security:{bearerAuth:!0}})}remix(e,t,n){return this._client.post(P`/videos/${e}/remix`,wt({body:t,...n,__security:{bearerAuth:!0}},this._client))}},Sa,Ca,wa,Ta=class extends N{constructor(){super(...arguments),Sa.add(this)}async unwrap(e,t,n=this._client.webhookSecret,r=300){return await this.verifySignature(e,t,n,r),JSON.parse(e)}async verifySignature(e,t,n=this._client.webhookSecret,i=300){if(typeof crypto>`u`||typeof crypto.subtle.importKey!=`function`||typeof crypto.subtle.verify!=`function`)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");r(this,Sa,`m`,Ca).call(this,n);let a=F([t]).values,o=r(this,Sa,`m`,wa).call(this,a,`webhook-signature`),s=r(this,Sa,`m`,wa).call(this,a,`webhook-timestamp`),c=r(this,Sa,`m`,wa).call(this,a,`webhook-id`),l=parseInt(s,10);if(isNaN(l))throw new S(`Invalid webhook timestamp format`);let u=Math.floor(Date.now()/1e3);if(u-l>i)throw new S(`Webhook timestamp is too old`);if(l>u+i)throw new S(`Webhook timestamp is too new`);let d=o.split(` `).map(e=>e.startsWith(`v1,`)?e.substring(3):e),f=n.startsWith(`whsec_`)?Buffer.from(n.replace(`whsec_`,``),`base64`):Buffer.from(n,`utf-8`),p=c?`${c}.${s}.${e}`:`${s}.${e}`,m=await crypto.subtle.importKey(`raw`,f,{name:`HMAC`,hash:`SHA-256`},!1,[`verify`]);for(let e of d)try{let t=Buffer.from(e,`base64`);if(await crypto.subtle.verify(`HMAC`,m,t,new TextEncoder().encode(p)))return}catch{continue}throw new S(`The given webhook signature does not match the expected signature`)}};Sa=new WeakSet,Ca=function(e){if(typeof e!=`string`||e.length===0)throw Error(`The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function`)},wa=function(e,t){if(!e)throw Error(`Headers are required`);let n=e.get(t);if(n==null)throw Error(`Missing required header: ${t}`);return n};var Ea,Da,Oa,ka,I=class{constructor({baseURL:e=Ur(`OPENAI_BASE_URL`),apiKey:t=Ur(`OPENAI_API_KEY`)??null,adminAPIKey:r=Ur(`OPENAI_ADMIN_KEY`)??null,organization:i=Ur(`OPENAI_ORG_ID`)??null,project:a=Ur(`OPENAI_PROJECT_ID`)??null,webhookSecret:o=Ur(`OPENAI_WEBHOOK_SECRET`)??null,workloadIdentity:c,...l}={}){Ea.add(this),Oa.set(this,void 0),this.completions=new _i(this),this.chat=new Xn(this),this.embeddings=new Ci(this),this.files=new Di(this),this.images=new Ri(this),this.audio=new jr(this),this.moderations=new Bi(this),this.models=new zi(this),this.fineTuning=new Fi(this),this.graders=new Li(this),this.vectorStores=new ba(this),this.webhooks=new Ta(this),this.beta=new gi(this),this.batches=new Mr(this),this.uploads=new ga(this),this.admin=new Tr(this),this.responses=new ua(this),this.realtime=new Ui(this),this.conversations=new Si(this),this.evals=new Ei(this),this.containers=new bi(this),this.skills=new ma(this),this.videos=new xa(this);let u={apiKey:t,adminAPIKey:r,organization:i,project:a,webhookSecret:o,workloadIdentity:c,...l,baseURL:e||`https://api.openai.com/v1`};if(t&&c)throw new s("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!t&&!r&&!c)throw new s("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!u.dangerouslyAllowBrowser&&oe())throw new s(`It looks like you're running in a browser-like environment.
|
|
8
8
|
|
|
9
9
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
10
10
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -13,58 +13,58 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
13
13
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
14
14
|
|
|
15
15
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
16
|
-
`);this.baseURL=u.baseURL,this.timeout=u.timeout??
|
|
17
|
-
`)){let n=t.indexOf(`:`);n>=0&&(e[t.substring(0,n).trim()]=t.substring(n+1).trim())}u.defaultHeaders=F([e,u.defaultHeaders])}this._options=u,c&&(this._workloadIdentityAuth=new yt(c,this.fetch)),this.apiKey=typeof t==`string`?t:null,this.adminAPIKey=r,this.organization=i,this.project=a,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(e.get(`authorization`)||e.get(`api-key`))&&!(t.has(`authorization`)||t.has(`api-key`))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw Error(`Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted`)}async authHeaders(e,t={bearerAuth:!0,adminAPIKeyAuth:!0}){return F([t.bearerAuth?await this.bearerAuth(e):null,t.adminAPIKeyAuth?await this.adminAPIKeyAuth(e):null])}async bearerAuth(e){if(this._workloadIdentityAuth)return F([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return F([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(e){if(this.adminAPIKey!=null)return F([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(e){return Ie(e)}getUserAgent(){return`${this.constructor.name}/JS ${ae}`}defaultIdempotencyKey(){return`stainless-node-retry-${i()}`}makeStatusError(e,t,n,r){return c.generate(e,t,n,r)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof s?e:new s(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new s(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){let i=!r(this,ba,`m`,Ca).call(this)&&n||this.baseURL,a=E(e)?new URL(e):new URL(i+(i.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),o=this.defaultQuery(),s=Object.fromEntries(a.searchParams);return(!A(o)||!A(s))&&(t={...s,...o,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}async prepareOptions(e){(e.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new ut(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:s,url:c,timeout:f}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(s,{url:c,options:r});let p=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),m=n===void 0?``:`, retryOf: ${n}`,h=Date.now();if($e(this).debug(`[${p}] sending request`,et({retryOfRequestLogID:n,method:r.method,url:c,options:r,headers:s.headers})),r.signal?.aborted)throw new l;let g=r.__security??{bearerAuth:!0},_=new AbortController,v=await this.fetchWithAuth(c,s,f,_,g).catch(o),y=Date.now();if(v instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new l;let i=a(v)||/timed? ?out/i.test(String(v)+(`cause`in v?String(v.cause):``));if(t)return $e(this).info(`[${p}] connection ${i?`timed out`:`failed`} - ${e}`),$e(this).debug(`[${p}] connection ${i?`timed out`:`failed`} (${e})`,et({retryOfRequestLogID:n,url:c,durationMs:y-h,message:v.message})),this.retryRequest(r,t,n??p);throw $e(this).info(`[${p}] connection ${i?`timed out`:`failed`} - error; no more retries left`),$e(this).debug(`[${p}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,et({retryOfRequestLogID:n,url:c,durationMs:y-h,message:v.message})),v instanceof C||v instanceof w?v:i?new d:new u({cause:v})}let b=`[${p}${m}${[...v.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${s.method} ${c} ${v.ok?`succeeded`:`failed`} with status ${v.status} in ${y-h}ms`;if(!v.ok){if(v.status===401&&this._workloadIdentityAuth&&g.bearerAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await ge(v.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??p);let e=await this.shouldRetry(v);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await ge(v.body),$e(this).info(`${b} - ${e}`),$e(this).debug(`[${p}] response error (${e})`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,durationMs:y-h})),this.retryRequest(r,t,n??p,v.headers)}let i=e?`error; no more retries left`:`error; not retryable`;$e(this).info(`${b} - ${i}`);let a=await v.text().catch(e=>o(e).message),s=re(a),c=s?void 0:a;throw $e(this).debug(`[${p}] response error (${i})`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,message:c,durationMs:Date.now()-h})),this.makeStatusError(v.status,s,c,v.headers)}return $e(this).info(b),$e(this).debug(`[${p}] response start`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,durationMs:y-h})),{response:v,options:r,controller:_,requestLogID:p,retryOfRequestLogID:n,startTime:h}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new pt(this,n,e)}async fetchWithAuth(e,t,n,r,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer workload-identity-auth`){let t=await this._workloadIdentityAuth.getToken();e.set(`Authorization`,`Bearer ${t}`)}}return await this.fetchWithTimeout(e,t,n,r)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await ie(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&ne(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l,isStreamingBody:u}=this.buildBody({options:n});return u&&(e.__metadata={...e.__metadata,hasStreamingBody:!0}),{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=F([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...fe(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e,e.__security??{bearerAuth:!0}),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a,e.__security??{bearerAuth:!0}),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=F([t]),i=globalThis.ReadableStream!==void 0&&e instanceof globalThis.ReadableStream,a=!i&&(typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||globalThis.Blob!==void 0&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!a}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:me(e),isStreamingBody:!0}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e),isStreamingBody:!1}:{...r(this,Sa,`f`).call(this,{body:e,headers:n}),isStreamingBody:!1}}};xa=I,Sa=new WeakMap,ba=new WeakSet,Ca=function(){return this.baseURL!==`https://api.openai.com/v1`},I.OpenAI=xa,I.DEFAULT_TIMEOUT=6e5,I.OpenAIError=s,I.APIError=c,I.APIConnectionError=u,I.APIConnectionTimeoutError=d,I.APIUserAbortError=l,I.NotFoundError=h,I.ConflictError=g,I.RateLimitError=v,I.BadRequestError=f,I.AuthenticationError=p,I.InternalServerError=y,I.PermissionDeniedError=m,I.UnprocessableEntityError=_,I.InvalidWebhookSignatureError=S,I.toFile=It,I.Completions=di,I.Chat=Xn,I.Embeddings=_i,I.Files=xi,I.Images=Mi,I.Audio=Tr,I.Moderations=Pi,I.Models=Ni,I.FineTuning=ki,I.Graders=ji,I.VectorStores=ma,I.Webhooks=ya,I.Beta=ui,I.Batches=Er,I.Uploads=ua,I.Admin=yr,I.Responses=ia,I.Realtime=Li,I.Conversations=gi,I.Evals=bi,I.Containers=mi,I.Skills=ca,I.Videos=ha;var wa=class extends I{constructor({baseURL:e=Lr(`OPENAI_BASE_URL`),apiKey:t=Lr(`AZURE_OPENAI_API_KEY`),apiVersion:n=Lr(`OPENAI_API_VERSION`),endpoint:r,deployment:i,azureADTokenProvider:a,dangerouslyAllowBrowser:o,...c}={}){if(!n)throw new s(`The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).`);if(typeof a==`function`&&(o=!0),!a&&!t)throw new s("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(a&&t)throw new s("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(c.defaultQuery={...c.defaultQuery,"api-version":n},!e){if(r||=process.env.AZURE_OPENAI_ENDPOINT,!r)throw new s("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${r}/openai`}else if(r)throw new s(`baseURL and endpoint are mutually exclusive`);super({apiKey:a??t,baseURL:e,...c,...o===void 0?{}:{dangerouslyAllowBrowser:o}}),this.apiVersion=``,this.apiVersion=n,this.deploymentName=i}async buildRequest(e,t={}){if(Ta.has(e.path)&&e.method===`post`&&e.body!==void 0){if(!te(e.body))throw Error(`Expected request body to be an object`);let t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes(`/deployments`)&&(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,t)}async authHeaders(e,t){let n=t??{bearerAuth:!0,adminAPIKeyAuth:!0};return n.bearerAuth&&typeof this._options.apiKey==`string`?F([{"api-key":this.apiKey}]):super.authHeaders(e,n)}};const Ta=new Set([`/completions`,`/chat/completions`,`/embeddings`,`/audio/transcriptions`,`/audio/translations`,`/audio/speech`,`/images/generations`,`/batches`,`/images/edits`]);var L;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(L||={});var Ea;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Ea||={});const R=L.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Da=e=>{switch(typeof e){case`undefined`:return R.undefined;case`string`:return R.string;case`number`:return Number.isNaN(e)?R.nan:R.number;case`boolean`:return R.boolean;case`function`:return R.function;case`bigint`:return R.bigint;case`symbol`:return R.symbol;case`object`:return Array.isArray(e)?R.array:e===null?R.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?R.promise:typeof Map<`u`&&e instanceof Map?R.map:typeof Set<`u`&&e instanceof Set?R.set:typeof Date<`u`&&e instanceof Date?R.date:R.object;default:return R.unknown}},z=L.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`]);var Oa=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Oa.create=e=>new Oa(e);const ka=(e,t)=>{let n;switch(e.code){case z.invalid_type:n=e.received===R.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,L.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:n=`Unrecognized key(s) in object: ${L.joinValues(e.keys,`, `)}`;break;case z.invalid_union:n=`Invalid input`;break;case z.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${L.joinValues(e.options)}`;break;case z.invalid_enum_value:n=`Invalid enum value. Expected ${L.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:n=`Invalid function arguments`;break;case z.invalid_return_type:n=`Invalid function return type`;break;case z.invalid_date:n=`Invalid date`;break;case z.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:L.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case z.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case z.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case z.custom:n=`Invalid input`;break;case z.invalid_intersection_types:n=`Intersection results could not be merged`;break;case z.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,L.assertNever(e)}return{message:n}};let Aa=ka;function ja(){return Aa}const Ma=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function B(e,t){let n=ja(),r=Ma({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ka?void 0:ka].filter(e=>!!e)});e.common.issues.push(r)}var Na=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return V;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return V;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const V=Object.freeze({status:`aborted`}),Pa=e=>({status:`dirty`,value:e}),Fa=e=>({status:`valid`,value:e}),Ia=e=>e.status===`aborted`,La=e=>e.status===`dirty`,Ra=e=>e.status===`valid`,za=e=>typeof Promise<`u`&&e instanceof Promise;var H;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(H||={});var Ba=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Va=(e,t)=>{if(Ra(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Oa(e.common.issues);return this._error=t,this._error}}};function U(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var W=class{get description(){return this._def.description}_getType(e){return Da(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Na,ctx:{common:e.parent.common,data:e.data,parsedType:Da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(za(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Da(e)};return Va(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Da(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ra(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ra(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Da(e)},r=this._parse({data:e,path:n.path,parent:n});return Va(n,await(za(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:z.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Wo({schema:this,typeName:G.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Go.create(this,this._def)}nullable(){return Ko.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return To.create(this)}promise(){return Uo.create(this,this._def)}or(e){return Oo.create([this,e],this._def)}and(e){return Mo.create(this,e,this._def)}transform(e){return new Wo({...U(this._def),schema:this,typeName:G.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new qo({...U(this._def),innerType:this,defaultValue:t,typeName:G.ZodDefault})}brand(){return new Xo({typeName:G.ZodBranded,type:this,...U(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Jo({...U(this._def),innerType:this,catchValue:t,typeName:G.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zo.create(this,e)}readonly(){return Qo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Ha=/^c[^\s-]{8,}$/i,Ua=/^[0-9a-z]+$/,Wa=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ga=/^[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,Ka=/^[a-z0-9_-]{21}$/i,qa=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ja=/^[-+]?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)?)??$/,Ya=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Xa;const Za=/^(?:(?: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])$/,Qa=/^(?:(?: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])$/,$a=/^(([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]))$/,eo=/^(([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])$/,to=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,no=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ro=`((\\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])))`,io=RegExp(`^${ro}$`);function ao(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function oo(e){return RegExp(`^${ao(e)}$`)}function so(e){let t=`${ro}T${ao(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function co(e,t){return!!((t===`v4`||!t)&&Za.test(e)||(t===`v6`||!t)&&$a.test(e))}function lo(e,t){if(!qa.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function uo(e,t){return!!((t===`v4`||!t)&&Qa.test(e)||(t===`v6`||!t)&&eo.test(e))}var fo=class e extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.string,received:t.parsedType}),V}let t=new Na,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Ya.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`email`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Xa||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),Xa.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`emoji`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ga.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`uuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Ka.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`nanoid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Ha.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ua.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid2`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Wa.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ulid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),B(n,{validation:`url`,code:z.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`regex`,code:z.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?so(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?io.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?oo(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Ja.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`duration`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?co(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ip`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?lo(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`jwt`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?uo(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cidr`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?to.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?no.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64url`,code:z.invalid_string,message:r.message}),t.dirty()):L.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:z.invalid_string,...H.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...H.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...H.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...H.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...H.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...H.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...H.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...H.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...H.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...H.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...H.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...H.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...H.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...H.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...H.errToObj(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:e?.precision===void 0?null:e?.precision,...H.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...H.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...H.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...H.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...H.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...H.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...H.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...H.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...H.errToObj(t)})}nonempty(e){return this.min(1,H.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...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(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};fo.create=e=>new fo({checks:[],typeName:G.ZodString,coerce:e?.coerce??!1,...U(e)});function po(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var mo=class e extends W{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)!==R.number){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.number,received:t.parsedType}),V}let t,n=new Na;for(let r of this._def.checks)r.kind===`int`?L.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?po(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_finite,message:r.message}),n.dirty()):L.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,H.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,H.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,H.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,H.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:H.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:H.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:H.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:H.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:H.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:H.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let 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`&&L.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};mo.create=e=>new mo({checks:[],typeName:G.ZodNumber,coerce:e?.coerce||!1,...U(e)});var ho=class e extends W{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)!==R.bigint)return this._getInvalidInput(e);let t,n=new Na;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):L.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.bigint,received:t.parsedType}),V}gte(e,t){return this.setLimit(`min`,e,!0,H.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,H.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,H.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,H.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:H.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:H.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ho.create=e=>new ho({checks:[],typeName:G.ZodBigInt,coerce:e?.coerce??!1,...U(e)});var go=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.boolean,received:t.parsedType}),V}return Fa(e.data)}};go.create=e=>new go({typeName:G.ZodBoolean,coerce:e?.coerce||!1,...U(e)});var _o=class e extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.date,received:t.parsedType}),V}if(Number.isNaN(e.data.getTime()))return B(this._getOrReturnCtx(e),{code:z.invalid_date}),V;let t=new Na,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):L.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:H.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:H.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};_o.create=e=>new _o({checks:[],coerce:e?.coerce||!1,typeName:G.ZodDate,...U(e)});var vo=class extends W{_parse(e){if(this._getType(e)!==R.symbol){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.symbol,received:t.parsedType}),V}return Fa(e.data)}};vo.create=e=>new vo({typeName:G.ZodSymbol,...U(e)});var yo=class extends W{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.undefined,received:t.parsedType}),V}return Fa(e.data)}};yo.create=e=>new yo({typeName:G.ZodUndefined,...U(e)});var bo=class extends W{_parse(e){if(this._getType(e)!==R.null){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.null,received:t.parsedType}),V}return Fa(e.data)}};bo.create=e=>new bo({typeName:G.ZodNull,...U(e)});var xo=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Fa(e.data)}};xo.create=e=>new xo({typeName:G.ZodAny,...U(e)});var So=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fa(e.data)}};So.create=e=>new So({typeName:G.ZodUnknown,...U(e)});var Co=class extends W{_parse(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.never,received:t.parsedType}),V}};Co.create=e=>new Co({typeName:G.ZodNever,...U(e)});var wo=class extends W{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.void,received:t.parsedType}),V}return Fa(e.data)}};wo.create=e=>new wo({typeName:G.ZodVoid,...U(e)});var To=class e extends W{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==R.array)return B(t,{code:z.invalid_type,expected:R.array,received:t.parsedType}),V;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(B(t,{code:e?z.too_big:z.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(B(t,{code:z.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(B(t,{code:z.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Ba(t,e,t.path,n)))).then(e=>Na.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Ba(t,e,t.path,n)));return Na.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:H.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:H.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:H.toString(n)}})}nonempty(e){return this.min(1,e)}};To.create=(e,t)=>new To({type:e,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...U(t)});function Eo(e){if(e instanceof Do){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Go.create(Eo(r))}return new Do({...e._def,shape:()=>t})}else if(e instanceof To)return new To({...e._def,type:Eo(e.element)});else if(e instanceof Go)return Go.create(Eo(e.unwrap()));else if(e instanceof Ko)return Ko.create(Eo(e.unwrap()));else if(e instanceof No)return No.create(e.items.map(e=>Eo(e)));else return e}var Do=class e extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=L.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==R.object){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),V}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Co&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Ba(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Co){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(B(n,{code:z.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Ba(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Na.mergeObjectSync(t,e)):Na.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return H.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:H.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:G.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of L.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of L.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Eo(this)}partial(t){let n={};for(let e of L.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of L.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Go;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Bo(L.objectKeys(this.shape))}};Do.create=(e,t)=>new Do({shape:()=>e,unknownKeys:`strip`,catchall:Co.create(),typeName:G.ZodObject,...U(t)}),Do.strictCreate=(e,t)=>new Do({shape:()=>e,unknownKeys:`strict`,catchall:Co.create(),typeName:G.ZodObject,...U(t)}),Do.lazycreate=(e,t)=>new Do({shape:e,unknownKeys:`strip`,catchall:Co.create(),typeName:G.ZodObject,...U(t)});var Oo=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Oa(e.ctx.common.issues));return B(t,{code:z.invalid_union,unionErrors:n}),V}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Oa(e));return B(t,{code:z.invalid_union,unionErrors:i}),V}}get options(){return this._def.options}};Oo.create=(e,t)=>new Oo({options:e,typeName:G.ZodUnion,...U(t)});const ko=e=>e instanceof Ro?ko(e.schema):e instanceof Wo?ko(e.innerType()):e instanceof zo?[e.value]:e instanceof Vo?e.options:e instanceof Ho?L.objectValues(e.enum):e instanceof qo?ko(e._def.innerType):e instanceof yo?[void 0]:e instanceof bo?[null]:e instanceof Go?[void 0,...ko(e.unwrap())]:e instanceof Ko?[null,...ko(e.unwrap())]:e instanceof Xo||e instanceof Qo?ko(e.unwrap()):e instanceof Jo?ko(e._def.innerType):[];var Ao=class e extends W{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.object)return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),V;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);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}):(B(t,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=ko(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:G.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...U(r)})}};function jo(e,t){let n=Da(e),r=Da(t);if(e===t)return{valid:!0,data:e};if(n===R.object&&r===R.object){let n=L.objectKeys(t),r=L.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=jo(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===R.array&&r===R.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=jo(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===R.date&&r===R.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Mo=class extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Ia(e)||Ia(r))return V;let i=jo(e.value,r.value);return i.valid?((La(e)||La(r))&&t.dirty(),{status:t.value,value:i.data}):(B(n,{code:z.invalid_intersection_types}),V)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Mo.create=(e,t,n)=>new Mo({left:e,right:t,typeName:G.ZodIntersection,...U(n)});var No=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return B(n,{code:z.invalid_type,expected:R.array,received:n.parsedType}),V;if(n.data.length<this._def.items.length)return B(n,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),V;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Ba(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Na.mergeArray(t,e)):Na.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};No.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new No({items:e,typeName:G.ZodTuple,rest:null,...U(t)})};var Po=class e extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.object)return B(n,{code:z.invalid_type,expected:R.object,received:n.parsedType}),V;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Ba(n,e,n.path,e)),value:a._parse(new Ba(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Na.mergeObjectAsync(t,r):Na.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof W?new e({keyType:t,valueType:n,typeName:G.ZodRecord,...U(r)}):new e({keyType:fo.create(),valueType:t,typeName:G.ZodRecord,...U(n)})}},Fo=class extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.map)return B(n,{code:z.invalid_type,expected:R.map,received:n.parsedType}),V;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Ba(n,e,n.path,[a,`key`])),value:i._parse(new Ba(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return V;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return V;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Fo.create=(e,t,n)=>new Fo({valueType:t,keyType:e,typeName:G.ZodMap,...U(n)});var Io=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return B(n,{code:z.invalid_type,expected:R.set,received:n.parsedType}),V;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(B(n,{code:z.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(B(n,{code:z.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return V;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Ba(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:H.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:H.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Io.create=(e,t)=>new Io({valueType:e,minSize:null,maxSize:null,typeName:G.ZodSet,...U(t)});var Lo=class e extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.function)return B(t,{code:z.invalid_type,expected:R.function,received:t.parsedType}),V;function n(e,n){return Ma({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ka].filter(e=>!!e),issueData:{code:z.invalid_arguments,argumentsError:n}})}function r(e,n){return Ma({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ka].filter(e=>!!e),issueData:{code:z.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Uo){let e=this;return Fa(async function(...t){let o=new Oa([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Fa(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Oa([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Oa([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:No.create(t).rest(So.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||No.create([]).rest(So.create()),returns:n||So.create(),typeName:G.ZodFunction,...U(r)})}},Ro=class extends W{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ro.create=(e,t)=>new Ro({getter:e,typeName:G.ZodLazy,...U(t)});var zo=class extends W{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:z.invalid_literal,expected:this._def.value}),V}return{status:`valid`,value:e.data}}get value(){return this._def.value}};zo.create=(e,t)=>new zo({value:e,typeName:G.ZodLiteral,...U(t)});function Bo(e,t){return new Vo({values:e,typeName:G.ZodEnum,...U(t)})}var Vo=class e extends W{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:L.joinValues(n),received:t.parsedType,code:z.invalid_type}),V}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:z.invalid_enum_value,options:n}),V}return Fa(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Vo.create=Bo;var Ho=class extends W{_parse(e){let t=L.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let e=L.objectValues(t);return B(n,{expected:L.joinValues(e),received:n.parsedType,code:z.invalid_type}),V}if(this._cache||=new Set(L.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=L.objectValues(t);return B(n,{received:n.data,code:z.invalid_enum_value,options:e}),V}return Fa(e.data)}get enum(){return this._def.values}};Ho.create=(e,t)=>new Ho({values:e,typeName:G.ZodNativeEnum,...U(t)});var Uo=class extends W{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==R.promise&&t.common.async===!1?(B(t,{code:z.invalid_type,expected:R.promise,received:t.parsedType}),V):Fa((t.parsedType===R.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Uo.create=(e,t)=>new Uo({type:e,typeName:G.ZodPromise,...U(t)});var Wo=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{B(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return V;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?V:r.status===`dirty`||t.value===`dirty`?Pa(r.value):r});{if(t.value===`aborted`)return V;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?V:r.status===`dirty`||t.value===`dirty`?Pa(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?V:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?V:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ra(e))return V;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ra(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):V);L.assertNever(r)}};Wo.create=(e,t,n)=>new Wo({schema:e,typeName:G.ZodEffects,effect:t,...U(n)}),Wo.createWithPreprocess=(e,t,n)=>new Wo({schema:t,effect:{type:`preprocess`,transform:e},typeName:G.ZodEffects,...U(n)});var Go=class extends W{_parse(e){return this._getType(e)===R.undefined?Fa(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Go.create=(e,t)=>new Go({innerType:e,typeName:G.ZodOptional,...U(t)});var Ko=class extends W{_parse(e){return this._getType(e)===R.null?Fa(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ko.create=(e,t)=>new Ko({innerType:e,typeName:G.ZodNullable,...U(t)});var qo=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};qo.create=(e,t)=>new qo({innerType:e,typeName:G.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...U(t)});var Jo=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return za(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Oa(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Oa(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Jo.create=(e,t)=>new Jo({innerType:e,typeName:G.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...U(t)});var Yo=class extends W{_parse(e){if(this._getType(e)!==R.nan){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.nan,received:t.parsedType}),V}return{status:`valid`,value:e.data}}};Yo.create=e=>new Yo({typeName:G.ZodNaN,...U(e)});var Xo=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Zo=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?V:e.status===`dirty`?(t.dirty(),Pa(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?V:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:G.ZodPipeline})}},Qo=class extends W{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ra(e)&&(e.value=Object.freeze(e.value)),e);return za(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Qo.create=(e,t)=>new Qo({innerType:e,typeName:G.ZodReadonly,...U(t)}),Do.lazycreate;var G;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(G||={});const $o=fo.create,es=mo.create;Yo.create,ho.create;const ts=go.create;_o.create,vo.create,yo.create,bo.create,xo.create,So.create,Co.create,wo.create;const ns=To.create,rs=Do.create;Do.strictCreate,Oo.create,Ao.create,Mo.create,No.create;const is=Po.create;Fo.create,Io.create,Lo.create,Ro.create,zo.create,Vo.create,Ho.create,Uo.create,Wo.create,Go.create,Ko.create,Wo.createWithPreprocess,Zo.create;function as(e){return e==null}function os(e){return typeof e==`object`&&!!e}function ss(e){return Array.isArray(e)?e:as(e)?[]:[e]}function cs(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function ls(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function us(e){return e===0&&1/e==-1/0}var ds={isNothing:as,isObject:os,toArray:ss,repeat:ls,isNegativeZero:us,extend:cs};function fs(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
|
|
18
|
-
|
|
19
|
-
`+e.mark.snippet),r+` `+n):r}function
|
|
20
|
-
`+s;for(l=
|
|
21
|
-
`,s+=
|
|
22
|
-
`,c=1;c<=t.linesAfter&&!(o+c>=i.length);c++)l=
|
|
23
|
-
`;return s.replace(/\n$/,``)}var
|
|
24
|
-
\r`;function
|
|
25
|
-
`:e===118?`\v`:e===102?`\f`:e===114?`\r`:e===101?`\x1B`:e===32?` `:e===34?`"`:e===47?`/`:e===92?`\\`:e===78?`
`:e===95?`\xA0`:e===76?`\u2028`:e===80?`\u2029`:``}function
|
|
26
|
-
`,t-1))}function
|
|
27
|
-
`,a?1+c:c):i===
|
|
28
|
-
`);break}for(r?
|
|
29
|
-
`,a?1+c:c)):l?(l=!1,e.result+=
|
|
30
|
-
`,c+1)):c===0?a&&(e.result+=` `):e.result+=
|
|
31
|
-
`,c):e.result+=
|
|
32
|
-
`,a?1+c:c),a=!0,o=!0,c=0,n=e.position;!
|
|
33
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new
|
|
16
|
+
`);this.baseURL=u.baseURL,this.timeout=u.timeout??Da.DEFAULT_TIMEOUT,this.logger=u.logger??console;let d=`warn`;this.logLevel=d,this.logLevel=Je(u.logLevel,`ClientOptions.logLevel`,this)??Je(Ur(`OPENAI_LOG`),`process.env['OPENAI_LOG']`,this)??d,this.fetchOptions=u.fetchOptions,this.maxRetries=u.maxRetries??2,this.fetch=u.fetch??M(),n(this,Oa,_e,`f`);let f=Ur(`OPENAI_CUSTOM_HEADERS`);if(f){let e={};for(let t of f.split(`
|
|
17
|
+
`)){let n=t.indexOf(`:`);n>=0&&(e[t.substring(0,n).trim()]=t.substring(n+1).trim())}u.defaultHeaders=F([e,u.defaultHeaders])}this._options=u,c&&(this._workloadIdentityAuth=new yt(c,this.fetch)),this.apiKey=typeof t==`string`?t:null,this.adminAPIKey=r,this.organization=i,this.project=a,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(e.get(`authorization`)||e.get(`api-key`))&&!(t.has(`authorization`)||t.has(`api-key`))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw Error(`Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted`)}async authHeaders(e,t={bearerAuth:!0,adminAPIKeyAuth:!0}){return F([t.bearerAuth?await this.bearerAuth(e):null,t.adminAPIKeyAuth?await this.adminAPIKeyAuth(e):null])}async bearerAuth(e){if(this._workloadIdentityAuth)return F([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return F([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(e){if(this.adminAPIKey!=null)return F([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(e){return Ie(e)}getUserAgent(){return`${this.constructor.name}/JS ${ae}`}defaultIdempotencyKey(){return`stainless-node-retry-${i()}`}makeStatusError(e,t,n,r){return c.generate(e,t,n,r)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof s?e:new s(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new s(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){let i=!r(this,Ea,`m`,ka).call(this)&&n||this.baseURL,a=E(e)?new URL(e):new URL(i+(i.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),o=this.defaultQuery(),s=Object.fromEntries(a.searchParams);return(!A(o)||!A(s))&&(t={...s,...o,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}async prepareOptions(e){(e.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new ut(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:s,url:c,timeout:f}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(s,{url:c,options:r});let p=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),m=n===void 0?``:`, retryOf: ${n}`,h=Date.now();if($e(this).debug(`[${p}] sending request`,et({retryOfRequestLogID:n,method:r.method,url:c,options:r,headers:s.headers})),r.signal?.aborted)throw new l;let g=r.__security??{bearerAuth:!0},_=new AbortController,v=await this.fetchWithAuth(c,s,f,_,g).catch(o),y=Date.now();if(v instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new l;let i=a(v)||/timed? ?out/i.test(String(v)+(`cause`in v?String(v.cause):``));if(t)return $e(this).info(`[${p}] connection ${i?`timed out`:`failed`} - ${e}`),$e(this).debug(`[${p}] connection ${i?`timed out`:`failed`} (${e})`,et({retryOfRequestLogID:n,url:c,durationMs:y-h,message:v.message})),this.retryRequest(r,t,n??p);throw $e(this).info(`[${p}] connection ${i?`timed out`:`failed`} - error; no more retries left`),$e(this).debug(`[${p}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,et({retryOfRequestLogID:n,url:c,durationMs:y-h,message:v.message})),v instanceof C||v instanceof w?v:i?new d:new u({cause:v})}let b=`[${p}${m}${[...v.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${s.method} ${c} ${v.ok?`succeeded`:`failed`} with status ${v.status} in ${y-h}ms`;if(!v.ok){if(v.status===401&&this._workloadIdentityAuth&&g.bearerAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await ge(v.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??p);let e=await this.shouldRetry(v);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await ge(v.body),$e(this).info(`${b} - ${e}`),$e(this).debug(`[${p}] response error (${e})`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,durationMs:y-h})),this.retryRequest(r,t,n??p,v.headers)}let i=e?`error; no more retries left`:`error; not retryable`;$e(this).info(`${b} - ${i}`);let a=await v.text().catch(e=>o(e).message),s=re(a),c=s?void 0:a;throw $e(this).debug(`[${p}] response error (${i})`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,message:c,durationMs:Date.now()-h})),this.makeStatusError(v.status,s,c,v.headers)}return $e(this).info(b),$e(this).debug(`[${p}] response start`,et({retryOfRequestLogID:n,url:v.url,status:v.status,headers:v.headers,durationMs:y-h})),{response:v,options:r,controller:_,requestLogID:p,retryOfRequestLogID:n,startTime:h}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new pt(this,n,e)}async fetchWithAuth(e,t,n,r,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer workload-identity-auth`){let t=await this._workloadIdentityAuth.getToken();e.set(`Authorization`,`Bearer ${t}`)}}return await this.fetchWithTimeout(e,t,n,r)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await ie(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&ne(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l,isStreamingBody:u}=this.buildBody({options:n});return u&&(e.__metadata={...e.__metadata,hasStreamingBody:!0}),{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=F([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...fe(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e,e.__security??{bearerAuth:!0}),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a,e.__security??{bearerAuth:!0}),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=F([t]),i=globalThis.ReadableStream!==void 0&&e instanceof globalThis.ReadableStream,a=!i&&(typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||globalThis.Blob!==void 0&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!a}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:me(e),isStreamingBody:!0}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e),isStreamingBody:!1}:{...r(this,Oa,`f`).call(this,{body:e,headers:n}),isStreamingBody:!1}}};Da=I,Oa=new WeakMap,Ea=new WeakSet,ka=function(){return this.baseURL!==`https://api.openai.com/v1`},I.OpenAI=Da,I.DEFAULT_TIMEOUT=6e5,I.OpenAIError=s,I.APIError=c,I.APIConnectionError=u,I.APIConnectionTimeoutError=d,I.APIUserAbortError=l,I.NotFoundError=h,I.ConflictError=g,I.RateLimitError=v,I.BadRequestError=f,I.AuthenticationError=p,I.InternalServerError=y,I.PermissionDeniedError=m,I.UnprocessableEntityError=_,I.InvalidWebhookSignatureError=S,I.toFile=It,I.Completions=_i,I.Chat=Xn,I.Embeddings=Ci,I.Files=Di,I.Images=Ri,I.Audio=jr,I.Moderations=Bi,I.Models=zi,I.FineTuning=Fi,I.Graders=Li,I.VectorStores=ba,I.Webhooks=Ta,I.Beta=gi,I.Batches=Mr,I.Uploads=ga,I.Admin=Tr,I.Responses=ua,I.Realtime=Ui,I.Conversations=Si,I.Evals=Ei,I.Containers=bi,I.Skills=ma,I.Videos=xa;var Aa=class extends I{constructor({baseURL:e=Ur(`OPENAI_BASE_URL`),apiKey:t=Ur(`AZURE_OPENAI_API_KEY`),apiVersion:n=Ur(`OPENAI_API_VERSION`),endpoint:r,deployment:i,azureADTokenProvider:a,dangerouslyAllowBrowser:o,...c}={}){if(!n)throw new s(`The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).`);if(typeof a==`function`&&(o=!0),!a&&!t)throw new s("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(a&&t)throw new s("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(c.defaultQuery={...c.defaultQuery,"api-version":n},!e){if(r||=process.env.AZURE_OPENAI_ENDPOINT,!r)throw new s("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${r}/openai`}else if(r)throw new s(`baseURL and endpoint are mutually exclusive`);super({apiKey:a??t,baseURL:e,...c,...o===void 0?{}:{dangerouslyAllowBrowser:o}}),this.apiVersion=``,this.apiVersion=n,this.deploymentName=i}async buildRequest(e,t={}){if(ja.has(e.path)&&e.method===`post`&&e.body!==void 0){if(!te(e.body))throw Error(`Expected request body to be an object`);let t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes(`/deployments`)&&(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,t)}async authHeaders(e,t){let n=t??{bearerAuth:!0,adminAPIKeyAuth:!0};return n.bearerAuth&&typeof this._options.apiKey==`string`?F([{"api-key":this.apiKey}]):super.authHeaders(e,n)}};const ja=new Set([`/completions`,`/chat/completions`,`/embeddings`,`/audio/transcriptions`,`/audio/translations`,`/audio/speech`,`/images/generations`,`/batches`,`/images/edits`]);var L;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(L||={});var Ma;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Ma||={});const R=L.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Na=e=>{switch(typeof e){case`undefined`:return R.undefined;case`string`:return R.string;case`number`:return Number.isNaN(e)?R.nan:R.number;case`boolean`:return R.boolean;case`function`:return R.function;case`bigint`:return R.bigint;case`symbol`:return R.symbol;case`object`:return Array.isArray(e)?R.array:e===null?R.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?R.promise:typeof Map<`u`&&e instanceof Map?R.map:typeof Set<`u`&&e instanceof Set?R.set:typeof Date<`u`&&e instanceof Date?R.date:R.object;default:return R.unknown}},z=L.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`]);var Pa=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Pa.create=e=>new Pa(e);const Fa=(e,t)=>{let n;switch(e.code){case z.invalid_type:n=e.received===R.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,L.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:n=`Unrecognized key(s) in object: ${L.joinValues(e.keys,`, `)}`;break;case z.invalid_union:n=`Invalid input`;break;case z.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${L.joinValues(e.options)}`;break;case z.invalid_enum_value:n=`Invalid enum value. Expected ${L.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:n=`Invalid function arguments`;break;case z.invalid_return_type:n=`Invalid function return type`;break;case z.invalid_date:n=`Invalid date`;break;case z.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:L.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case z.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case z.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case z.custom:n=`Invalid input`;break;case z.invalid_intersection_types:n=`Intersection results could not be merged`;break;case z.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,L.assertNever(e)}return{message:n}};let Ia=Fa;function La(){return Ia}const Ra=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function B(e,t){let n=La(),r=Ra({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Fa?void 0:Fa].filter(e=>!!e)});e.common.issues.push(r)}var za=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return V;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return V;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const V=Object.freeze({status:`aborted`}),Ba=e=>({status:`dirty`,value:e}),Va=e=>({status:`valid`,value:e}),Ha=e=>e.status===`aborted`,Ua=e=>e.status===`dirty`,Wa=e=>e.status===`valid`,Ga=e=>typeof Promise<`u`&&e instanceof Promise;var H;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(H||={});var Ka=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const qa=(e,t)=>{if(Wa(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Pa(e.common.issues);return this._error=t,this._error}}};function U(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var W=class{get description(){return this._def.description}_getType(e){return Na(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Na(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new za,ctx:{common:e.parent.common,data:e.data,parsedType:Na(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ga(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Na(e)};return qa(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Na(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Wa(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Wa(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Na(e)},r=this._parse({data:e,path:n.path,parent:n});return qa(n,await(Ga(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:z.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Xo({schema:this,typeName:G.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Zo.create(this,this._def)}nullable(){return Qo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jo.create(this)}promise(){return Yo.create(this,this._def)}or(e){return Po.create([this,e],this._def)}and(e){return Ro.create(this,e,this._def)}transform(e){return new Xo({...U(this._def),schema:this,typeName:G.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new $o({...U(this._def),innerType:this,defaultValue:t,typeName:G.ZodDefault})}brand(){return new ns({typeName:G.ZodBranded,type:this,...U(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new es({...U(this._def),innerType:this,catchValue:t,typeName:G.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return rs.create(this,e)}readonly(){return is.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Ja=/^c[^\s-]{8,}$/i,Ya=/^[0-9a-z]+$/,Xa=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Za=/^[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,Qa=/^[a-z0-9_-]{21}$/i,$a=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,eo=/^[-+]?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)?)??$/,to=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let no;const ro=/^(?:(?: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])$/,io=/^(?:(?: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])$/,ao=/^(([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]))$/,oo=/^(([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])$/,so=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,co=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,lo=`((\\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])))`,uo=RegExp(`^${lo}$`);function fo(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function po(e){return RegExp(`^${fo(e)}$`)}function mo(e){let t=`${lo}T${fo(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ho(e,t){return!!((t===`v4`||!t)&&ro.test(e)||(t===`v6`||!t)&&ao.test(e))}function go(e,t){if(!$a.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function _o(e,t){return!!((t===`v4`||!t)&&io.test(e)||(t===`v6`||!t)&&oo.test(e))}var vo=class e extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.string,received:t.parsedType}),V}let t=new za,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&B(n,{code:z.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)to.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`email`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)no||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),no.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`emoji`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Za.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`uuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Qa.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`nanoid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Ja.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ya.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cuid2`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Xa.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ulid`,code:z.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),B(n,{validation:`url`,code:z.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`regex`,code:z.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?mo(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?uo.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?po(r).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:z.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?eo.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`duration`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ho(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`ip`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?go(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`jwt`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?_o(e.data,r.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`cidr`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?so.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64`,code:z.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?co.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:`base64url`,code:z.invalid_string,message:r.message}),t.dirty()):L.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:z.invalid_string,...H.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...H.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...H.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...H.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...H.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...H.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...H.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...H.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...H.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...H.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...H.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...H.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...H.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...H.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...H.errToObj(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:e?.precision===void 0?null:e?.precision,...H.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...H.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...H.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...H.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...H.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...H.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...H.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...H.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...H.errToObj(t)})}nonempty(e){return this.min(1,H.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...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(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};vo.create=e=>new vo({checks:[],typeName:G.ZodString,coerce:e?.coerce??!1,...U(e)});function yo(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var bo=class e extends W{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)!==R.number){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.number,received:t.parsedType}),V}let t,n=new za;for(let r of this._def.checks)r.kind===`int`?L.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?yo(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_finite,message:r.message}),n.dirty()):L.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,H.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,H.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,H.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,H.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:H.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:H.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:H.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:H.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:H.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:H.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let 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`&&L.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};bo.create=e=>new bo({checks:[],typeName:G.ZodNumber,coerce:e?.coerce||!1,...U(e)});var xo=class e extends W{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)!==R.bigint)return this._getInvalidInput(e);let t,n=new za;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):L.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.bigint,received:t.parsedType}),V}gte(e,t){return this.setLimit(`min`,e,!0,H.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,H.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,H.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,H.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:H.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:H.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};xo.create=e=>new xo({checks:[],typeName:G.ZodBigInt,coerce:e?.coerce??!1,...U(e)});var So=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.boolean,received:t.parsedType}),V}return Va(e.data)}};So.create=e=>new So({typeName:G.ZodBoolean,coerce:e?.coerce||!1,...U(e)});var Co=class e extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.date,received:t.parsedType}),V}if(Number.isNaN(e.data.getTime()))return B(this._getOrReturnCtx(e),{code:z.invalid_date}),V;let t=new za,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):L.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:H.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:H.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Co.create=e=>new Co({checks:[],coerce:e?.coerce||!1,typeName:G.ZodDate,...U(e)});var wo=class extends W{_parse(e){if(this._getType(e)!==R.symbol){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.symbol,received:t.parsedType}),V}return Va(e.data)}};wo.create=e=>new wo({typeName:G.ZodSymbol,...U(e)});var To=class extends W{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.undefined,received:t.parsedType}),V}return Va(e.data)}};To.create=e=>new To({typeName:G.ZodUndefined,...U(e)});var Eo=class extends W{_parse(e){if(this._getType(e)!==R.null){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.null,received:t.parsedType}),V}return Va(e.data)}};Eo.create=e=>new Eo({typeName:G.ZodNull,...U(e)});var Do=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Va(e.data)}};Do.create=e=>new Do({typeName:G.ZodAny,...U(e)});var Oo=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Va(e.data)}};Oo.create=e=>new Oo({typeName:G.ZodUnknown,...U(e)});var ko=class extends W{_parse(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.never,received:t.parsedType}),V}};ko.create=e=>new ko({typeName:G.ZodNever,...U(e)});var Ao=class extends W{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.void,received:t.parsedType}),V}return Va(e.data)}};Ao.create=e=>new Ao({typeName:G.ZodVoid,...U(e)});var jo=class e extends W{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==R.array)return B(t,{code:z.invalid_type,expected:R.array,received:t.parsedType}),V;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(B(t,{code:e?z.too_big:z.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(B(t,{code:z.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(B(t,{code:z.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Ka(t,e,t.path,n)))).then(e=>za.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Ka(t,e,t.path,n)));return za.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:H.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:H.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:H.toString(n)}})}nonempty(e){return this.min(1,e)}};jo.create=(e,t)=>new jo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...U(t)});function Mo(e){if(e instanceof No){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Zo.create(Mo(r))}return new No({...e._def,shape:()=>t})}else if(e instanceof jo)return new jo({...e._def,type:Mo(e.element)});else if(e instanceof Zo)return Zo.create(Mo(e.unwrap()));else if(e instanceof Qo)return Qo.create(Mo(e.unwrap()));else if(e instanceof zo)return zo.create(e.items.map(e=>Mo(e)));else return e}var No=class e extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=L.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==R.object){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),V}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ko&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Ka(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ko){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(B(n,{code:z.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Ka(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>za.mergeObjectSync(t,e)):za.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return H.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:H.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:G.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of L.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of L.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Mo(this)}partial(t){let n={};for(let e of L.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of L.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Zo;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ko(L.objectKeys(this.shape))}};No.create=(e,t)=>new No({shape:()=>e,unknownKeys:`strip`,catchall:ko.create(),typeName:G.ZodObject,...U(t)}),No.strictCreate=(e,t)=>new No({shape:()=>e,unknownKeys:`strict`,catchall:ko.create(),typeName:G.ZodObject,...U(t)}),No.lazycreate=(e,t)=>new No({shape:e,unknownKeys:`strip`,catchall:ko.create(),typeName:G.ZodObject,...U(t)});var Po=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Pa(e.ctx.common.issues));return B(t,{code:z.invalid_union,unionErrors:n}),V}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Pa(e));return B(t,{code:z.invalid_union,unionErrors:i}),V}}get options(){return this._def.options}};Po.create=(e,t)=>new Po({options:e,typeName:G.ZodUnion,...U(t)});const Fo=e=>e instanceof Wo?Fo(e.schema):e instanceof Xo?Fo(e.innerType()):e instanceof Go?[e.value]:e instanceof qo?e.options:e instanceof Jo?L.objectValues(e.enum):e instanceof $o?Fo(e._def.innerType):e instanceof To?[void 0]:e instanceof Eo?[null]:e instanceof Zo?[void 0,...Fo(e.unwrap())]:e instanceof Qo?[null,...Fo(e.unwrap())]:e instanceof ns||e instanceof is?Fo(e.unwrap()):e instanceof es?Fo(e._def.innerType):[];var Io=class e extends W{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.object)return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),V;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);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}):(B(t,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Fo(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:G.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...U(r)})}};function Lo(e,t){let n=Na(e),r=Na(t);if(e===t)return{valid:!0,data:e};if(n===R.object&&r===R.object){let n=L.objectKeys(t),r=L.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Lo(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===R.array&&r===R.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Lo(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===R.date&&r===R.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Ro=class extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Ha(e)||Ha(r))return V;let i=Lo(e.value,r.value);return i.valid?((Ua(e)||Ua(r))&&t.dirty(),{status:t.value,value:i.data}):(B(n,{code:z.invalid_intersection_types}),V)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ro.create=(e,t,n)=>new Ro({left:e,right:t,typeName:G.ZodIntersection,...U(n)});var zo=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return B(n,{code:z.invalid_type,expected:R.array,received:n.parsedType}),V;if(n.data.length<this._def.items.length)return B(n,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),V;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Ka(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>za.mergeArray(t,e)):za.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};zo.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new zo({items:e,typeName:G.ZodTuple,rest:null,...U(t)})};var Bo=class e extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.object)return B(n,{code:z.invalid_type,expected:R.object,received:n.parsedType}),V;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Ka(n,e,n.path,e)),value:a._parse(new Ka(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?za.mergeObjectAsync(t,r):za.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof W?new e({keyType:t,valueType:n,typeName:G.ZodRecord,...U(r)}):new e({keyType:vo.create(),valueType:t,typeName:G.ZodRecord,...U(n)})}},Vo=class extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.map)return B(n,{code:z.invalid_type,expected:R.map,received:n.parsedType}),V;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Ka(n,e,n.path,[a,`key`])),value:i._parse(new Ka(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return V;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return V;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Vo.create=(e,t,n)=>new Vo({valueType:t,keyType:e,typeName:G.ZodMap,...U(n)});var Ho=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return B(n,{code:z.invalid_type,expected:R.set,received:n.parsedType}),V;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(B(n,{code:z.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(B(n,{code:z.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return V;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Ka(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:H.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:H.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ho.create=(e,t)=>new Ho({valueType:e,minSize:null,maxSize:null,typeName:G.ZodSet,...U(t)});var Uo=class e extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.function)return B(t,{code:z.invalid_type,expected:R.function,received:t.parsedType}),V;function n(e,n){return Ra({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,La(),Fa].filter(e=>!!e),issueData:{code:z.invalid_arguments,argumentsError:n}})}function r(e,n){return Ra({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,La(),Fa].filter(e=>!!e),issueData:{code:z.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Yo){let e=this;return Va(async function(...t){let o=new Pa([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Va(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Pa([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Pa([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:zo.create(t).rest(Oo.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||zo.create([]).rest(Oo.create()),returns:n||Oo.create(),typeName:G.ZodFunction,...U(r)})}},Wo=class extends W{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Wo.create=(e,t)=>new Wo({getter:e,typeName:G.ZodLazy,...U(t)});var Go=class extends W{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:z.invalid_literal,expected:this._def.value}),V}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Go.create=(e,t)=>new Go({value:e,typeName:G.ZodLiteral,...U(t)});function Ko(e,t){return new qo({values:e,typeName:G.ZodEnum,...U(t)})}var qo=class e extends W{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:L.joinValues(n),received:t.parsedType,code:z.invalid_type}),V}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:z.invalid_enum_value,options:n}),V}return Va(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};qo.create=Ko;var Jo=class extends W{_parse(e){let t=L.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let e=L.objectValues(t);return B(n,{expected:L.joinValues(e),received:n.parsedType,code:z.invalid_type}),V}if(this._cache||=new Set(L.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=L.objectValues(t);return B(n,{received:n.data,code:z.invalid_enum_value,options:e}),V}return Va(e.data)}get enum(){return this._def.values}};Jo.create=(e,t)=>new Jo({values:e,typeName:G.ZodNativeEnum,...U(t)});var Yo=class extends W{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==R.promise&&t.common.async===!1?(B(t,{code:z.invalid_type,expected:R.promise,received:t.parsedType}),V):Va((t.parsedType===R.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Yo.create=(e,t)=>new Yo({type:e,typeName:G.ZodPromise,...U(t)});var Xo=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{B(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return V;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?V:r.status===`dirty`||t.value===`dirty`?Ba(r.value):r});{if(t.value===`aborted`)return V;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?V:r.status===`dirty`||t.value===`dirty`?Ba(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?V:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?V:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Wa(e))return V;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Wa(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):V);L.assertNever(r)}};Xo.create=(e,t,n)=>new Xo({schema:e,typeName:G.ZodEffects,effect:t,...U(n)}),Xo.createWithPreprocess=(e,t,n)=>new Xo({schema:t,effect:{type:`preprocess`,transform:e},typeName:G.ZodEffects,...U(n)});var Zo=class extends W{_parse(e){return this._getType(e)===R.undefined?Va(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Zo.create=(e,t)=>new Zo({innerType:e,typeName:G.ZodOptional,...U(t)});var Qo=class extends W{_parse(e){return this._getType(e)===R.null?Va(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qo.create=(e,t)=>new Qo({innerType:e,typeName:G.ZodNullable,...U(t)});var $o=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};$o.create=(e,t)=>new $o({innerType:e,typeName:G.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...U(t)});var es=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ga(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Pa(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Pa(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};es.create=(e,t)=>new es({innerType:e,typeName:G.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...U(t)});var ts=class extends W{_parse(e){if(this._getType(e)!==R.nan){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.nan,received:t.parsedType}),V}return{status:`valid`,value:e.data}}};ts.create=e=>new ts({typeName:G.ZodNaN,...U(e)});var ns=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},rs=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?V:e.status===`dirty`?(t.dirty(),Ba(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?V:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:G.ZodPipeline})}},is=class extends W{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Wa(e)&&(e.value=Object.freeze(e.value)),e);return Ga(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};is.create=(e,t)=>new is({innerType:e,typeName:G.ZodReadonly,...U(t)}),No.lazycreate;var G;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(G||={});const as=vo.create,os=bo.create;ts.create,xo.create;const ss=So.create;Co.create,wo.create,To.create,Eo.create,Do.create,Oo.create,ko.create,Ao.create;const cs=jo.create,ls=No.create;No.strictCreate,Po.create,Io.create,Ro.create,zo.create;const us=Bo.create;Vo.create,Ho.create,Uo.create,Wo.create,Go.create,qo.create,Jo.create,Yo.create,Xo.create,Zo.create,Qo.create,Xo.createWithPreprocess,rs.create;function ds(e){return e==null}function fs(e){return typeof e==`object`&&!!e}function ps(e){return Array.isArray(e)?e:ds(e)?[]:[e]}function ms(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function hs(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function gs(e){return e===0&&1/e==-1/0}var _s={isNothing:ds,isObject:fs,toArray:ps,repeat:hs,isNegativeZero:gs,extend:ms};function vs(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
|
|
18
|
+
|
|
19
|
+
`+e.mark.snippet),r+` `+n):r}function ys(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=vs(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}ys.prototype=Object.create(Error.prototype),ys.prototype.constructor=ys,ys.prototype.toString=function(e){return this.name+`: `+vs(this,e)};var bs=ys;function xs(e,t,n,r,i){var a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function Ss(e,t){return _s.repeat(` `,t-e.length)+e}function Cs(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||=79,typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],i=[],a,o=-1;a=n.exec(e.buffer);)i.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&o<0&&(o=r.length-2);o<0&&(o=r.length-1);var s=``,c,l,u=Math.min(e.line+t.linesAfter,i.length).toString().length,d=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(o-c<0);c++)l=xs(e.buffer,r[o-c],i[o-c],e.position-(r[o]-r[o-c]),d),s=_s.repeat(` `,t.indent)+Ss((e.line-c+1).toString(),u)+` | `+l.str+`
|
|
20
|
+
`+s;for(l=xs(e.buffer,r[o],i[o],e.position,d),s+=_s.repeat(` `,t.indent)+Ss((e.line+1).toString(),u)+` | `+l.str+`
|
|
21
|
+
`,s+=_s.repeat(`-`,t.indent+u+3+l.pos)+`^
|
|
22
|
+
`,c=1;c<=t.linesAfter&&!(o+c>=i.length);c++)l=xs(e.buffer,r[o+c],i[o+c],e.position-(r[o]-r[o+c]),d),s+=_s.repeat(` `,t.indent)+Ss((e.line+c+1).toString(),u)+` | `+l.str+`
|
|
23
|
+
`;return s.replace(/\n$/,``)}var ws=Cs,Ts=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],Es=[`scalar`,`sequence`,`mapping`];function Ds(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function Os(e,t){if(t||={},Object.keys(t).forEach(function(t){if(Ts.indexOf(t)===-1)throw new bs(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=Ds(t.styleAliases||null),Es.indexOf(this.kind)===-1)throw new bs(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}var ks=Os;function As(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function js(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function Ms(e){return this.extend(e)}Ms.prototype.extend=function(e){var t=[],n=[];if(e instanceof ks)n.push(e);else if(Array.isArray(e))n=n.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit));else throw new bs(`Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })`);t.forEach(function(e){if(!(e instanceof ks))throw new bs(`Specified list of YAML types (or a single Type object) contains a non-Type object.`);if(e.loadKind&&e.loadKind!==`scalar`)throw new bs(`There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.`);if(e.multi)throw new bs(`There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.`)}),n.forEach(function(e){if(!(e instanceof ks))throw new bs(`Specified list of YAML types (or a single Type object) contains a non-Type object.`)});var r=Object.create(Ms.prototype);return r.implicit=(this.implicit||[]).concat(t),r.explicit=(this.explicit||[]).concat(n),r.compiledImplicit=As(r,`implicit`),r.compiledExplicit=As(r,`explicit`),r.compiledTypeMap=js(r.compiledImplicit,r.compiledExplicit),r};var Ns=new Ms({explicit:[new ks(`tag:yaml.org,2002:str`,{kind:`scalar`,construct:function(e){return e===null?``:e}}),new ks(`tag:yaml.org,2002:seq`,{kind:`sequence`,construct:function(e){return e===null?[]:e}}),new ks(`tag:yaml.org,2002:map`,{kind:`mapping`,construct:function(e){return e===null?{}:e}})]});function Ps(e){if(e===null)return!0;var t=e.length;return t===1&&e===`~`||t===4&&(e===`null`||e===`Null`||e===`NULL`)}function Fs(){return null}function Is(e){return e===null}var Ls=new ks(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:Ps,construct:Fs,predicate:Is,represent:{canonical:function(){return`~`},lowercase:function(){return`null`},uppercase:function(){return`NULL`},camelcase:function(){return`Null`},empty:function(){return``}},defaultStyle:`lowercase`});function Rs(e){if(e===null)return!1;var t=e.length;return t===4&&(e===`true`||e===`True`||e===`TRUE`)||t===5&&(e===`false`||e===`False`||e===`FALSE`)}function zs(e){return e===`true`||e===`True`||e===`TRUE`}function Bs(e){return Object.prototype.toString.call(e)===`[object Boolean]`}var Vs=new ks(`tag:yaml.org,2002:bool`,{kind:`scalar`,resolve:Rs,construct:zs,predicate:Bs,represent:{lowercase:function(e){return e?`true`:`false`},uppercase:function(e){return e?`TRUE`:`FALSE`},camelcase:function(e){return e?`True`:`False`}},defaultStyle:`lowercase`});function Hs(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Us(e){return 48<=e&&e<=55}function Ws(e){return 48<=e&&e<=57}function Gs(e){if(e===null)return!1;var t=e.length,n=0,r=!1,i;if(!t)return!1;if(i=e[n],(i===`-`||i===`+`)&&(i=e[++n]),i===`0`){if(n+1===t)return!0;if(i=e[++n],i===`b`){for(n++;n<t;n++)if(i=e[n],i!==`_`){if(i!==`0`&&i!==`1`)return!1;r=!0}return r&&i!==`_`}if(i===`x`){for(n++;n<t;n++)if(i=e[n],i!==`_`){if(!Hs(e.charCodeAt(n)))return!1;r=!0}return r&&i!==`_`}if(i===`o`){for(n++;n<t;n++)if(i=e[n],i!==`_`){if(!Us(e.charCodeAt(n)))return!1;r=!0}return r&&i!==`_`}}if(i===`_`)return!1;for(;n<t;n++)if(i=e[n],i!==`_`){if(!Ws(e.charCodeAt(n)))return!1;r=!0}return!(!r||i===`_`)}function Ks(e){var t=e,n=1,r;if(t.indexOf(`_`)!==-1&&(t=t.replace(/_/g,``)),r=t[0],(r===`-`||r===`+`)&&(r===`-`&&(n=-1),t=t.slice(1),r=t[0]),t===`0`)return 0;if(r===`0`){if(t[1]===`b`)return n*parseInt(t.slice(2),2);if(t[1]===`x`)return n*parseInt(t.slice(2),16);if(t[1]===`o`)return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function qs(e){return Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!_s.isNegativeZero(e)}var Js=new ks(`tag:yaml.org,2002:int`,{kind:`scalar`,resolve:Gs,construct:Ks,predicate:qs,represent:{binary:function(e){return e>=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}}),Ys=RegExp(`^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function Xs(e){return!(e===null||!Ys.test(e)||e[e.length-1]===`_`)}function Zs(e){var t=e.replace(/_/g,``).toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}var Qs=/^[-+]?[0-9]+e/;function $s(e,t){var n;if(isNaN(e))switch(t){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(e===1/0)switch(t){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(e===-1/0)switch(t){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(_s.isNegativeZero(e))return`-0.0`;return n=e.toString(10),Qs.test(n)?n.replace(`e`,`.e`):n}function ec(e){return Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||_s.isNegativeZero(e))}var tc=new ks(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:Xs,construct:Zs,predicate:ec,represent:$s,defaultStyle:`lowercase`}),nc=Ns.extend({implicit:[Ls,Vs,Js,tc]}),rc=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),ic=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function ac(e){return e===null?!1:rc.exec(e)!==null||ic.exec(e)!==null}function oc(e){var t,n,r,i,a,o,s,c=0,l=null,u,d,f;if(t=rc.exec(e),t===null&&(t=ic.exec(e)),t===null)throw Error(`Date resolve error`);if(n=+t[1],r=t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(n,r,i));if(a=+t[4],o=+t[5],s=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+=`0`;c=+c}return t[9]&&(u=+t[10],d=+(t[11]||0),l=(u*60+d)*6e4,t[9]===`-`&&(l=-l)),f=new Date(Date.UTC(n,r,i,a,o,s,c)),l&&f.setTime(f.getTime()-l),f}function sc(e){return e.toISOString()}var cc=new ks(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:ac,construct:oc,instanceOf:Date,represent:sc});function lc(e){return e===`<<`||e===null}var uc=new ks(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:lc}),dc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
24
|
+
\r`;function fc(e){if(e===null)return!1;var t,n,r=0,i=e.length,a=dc;for(n=0;n<i;n++)if(t=a.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8==0}function pc(e){var t,n,r=e.replace(/[\r\n=]/g,``),i=r.length,a=dc,o=0,s=[];for(t=0;t<i;t++)t%4==0&&t&&(s.push(o>>16&255),s.push(o>>8&255),s.push(o&255)),o=o<<6|a.indexOf(r.charAt(t));return n=i%4*6,n===0?(s.push(o>>16&255),s.push(o>>8&255),s.push(o&255)):n===18?(s.push(o>>10&255),s.push(o>>2&255)):n===12&&s.push(o>>4&255),new Uint8Array(s)}function mc(e){var t=``,n=0,r,i,a=e.length,o=dc;for(r=0;r<a;r++)r%3==0&&r&&(t+=o[n>>18&63],t+=o[n>>12&63],t+=o[n>>6&63],t+=o[n&63]),n=(n<<8)+e[r];return i=a%3,i===0?(t+=o[n>>18&63],t+=o[n>>12&63],t+=o[n>>6&63],t+=o[n&63]):i===2?(t+=o[n>>10&63],t+=o[n>>4&63],t+=o[n<<2&63],t+=o[64]):i===1&&(t+=o[n>>2&63],t+=o[n<<4&63],t+=o[64],t+=o[64]),t}function hc(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}var gc=new ks(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:fc,construct:pc,predicate:hc,represent:mc}),_c=Object.prototype.hasOwnProperty,vc=Object.prototype.toString;function yc(e){if(e===null)return!0;var t=[],n,r,i,a,o,s=e;for(n=0,r=s.length;n<r;n+=1){if(i=s[n],o=!1,vc.call(i)!==`[object Object]`)return!1;for(a in i)if(_c.call(i,a))if(!o)o=!0;else return!1;if(!o)return!1;if(t.indexOf(a)===-1)t.push(a);else return!1}return!0}function bc(e){return e===null?[]:e}var xc=new ks(`tag:yaml.org,2002:omap`,{kind:`sequence`,resolve:yc,construct:bc}),Sc=Object.prototype.toString;function Cc(e){if(e===null)return!0;var t,n,r,i,a,o=e;for(a=Array(o.length),t=0,n=o.length;t<n;t+=1){if(r=o[t],Sc.call(r)!==`[object Object]`||(i=Object.keys(r),i.length!==1))return!1;a[t]=[i[0],r[i[0]]]}return!0}function wc(e){if(e===null)return[];var t,n,r,i,a,o=e;for(a=Array(o.length),t=0,n=o.length;t<n;t+=1)r=o[t],i=Object.keys(r),a[t]=[i[0],r[i[0]]];return a}var Tc=new ks(`tag:yaml.org,2002:pairs`,{kind:`sequence`,resolve:Cc,construct:wc}),Ec=Object.prototype.hasOwnProperty;function Dc(e){if(e===null)return!0;var t,n=e;for(t in n)if(Ec.call(n,t)&&n[t]!==null)return!1;return!0}function Oc(e){return e===null?{}:e}var kc=new ks(`tag:yaml.org,2002:set`,{kind:`mapping`,resolve:Dc,construct:Oc}),Ac=nc.extend({implicit:[cc,uc],explicit:[gc,xc,Tc,kc]}),jc=Object.prototype.hasOwnProperty,Mc=1,Nc=2,Pc=3,Fc=4,Ic=1,Lc=2,Rc=3,zc=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Bc=/[\x85\u2028\u2029]/,Vc=/[,\[\]\{\}]/,Hc=/^(?:!|!!|![a-z\-]+!)$/i,Uc=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Wc(e){return Object.prototype.toString.call(e)}function Gc(e){return e===10||e===13}function Kc(e){return e===9||e===32}function qc(e){return e===9||e===32||e===10||e===13}function Jc(e){return e===44||e===91||e===93||e===123||e===125}function Yc(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function Xc(e){return e===120?2:e===117?4:e===85?8:0}function Zc(e){return 48<=e&&e<=57?e-48:-1}function Qc(e){return e===48?`\0`:e===97?`\x07`:e===98?`\b`:e===116||e===9?` `:e===110?`
|
|
25
|
+
`:e===118?`\v`:e===102?`\f`:e===114?`\r`:e===101?`\x1B`:e===32?` `:e===34?`"`:e===47?`/`:e===92?`\\`:e===78?`
`:e===95?`\xA0`:e===76?`\u2028`:e===80?`\u2029`:``}function $c(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function el(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var tl=Array(256),nl=Array(256),rl=0;rl<256;rl++)tl[rl]=+!!Qc(rl),nl[rl]=Qc(rl);function il(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Ac,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function al(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=ws(n),new bs(t,n)}function K(e,t){throw al(e,t)}function ol(e,t){e.onWarning&&e.onWarning.call(null,al(e,t))}var sl={YAML:function(e,t,n){var r,i,a;e.version!==null&&K(e,`duplication of %YAML directive`),n.length!==1&&K(e,`YAML directive accepts exactly one argument`),r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),r===null&&K(e,`ill-formed argument of the YAML directive`),i=parseInt(r[1],10),a=parseInt(r[2],10),i!==1&&K(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&ol(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){var r,i;n.length!==2&&K(e,`TAG directive accepts exactly two arguments`),r=n[0],i=n[1],Hc.test(r)||K(e,`ill-formed tag handle (first argument) of the TAG directive`),jc.call(e.tagMap,r)&&K(e,`there is a previously declared suffix for "`+r+`" tag handle`),Uc.test(i)||K(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{i=decodeURIComponent(i)}catch{K(e,`tag prefix is malformed: `+i)}e.tagMap[r]=i}};function cl(e,t,n,r){var i,a,o,s;if(t<n){if(s=e.input.slice(t,n),r)for(i=0,a=s.length;i<a;i+=1)o=s.charCodeAt(i),o===9||32<=o&&o<=1114111||K(e,`expected valid JSON character`);else zc.test(s)&&K(e,`the stream contains non-printable characters`);e.result+=s}}function ll(e,t,n,r){var i,a,o,s;for(_s.isObject(n)||K(e,`cannot merge mappings; the provided source object is unacceptable`),i=Object.keys(n),o=0,s=i.length;o<s;o+=1)a=i[o],jc.call(t,a)||(el(t,a,n[a]),r[a]=!0)}function ul(e,t,n,r,i,a,o,s,c){var l,u;if(Array.isArray(i))for(i=Array.prototype.slice.call(i),l=0,u=i.length;l<u;l+=1)Array.isArray(i[l])&&K(e,`nested arrays are not supported inside keys`),typeof i==`object`&&Wc(i[l])===`[object Object]`&&(i[l]=`[object Object]`);if(typeof i==`object`&&Wc(i)===`[object Object]`&&(i=`[object Object]`),i=String(i),t===null&&(t={}),r===`tag:yaml.org,2002:merge`)if(Array.isArray(a))for(l=0,u=a.length;l<u;l+=1)ll(e,t,a[l],n);else ll(e,t,a,n);else !e.json&&!jc.call(n,i)&&jc.call(t,i)&&(e.line=o||e.line,e.lineStart=s||e.lineStart,e.position=c||e.position,K(e,`duplicated mapping key`)),el(t,i,a),delete n[i];return t}function dl(e){var t=e.input.charCodeAt(e.position);t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):K(e,`a line break is expected`),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function fl(e,t,n){for(var r=0,i=e.input.charCodeAt(e.position);i!==0;){for(;Kc(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(Gc(i))for(dl(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&ol(e,`deficient indentation`),r}function pl(e){var t=e.position,n=e.input.charCodeAt(t);return!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||qc(n)))}function ml(e,t){t===1?e.result+=` `:t>1&&(e.result+=_s.repeat(`
|
|
26
|
+
`,t-1))}function hl(e,t,n){var r,i,a,o,s,c,l,u,d=e.kind,f=e.result,p=e.input.charCodeAt(e.position);if(qc(p)||Jc(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(i=e.input.charCodeAt(e.position+1),qc(i)||n&&Jc(i)))return!1;for(e.kind=`scalar`,e.result=``,a=o=e.position,s=!1;p!==0;){if(p===58){if(i=e.input.charCodeAt(e.position+1),qc(i)||n&&Jc(i))break}else if(p===35){if(r=e.input.charCodeAt(e.position-1),qc(r))break}else if(e.position===e.lineStart&&pl(e)||n&&Jc(p))break;else if(Gc(p))if(c=e.line,l=e.lineStart,u=e.lineIndent,fl(e,!1,-1),e.lineIndent>=t){s=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=o,e.line=c,e.lineStart=l,e.lineIndent=u;break}s&&=(cl(e,a,o,!1),ml(e,e.line-c),a=o=e.position,!1),Kc(p)||(o=e.position+1),p=e.input.charCodeAt(++e.position)}return cl(e,a,o,!1),e.result?!0:(e.kind=d,e.result=f,!1)}function gl(e,t){var n=e.input.charCodeAt(e.position),r,i;if(n!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,r=i=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(cl(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,i=e.position;else return!0;else Gc(n)?(cl(e,r,i,!0),ml(e,fl(e,!1,t)),r=i=e.position):e.position===e.lineStart&&pl(e)?K(e,`unexpected end of the document within a single quoted scalar`):(e.position++,i=e.position);K(e,`unexpected end of the stream within a single quoted scalar`)}function _l(e,t){var n,r,i,a,o,s=e.input.charCodeAt(e.position);if(s!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(s=e.input.charCodeAt(e.position))!==0;)if(s===34)return cl(e,n,e.position,!0),e.position++,!0;else if(s===92){if(cl(e,n,e.position,!0),s=e.input.charCodeAt(++e.position),Gc(s))fl(e,!1,t);else if(s<256&&tl[s])e.result+=nl[s],e.position++;else if((o=Xc(s))>0){for(i=o,a=0;i>0;i--)s=e.input.charCodeAt(++e.position),(o=Yc(s))>=0?a=(a<<4)+o:K(e,`expected hexadecimal character`);e.result+=$c(a),e.position++}else K(e,`unknown escape sequence`);n=r=e.position}else Gc(s)?(cl(e,n,r,!0),ml(e,fl(e,!1,t)),n=r=e.position):e.position===e.lineStart&&pl(e)?K(e,`unexpected end of the document within a double quoted scalar`):(e.position++,r=e.position);K(e,`unexpected end of the stream within a double quoted scalar`)}function vl(e,t){var n=!0,r,i,a,o=e.tag,s,c=e.anchor,l,u,d,f,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)u=93,p=!1,s=[];else if(v===123)u=125,p=!0,s={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),v=e.input.charCodeAt(++e.position);v!==0;){if(fl(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=o,e.anchor=c,e.kind=p?`mapping`:`sequence`,e.result=s,!0;n?v===44&&K(e,`expected the node content, but found ','`):K(e,`missed comma between flow collection entries`),g=h=_=null,d=f=!1,v===63&&(l=e.input.charCodeAt(e.position+1),qc(l)&&(d=f=!0,e.position++,fl(e,!0,t))),r=e.line,i=e.lineStart,a=e.position,Tl(e,t,Mc,!1,!0),g=e.tag,h=e.result,fl(e,!0,t),v=e.input.charCodeAt(e.position),(f||e.line===r)&&v===58&&(d=!0,v=e.input.charCodeAt(++e.position),fl(e,!0,t),Tl(e,t,Mc,!1,!0),_=e.result),p?ul(e,s,m,g,h,_,r,i,a):d?s.push(ul(e,null,m,g,h,_,r,i,a)):s.push(h),fl(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}K(e,`unexpected end of the stream within a flow collection`)}function yl(e,t){var n,r,i=Ic,a=!1,o=!1,s=t,c=0,l=!1,u,d=e.input.charCodeAt(e.position);if(d===124)r=!1;else if(d===62)r=!0;else return!1;for(e.kind=`scalar`,e.result=``;d!==0;)if(d=e.input.charCodeAt(++e.position),d===43||d===45)Ic===i?i=d===43?Rc:Lc:K(e,`repeat of a chomping mode identifier`);else if((u=Zc(d))>=0)u===0?K(e,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?K(e,`repeat of an indentation width identifier`):(s=t+u-1,o=!0);else break;if(Kc(d)){do d=e.input.charCodeAt(++e.position);while(Kc(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!Gc(d)&&d!==0)}for(;d!==0;){for(dl(e),e.lineIndent=0,d=e.input.charCodeAt(e.position);(!o||e.lineIndent<s)&&d===32;)e.lineIndent++,d=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>s&&(s=e.lineIndent),Gc(d)){c++;continue}if(e.lineIndent<s){i===Rc?e.result+=_s.repeat(`
|
|
27
|
+
`,a?1+c:c):i===Ic&&a&&(e.result+=`
|
|
28
|
+
`);break}for(r?Kc(d)?(l=!0,e.result+=_s.repeat(`
|
|
29
|
+
`,a?1+c:c)):l?(l=!1,e.result+=_s.repeat(`
|
|
30
|
+
`,c+1)):c===0?a&&(e.result+=` `):e.result+=_s.repeat(`
|
|
31
|
+
`,c):e.result+=_s.repeat(`
|
|
32
|
+
`,a?1+c:c),a=!0,o=!0,c=0,n=e.position;!Gc(d)&&d!==0;)d=e.input.charCodeAt(++e.position);cl(e,n,e.position,!1)}return!0}function bl(e,t){var n,r=e.tag,i=e.anchor,a=[],o,s=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,K(e,`tab characters must not be used in indentation`)),!(c!==45||(o=e.input.charCodeAt(e.position+1),!qc(o))));){if(s=!0,e.position++,fl(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Tl(e,t,Pc,!1,!0),a.push(e.result),fl(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)K(e,`bad indentation of a sequence entry`);else if(e.lineIndent<t)break}return s?(e.tag=r,e.anchor=i,e.kind=`sequence`,e.result=a,!0):!1}function xl(e,t,n){var r,i,a,o,s,c,l=e.tag,u=e.anchor,d={},f=Object.create(null),p=null,m=null,h=null,g=!1,_=!1,v;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=d),v=e.input.charCodeAt(e.position);v!==0;){if(!g&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,K(e,`tab characters must not be used in indentation`)),r=e.input.charCodeAt(e.position+1),a=e.line,(v===63||v===58)&&qc(r))v===63?(g&&(ul(e,d,f,p,m,null,o,s,c),p=m=h=null),_=!0,g=!0,i=!0):g?(g=!1,i=!0):K(e,`incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line`),e.position+=1,v=r;else{if(o=e.line,s=e.lineStart,c=e.position,!Tl(e,n,Nc,!1,!0))break;if(e.line===a){for(v=e.input.charCodeAt(e.position);Kc(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),qc(v)||K(e,`a whitespace character is expected after the key-value separator within a block mapping`),g&&(ul(e,d,f,p,m,null,o,s,c),p=m=h=null),_=!0,g=!1,i=!1,p=e.tag,m=e.result;else if(_)K(e,`can not read an implicit mapping pair; a colon is missed`);else return e.tag=l,e.anchor=u,!0}else if(_)K(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return e.tag=l,e.anchor=u,!0}if((e.line===a||e.lineIndent>t)&&(g&&(o=e.line,s=e.lineStart,c=e.position),Tl(e,t,Fc,!0,i)&&(g?m=e.result:h=e.result),g||(ul(e,d,f,p,m,h,o,s,c),p=m=h=null),fl(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&v!==0)K(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return g&&ul(e,d,f,p,m,null,o,s,c),_&&(e.tag=l,e.anchor=u,e.kind=`mapping`,e.result=d),_}function Sl(e){var t,n=!1,r=!1,i,a,o=e.input.charCodeAt(e.position);if(o!==33)return!1;if(e.tag!==null&&K(e,`duplication of a tag property`),o=e.input.charCodeAt(++e.position),o===60?(n=!0,o=e.input.charCodeAt(++e.position)):o===33?(r=!0,i=`!!`,o=e.input.charCodeAt(++e.position)):i=`!`,t=e.position,n){do o=e.input.charCodeAt(++e.position);while(o!==0&&o!==62);e.position<e.length?(a=e.input.slice(t,e.position),o=e.input.charCodeAt(++e.position)):K(e,`unexpected end of the stream within a verbatim tag`)}else{for(;o!==0&&!qc(o);)o===33&&(r?K(e,`tag suffix cannot contain exclamation marks`):(i=e.input.slice(t-1,e.position+1),Hc.test(i)||K(e,`named tag handle cannot contain such characters`),r=!0,t=e.position+1)),o=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),Vc.test(a)&&K(e,`tag suffix cannot contain flow indicator characters`)}a&&!Uc.test(a)&&K(e,`tag name cannot contain such characters: `+a);try{a=decodeURIComponent(a)}catch{K(e,`tag name is malformed: `+a)}return n?e.tag=a:jc.call(e.tagMap,i)?e.tag=e.tagMap[i]+a:i===`!`?e.tag=`!`+a:i===`!!`?e.tag=`tag:yaml.org,2002:`+a:K(e,`undeclared tag handle "`+i+`"`),!0}function Cl(e){var t,n=e.input.charCodeAt(e.position);if(n!==38)return!1;for(e.anchor!==null&&K(e,`duplication of an anchor property`),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!qc(n)&&!Jc(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&K(e,`name of an anchor node must contain at least one character`),e.anchor=e.input.slice(t,e.position),!0}function wl(e){var t,n,r=e.input.charCodeAt(e.position);if(r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!qc(r)&&!Jc(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&K(e,`name of an alias node must contain at least one character`),n=e.input.slice(t,e.position),jc.call(e.anchorMap,n)||K(e,`unidentified alias "`+n+`"`),e.result=e.anchorMap[n],fl(e,!0,-1),!0}function Tl(e,t,n,r,i){var a,o,s,c=1,l=!1,u=!1,d,f,p,m,h,g;if(e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=o=s=Fc===n||Pc===n,r&&fl(e,!0,-1)&&(l=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;Sl(e)||Cl(e);)fl(e,!0,-1)?(l=!0,s=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):s=!1;if(s&&=l||i,(c===1||Fc===n)&&(h=Mc===n||Nc===n?t:t+1,g=e.position-e.lineStart,c===1?s&&(bl(e,g)||xl(e,g,h))||vl(e,h)?u=!0:(o&&yl(e,h)||gl(e,h)||_l(e,h)?u=!0:wl(e)?(u=!0,(e.tag!==null||e.anchor!==null)&&K(e,`alias node should not have any properties`)):hl(e,h,Mc===n)&&(u=!0,e.tag===null&&(e.tag=`?`)),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(u=s&&bl(e,g))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag===`?`){for(e.result!==null&&e.kind!==`scalar`&&K(e,`unacceptable node kind for !<?> tag; it should be "scalar", not "`+e.kind+`"`),d=0,f=e.implicitTypes.length;d<f;d+=1)if(m=e.implicitTypes[d],m.resolve(e.result)){e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!==`!`){if(jc.call(e.typeMap[e.kind||`fallback`],e.tag))m=e.typeMap[e.kind||`fallback`][e.tag];else for(m=null,p=e.typeMap.multi[e.kind||`fallback`],d=0,f=p.length;d<f;d+=1)if(e.tag.slice(0,p[d].tag.length)===p[d].tag){m=p[d];break}m||K(e,`unknown tag !<`+e.tag+`>`),e.result!==null&&m.kind!==e.kind&&K(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+m.kind+`", not "`+e.kind+`"`),m.resolve(e.result,e.tag)?(e.result=m.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):K(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),e.tag!==null||e.anchor!==null||u}function El(e){var t=e.position,n,r,i,a=!1,o;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(o=e.input.charCodeAt(e.position))!==0&&(fl(e,!0,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||o!==37));){for(a=!0,o=e.input.charCodeAt(++e.position),n=e.position;o!==0&&!qc(o);)o=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),i=[],r.length<1&&K(e,`directive name must not be less than one character in length`);o!==0;){for(;Kc(o);)o=e.input.charCodeAt(++e.position);if(o===35){do o=e.input.charCodeAt(++e.position);while(o!==0&&!Gc(o));break}if(Gc(o))break;for(n=e.position;o!==0&&!qc(o);)o=e.input.charCodeAt(++e.position);i.push(e.input.slice(n,e.position))}o!==0&&dl(e),jc.call(sl,r)?sl[r](e,r,i):ol(e,`unknown document directive "`+r+`"`)}if(fl(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,fl(e,!0,-1)):a&&K(e,`directives end mark is expected`),Tl(e,e.lineIndent-1,Fc,!1,!0),fl(e,!0,-1),e.checkLineBreaks&&Bc.test(e.input.slice(t,e.position))&&ol(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&pl(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,fl(e,!0,-1));return}if(e.position<e.length-1)K(e,`end of the stream or a document separator is expected`);else return}function Dl(e,t){e=String(e),t||={},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
33
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new il(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,K(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)El(n);return n.documents}function Ol(e,t,n){typeof t==`object`&&t&&n===void 0&&(n=t,t=null);var r=Dl(e,n);if(typeof t!=`function`)return r;for(var i=0,a=r.length;i<a;i+=1)t(r[i])}function kl(e,t){var n=Dl(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new bs(`expected a single document in the stream, but found more`)}}var Al={loadAll:Ol,load:kl},jl=Object.prototype.toString,Ml=Object.prototype.hasOwnProperty,Nl=65279,Pl=9,Fl=10,Il=13,Ll=32,Rl=33,zl=34,Bl=35,Vl=37,Hl=38,Ul=39,Wl=42,Gl=44,Kl=45,ql=58,Jl=61,Yl=62,Xl=63,Zl=64,Ql=91,$l=93,eu=96,tu=123,nu=124,ru=125,iu={};iu[0]=`\\0`,iu[7]=`\\a`,iu[8]=`\\b`,iu[9]=`\\t`,iu[10]=`\\n`,iu[11]=`\\v`,iu[12]=`\\f`,iu[13]=`\\r`,iu[27]=`\\e`,iu[34]=`\\"`,iu[92]=`\\\\`,iu[133]=`\\N`,iu[160]=`\\_`,iu[8232]=`\\L`,iu[8233]=`\\P`;var au=[`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],ou=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function su(e,t){var n,r,i,a,o,s,c;if(t===null)return{};for(n={},r=Object.keys(t),i=0,a=r.length;i<a;i+=1)o=r[i],s=String(t[o]),o.slice(0,2)===`!!`&&(o=`tag:yaml.org,2002:`+o.slice(2)),c=e.compiledTypeMap.fallback[o],c&&Ml.call(c.styleAliases,s)&&(s=c.styleAliases[s]),n[o]=s;return n}function cu(e){var t=e.toString(16).toUpperCase(),n,r;if(e<=255)n=`x`,r=2;else if(e<=65535)n=`u`,r=4;else if(e<=4294967295)n=`U`,r=8;else throw new bs(`code point within a string may not be greater than 0xFFFFFFFF`);return`\\`+n+_s.repeat(`0`,r-t.length)+t}var lu=1,uu=2;function du(e){this.schema=e.schema||Ac,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=_s.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=su(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType===`"`?uu:lu,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer==`function`?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result=``,this.duplicates=[],this.usedDuplicates=null}function fu(e,t){for(var n=_s.repeat(` `,t),r=0,i=-1,a=``,o,s=e.length;r<s;)i=e.indexOf(`
|
|
34
34
|
`,r),i===-1?(o=e.slice(r),r=s):(o=e.slice(r,i+1),r=i+1),o.length&&o!==`
|
|
35
|
-
`&&(a+=n),a+=o;return a}function
|
|
36
|
-
`+
|
|
35
|
+
`&&(a+=n),a+=o;return a}function pu(e,t){return`
|
|
36
|
+
`+_s.repeat(` `,e.indent*t)}function mu(e,t){var n,r,i;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(i=e.implicitTypes[n],i.resolve(t))return!0;return!1}function hu(e){return e===Ll||e===Pl}function gu(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Nl||65536<=e&&e<=1114111}function _u(e){return gu(e)&&e!==Nl&&e!==Il&&e!==Fl}function vu(e,t,n){var r=_u(e),i=r&&!hu(e);return(n?r:r&&e!==Gl&&e!==Ql&&e!==$l&&e!==tu&&e!==ru)&&e!==Bl&&!(t===ql&&!i)||_u(t)&&!hu(t)&&e===Bl||t===ql&&i}function yu(e){return gu(e)&&e!==Nl&&!hu(e)&&e!==Kl&&e!==Xl&&e!==ql&&e!==Gl&&e!==Ql&&e!==$l&&e!==tu&&e!==ru&&e!==Bl&&e!==Hl&&e!==Wl&&e!==Rl&&e!==nu&&e!==Jl&&e!==Yl&&e!==Ul&&e!==zl&&e!==Vl&&e!==Zl&&e!==eu}function bu(e){return!hu(e)&&e!==ql}function xu(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Su(e){return/^\n* /.test(e)}var Cu=1,wu=2,Tu=3,Eu=4,Du=5;function Ou(e,t,n,r,i,a,o,s){var c,l=0,u=null,d=!1,f=!1,p=r!==-1,m=-1,h=yu(xu(e,0))&&bu(xu(e,e.length-1));if(t||o)for(c=0;c<e.length;l>=65536?c+=2:c++){if(l=xu(e,c),!gu(l))return Du;h&&=vu(l,u,s),u=l}else{for(c=0;c<e.length;l>=65536?c+=2:c++){if(l=xu(e,c),l===Fl)d=!0,p&&(f||=c-m-1>r&&e[m+1]!==` `,m=c);else if(!gu(l))return Du;h&&=vu(l,u,s),u=l}f||=p&&c-m-1>r&&e[m+1]!==` `}return!d&&!f?h&&!o&&!i(e)?Cu:a===uu?Du:wu:n>9&&Su(e)?Du:o?a===uu?Du:wu:f?Eu:Tu}function ku(e,t,n,r,i){e.dump=function(){if(t.length===0)return e.quotingType===uu?`""`:`''`;if(!e.noCompatMode&&(au.indexOf(t)!==-1||ou.test(t)))return e.quotingType===uu?`"`+t+`"`:`'`+t+`'`;var a=e.indent*Math.max(1,n),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),s=r||e.flowLevel>-1&&n>=e.flowLevel;function c(t){return mu(e,t)}switch(Ou(t,s,e.indent,o,c,e.quotingType,e.forceQuotes&&!r,i)){case Cu:return t;case wu:return`'`+t.replace(/'/g,`''`)+`'`;case Tu:return`|`+Au(t,e.indent)+ju(fu(t,a));case Eu:return`>`+Au(t,e.indent)+ju(fu(Mu(t,o),a));case Du:return`"`+Pu(t)+`"`;default:throw new bs(`impossible error: invalid scalar style`)}}()}function Au(e,t){var n=Su(e)?String(t):``,r=e[e.length-1]===`
|
|
37
37
|
`;return n+(r&&(e[e.length-2]===`
|
|
38
38
|
`||e===`
|
|
39
39
|
`)?`+`:r?``:`-`)+`
|
|
40
|
-
`}function
|
|
41
|
-
`?e.slice(0,-1):e}function
|
|
42
|
-
`);return r=r===-1?e.length:r,n.lastIndex=r,
|
|
40
|
+
`}function ju(e){return e[e.length-1]===`
|
|
41
|
+
`?e.slice(0,-1):e}function Mu(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var r=e.indexOf(`
|
|
42
|
+
`);return r=r===-1?e.length:r,n.lastIndex=r,Nu(e.slice(0,r),t)}(),i=e[0]===`
|
|
43
43
|
`||e[0]===` `,a,o;o=n.exec(e);){var s=o[1],c=o[2];a=c[0]===` `,r+=s+(!i&&!a&&c!==``?`
|
|
44
|
-
`:``)+
|
|
44
|
+
`:``)+Nu(c,t),i=a}return r}function Nu(e,t){if(e===``||e[0]===` `)return e;for(var n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=`
|
|
45
45
|
`+e.slice(i,a),i=a+1),o=s;return c+=`
|
|
46
46
|
`,e.length-i>t&&o>i?c+=e.slice(i,o)+`
|
|
47
|
-
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function
|
|
48
|
-
`:``}var
|
|
49
|
-
`&&(u(),c=``,l=0,n=!1);if(!h.scan(d))break;if(o=!0,_=h.scan(
|
|
47
|
+
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function Pu(e){for(var t=``,n=0,r,i=0;i<e.length;n>=65536?i+=2:i++)n=xu(e,i),r=iu[n],!r&&gu(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||cu(n);return t}function Fu(e,t,n){var r=``,i=e.tag,a,o,s;for(a=0,o=n.length;a<o;a+=1)s=n[a],e.replacer&&(s=e.replacer.call(n,String(a),s)),(Bu(e,t,s,!1,!1)||s===void 0&&Bu(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump);e.tag=i,e.dump=`[`+r+`]`}function Iu(e,t,n,r){var i=``,a=e.tag,o,s,c;for(o=0,s=n.length;o<s;o+=1)c=n[o],e.replacer&&(c=e.replacer.call(n,String(o),c)),(Bu(e,t+1,c,!0,!0,!1,!0)||c===void 0&&Bu(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=pu(e,t)),e.dump&&Fl===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump);e.tag=a,e.dump=i||`[]`}function Lu(e,t,n){var r=``,i=e.tag,a=Object.keys(n),o,s,c,l,u;for(o=0,s=a.length;o<s;o+=1)u=``,r!==``&&(u+=`, `),e.condenseFlow&&(u+=`"`),c=a[o],l=n[c],e.replacer&&(l=e.replacer.call(n,c,l)),Bu(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+=`? `),u+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),Bu(e,t,l,!1,!1)&&(u+=e.dump,r+=u));e.tag=i,e.dump=`{`+r+`}`}function Ru(e,t,n,r){var i=``,a=e.tag,o=Object.keys(n),s,c,l,u,d,f;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys==`function`)o.sort(e.sortKeys);else if(e.sortKeys)throw new bs(`sortKeys must be a boolean or a function`);for(s=0,c=o.length;s<c;s+=1)f=``,(!r||i!==``)&&(f+=pu(e,t)),l=o[s],u=n[l],e.replacer&&(u=e.replacer.call(n,l,u)),Bu(e,t+1,l,!0,!0,!0)&&(d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024,d&&(e.dump&&Fl===e.dump.charCodeAt(0)?f+=`?`:f+=`? `),f+=e.dump,d&&(f+=pu(e,t)),Bu(e,t+1,u,!0,d)&&(e.dump&&Fl===e.dump.charCodeAt(0)?f+=`:`:f+=`: `,f+=e.dump,i+=f));e.tag=a,e.dump=i||`{}`}function zu(e,t,n){var r,i=n?e.explicitTypes:e.implicitTypes,a,o,s,c;for(a=0,o=i.length;a<o;a+=1)if(s=i[a],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof t==`object`&&t instanceof s.instanceOf)&&(!s.predicate||s.predicate(t))){if(n?s.multi&&s.representName?e.tag=s.representName(t):e.tag=s.tag:e.tag=`?`,s.represent){if(c=e.styleMap[s.tag]||s.defaultStyle,jl.call(s.represent)===`[object Function]`)r=s.represent(t,c);else if(Ml.call(s.represent,c))r=s.represent[c](t,c);else throw new bs(`!<`+s.tag+`> tag resolver accepts not "`+c+`" style`);e.dump=r}return!0}return!1}function Bu(e,t,n,r,i,a,o){e.tag=null,e.dump=n,zu(e,n,!1)||zu(e,n,!0);var s=jl.call(e.dump),c=r,l;r&&=e.flowLevel<0||e.flowLevel>t;var u=s===`[object Object]`||s===`[object Array]`,d,f;if(u&&(d=e.duplicates.indexOf(n),f=d!==-1),(e.tag!==null&&e.tag!==`?`||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[d])e.dump=`*ref_`+d;else{if(u&&f&&!e.usedDuplicates[d]&&(e.usedDuplicates[d]=!0),s===`[object Object]`)r&&Object.keys(e.dump).length!==0?(Ru(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(Lu(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object Array]`)r&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?Iu(e,t-1,e.dump,i):Iu(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(Fu(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object String]`)e.tag!==`?`&&ku(e,e.dump,t,a,c);else if(s===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new bs(`unacceptable kind of an object to dump `+s)}e.tag!==null&&e.tag!==`?`&&(l=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`),l=e.tag[0]===`!`?`!`+l:l.slice(0,18)===`tag:yaml.org,2002:`?`!!`+l.slice(18):`!<`+l+`>`,e.dump=l+` `+e.dump)}return!0}function Vu(e,t){var n=[],r=[],i,a;for(Hu(e,n,r),i=0,a=r.length;i<a;i+=1)t.duplicates.push(n[r[i]]);t.usedDuplicates=Array(a)}function Hu(e,t,n){var r,i,a;if(typeof e==`object`&&e)if(i=t.indexOf(e),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(t.push(e),Array.isArray(e))for(i=0,a=e.length;i<a;i+=1)Hu(e[i],t,n);else for(r=Object.keys(e),i=0,a=r.length;i<a;i+=1)Hu(e[r[i]],t,n)}function Uu(e,t){t||={};var n=new du(t);n.noRefs||Vu(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),Bu(n,0,r,!0,!0)?n.dump+`
|
|
48
|
+
`:``}var Wu={dump:Uu},Gu=Al.load;Al.loadAll,Wu.dump;var Ku=Object.prototype.toString,qu=Array.isArray||function(e){return Ku.call(e)===`[object Array]`};function Ju(e){return typeof e==`function`}function Yu(e){return qu(e)?`array`:typeof e}function Xu(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function Zu(e,t){return typeof e==`object`&&!!e&&t in e}function Qu(e,t){return e!=null&&typeof e!=`object`&&e.hasOwnProperty&&e.hasOwnProperty(t)}var $u=RegExp.prototype.test;function ed(e,t){return $u.call(e,t)}var td=/\S/;function nd(e){return!ed(td,e)}var rd={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`,"`":```,"=":`=`};function id(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return rd[e]})}var ad=/\s*/,od=/\s+/,sd=/\s*=/,cd=/\s*\}/,ld=/#|\^|\/|>|\{|&|=|!/;function ud(e,t){if(!e)return[];var n=!1,r=[],i=[],a=[],o=!1,s=!1,c=``,l=0;function u(){if(o&&!s)for(;a.length;)delete i[a.pop()];else a=[];o=!1,s=!1}var d,f,p;function m(e){if(typeof e==`string`&&(e=e.split(od,2)),!qu(e)||e.length!==2)throw Error(`Invalid tags: `+e);d=RegExp(Xu(e[0])+`\\s*`),f=RegExp(`\\s*`+Xu(e[1])),p=RegExp(`\\s*`+Xu(`}`+e[1]))}m(t||gd.tags);for(var h=new pd(e),g,_,v,y,b,x;!h.eos();){if(g=h.pos,v=h.scanUntil(d),v)for(var S=0,C=v.length;S<C;++S)y=v.charAt(S),nd(y)?(a.push(i.length),c+=y):(s=!0,n=!0,c+=` `),i.push([`text`,y,g,g+1]),g+=1,y===`
|
|
49
|
+
`&&(u(),c=``,l=0,n=!1);if(!h.scan(d))break;if(o=!0,_=h.scan(ld)||`name`,h.scan(ad),_===`=`?(v=h.scanUntil(sd),h.scan(sd),h.scanUntil(f)):_===`{`?(v=h.scanUntil(p),h.scan(cd),h.scanUntil(f),_=`&`):v=h.scanUntil(f),!h.scan(f))throw Error(`Unclosed tag at `+h.pos);if(b=_==`>`?[_,v,g,h.pos,c,l,n]:[_,v,g,h.pos],l++,i.push(b),_===`#`||_===`^`)r.push(b);else if(_===`/`){if(x=r.pop(),!x)throw Error(`Unopened section "`+v+`" at `+g);if(x[1]!==v)throw Error(`Unclosed section "`+x[1]+`" at `+g)}else _===`name`||_===`{`||_===`&`?s=!0:_===`=`&&m(v)}if(u(),x=r.pop(),x)throw Error(`Unclosed section "`+x[1]+`" at `+h.pos);return fd(dd(i))}function dd(e){for(var t=[],n,r,i=0,a=e.length;i<a;++i)n=e[i],n&&(n[0]===`text`&&r&&r[0]===`text`?(r[1]+=n[1],r[3]=n[3]):(t.push(n),r=n));return t}function fd(e){for(var t=[],n=t,r=[],i,a,o=0,s=e.length;o<s;++o)switch(i=e[o],i[0]){case`#`:case`^`:n.push(i),r.push(i),n=i[4]=[];break;case`/`:a=r.pop(),a[5]=i[2],n=r.length>0?r[r.length-1][4]:t;break;default:n.push(i)}return t}function pd(e){this.string=e,this.tail=e,this.pos=0}pd.prototype.eos=function(){return this.tail===``},pd.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return``;var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},pd.prototype.scanUntil=function(e){var t=this.tail.search(e),n;switch(t){case-1:n=this.tail,this.tail=``;break;case 0:n=``;break;default:n=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=n.length,n};function md(e,t){this.view=e,this.cache={".":this.view},this.parent=t}md.prototype.push=function(e){return new md(e,this)},md.prototype.lookup=function(e){var t=this.cache,n;if(t.hasOwnProperty(e))n=t[e];else{for(var r=this,i,a,o,s=!1;r;){if(e.indexOf(`.`)>0)for(i=r.view,a=e.split(`.`),o=0;i!=null&&o<a.length;)o===a.length-1&&(s=Zu(i,a[o])||Qu(i,a[o])),i=i[a[o++]];else i=r.view[e],s=Zu(r.view,e);if(s){n=i;break}r=r.parent}t[e]=n}return Ju(n)&&(n=n.call(this.view)),n};function hd(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}hd.prototype.clearCache=function(){this.templateCache!==void 0&&this.templateCache.clear()},hd.prototype.parse=function(e,t){var n=this.templateCache,r=e+`:`+(t||gd.tags).join(`:`),i=n!==void 0,a=i?n.get(r):void 0;return a??(a=ud(e,t),i&&n.set(r,a)),a},hd.prototype.render=function(e,t,n,r){var i=this.getConfigTags(r),a=this.parse(e,i),o=t instanceof md?t:new md(t,void 0);return this.renderTokens(a,o,n,e,r)},hd.prototype.renderTokens=function(e,t,n,r,i){for(var a=``,o,s,c,l=0,u=e.length;l<u;++l)c=void 0,o=e[l],s=o[0],s===`#`?c=this.renderSection(o,t,n,r,i):s===`^`?c=this.renderInverted(o,t,n,r,i):s===`>`?c=this.renderPartial(o,t,n,i):s===`&`?c=this.unescapedValue(o,t):s===`name`?c=this.escapedValue(o,t,i):s===`text`&&(c=this.rawValue(o)),c!==void 0&&(a+=c);return a},hd.prototype.renderSection=function(e,t,n,r,i){var a=this,o=``,s=t.lookup(e[1]);function c(e){return a.render(e,t,n,i)}if(s){if(qu(s))for(var l=0,u=s.length;l<u;++l)o+=this.renderTokens(e[4],t.push(s[l]),n,r,i);else if(typeof s==`object`||typeof s==`string`||typeof s==`number`)o+=this.renderTokens(e[4],t.push(s),n,r,i);else if(Ju(s)){if(typeof r!=`string`)throw Error(`Cannot use higher-order sections without the original template`);s=s.call(t.view,r.slice(e[3],e[5]),c),s!=null&&(o+=s)}else o+=this.renderTokens(e[4],t,n,r,i);return o}},hd.prototype.renderInverted=function(e,t,n,r,i){var a=t.lookup(e[1]);if(!a||qu(a)&&a.length===0)return this.renderTokens(e[4],t,n,r,i)},hd.prototype.indentPartial=function(e,t,n){for(var r=t.replace(/[^ \t]/g,``),i=e.split(`
|
|
50
50
|
`),a=0;a<i.length;a++)i[a].length&&(a>0||!n)&&(i[a]=r+i[a]);return i.join(`
|
|
51
|
-
`)},ld.prototype.renderPartial=function(e,t,n,r){if(n){var i=this.getConfigTags(r),a=Hu(n)?n(e[1]):n[e[1]];if(a!=null){var o=e[6],s=e[5],c=e[4],l=a;s==0&&c&&(l=this.indentPartial(a,c,o));var u=this.parse(l,i);return this.renderTokens(u,t,n,l,r)}}},ld.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(n!=null)return n},ld.prototype.escapedValue=function(e,t,n){var r=this.getConfigEscape(n)||ud.escape,i=t.lookup(e[1]);if(i!=null)return typeof i==`number`&&r===ud.escape?String(i):r(i)},ld.prototype.rawValue=function(e){return e[1]},ld.prototype.getConfigTags=function(e){if(Vu(e))return e;if(e&&typeof e==`object`)return e.tags},ld.prototype.getConfigEscape=function(e){if(e&&typeof e==`object`&&!Vu(e))return e.escape};var ud={name:`mustache.js`,version:`4.2.0`,tags:[`{{`,`}}`],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){dd.templateCache=e},get templateCache(){return dd.templateCache}},dd=new ld;ud.clearCache=function(){return dd.clearCache()},ud.parse=function(e,t){return dd.parse(e,t)},ud.render=function(e,t,n,r){if(typeof e!=`string`)throw TypeError(`Invalid template! Template should be a "string" but "`+Uu(e)+`" was given as the first argument for mustache#render(template, view, partials)`);return dd.render(e,t,n,r)},ud.escape=Qu,ud.Scanner=sd,ud.Context=cd,ud.Writer=ld;var fd=t(((e,t)=>{t.exports=(function(){function e(e,t,n,r,i){return e<t||n<t?e>n?n+1:e+1:r===i?t:t+1}return function(t,n){if(t===n)return 0;if(t.length>n.length){var r=t;t=n,n=r}for(var i=t.length,a=n.length;i>0&&t.charCodeAt(i-1)===n.charCodeAt(a-1);)i--,a--;for(var o=0;o<i&&t.charCodeAt(o)===n.charCodeAt(o);)o++;if(i-=o,a-=o,i===0||a<3)return a;var s=0,c,l,u,d,f,p,m,h,g,_,v,y,b=[];for(c=0;c<i;c++)b.push(c+1),b.push(t.charCodeAt(o+c));for(var x=b.length-1;s<a-3;)for(g=n.charCodeAt(o+(l=s)),_=n.charCodeAt(o+(u=s+1)),v=n.charCodeAt(o+(d=s+2)),y=n.charCodeAt(o+(f=s+3)),p=s+=4,c=0;c<x;c+=2)m=b[c],h=b[c+1],l=e(m,l,u,g,h),u=e(l,u,d,_,h),d=e(u,d,f,v,h),p=e(d,f,p,y,h),b[c]=p,f=d,d=u,u=l,l=m;for(;s<a;)for(g=n.charCodeAt(o+(l=s)),p=++s,c=0;c<x;c+=2)m=b[c],b[c]=p=e(m,l,p,g,b[c+1]),l=m;return p}})()})),pd=t(((e,t)=>{function n(e){return Object.prototype.toString.call(e)===`[object Array]`}t.exports=Array.isArray||n})),md=t(((e,t)=>{function n(e){return typeof e==`function`}t.exports=n})),hd=t(((e,t)=>{var n=pd(),r=md();function i(e,t,i){if(!n(e))throw TypeError("dot()::invalid input argument. First argument must be an array. Value: `"+e+"`.");if(!n(t))throw TypeError("dot()::invalid input argument. Second argument must be an array. Value: `"+t+"`.");if(arguments.length>2&&!r(i))throw TypeError("dot()::invalid input argument. Accessor must be a function. Value: `"+i+"`.");var a=e.length,o=0,s;if(a!==t.length)throw Error(`dot()::invalid input argument. Arrays must be of equal length.`);if(!a)return null;if(i)for(s=0;s<a;s++)o+=i(e[s],s,0)*i(t[s],s,1);else for(s=0;s<a;s++)o+=e[s]*t[s];return o}t.exports=i})),gd=t(((e,t)=>{var n=pd(),r=md();function i(e,t){if(!n(e))throw TypeError("l2norm()::invalid input argument. Must provide an array. Value: `"+e+"`.");if(arguments.length>1&&!r(t))throw TypeError("l2norm()::invalid input argument. Accessor must be a function. Value: `"+t+"`.");var i=e.length,a=0,o=1,s,c,l,u;if(!i)return null;if(t)for(u=0;u<i;u++)c=t(e[u],u),l=c<0?-c:c,l>0&&(l>a?(s=a/c,o=1+o*s*s,a=l):(s=c/a,o+=s*s));else for(u=0;u<i;u++)c=e[u],l=c<0?-c:c,l>0&&(l>a?(s=a/c,o=1+o*s*s,a=l):(s=c/a,o+=s*s));return a*Math.sqrt(o)}t.exports=i})),_d=t(((e,t)=>{var n=hd(),r=gd(),i=pd(),a=md();function o(e,t){return function(n,r){return e(n,r,t)}}function s(e,t,s){var c,l,u;if(!i(e))throw TypeError("cosine-similarity()::invalid input argument. First argument must be an array. Value: `"+e+"`.");if(!i(t))throw TypeError("cosine-similarity()::invalid input argument. Second argument must be an array. Value: `"+t+"`.");if(arguments.length>2&&!a(s))throw TypeError("cosine-similarity()::invalid input argument. Accessor must be a function. Value: `"+s+"`.");if(e.length!==t.length)throw Error(`cosine-similarity()::invalid input argument. Input arrays must have the same length.`);return e.length?(s?(c=n(e,t,s),l=r(e,o(s,0)),u=r(t,o(s,1))):(c=n(e,t),l=r(e),u=r(t)),c/(l*u)):null}t.exports=s})),vd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),yd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=vd();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),q=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=vd(),n=yd();var r=vd();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=yd();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ee(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
52
|
-
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ee(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${oe(e)}`}e.not=ee;let te=ae(e.operators.AND);function ne(...e){return e.reduce(te)}e.and=ne;let re=ae(e.operators.OR);function ie(...e){return e.reduce(re)}e.or=ie;function ae(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${oe(n)} ${e} ${oe(r)}`}function oe(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=vd();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),bd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),xd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=bd();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Sd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=xd(),n=q(),r=bd(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Cd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),wd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Td=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=Cd(),n=wd(),r=xd(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
51
|
+
`)},hd.prototype.renderPartial=function(e,t,n,r){if(n){var i=this.getConfigTags(r),a=Ju(n)?n(e[1]):n[e[1]];if(a!=null){var o=e[6],s=e[5],c=e[4],l=a;s==0&&c&&(l=this.indentPartial(a,c,o));var u=this.parse(l,i);return this.renderTokens(u,t,n,l,r)}}},hd.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(n!=null)return n},hd.prototype.escapedValue=function(e,t,n){var r=this.getConfigEscape(n)||gd.escape,i=t.lookup(e[1]);if(i!=null)return typeof i==`number`&&r===gd.escape?String(i):r(i)},hd.prototype.rawValue=function(e){return e[1]},hd.prototype.getConfigTags=function(e){if(qu(e))return e;if(e&&typeof e==`object`)return e.tags},hd.prototype.getConfigEscape=function(e){if(e&&typeof e==`object`&&!qu(e))return e.escape};var gd={name:`mustache.js`,version:`4.2.0`,tags:[`{{`,`}}`],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){_d.templateCache=e},get templateCache(){return _d.templateCache}},_d=new hd;gd.clearCache=function(){return _d.clearCache()},gd.parse=function(e,t){return _d.parse(e,t)},gd.render=function(e,t,n,r){if(typeof e!=`string`)throw TypeError(`Invalid template! Template should be a "string" but "`+Yu(e)+`" was given as the first argument for mustache#render(template, view, partials)`);return _d.render(e,t,n,r)},gd.escape=id,gd.Scanner=pd,gd.Context=md,gd.Writer=hd;var vd=t(((e,t)=>{t.exports=(function(){function e(e,t,n,r,i){return e<t||n<t?e>n?n+1:e+1:r===i?t:t+1}return function(t,n){if(t===n)return 0;if(t.length>n.length){var r=t;t=n,n=r}for(var i=t.length,a=n.length;i>0&&t.charCodeAt(i-1)===n.charCodeAt(a-1);)i--,a--;for(var o=0;o<i&&t.charCodeAt(o)===n.charCodeAt(o);)o++;if(i-=o,a-=o,i===0||a<3)return a;var s=0,c,l,u,d,f,p,m,h,g,_,v,y,b=[];for(c=0;c<i;c++)b.push(c+1),b.push(t.charCodeAt(o+c));for(var x=b.length-1;s<a-3;)for(g=n.charCodeAt(o+(l=s)),_=n.charCodeAt(o+(u=s+1)),v=n.charCodeAt(o+(d=s+2)),y=n.charCodeAt(o+(f=s+3)),p=s+=4,c=0;c<x;c+=2)m=b[c],h=b[c+1],l=e(m,l,u,g,h),u=e(l,u,d,_,h),d=e(u,d,f,v,h),p=e(d,f,p,y,h),b[c]=p,f=d,d=u,u=l,l=m;for(;s<a;)for(g=n.charCodeAt(o+(l=s)),p=++s,c=0;c<x;c+=2)m=b[c],b[c]=p=e(m,l,p,g,b[c+1]),l=m;return p}})()})),yd=t(((e,t)=>{function n(e){return Object.prototype.toString.call(e)===`[object Array]`}t.exports=Array.isArray||n})),bd=t(((e,t)=>{function n(e){return typeof e==`function`}t.exports=n})),xd=t(((e,t)=>{var n=yd(),r=bd();function i(e,t,i){if(!n(e))throw TypeError("dot()::invalid input argument. First argument must be an array. Value: `"+e+"`.");if(!n(t))throw TypeError("dot()::invalid input argument. Second argument must be an array. Value: `"+t+"`.");if(arguments.length>2&&!r(i))throw TypeError("dot()::invalid input argument. Accessor must be a function. Value: `"+i+"`.");var a=e.length,o=0,s;if(a!==t.length)throw Error(`dot()::invalid input argument. Arrays must be of equal length.`);if(!a)return null;if(i)for(s=0;s<a;s++)o+=i(e[s],s,0)*i(t[s],s,1);else for(s=0;s<a;s++)o+=e[s]*t[s];return o}t.exports=i})),Sd=t(((e,t)=>{var n=yd(),r=bd();function i(e,t){if(!n(e))throw TypeError("l2norm()::invalid input argument. Must provide an array. Value: `"+e+"`.");if(arguments.length>1&&!r(t))throw TypeError("l2norm()::invalid input argument. Accessor must be a function. Value: `"+t+"`.");var i=e.length,a=0,o=1,s,c,l,u;if(!i)return null;if(t)for(u=0;u<i;u++)c=t(e[u],u),l=c<0?-c:c,l>0&&(l>a?(s=a/c,o=1+o*s*s,a=l):(s=c/a,o+=s*s));else for(u=0;u<i;u++)c=e[u],l=c<0?-c:c,l>0&&(l>a?(s=a/c,o=1+o*s*s,a=l):(s=c/a,o+=s*s));return a*Math.sqrt(o)}t.exports=i})),Cd=t(((e,t)=>{var n=xd(),r=Sd(),i=yd(),a=bd();function o(e,t){return function(n,r){return e(n,r,t)}}function s(e,t,s){var c,l,u;if(!i(e))throw TypeError("cosine-similarity()::invalid input argument. First argument must be an array. Value: `"+e+"`.");if(!i(t))throw TypeError("cosine-similarity()::invalid input argument. Second argument must be an array. Value: `"+t+"`.");if(arguments.length>2&&!a(s))throw TypeError("cosine-similarity()::invalid input argument. Accessor must be a function. Value: `"+s+"`.");if(e.length!==t.length)throw Error(`cosine-similarity()::invalid input argument. Input arrays must have the same length.`);return e.length?(s?(c=n(e,t,s),l=r(e,o(s,0)),u=r(t,o(s,1))):(c=n(e,t),l=r(e),u=r(t)),c/(l*u)):null}t.exports=s})),wd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Td=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=wd();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),q=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=wd(),n=Td();var r=wd();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=Td();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ee(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
52
|
+
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ee(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${oe(e)}`}e.not=ee;let te=ae(e.operators.AND);function ne(...e){return e.reduce(te)}e.and=ne;let re=ae(e.operators.OR);function ie(...e){return e.reduce(re)}e.or=ie;function ae(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${oe(n)} ${e} ${oe(r)}`}function oe(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=wd();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),Ed=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Dd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=Ed();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Od=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Dd(),n=q(),r=Ed(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),kd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Ad=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),jd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=kd(),n=Ad(),r=Dd(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
53
53
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
54
54
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
55
|
-
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Ed=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=q(),n=J();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Dd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=q(),n=J(),r=bd(),i=J();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Od=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=q(),n=bd(),r=Dd(),i=xd();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),kd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=q(),n=J();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Ad=t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),jd=t(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Md=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=J(),n=Ad(),r=jd(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Nd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Sd(),n=Td(),r=wd(),i=Td(),a=Ed(),o=Od(),s=kd(),c=q(),l=bd(),u=Md(),d=J(),f=xd();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ee(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return ne(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ne(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ee(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&te(e),t.return((0,c._)`${l.default.errors} === 0`))}function te({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ne(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>fe(e,`$ref`,h.all.$ref.definition));return}p.jtd||ie(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),re(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):re(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function re(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&fe(e,n.keyword,n.definition,t.type)})}function ie(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ae(e,t),e.opts.allowUnionTypes||oe(e,t),se(e,e.dataTypes))}function ae(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ce(e.dataTypes,t)||ue(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),le(e,t)}}function oe(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&ue(e,`use allowUnionTypes to allow union type keyword`)}function se(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>j(t,e))&&ue(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function j(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ce(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function le(e,t){let n=[];for(let r of e.dataTypes)ce(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function ue(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var de=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,me(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=de;function fe(e,t,n,r){let i=new de(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let M=/^\/(?:[^~]|~0|~1)*$/,pe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function me(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!M.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=pe.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=me})),Pd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Fd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Md();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Id=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=q(),n=Pd(),r=bd(),i=Md(),a=J(),o=Nd();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Ld=t(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),Rd=t(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),zd=t(((e,t)=>{let{isUUID:n}=Rd(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Bd=t(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Rd(),{SCHEMES:d,getSchemeHandler:f}=zd();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),Vd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Bd();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Hd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Nd();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=q();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Pd(),i=Fd(),a=Cd(),o=Id(),s=q(),c=Md(),l=Td(),u=J(),d=Ld(),f=Vd(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=D(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(k.call(this,n,t),!t)return(0,u.eachItem)(n,e=>A.call(this,e)),this;te.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>A.call(this,e,r):e=>r.type.forEach(t=>A.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=re(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function D(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let O=/^[a-z_$][a-z0-9_$:-]*$/i;function k(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!O.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function A(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ee.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ee(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function te(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=re(t)),e.validateSchema=this.compile(t,!0))}let ne={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function re(e){return{anyOf:[e,ne]}}})),Ud=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Wd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Fd(),n=Dd(),r=q(),i=bd(),a=Id(),o=J(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Gd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ud(),n=Wd();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Kd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),qd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Jd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Yd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Jd();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Xd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dd(),n=J(),r=q();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Zd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Qd=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dd(),n=q(),r=J();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),$d=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),ef=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ad();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),tf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Td(),n=q(),r=J(),i=ef();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),nf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=ef();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),rf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=ef();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),af=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Kd(),n=qd(),r=Yd(),i=Xd(),a=Zd(),o=Qd(),s=$d(),c=tf(),l=nf(),u=rf();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),of=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=q(),n=J(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),sf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=q(),n=J(),r=Dd(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),cf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sf();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),lf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Dd(),i=of();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),uf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),df=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=q(),n=J(),r=Dd();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
55
|
+
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Md=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=q(),n=J();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Nd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=q(),n=J(),r=Ed(),i=J();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Pd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=q(),n=Ed(),r=Nd(),i=Dd();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Fd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=q(),n=J();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Id=t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Ld=t(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Rd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=J(),n=Id(),r=Ld(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),zd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Od(),n=jd(),r=Ad(),i=jd(),a=Md(),o=Pd(),s=Fd(),c=q(),l=Ed(),u=Rd(),d=J(),f=Dd();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ee(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return ne(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ne(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ee(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&te(e),t.return((0,c._)`${l.default.errors} === 0`))}function te({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ne(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>fe(e,`$ref`,h.all.$ref.definition));return}p.jtd||ie(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),re(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):re(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function re(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&fe(e,n.keyword,n.definition,t.type)})}function ie(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ae(e,t),e.opts.allowUnionTypes||oe(e,t),se(e,e.dataTypes))}function ae(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ce(e.dataTypes,t)||ue(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),le(e,t)}}function oe(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&ue(e,`use allowUnionTypes to allow union type keyword`)}function se(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>j(t,e))&&ue(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function j(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ce(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function le(e,t){let n=[];for(let r of e.dataTypes)ce(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function ue(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var de=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,me(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=de;function fe(e,t,n,r){let i=new de(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let M=/^\/(?:[^~]|~0|~1)*$/,pe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function me(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!M.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=pe.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=me})),Bd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Vd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Rd();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Hd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=q(),n=Bd(),r=Ed(),i=Rd(),a=J(),o=zd();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Ud=t(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),Wd=t(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Gd=t(((e,t)=>{let{isUUID:n}=Wd(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Kd=t(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Wd(),{SCHEMES:d,getSchemeHandler:f}=Gd();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),qd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Kd();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Jd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=zd();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});let r=Bd(),i=Vd(),a=kd(),o=Hd(),s=q(),c=Rd(),l=jd(),u=J(),d=Ud(),f=qd(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=D(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(k.call(this,n,t),!t)return(0,u.eachItem)(n,e=>A.call(this,e)),this;te.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>A.call(this,e,r):e=>r.type.forEach(t=>A.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=re(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function D(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let O=/^[a-z_$][a-z0-9_$:-]*$/i;function k(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!O.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function A(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ee.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ee(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function te(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=re(t)),e.validateSchema=this.compile(t,!0))}let ne={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function re(e){return{anyOf:[e,ne]}}})),Yd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Xd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=Vd(),n=Nd(),r=q(),i=Ed(),a=Hd(),o=J(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Zd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yd(),n=Xd();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Qd=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),$d=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),ef=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),tf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=ef();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),nf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Nd(),n=J(),r=q();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),rf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),af=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Nd(),n=q(),r=J();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),of=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),sf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Id();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),cf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=jd(),n=q(),r=J(),i=sf();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),lf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=sf();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),uf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=sf();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),df=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Qd(),n=$d(),r=tf(),i=nf(),a=rf(),o=af(),s=of(),c=cf(),l=lf(),u=uf();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),ff=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=q(),n=J(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),pf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=q(),n=J(),r=Nd(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),mf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=pf();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),hf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=Nd(),i=ff();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),gf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),_f=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=q(),n=J(),r=Nd();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
56
56
|
missingProperty: ${i},
|
|
57
57
|
depsCount: ${n},
|
|
58
|
-
deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),ff=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),pf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dd(),n=q(),r=bd(),i=J();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),mf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Nd(),n=Dd(),r=J(),i=pf();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),hf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dd(),n=q(),r=J(),i=J();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),gf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),_f=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Dd().validateUnion,error:{message:`must match a schema in anyOf`}}})),vf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),yf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),bf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),xf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Sf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=of(),n=cf(),r=sf(),i=lf(),a=uf(),o=df(),s=ff(),c=pf(),l=mf(),u=hf(),d=gf(),f=_f(),p=vf(),m=yf(),h=bf(),g=xf();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Cf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),wf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Cf().default]})),Tf=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Ef=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Gd(),n=af(),r=Sf(),i=wf(),a=Tf();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Df=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Of=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=Df(),r=Id(),i=Fd(),a=J();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),kf=t(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),Af=t(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Hd(),r=Ef(),i=Of(),a=kf(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=Nd();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=q();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Pd();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Fd();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})})),jf=e(fd(),1),Mf=e(_d(),1),Nf=e(Af(),1);const Pf=Symbol(`Let zodToJsonSchema decide on which parser to use`),Ff={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},If=e=>typeof e==`string`?{...Ff,name:e}:{...Ff,...e},Lf=e=>{let t=If(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Rf(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Y(e,t,n,r,i){e[t]=n,Rf(e,t,r,i)}const zf=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Bf(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?zf(t,e.currentPath):t.join(`/`)}}function Vf(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==G.ZodAny&&(n.items=X(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&Y(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&Y(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Y(n,`minItems`,e.exactLength.value,e.exactLength.message,t),Y(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Hf(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?Y(n,`minimum`,r.value,r.message,t):Y(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Y(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Y(n,`maximum`,r.value,r.message,t):Y(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Y(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Y(n,`multipleOf`,r.value,r.message,t);break}return n}function Uf(){return{type:`boolean`}}function Wf(e,t){return X(e.type._def,t)}const Gf=(e,t)=>X(e.innerType._def,t);function Kf(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Kf(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return qf(e,t)}}const qf=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:Y(n,`minimum`,r.value,r.message,t);break;case`max`:Y(n,`maximum`,r.value,r.message,t);break}return n};function Jf(e,t){return{...X(e.innerType._def,t),default:e.defaultValue()}}function Yf(e,t){return t.effectStrategy===`input`?X(e.schema._def,t):Bf(t)}function Xf(e){return{type:`string`,enum:Array.from(e.values)}}const Zf=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Qf(e,t){let n=[X(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),X(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(Zf(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function $f(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let ep;const tp={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ep===void 0&&(ep=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),ep),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function np(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:Y(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:Y(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:op(n,`email`,r.message,t);break;case`format:idn-email`:op(n,`idn-email`,r.message,t);break;case`pattern:zod`:sp(n,tp.email,r.message,t);break}break;case`url`:op(n,`uri`,r.message,t);break;case`uuid`:op(n,`uuid`,r.message,t);break;case`regex`:sp(n,r.regex,r.message,t);break;case`cuid`:sp(n,tp.cuid,r.message,t);break;case`cuid2`:sp(n,tp.cuid2,r.message,t);break;case`startsWith`:sp(n,RegExp(`^${rp(r.value,t)}`),r.message,t);break;case`endsWith`:sp(n,RegExp(`${rp(r.value,t)}$`),r.message,t);break;case`datetime`:op(n,`date-time`,r.message,t);break;case`date`:op(n,`date`,r.message,t);break;case`time`:op(n,`time`,r.message,t);break;case`duration`:op(n,`duration`,r.message,t);break;case`length`:Y(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),Y(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:sp(n,RegExp(rp(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&op(n,`ipv4`,r.message,t),r.version!==`v4`&&op(n,`ipv6`,r.message,t);break;case`base64url`:sp(n,tp.base64url,r.message,t);break;case`jwt`:sp(n,tp.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&sp(n,tp.ipv4Cidr,r.message,t),r.version!==`v4`&&sp(n,tp.ipv6Cidr,r.message,t);break;case`emoji`:sp(n,tp.emoji(),r.message,t);break;case`ulid`:sp(n,tp.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:op(n,`binary`,r.message,t);break;case`contentEncoding:base64`:Y(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:sp(n,tp.base64,r.message,t);break}break;case`nanoid`:sp(n,tp.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function rp(e,t){return t.patternStrategy===`escape`?ap(e):e}const ip=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function ap(e){let t=``;for(let n=0;n<e.length;n++)ip.has(e[n])||(t+=`\\`),t+=e[n];return t}function op(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Y(e,`format`,t,n,r)}function sp(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:cp(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Y(e,`pattern`,cp(t,r),n,r)}function cp(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
58
|
+
deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),vf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),yf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Nd(),n=q(),r=Ed(),i=J();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),bf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=zd(),n=Nd(),r=J(),i=yf();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),xf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Nd(),n=q(),r=J(),i=J();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),Sf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Cf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Nd().validateUnion,error:{message:`must match a schema in anyOf`}}})),wf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Tf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Ef=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),Df=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Of=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ff(),n=mf(),r=pf(),i=hf(),a=gf(),o=_f(),s=vf(),c=yf(),l=bf(),u=xf(),d=Sf(),f=Cf(),p=wf(),m=Tf(),h=Ef(),g=Df();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),kf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Af=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[kf().default]})),jf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Mf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Zd(),n=df(),r=Of(),i=Af(),a=jf();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Nf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Pf=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=Nf(),r=Hd(),i=Vd(),a=J();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Ff=t(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),If=t(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Jd(),r=Mf(),i=Pf(),a=Ff(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=zd();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=Bd();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=Vd();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})),Lf=e(vd(),1),Rf=e(Cd(),1),zf=e(If(),1);const Bf=Symbol(`Let zodToJsonSchema decide on which parser to use`),Vf={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},Hf=e=>typeof e==`string`?{...Vf,name:e}:{...Vf,...e},Uf=e=>{let t=Hf(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Wf(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Y(e,t,n,r,i){e[t]=n,Wf(e,t,r,i)}const Gf=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Kf(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?Gf(t,e.currentPath):t.join(`/`)}}function qf(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==G.ZodAny&&(n.items=X(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&Y(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&Y(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Y(n,`minItems`,e.exactLength.value,e.exactLength.message,t),Y(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Jf(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?Y(n,`minimum`,r.value,r.message,t):Y(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Y(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Y(n,`maximum`,r.value,r.message,t):Y(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Y(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Y(n,`multipleOf`,r.value,r.message,t);break}return n}function Yf(){return{type:`boolean`}}function Xf(e,t){return X(e.type._def,t)}const Zf=(e,t)=>X(e.innerType._def,t);function Qf(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Qf(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return $f(e,t)}}const $f=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:Y(n,`minimum`,r.value,r.message,t);break;case`max`:Y(n,`maximum`,r.value,r.message,t);break}return n};function ep(e,t){return{...X(e.innerType._def,t),default:e.defaultValue()}}function tp(e,t){return t.effectStrategy===`input`?X(e.schema._def,t):Kf(t)}function np(e){return{type:`string`,enum:Array.from(e.values)}}const rp=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function ip(e,t){let n=[X(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),X(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(rp(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function ap(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let op;const sp={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(op===void 0&&(op=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),op),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function cp(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:Y(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:Y(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:fp(n,`email`,r.message,t);break;case`format:idn-email`:fp(n,`idn-email`,r.message,t);break;case`pattern:zod`:pp(n,sp.email,r.message,t);break}break;case`url`:fp(n,`uri`,r.message,t);break;case`uuid`:fp(n,`uuid`,r.message,t);break;case`regex`:pp(n,r.regex,r.message,t);break;case`cuid`:pp(n,sp.cuid,r.message,t);break;case`cuid2`:pp(n,sp.cuid2,r.message,t);break;case`startsWith`:pp(n,RegExp(`^${lp(r.value,t)}`),r.message,t);break;case`endsWith`:pp(n,RegExp(`${lp(r.value,t)}$`),r.message,t);break;case`datetime`:fp(n,`date-time`,r.message,t);break;case`date`:fp(n,`date`,r.message,t);break;case`time`:fp(n,`time`,r.message,t);break;case`duration`:fp(n,`duration`,r.message,t);break;case`length`:Y(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),Y(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:pp(n,RegExp(lp(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&fp(n,`ipv4`,r.message,t),r.version!==`v4`&&fp(n,`ipv6`,r.message,t);break;case`base64url`:pp(n,sp.base64url,r.message,t);break;case`jwt`:pp(n,sp.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&pp(n,sp.ipv4Cidr,r.message,t),r.version!==`v4`&&pp(n,sp.ipv6Cidr,r.message,t);break;case`emoji`:pp(n,sp.emoji(),r.message,t);break;case`ulid`:pp(n,sp.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:fp(n,`binary`,r.message,t);break;case`contentEncoding:base64`:Y(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:pp(n,sp.base64,r.message,t);break}break;case`nanoid`:pp(n,sp.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function lp(e,t){return t.patternStrategy===`escape`?dp(e):e}const up=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function dp(e){let t=``;for(let n=0;n<e.length;n++)up.has(e[n])||(t+=`\\`),t+=e[n];return t}function fp(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Y(e,`format`,t,n,r)}function pp(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:mp(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Y(e,`pattern`,mp(t,r),n,r)}function mp(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
59
59
|
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
60
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function lp(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===G.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??Bf(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===G.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=np(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===G.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===G.ZodBranded&&e.keyType._def.type._def.typeName===G.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Wf(e.keyType._def,t);return{...n,propertyNames:i}}return n}function up(e,t){return t.mapStrategy===`record`?lp(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[X(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Bf(t),X(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Bf(t)],minItems:2,maxItems:2}}}function dp(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function fp(e){return e.target===`openAi`?void 0:{not:Bf({...e,currentPath:[...e.currentPath,`not`]})}}function pp(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}const mp={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function hp(e,t){if(t.target===`openApi3`)return gp(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in mp&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=mp[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return gp(e,t)}const gp=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function _p(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:mp[e.innerType._def.typeName],nullable:!0}:{type:[mp[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function vp(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Rf(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?Y(n,`minimum`,r.value,r.message,t):Y(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Y(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Y(n,`maximum`,r.value,r.message,t):Y(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Y(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Y(n,`multipleOf`,r.value,r.message,t);break}return n}function yp(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=xp(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=X(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=bp(e,t);return o!==void 0&&(r.additionalProperties=o),r}function bp(e,t){if(e.catchall._def.typeName!==`ZodNever`)return X(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function xp(e){try{return e.isOptional()}catch{return!0}}const Sp=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return X(e.innerType._def,t);let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Bf(t)},n]}:Bf(t)},Cp=(e,t)=>{if(t.pipeStrategy===`input`)return X(e.in._def,t);if(t.pipeStrategy===`output`)return X(e.out._def,t);let n=X(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,X(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function wp(e,t){return X(e.type._def,t)}function Tp(e,t){let n={type:`array`,uniqueItems:!0,items:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&Y(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&Y(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function Ep(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:X(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Dp(e){return{not:Bf(e)}}function Op(e){return Bf(e)}const kp=(e,t)=>X(e.innerType._def,t),Ap=(e,t,n)=>{switch(t){case G.ZodString:return np(e,n);case G.ZodNumber:return vp(e,n);case G.ZodObject:return yp(e,n);case G.ZodBigInt:return Hf(e,n);case G.ZodBoolean:return Uf();case G.ZodDate:return Kf(e,n);case G.ZodUndefined:return Dp(n);case G.ZodNull:return pp(n);case G.ZodArray:return Vf(e,n);case G.ZodUnion:case G.ZodDiscriminatedUnion:return hp(e,n);case G.ZodIntersection:return Qf(e,n);case G.ZodTuple:return Ep(e,n);case G.ZodRecord:return lp(e,n);case G.ZodLiteral:return $f(e,n);case G.ZodEnum:return Xf(e);case G.ZodNativeEnum:return dp(e);case G.ZodNullable:return _p(e,n);case G.ZodOptional:return Sp(e,n);case G.ZodMap:return up(e,n);case G.ZodSet:return Tp(e,n);case G.ZodLazy:return()=>e.getter()._def;case G.ZodPromise:return wp(e,n);case G.ZodNaN:case G.ZodNever:return fp(n);case G.ZodEffects:return Yf(e,n);case G.ZodAny:return Bf(n);case G.ZodUnknown:return Op(n);case G.ZodDefault:return Jf(e,n);case G.ZodBranded:return Wf(e,n);case G.ZodReadonly:return kp(e,n);case G.ZodCatch:return Gf(e,n);case G.ZodPipeline:return Cp(e,n);case G.ZodFunction:case G.ZodVoid:case G.ZodSymbol:return;default:return(e=>void 0)(t)}};function X(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Pf)return i}if(r&&!n){let e=jp(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ap(e,e.typeName,t),o=typeof a==`function`?X(a(),t):a;if(o&&Mp(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}const jp=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:zf(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Bf(t)):t.$refStrategy===`seen`?Bf(t):void 0}},Mp=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n);var Np=(e,t)=>{let n=Lf(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:X(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Bf(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=X(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Bf(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s},Pp=Object.create,Fp=Object.defineProperty,Ip=Object.getOwnPropertyDescriptor,Lp=Object.getOwnPropertyNames,Rp=Object.getPrototypeOf,zp=Object.prototype.hasOwnProperty,Bp=e=>{throw TypeError(e)},Vp=(e,t,n)=>t in e?Fp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hp=(e,t)=>function(){return e&&(t=(0,e[Lp(e)[0]])(e=0)),t},Z=(e,t)=>function(){return t||(0,e[Lp(e)[0]])((t={exports:{}}).exports,t),t.exports},Up=(e,t)=>{for(var n in t)Fp(e,n,{get:t[n],enumerable:!0})},Wp=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Lp(t))!zp.call(e,i)&&i!==n&&Fp(e,i,{get:()=>t[i],enumerable:!(r=Ip(t,i))||r.enumerable});return e},Gp=(e,t,n)=>(n=e==null?{}:Pp(Rp(e)),Wp(t||!e||!e.__esModule?Fp(n,`default`,{value:e,enumerable:!0}):n,e)),Kp=e=>Wp(Fp({},`__esModule`,{value:!0}),e),qp=(e,t,n)=>Vp(e,typeof t==`symbol`?t:t+``,n),Jp=(e,t,n)=>t.has(e)||Bp(`Cannot `+n),Yp=(e,t,n)=>(Jp(e,t,`read from private field`),n?n.call(e):t.get(e)),Xp=(e,t,n)=>t.has(e)?Bp(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Zp=(e,t,n,r)=>(Jp(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),Qp=(e,t,n)=>(Jp(e,t,`access private method`),n),$p={};Up($p,{isAnyArray:()=>em});function em(e){let t=tm.call(e);return t.endsWith(`Array]`)&&!t.includes(`Big`)}var tm,nm=Hp({"../node_modules/.pnpm/is-any-array@2.0.1/node_modules/is-any-array/lib-esm/index.js"(){tm=Object.prototype.toString}});function rm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!em(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n=t.fromIndex,r=n===void 0?0:n,i=t.toIndex,a=i===void 0?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw Error(`fromIndex must be a positive integer smaller than length`);if(a<=r||a>e.length||!Number.isInteger(a))throw Error(`toIndex must be an integer greater than fromIndex and at most equal to length`);for(var o=e[r],s=r+1;s<a;s++)e[s]>o&&(o=e[s]);return o}var im=Hp({"../node_modules/.pnpm/ml-array-max@1.2.4/node_modules/ml-array-max/lib-es6/index.js"(){nm()}});function am(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!em(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n=t.fromIndex,r=n===void 0?0:n,i=t.toIndex,a=i===void 0?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw Error(`fromIndex must be a positive integer smaller than length`);if(a<=r||a>e.length||!Number.isInteger(a))throw Error(`toIndex must be an integer greater than fromIndex and at most equal to length`);for(var o=e[r],s=r+1;s<a;s++)e[s]<o&&(o=e[s]);return o}var om=Hp({"../node_modules/.pnpm/ml-array-min@1.2.3/node_modules/ml-array-min/lib-es6/index.js"(){nm()}}),sm={};Up(sm,{default:()=>cm});function cm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!em(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n;if(t.output!==void 0){if(!em(t.output))throw TypeError(`output option must be an array if specified`);n=t.output}else n=Array(e.length);var r=am(e),i=rm(e);if(r===i)throw RangeError(`minimum and maximum input values are equal. Cannot rescale a constant array`);var a=t.min,o=a===void 0?t.autoMinMax?r:0:a,s=t.max,c=s===void 0?t.autoMinMax?i:1:s;if(o>=c)throw RangeError(`min option must be smaller than max option`);for(var l=(c-o)/(i-r),u=0;u<e.length;u++)n[u]=(e[u]-r)*l+o;return n}var lm=Hp({"../node_modules/.pnpm/ml-array-rescale@1.3.7/node_modules/ml-array-rescale/lib-es6/index.js"(){nm(),im(),om()}}),um=Z({"../node_modules/.pnpm/ml-matrix@6.11.0/node_modules/ml-matrix/matrix.js"(e){Object.defineProperty(e,`__esModule`,{value:!0});var t=(nm(),Kp($p)),n=(lm(),Kp(sm)),r=` `.repeat(2),i=` `.repeat(4);function a(){return o(this)}function o(e,t={}){let{maxRows:n=15,maxColumns:a=10,maxNumSize:o=8,padMinus:c=`auto`}=t;return`${e.constructor.name} {
|
|
60
|
+
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hp(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===G.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??Kf(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===G.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=cp(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===G.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===G.ZodBranded&&e.keyType._def.type._def.typeName===G.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Xf(e.keyType._def,t);return{...n,propertyNames:i}}return n}function gp(e,t){return t.mapStrategy===`record`?hp(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[X(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Kf(t),X(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Kf(t)],minItems:2,maxItems:2}}}function _p(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function vp(e){return e.target===`openAi`?void 0:{not:Kf({...e,currentPath:[...e.currentPath,`not`]})}}function yp(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}const bp={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function xp(e,t){if(t.target===`openApi3`)return Sp(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in bp&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=bp[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Sp(e,t)}const Sp=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Cp(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:bp[e.innerType._def.typeName],nullable:!0}:{type:[bp[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function wp(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Wf(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?Y(n,`minimum`,r.value,r.message,t):Y(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Y(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Y(n,`maximum`,r.value,r.message,t):Y(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Y(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Y(n,`multipleOf`,r.value,r.message,t);break}return n}function Tp(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=Dp(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=X(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=Ep(e,t);return o!==void 0&&(r.additionalProperties=o),r}function Ep(e,t){if(e.catchall._def.typeName!==`ZodNever`)return X(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Dp(e){try{return e.isOptional()}catch{return!0}}const Op=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return X(e.innerType._def,t);let n=X(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Kf(t)},n]}:Kf(t)},kp=(e,t)=>{if(t.pipeStrategy===`input`)return X(e.in._def,t);if(t.pipeStrategy===`output`)return X(e.out._def,t);let n=X(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,X(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Ap(e,t){return X(e.type._def,t)}function jp(e,t){let n={type:`array`,uniqueItems:!0,items:X(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&Y(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&Y(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function Mp(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:X(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>X(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Np(e){return{not:Kf(e)}}function Pp(e){return Kf(e)}const Fp=(e,t)=>X(e.innerType._def,t),Ip=(e,t,n)=>{switch(t){case G.ZodString:return cp(e,n);case G.ZodNumber:return wp(e,n);case G.ZodObject:return Tp(e,n);case G.ZodBigInt:return Jf(e,n);case G.ZodBoolean:return Yf();case G.ZodDate:return Qf(e,n);case G.ZodUndefined:return Np(n);case G.ZodNull:return yp(n);case G.ZodArray:return qf(e,n);case G.ZodUnion:case G.ZodDiscriminatedUnion:return xp(e,n);case G.ZodIntersection:return ip(e,n);case G.ZodTuple:return Mp(e,n);case G.ZodRecord:return hp(e,n);case G.ZodLiteral:return ap(e,n);case G.ZodEnum:return np(e);case G.ZodNativeEnum:return _p(e);case G.ZodNullable:return Cp(e,n);case G.ZodOptional:return Op(e,n);case G.ZodMap:return gp(e,n);case G.ZodSet:return jp(e,n);case G.ZodLazy:return()=>e.getter()._def;case G.ZodPromise:return Ap(e,n);case G.ZodNaN:case G.ZodNever:return vp(n);case G.ZodEffects:return tp(e,n);case G.ZodAny:return Kf(n);case G.ZodUnknown:return Pp(n);case G.ZodDefault:return ep(e,n);case G.ZodBranded:return Xf(e,n);case G.ZodReadonly:return Fp(e,n);case G.ZodCatch:return Zf(e,n);case G.ZodPipeline:return kp(e,n);case G.ZodFunction:case G.ZodVoid:case G.ZodSymbol:return;default:return(e=>void 0)(t)}};function X(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Bf)return i}if(r&&!n){let e=Lp(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ip(e,e.typeName,t),o=typeof a==`function`?X(a(),t):a;if(o&&Rp(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}const Lp=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Gf(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Kf(t)):t.$refStrategy===`seen`?Kf(t):void 0}},Rp=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n);var zp=(e,t)=>{let n=Uf(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:X(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Kf(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=X(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Kf(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s},Bp=Object.create,Vp=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,Up=Object.getOwnPropertyNames,Wp=Object.getPrototypeOf,Gp=Object.prototype.hasOwnProperty,Kp=e=>{throw TypeError(e)},qp=(e,t,n)=>t in e?Vp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jp=(e,t)=>function(){return e&&(t=(0,e[Up(e)[0]])(e=0)),t},Z=(e,t)=>function(){return t||(0,e[Up(e)[0]])((t={exports:{}}).exports,t),t.exports},Yp=(e,t)=>{for(var n in t)Vp(e,n,{get:t[n],enumerable:!0})},Xp=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Up(t))!Gp.call(e,i)&&i!==n&&Vp(e,i,{get:()=>t[i],enumerable:!(r=Hp(t,i))||r.enumerable});return e},Zp=(e,t,n)=>(n=e==null?{}:Bp(Wp(e)),Xp(t||!e||!e.__esModule?Vp(n,`default`,{value:e,enumerable:!0}):n,e)),Qp=e=>Xp(Vp({},`__esModule`,{value:!0}),e),$p=(e,t,n)=>qp(e,typeof t==`symbol`?t:t+``,n),em=(e,t,n)=>t.has(e)||Kp(`Cannot `+n),tm=(e,t,n)=>(em(e,t,`read from private field`),n?n.call(e):t.get(e)),nm=(e,t,n)=>t.has(e)?Kp(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),rm=(e,t,n,r)=>(em(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),im=(e,t,n)=>(em(e,t,`access private method`),n),am={};Yp(am,{isAnyArray:()=>om});function om(e){let t=sm.call(e);return t.endsWith(`Array]`)&&!t.includes(`Big`)}var sm,cm=Jp({"../node_modules/.pnpm/is-any-array@2.0.1/node_modules/is-any-array/lib-esm/index.js"(){sm=Object.prototype.toString}});function lm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!om(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n=t.fromIndex,r=n===void 0?0:n,i=t.toIndex,a=i===void 0?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw Error(`fromIndex must be a positive integer smaller than length`);if(a<=r||a>e.length||!Number.isInteger(a))throw Error(`toIndex must be an integer greater than fromIndex and at most equal to length`);for(var o=e[r],s=r+1;s<a;s++)e[s]>o&&(o=e[s]);return o}var um=Jp({"../node_modules/.pnpm/ml-array-max@1.2.4/node_modules/ml-array-max/lib-es6/index.js"(){cm()}});function dm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!om(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n=t.fromIndex,r=n===void 0?0:n,i=t.toIndex,a=i===void 0?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw Error(`fromIndex must be a positive integer smaller than length`);if(a<=r||a>e.length||!Number.isInteger(a))throw Error(`toIndex must be an integer greater than fromIndex and at most equal to length`);for(var o=e[r],s=r+1;s<a;s++)e[s]<o&&(o=e[s]);return o}var fm=Jp({"../node_modules/.pnpm/ml-array-min@1.2.3/node_modules/ml-array-min/lib-es6/index.js"(){cm()}}),pm={};Yp(pm,{default:()=>mm});function mm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!om(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);var n;if(t.output!==void 0){if(!om(t.output))throw TypeError(`output option must be an array if specified`);n=t.output}else n=Array(e.length);var r=dm(e),i=lm(e);if(r===i)throw RangeError(`minimum and maximum input values are equal. Cannot rescale a constant array`);var a=t.min,o=a===void 0?t.autoMinMax?r:0:a,s=t.max,c=s===void 0?t.autoMinMax?i:1:s;if(o>=c)throw RangeError(`min option must be smaller than max option`);for(var l=(c-o)/(i-r),u=0;u<e.length;u++)n[u]=(e[u]-r)*l+o;return n}var hm=Jp({"../node_modules/.pnpm/ml-array-rescale@1.3.7/node_modules/ml-array-rescale/lib-es6/index.js"(){cm(),um(),fm()}}),gm=Z({"../node_modules/.pnpm/ml-matrix@6.11.0/node_modules/ml-matrix/matrix.js"(e){Object.defineProperty(e,"__esModule",{value:!0});var t=(cm(),Qp(am)),n=(hm(),Qp(pm)),r=` `.repeat(2),i=` `.repeat(4);function a(){return o(this)}function o(e,t={}){let{maxRows:n=15,maxColumns:a=10,maxNumSize:o=8,padMinus:c=`auto`}=t;return`${e.constructor.name} {
|
|
61
61
|
${r}[
|
|
62
62
|
${i}${s(e,n,a,o,c)}
|
|
63
63
|
${r}]
|
|
64
64
|
${r}rows: ${e.rows}
|
|
65
65
|
${r}columns: ${e.columns}
|
|
66
66
|
}`}function s(e,t,n,r,a){let{rows:o,columns:s}=e,l=Math.min(o,t),u=Math.min(s,n),d=[];if(a===`auto`){a=!1;loop:for(let t=0;t<l;t++)for(let n=0;n<u;n++)if(e.get(t,n)<0){a=!0;break loop}}for(let t=0;t<l;t++){let n=[];for(let i=0;i<u;i++)n.push(c(e.get(t,i),r,a));d.push(`${n.join(` `)}`)}return u!==s&&(d[d.length-1]+=` ... ${s-n} more columns`),l!==o&&d.push(`... ${o-t} more rows`),d.join(`
|
|
67
|
-
${i}`)}function c(e,t,n){return(e>=0&&n?` ${l(e,t-1)}`:l(e,t)).padEnd(t)}function l(e,t){let n=e.toString();if(n.length<=t)return n;let r=e.toFixed(t);if(r.length>t&&(r=e.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith(`0.000`)&&!r.startsWith(`-0.000`))return r;let i=e.toExponential(t);return i.length>t&&(i=e.toExponential(Math.max(0,t-(i.length-t)))),i.slice(0)}function u(e,t){e.prototype.add=function(e){return typeof e==`number`?this.addS(e):this.addM(e)},e.prototype.addS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e);return this},e.prototype.addM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e.get(t,n));return this},e.add=function(e,n){return new t(e).add(n)},e.prototype.sub=function(e){return typeof e==`number`?this.subS(e):this.subM(e)},e.prototype.subS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e);return this},e.prototype.subM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e.get(t,n));return this},e.sub=function(e,n){return new t(e).sub(n)},e.prototype.subtract=e.prototype.sub,e.prototype.subtractS=e.prototype.subS,e.prototype.subtractM=e.prototype.subM,e.subtract=e.sub,e.prototype.mul=function(e){return typeof e==`number`?this.mulS(e):this.mulM(e)},e.prototype.mulS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this},e.prototype.mulM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e.get(t,n));return this},e.mul=function(e,n){return new t(e).mul(n)},e.prototype.multiply=e.prototype.mul,e.prototype.multiplyS=e.prototype.mulS,e.prototype.multiplyM=e.prototype.mulM,e.multiply=e.mul,e.prototype.div=function(e){return typeof e==`number`?this.divS(e):this.divM(e)},e.prototype.divS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e);return this},e.prototype.divM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e.get(t,n));return this},e.div=function(e,n){return new t(e).div(n)},e.prototype.divide=e.prototype.div,e.prototype.divideS=e.prototype.divS,e.prototype.divideM=e.prototype.divM,e.divide=e.div,e.prototype.mod=function(e){return typeof e==`number`?this.modS(e):this.modM(e)},e.prototype.modS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)%e);return this},e.prototype.modM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)%e.get(t,n));return this},e.mod=function(e,n){return new t(e).mod(n)},e.prototype.modulus=e.prototype.mod,e.prototype.modulusS=e.prototype.modS,e.prototype.modulusM=e.prototype.modM,e.modulus=e.mod,e.prototype.and=function(e){return typeof e==`number`?this.andS(e):this.andM(e)},e.prototype.andS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)&e);return this},e.prototype.andM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)&e.get(t,n));return this},e.and=function(e,n){return new t(e).and(n)},e.prototype.or=function(e){return typeof e==`number`?this.orS(e):this.orM(e)},e.prototype.orS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)|e);return this},e.prototype.orM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)|e.get(t,n));return this},e.or=function(e,n){return new t(e).or(n)},e.prototype.xor=function(e){return typeof e==`number`?this.xorS(e):this.xorM(e)},e.prototype.xorS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)^e);return this},e.prototype.xorM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)^e.get(t,n));return this},e.xor=function(e,n){return new t(e).xor(n)},e.prototype.leftShift=function(e){return typeof e==`number`?this.leftShiftS(e):this.leftShiftM(e)},e.prototype.leftShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)<<e);return this},e.prototype.leftShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)<<e.get(t,n));return this},e.leftShift=function(e,n){return new t(e).leftShift(n)},e.prototype.signPropagatingRightShift=function(e){return typeof e==`number`?this.signPropagatingRightShiftS(e):this.signPropagatingRightShiftM(e)},e.prototype.signPropagatingRightShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>e);return this},e.prototype.signPropagatingRightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>e.get(t,n));return this},e.signPropagatingRightShift=function(e,n){return new t(e).signPropagatingRightShift(n)},e.prototype.rightShift=function(e){return typeof e==`number`?this.rightShiftS(e):this.rightShiftM(e)},e.prototype.rightShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>>e);return this},e.prototype.rightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>>e.get(t,n));return this},e.rightShift=function(e,n){return new t(e).rightShift(n)},e.prototype.zeroFillRightShift=e.prototype.rightShift,e.prototype.zeroFillRightShiftS=e.prototype.rightShiftS,e.prototype.zeroFillRightShiftM=e.prototype.rightShiftM,e.zeroFillRightShift=e.rightShift,e.prototype.not=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,~this.get(e,t));return this},e.not=function(e){return new t(e).not()},e.prototype.abs=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.abs(this.get(e,t)));return this},e.abs=function(e){return new t(e).abs()},e.prototype.acos=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acos(this.get(e,t)));return this},e.acos=function(e){return new t(e).acos()},e.prototype.acosh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acosh(this.get(e,t)));return this},e.acosh=function(e){return new t(e).acosh()},e.prototype.asin=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asin(this.get(e,t)));return this},e.asin=function(e){return new t(e).asin()},e.prototype.asinh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asinh(this.get(e,t)));return this},e.asinh=function(e){return new t(e).asinh()},e.prototype.atan=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atan(this.get(e,t)));return this},e.atan=function(e){return new t(e).atan()},e.prototype.atanh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atanh(this.get(e,t)));return this},e.atanh=function(e){return new t(e).atanh()},e.prototype.cbrt=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cbrt(this.get(e,t)));return this},e.cbrt=function(e){return new t(e).cbrt()},e.prototype.ceil=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.ceil(this.get(e,t)));return this},e.ceil=function(e){return new t(e).ceil()},e.prototype.clz32=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.clz32(this.get(e,t)));return this},e.clz32=function(e){return new t(e).clz32()},e.prototype.cos=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cos(this.get(e,t)));return this},e.cos=function(e){return new t(e).cos()},e.prototype.cosh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cosh(this.get(e,t)));return this},e.cosh=function(e){return new t(e).cosh()},e.prototype.exp=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.exp(this.get(e,t)));return this},e.exp=function(e){return new t(e).exp()},e.prototype.expm1=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.expm1(this.get(e,t)));return this},e.expm1=function(e){return new t(e).expm1()},e.prototype.floor=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.floor(this.get(e,t)));return this},e.floor=function(e){return new t(e).floor()},e.prototype.fround=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.fround(this.get(e,t)));return this},e.fround=function(e){return new t(e).fround()},e.prototype.log=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log(this.get(e,t)));return this},e.log=function(e){return new t(e).log()},e.prototype.log1p=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log1p(this.get(e,t)));return this},e.log1p=function(e){return new t(e).log1p()},e.prototype.log10=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log10(this.get(e,t)));return this},e.log10=function(e){return new t(e).log10()},e.prototype.log2=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log2(this.get(e,t)));return this},e.log2=function(e){return new t(e).log2()},e.prototype.round=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.round(this.get(e,t)));return this},e.round=function(e){return new t(e).round()},e.prototype.sign=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sign(this.get(e,t)));return this},e.sign=function(e){return new t(e).sign()},e.prototype.sin=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sin(this.get(e,t)));return this},e.sin=function(e){return new t(e).sin()},e.prototype.sinh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sinh(this.get(e,t)));return this},e.sinh=function(e){return new t(e).sinh()},e.prototype.sqrt=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sqrt(this.get(e,t)));return this},e.sqrt=function(e){return new t(e).sqrt()},e.prototype.tan=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tan(this.get(e,t)));return this},e.tan=function(e){return new t(e).tan()},e.prototype.tanh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tanh(this.get(e,t)));return this},e.tanh=function(e){return new t(e).tanh()},e.prototype.trunc=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.trunc(this.get(e,t)));return this},e.trunc=function(e){return new t(e).trunc()},e.pow=function(e,n){return new t(e).pow(n)},e.prototype.pow=function(e){return typeof e==`number`?this.powS(e):this.powM(e)},e.prototype.powS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)**+e);return this},e.prototype.powM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)**+e.get(t,n));return this}}function d(e,t,n){let r=n?e.rows:e.rows-1;if(t<0||t>r)throw RangeError(`Row index out of range`)}function f(e,t,n){let r=n?e.columns:e.columns-1;if(t<0||t>r)throw RangeError(`Column index out of range`)}function p(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.columns)throw RangeError(`vector size must be the same as the number of columns`);return t}function m(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.rows)throw RangeError(`vector size must be the same as the number of rows`);return t}function h(e,n){if(!t.isAnyArray(n))throw TypeError(`row indices must be an array`);for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.rows)throw RangeError(`row indices are out of range`)}function g(e,n){if(!t.isAnyArray(n))throw TypeError(`column indices must be an array`);for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.columns)throw RangeError(`column indices are out of range`)}function _(e,t,n,r,i){if(arguments.length!==5)throw RangeError(`expected 4 arguments`);if(y(`startRow`,t),y(`endRow`,n),y(`startColumn`,r),y(`endColumn`,i),t>n||r>i||t<0||t>=e.rows||n<0||n>=e.rows||r<0||r>=e.columns||i<0||i>=e.columns)throw RangeError(`Submatrix indices are out of range`)}function v(e,t=0){let n=[];for(let r=0;r<e;r++)n.push(t);return n}function y(e,t){if(typeof t!=`number`)throw TypeError(`${e} must be a number`)}function b(e){if(e.isEmpty())throw Error(`Empty matrix has no elements to index`)}function x(e){let t=v(e.rows);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]+=e.get(n,r);return t}function S(e){let t=v(e.columns);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]+=e.get(n,r);return t}function C(e){let t=0;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t+=e.get(n,r);return t}function w(e){let t=v(e.rows,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]*=e.get(n,r);return t}function T(e){let t=v(e.columns,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]*=e.get(n,r);return t}function E(e){let t=1;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t*=e.get(n,r);return t}function D(e,t,n){let r=e.rows,i=e.columns,a=[];for(let o=0;o<r;o++){let r=0,s=0,c=0;for(let t=0;t<i;t++)c=e.get(o,t)-n[o],r+=c,s+=c*c;t?a.push((s-r*r/i)/(i-1)):a.push((s-r*r/i)/i)}return a}function O(e,t,n){let r=e.rows,i=e.columns,a=[];for(let o=0;o<i;o++){let i=0,s=0,c=0;for(let t=0;t<r;t++)c=e.get(t,o)-n[o],i+=c,s+=c*c;t?a.push((s-i*i/r)/(r-1)):a.push((s-i*i/r)/r)}return a}function k(e,t,n){let r=e.rows,i=e.columns,a=r*i,o=0,s=0,c=0;for(let t=0;t<r;t++)for(let r=0;r<i;r++)c=e.get(t,r)-n,o+=c,s+=c*c;return t?(s-o*o/a)/(a-1):(s-o*o/a)/a}function A(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[n])}function ee(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[r])}function te(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t)}function ne(e){let t=[];for(let n=0;n<e.rows;n++){let r=0;for(let t=0;t<e.columns;t++)r+=e.get(n,t)**2/(e.columns-1);t.push(Math.sqrt(r))}return t}function re(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[n])}function ie(e){let t=[];for(let n=0;n<e.columns;n++){let r=0;for(let t=0;t<e.rows;t++)r+=e.get(t,n)**2/(e.rows-1);t.push(Math.sqrt(r))}return t}function ae(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[r])}function oe(e){let t=e.size-1,n=0;for(let r=0;r<e.columns;r++)for(let i=0;i<e.rows;i++)n+=e.get(i,r)**2/t;return Math.sqrt(n)}function se(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t)}var j=class e{static from1DArray(e,t,n){if(e*t!==n.length)throw RangeError(`data length does not match given dimensions`);let r=new M(e,t);for(let i=0;i<e;i++)for(let e=0;e<t;e++)r.set(i,e,n[i*t+e]);return r}static rowVector(e){let t=new M(1,e.length);for(let n=0;n<e.length;n++)t.set(0,n,e[n]);return t}static columnVector(e){let t=new M(e.length,1);for(let n=0;n<e.length;n++)t.set(n,0,e[n]);return t}static zeros(e,t){return new M(e,t)}static ones(e,t){return new M(e,t).fill(1)}static rand(e,t,n={}){if(typeof n!=`object`)throw TypeError(`options must be an object`);let{random:r=Math.random}=n,i=new M(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++)i.set(n,e,r());return i}static randInt(e,t,n={}){if(typeof n!=`object`)throw TypeError(`options must be an object`);let{min:r=0,max:i=1e3,random:a=Math.random}=n;if(!Number.isInteger(r))throw TypeError(`min must be an integer`);if(!Number.isInteger(i))throw TypeError(`max must be an integer`);if(r>=i)throw RangeError(`min must be smaller than max`);let o=i-r,s=new M(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++){let t=r+Math.round(a()*o);s.set(n,e,t)}return s}static eye(e,t,n){t===void 0&&(t=e),n===void 0&&(n=1);let r=Math.min(e,t),i=this.zeros(e,t);for(let e=0;e<r;e++)i.set(e,e,n);return i}static diag(e,t,n){let r=e.length;t===void 0&&(t=r),n===void 0&&(n=t);let i=Math.min(r,t,n),a=this.zeros(t,n);for(let t=0;t<i;t++)a.set(t,t,e[t]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new M(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.min(e.get(a,n),t.get(a,n)));return i}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new this(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.max(e.get(a,n),t.get(a,n)));return i}static checkMatrix(t){return e.isMatrix(t)?t:new M(t)}static isMatrix(e){return e!=null&&e.klass===`Matrix`}get size(){return this.rows*this.columns}apply(e){if(typeof e!=`function`)throw TypeError(`callback must be a function`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.call(this,t,n);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let n=0;n<this.columns;n++)e[t].push(this.get(t,n))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>n?(i=!0,n=t):(r=!1,i=!0);e++}return r}isReducedEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>n?(i=!0,n=t):(r=!1,i=!0);for(let n=t+1;n<this.rows;n++)this.get(e,n)!==0&&(r=!1);e++}return r}echelonForm(){let e=this.clone(),t=0,n=0;for(;t<e.rows&&n<e.columns;){let r=t;for(let i=t;i<e.rows;i++)e.get(i,n)>e.get(r,n)&&(r=i);if(e.get(r,n)===0)n++;else{e.swapRows(t,r);let i=e.get(t,n);for(let r=n;r<e.columns;r++)e.set(t,r,e.get(t,r)/i);for(let r=t+1;r<e.rows;r++){let i=e.get(r,n)/e.get(t,n);e.set(r,n,0);for(let a=n+1;a<e.columns;a++)e.set(r,a,e.get(r,a)-e.get(t,a)*i)}t++,n++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,n=e.rows,r=n-1;for(;r>=0;)if(e.maxRow(r)===0)r--;else{let i=0,a=!1;for(;i<n&&a===!1;)e.get(r,i)===1?a=!0:i++;for(let n=0;n<r;n++){let a=e.get(n,i);for(let o=i;o<t;o++){let t=e.get(n,o)-a*e.get(r,o);e.set(n,o,t)}}r--}return e}set(){throw Error(`set method is unimplemented`)}get(){throw Error(`get method is unimplemented`)}repeat(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{rows:t=1,columns:n=1}=e;if(!Number.isInteger(t)||t<=0)throw TypeError(`rows must be a positive integer`);if(!Number.isInteger(n)||n<=0)throw TypeError(`columns must be a positive integer`);let r=new M(this.rows*t,this.columns*n);for(let e=0;e<t;e++)for(let t=0;t<n;t++)r.setSubMatrix(this,this.rows*e,this.columns*t);return r}fill(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,e);return this}neg(){return this.mulS(-1)}getRow(e){d(this,e);let t=[];for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}getRowVector(e){return M.rowVector(this.getRow(e))}setRow(e,t){d(this,e),t=p(this,t);for(let n=0;n<this.columns;n++)this.set(e,n,t[n]);return this}swapRows(e,t){d(this,e),d(this,t);for(let n=0;n<this.columns;n++){let r=this.get(e,n);this.set(e,n,this.get(t,n)),this.set(t,n,r)}return this}getColumn(e){f(this,e);let t=[];for(let n=0;n<this.rows;n++)t.push(this.get(n,e));return t}getColumnVector(e){return M.columnVector(this.getColumn(e))}setColumn(e,t){f(this,e),t=m(this,t);for(let n=0;n<this.rows;n++)this.set(n,e,t[n]);return this}swapColumns(e,t){f(this,e),f(this,t);for(let n=0;n<this.rows;n++){let r=this.get(n,e);this.set(n,e,this.get(n,t)),this.set(n,t,r)}return this}addRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[n]);return this}subRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[n]);return this}mulRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[n]);return this}divRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[n]);return this}addColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[t]);return this}subColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[t]);return this}mulColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[t]);return this}divColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[t]);return this}mulRow(e,t){d(this,e);for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this}mulColumn(e,t){f(this,e);for(let n=0;n<this.rows;n++)this.set(n,e,this.get(n,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case`row`:{let e=Array(this.rows).fill(-1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e[t]&&(e[t]=this.get(t,n));return e}case`column`:{let e=Array(this.columns).fill(-1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e[n]&&(e[n]=this.get(t,n));return e}case void 0:{let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}default:throw Error(`invalid option: ${e}`)}}maxIndex(){b(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}min(e){if(this.isEmpty())return NaN;switch(e){case`row`:{let e=Array(this.rows).fill(1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e[t]&&(e[t]=this.get(t,n));return e}case`column`:{let e=Array(this.columns).fill(1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e[n]&&(e[n]=this.get(t,n));return e}case void 0:{let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}default:throw Error(`invalid option: ${e}`)}}minIndex(){b(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}maxRow(e){if(d(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}maxRowIndex(e){d(this,e),b(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r),n[1]=r);return n}minRow(e){if(d(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}minRowIndex(e){d(this,e),b(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r),n[1]=r);return n}maxColumn(e){if(f(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e));return t}maxColumnIndex(e){f(this,e),b(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e),n[0]=r);return n}minColumn(e){if(f(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e));return t}minColumnIndex(e){f(this,e),b(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e),n[0]=r);return n}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let n=0;n<e;n++)t.push(this.get(n,n));return t}norm(e=`frobenius`){switch(e){case`max`:return this.max();case`frobenius`:return Math.sqrt(this.dot(this));default:throw RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n),this.set(t,n,e);return this}dot(t){e.isMatrix(t)&&(t=t.to1DArray());let n=this.to1DArray();if(n.length!==t.length)throw RangeError(`vectors do not have the same size`);let r=0;for(let e=0;e<n.length;e++)r+=n[e]*t[e];return r}mmul(e){e=M.checkMatrix(e);let t=this.rows,n=this.columns,r=e.columns,i=new M(t,r),a=new Float64Array(n);for(let o=0;o<r;o++){for(let t=0;t<n;t++)a[t]=e.get(t,o);for(let e=0;e<t;e++){let t=0;for(let r=0;r<n;r++)t+=this.get(e,r)*a[r];i.set(e,o,t)}}return i}strassen2x2(e){e=M.checkMatrix(e);let t=new M(2,2),n=this.get(0,0),r=e.get(0,0),i=this.get(0,1),a=e.get(0,1),o=this.get(1,0),s=e.get(1,0),c=this.get(1,1),l=e.get(1,1),u=(n+c)*(r+l),d=(o+c)*r,f=n*(a-l),p=c*(s-r),m=(n+i)*l,h=(o-n)*(r+a),g=(i-c)*(s+l),_=u+p-m+g,v=f+m,y=d+p,b=u-d+f+h;return t.set(0,0,_),t.set(0,1,v),t.set(1,0,y),t.set(1,1,b),t}strassen3x3(e){e=M.checkMatrix(e);let t=new M(3,3),n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),a=this.get(1,0),o=this.get(1,1),s=this.get(1,2),c=this.get(2,0),l=this.get(2,1),u=this.get(2,2),d=e.get(0,0),f=e.get(0,1),p=e.get(0,2),m=e.get(1,0),h=e.get(1,1),g=e.get(1,2),_=e.get(2,0),v=e.get(2,1),y=e.get(2,2),b=(n+r+i-a-o-l-u)*h,x=(n-a)*(-f+h),S=o*(-d+f+m-h-g-_+y),C=(-n+a+o)*(d-f+h),w=(a+o)*(-d+f),T=n*d,E=(-n+c+l)*(d-p+g),D=(-n+c)*(p-g),O=(c+l)*(-d+p),k=(n+r+i-o-s-c-l)*g,A=l*(-d+p+m-h-g-_+v),ee=(-i+l+u)*(h+_-v),te=(i-u)*(h-v),ne=i*_,re=(l+u)*(-_+v),ie=(-i+o+s)*(g+_-y),ae=(i-s)*(g-y),oe=(o+s)*(-_+y),se=r*m,j=s*v,ce=a*p,le=c*f,ue=u*y,de=T+ne+se,fe=b+C+w+T+ee+ne+re,pe=T+E+O+k+ne+ie+oe,me=x+S+C+T+ne+ie+ae,he=x+C+w+T+j,ge=ne+ie+ae+oe+ce,_e=T+E+D+A+ee+te+ne,ve=ee+te+ne+re+le,ye=T+E+D+O+ue;return t.set(0,0,de),t.set(0,1,fe),t.set(0,2,pe),t.set(1,0,me),t.set(1,1,he),t.set(1,2,ge),t.set(2,0,_e),t.set(2,1,ve),t.set(2,2,ye),t}mmulStrassen(t){t=M.checkMatrix(t);let n=this.clone(),r=n.rows,i=n.columns,a=t.rows,o=t.columns;i!==a&&console.warn(`Multiplying ${r} x ${i} and ${a} x ${o} matrix: dimensions do not match.`);function s(t,n,r){let i=t.rows,a=t.columns;if(i===n&&a===r)return t;{let i=e.zeros(n,r);return i=i.setSubMatrix(t,0,0),i}}let c=Math.max(r,a),l=Math.max(i,o);n=s(n,c,l),t=s(t,c,l);function u(t,n,r,i){if(r<=512||i<=512)return t.mmul(n);r%2==1&&i%2==1?(t=s(t,r+1,i+1),n=s(n,r+1,i+1)):r%2==1?(t=s(t,r+1,i),n=s(n,r+1,i)):i%2==1&&(t=s(t,r,i+1),n=s(n,r,i+1));let a=parseInt(t.rows/2,10),o=parseInt(t.columns/2,10),c=t.subMatrix(0,a-1,0,o-1),l=n.subMatrix(0,a-1,0,o-1),d=t.subMatrix(0,a-1,o,t.columns-1),f=n.subMatrix(0,a-1,o,n.columns-1),p=t.subMatrix(a,t.rows-1,0,o-1),m=n.subMatrix(a,n.rows-1,0,o-1),h=t.subMatrix(a,t.rows-1,o,t.columns-1),g=n.subMatrix(a,n.rows-1,o,n.columns-1),_=u(e.add(c,h),e.add(l,g),a,o),v=u(e.add(p,h),l,a,o),y=u(c,e.sub(f,g),a,o),b=u(h,e.sub(m,l),a,o),x=u(e.add(c,d),g,a,o),S=u(e.sub(p,c),e.add(l,f),a,o),C=u(e.sub(d,h),e.add(m,g),a,o),w=e.add(_,b);w.sub(x),w.add(C);let T=e.add(y,x),E=e.add(v,b),D=e.sub(_,v);D.add(y),D.add(S);let O=e.zeros(2*w.rows,2*w.columns);return O=O.setSubMatrix(w,0,0),O=O.setSubMatrix(T,w.rows,0),O=O.setSubMatrix(E,0,w.columns),O=O.setSubMatrix(D,w.rows,w.columns),O.subMatrix(0,r-1,0,i-1)}return u(n,t,c,l)}scaleRows(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw TypeError(`min must be a number`);if(!Number.isFinite(r))throw TypeError(`max must be a number`);if(t>=r)throw RangeError(`min must be smaller than max`);let i=new M(this.rows,this.columns);for(let e=0;e<this.rows;e++){let a=this.getRow(e);a.length>0&&n(a,{min:t,max:r,output:a}),i.setRow(e,a)}return i}scaleColumns(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw TypeError(`min must be a number`);if(!Number.isFinite(r))throw TypeError(`max must be a number`);if(t>=r)throw RangeError(`min must be smaller than max`);let i=new M(this.rows,this.columns);for(let e=0;e<this.columns;e++){let a=this.getColumn(e);a.length&&n(a,{min:t,max:r,output:a}),i.setColumn(e,a)}return i}flipRows(){let e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let n=0;n<e;n++){let e=this.get(t,n),r=this.get(t,this.columns-1-n);this.set(t,n,r),this.set(t,this.columns-1-n,e)}return this}flipColumns(){let e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let n=0;n<e;n++){let e=this.get(n,t),r=this.get(this.rows-1-n,t);this.set(n,t,r),this.set(this.rows-1-n,t,e)}return this}kroneckerProduct(e){e=M.checkMatrix(e);let t=this.rows,n=this.columns,r=e.rows,i=e.columns,a=new M(t*r,n*i);for(let o=0;o<t;o++)for(let t=0;t<n;t++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)a.set(r*o+n,i*t+s,this.get(o,t)*e.get(n,s));return a}kroneckerSum(e){if(e=M.checkMatrix(e),!this.isSquare()||!e.isSquare())throw Error(`Kronecker Sum needs two Square Matrices`);let t=this.rows,n=e.rows,r=this.kroneckerProduct(M.eye(n,n)),i=M.eye(t,t).kroneckerProduct(e);return r.add(i)}transpose(){let e=new M(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(n,t,this.get(t,n));return e}sortRows(e=ce){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=ce){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,n,r){_(this,e,t,n,r);let i=new M(t-e+1,r-n+1);for(let a=e;a<=t;a++)for(let t=n;t<=r;t++)i.set(a-e,t-n,this.get(a,t));return i}subMatrixRow(e,t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.columns-1),t>n||t<0||t>=this.columns||n<0||n>=this.columns)throw RangeError(`Argument out of range`);let r=new M(e.length,n-t+1);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.rows)throw RangeError(`Row index out of range: ${e[i]}`);r.set(i,a-t,this.get(e[i],a))}return r}subMatrixColumn(e,t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.rows-1),t>n||t<0||t>=this.rows||n<0||n>=this.rows)throw RangeError(`Argument out of range`);let r=new M(n-t+1,e.length);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.columns)throw RangeError(`Column index out of range: ${e[i]}`);r.set(a-t,i,this.get(a,e[i]))}return r}setSubMatrix(e,t,n){if(e=M.checkMatrix(e),e.isEmpty())return this;let r=t+e.rows-1,i=n+e.columns-1;_(this,t,r,n,i);for(let r=0;r<e.rows;r++)for(let i=0;i<e.columns;i++)this.set(t+r,n+i,e.get(r,i));return this}selection(e,t){h(this,e),g(this,t);let n=new M(e.length,t.length);for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<t.length;e++){let a=t[e];n.set(r,e,this.get(i,a))}}return n}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let n=0;n<e;n++)t+=this.get(n,n);return t}clone(){return this.constructor.copy(this,new M(this.rows,this.columns))}static copy(e,t){for(let[n,r,i]of e.entries())t.set(n,r,i);return t}sum(e){switch(e){case`row`:return x(this);case`column`:return S(this);case void 0:return C(this);default:throw Error(`invalid option: ${e}`)}}product(e){switch(e){case`row`:return w(this);case`column`:return T(this);case void 0:return E(this);default:throw Error(`invalid option: ${e}`)}}mean(e){let t=this.sum(e);switch(e){case`row`:for(let e=0;e<this.rows;e++)t[e]/=this.columns;return t;case`column`:for(let e=0;e<this.columns;e++)t[e]/=this.rows;return t;case void 0:return t/this.size;default:throw Error(`invalid option: ${e}`)}}variance(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let{unbiased:r=!0,mean:i=this.mean(e)}=n;if(typeof r!=`boolean`)throw TypeError(`unbiased must be a boolean`);switch(e){case`row`:if(!t.isAnyArray(i))throw TypeError(`mean must be an array`);return D(this,r,i);case`column`:if(!t.isAnyArray(i))throw TypeError(`mean must be an array`);return O(this,r,i);case void 0:if(typeof i!=`number`)throw TypeError(`mean must be a number`);return k(this,r,i);default:throw Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e==`object`&&(t=e,e=void 0);let n=this.variance(e,t);if(e===void 0)return Math.sqrt(n);for(let e=0;e<n.length;e++)n[e]=Math.sqrt(n[e]);return n}center(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let{center:r=this.mean(e)}=n;switch(e){case`row`:if(!t.isAnyArray(r))throw TypeError(`center must be an array`);return A(this,r),this;case`column`:if(!t.isAnyArray(r))throw TypeError(`center must be an array`);return ee(this,r),this;case void 0:if(typeof r!=`number`)throw TypeError(`center must be a number`);return te(this,r),this;default:throw Error(`invalid option: ${e}`)}}scale(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let r=n.scale;switch(e){case`row`:if(r===void 0)r=ne(this);else if(!t.isAnyArray(r))throw TypeError(`scale must be an array`);return re(this,r),this;case`column`:if(r===void 0)r=ie(this);else if(!t.isAnyArray(r))throw TypeError(`scale must be an array`);return ae(this,r),this;case void 0:if(r===void 0)r=oe(this);else if(typeof r!=`number`)throw TypeError(`scale must be a number`);return se(this,r),this;default:throw Error(`invalid option: ${e}`)}}toString(e){return o(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}};j.prototype.klass=`Matrix`,typeof Symbol<`u`&&(j.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a);function ce(e,t){return e-t}function le(e){return e.every(e=>typeof e==`number`)}j.random=j.rand,j.randomInt=j.randInt,j.diagonal=j.diag,j.prototype.diagonal=j.prototype.diag,j.identity=j.eye,j.prototype.negate=j.prototype.neg,j.prototype.tensorProduct=j.prototype.kroneckerProduct;var ue,de,fe=class e extends j{constructor(n,r){if(super(),Xp(this,ue),qp(this,`data`),e.isMatrix(n))Qp(this,ue,de).call(this,n.rows,n.columns),e.copy(n,this);else if(Number.isInteger(n)&&n>=0)Qp(this,ue,de).call(this,n,r);else if(t.isAnyArray(n)){let e=n;if(n=e.length,r=n?e[0].length:0,typeof r!=`number`)throw TypeError(`Data must be a 2D array with at least one element`);this.data=[];for(let t=0;t<n;t++){if(e[t].length!==r)throw RangeError(`Inconsistent array dimensions`);if(!le(e[t]))throw TypeError(`Input data contains non-numeric values`);this.data.push(Float64Array.from(e[t]))}this.rows=n,this.columns=r}else throw TypeError(`First argument must be a positive number or an array`)}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}removeRow(e){return d(this,e),this.data.splice(e,1),--this.rows,this}addRow(e,t){return t===void 0&&(t=e,e=this.rows),d(this,e,!0),t=Float64Array.from(p(this,t)),this.data.splice(e,0,t),this.rows+=1,this}removeColumn(e){f(this,e);for(let t=0;t<this.rows;t++){let n=new Float64Array(this.columns-1);for(let r=0;r<e;r++)n[r]=this.data[t][r];for(let r=e+1;r<this.columns;r++)n[r-1]=this.data[t][r];this.data[t]=n}return--this.columns,this}addColumn(e,t){t===void 0&&(t=e,e=this.columns),f(this,e,!0),t=m(this,t);for(let n=0;n<this.rows;n++){let r=new Float64Array(this.columns+1),i=0;for(;i<e;i++)r[i]=this.data[n][i];for(r[i++]=t[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};ue=new WeakSet,de=function(e,t){if(this.data=[],Number.isInteger(t)&&t>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(t));else throw TypeError(`nColumns must be a positive integer`);this.rows=e,this.columns=t};var M=fe;u(j,M);var pe,me=class e extends j{constructor(e){if(super(),Xp(this,pe),M.isMatrix(e)){if(!e.isSymmetric())throw TypeError(`not symmetric data`);Zp(this,pe,M.copy(e,new M(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)Zp(this,pe,new M(e,e));else if(Zp(this,pe,new M(e)),!this.isSymmetric())throw TypeError(`not symmetric data`)}get size(){return Yp(this,pe).size}get rows(){return Yp(this,pe).rows}get columns(){return Yp(this,pe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return M.isMatrix(e)&&e.klassType===`SymmetricMatrix`}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){let t=new e(this.diagonalSize);for(let[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new M(this)}get(e,t){return Yp(this,pe).get(e,t)}set(e,t,n){return Yp(this,pe).set(e,t,n),Yp(this,pe).set(t,e,n),this}removeCross(e){return Yp(this,pe).removeRow(e),Yp(this,pe).removeColumn(e),this}addCross(e,t){t===void 0&&(t=e,e=this.diagonalSize);let n=t.slice();return n.splice(e,1),Yp(this,pe).addRow(e,n),Yp(this,pe).addColumn(e,t),this}applyMask(e){if(e.length!==this.diagonalSize)throw RangeError(`Mask size do not match with matrix size`);let t=[];for(let[n,r]of e.entries())r||t.push(n);t.reverse();for(let e of t)this.removeCross(e);return this}toCompact(){let{diagonalSize:e}=this,t=Array(e*(e+1)/2);for(let n=0,r=0,i=0;i<t.length;i++)t[i]=this.get(r,n),++n>=e&&(n=++r);return t}static fromCompact(t){let n=t.length,r=(Math.sqrt(8*n+1)-1)/2;if(!Number.isInteger(r))throw TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);let i=new e(r);for(let e=0,a=0,o=0;o<n;o++)i.set(e,a,t[o]),++e>=r&&(e=++a);return i}*upperRightEntries(){for(let e=0,t=0;e<this.diagonalSize;){let n=this.get(e,t);yield[e,t,n],++t>=this.diagonalSize&&(t=++e)}}*upperRightValues(){for(let e=0,t=0;e<this.diagonalSize;)yield this.get(e,t),++t>=this.diagonalSize&&(t=++e)}};pe=new WeakMap;var he=me;he.prototype.klassType=`SymmetricMatrix`;var ge=class e extends he{static isDistanceMatrix(e){return he.isSymmetricMatrix(e)&&e.klassSubType===`DistanceMatrix`}constructor(e){if(super(e),!this.isDistance())throw TypeError(`Provided arguments do no produce a distance matrix`)}set(e,t,n){return e===t&&(n=0),super.set(e,t,n)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new he(this)}clone(){let t=new e(this.diagonalSize);for(let[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){let{diagonalSize:e}=this,t=(e-1)*e/2,n=Array(t);for(let t=1,r=0,i=0;i<n.length;i++)n[i]=this.get(r,t),++t>=e&&(t=++r+1);return n}static fromCompact(e){let t=e.length,n=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(n))throw TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);let r=new this(n);for(let i=1,a=0,o=0;o<t;o++)r.set(i,a,e[o]),++i>=n&&(i=++a+1);return r}};ge.prototype.klassSubType=`DistanceMatrix`;var _e=class extends j{constructor(e,t,n){super(),this.matrix=e,this.rows=t,this.columns=n}},ve=class extends _e{constructor(e,t){f(e,t),super(e,e.rows,1),this.column=t}set(e,t,n){return this.matrix.set(e,this.column,n),this}get(e){return this.matrix.get(e,this.column)}},ye=class extends _e{constructor(e,t){g(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,n){return this.matrix.set(e,this.columnIndices[t],n),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}},be=class extends _e{constructor(e){super(e,e.rows,e.columns)}set(e,t,n){return this.matrix.set(e,this.columns-t-1,n),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}},xe=class extends _e{constructor(e){super(e,e.rows,e.columns)}set(e,t,n){return this.matrix.set(this.rows-e-1,t,n),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}},Se=class extends _e{constructor(e,t){d(e,t),super(e,1,e.columns),this.row=t}set(e,t,n){return this.matrix.set(this.row,t,n),this}get(e,t){return this.matrix.get(this.row,t)}},Ce=class extends _e{constructor(e,t){h(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,n){return this.matrix.set(this.rowIndices[e],t,n),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}},we=class extends _e{constructor(e,t,n){h(e,t),g(e,n),super(e,t.length,n.length),this.rowIndices=t,this.columnIndices=n}set(e,t,n){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],n),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}},Te=class extends _e{constructor(e,t,n,r,i){_(e,t,n,r,i),super(e,n-t+1,i-r+1),this.startRow=t,this.startColumn=r}set(e,t,n){return this.matrix.set(this.startRow+e,this.startColumn+t,n),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}},Ee=class extends _e{constructor(e){super(e,e.columns,e.rows)}set(e,t,n){return this.matrix.set(t,e,n),this}get(e,t){return this.matrix.get(t,e)}},De=class extends j{constructor(e,t={}){let{rows:n=1}=t;if(e.length%n!==0)throw Error(`the data length is not divisible by the number of rows`);super(),this.rows=n,this.columns=e.length/n,this.data=e}set(e,t,n){let r=this._calculateIndex(e,t);return this.data[r]=n,this}get(e,t){let n=this._calculateIndex(e,t);return this.data[n]}_calculateIndex(e,t){return e*this.columns+t}},Oe=class extends j{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}};function ke(e,n){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new Oe(e):new De(e,n);throw Error(`the argument is not an array`)}var Ae=class{constructor(e){e=Oe.checkMatrix(e);let t=e.clone(),n=t.rows,r=t.columns,i=new Float64Array(n),a=1,o,s,c,l,u,d,f,p,m;for(o=0;o<n;o++)i[o]=o;for(p=new Float64Array(n),s=0;s<r;s++){for(o=0;o<n;o++)p[o]=t.get(o,s);for(o=0;o<n;o++){for(m=Math.min(o,s),u=0,c=0;c<m;c++)u+=t.get(o,c)*p[c];p[o]-=u,t.set(o,s,p[o])}for(l=s,o=s+1;o<n;o++)Math.abs(p[o])>Math.abs(p[l])&&(l=o);if(l!==s){for(c=0;c<r;c++)d=t.get(l,c),t.set(l,c,t.get(s,c)),t.set(s,c,d);f=i[l],i[l]=i[s],i[s]=f,a=-a}if(s<n&&t.get(s,s)!==0)for(o=s+1;o<n;o++)t.set(o,s,t.get(o,s)/t.get(s,s))}this.LU=t,this.pivotVector=i,this.pivotSign=a}isSingular(){let e=this.LU,t=e.columns;for(let n=0;n<t;n++)if(e.get(n,n)===0)return!0;return!1}solve(e){e=M.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw Error(`Invalid matrix dimensions`);if(this.isSingular())throw Error(`LU matrix is singular`);let n=e.columns,r=e.subMatrixRow(this.pivotVector,0,n-1),i=t.columns,a,o,s;for(s=0;s<i;s++)for(a=s+1;a<i;a++)for(o=0;o<n;o++)r.set(a,o,r.get(a,o)-r.get(s,o)*t.get(a,s));for(s=i-1;s>=0;s--){for(o=0;o<n;o++)r.set(s,o,r.get(s,o)/t.get(s,s));for(a=0;a<s;a++)for(o=0;o<n;o++)r.set(a,o,r.get(a,o)-r.get(s,o)*t.get(a,s))}return r}get determinant(){let e=this.LU;if(!e.isSquare())throw Error(`Matrix must be square`);let t=this.pivotSign,n=e.columns;for(let r=0;r<n;r++)t*=e.get(r,r);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new M(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)i>t?r.set(i,t,e.get(i,t)):i===t?r.set(i,t,1):r.set(i,t,0);return r}get upperTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new M(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)i<=t?r.set(i,t,e.get(i,t)):r.set(i,t,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}};function je(e,t){let n=0;return Math.abs(e)>Math.abs(t)?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):t===0?0:(n=e/t,Math.abs(t)*Math.sqrt(1+n*n))}var Me=class{constructor(e){e=Oe.checkMatrix(e);let t=e.clone(),n=e.rows,r=e.columns,i=new Float64Array(r),a,o,s,c;for(s=0;s<r;s++){let e=0;for(a=s;a<n;a++)e=je(e,t.get(a,s));if(e!==0){for(t.get(s,s)<0&&(e=-e),a=s;a<n;a++)t.set(a,s,t.get(a,s)/e);for(t.set(s,s,t.get(s,s)+1),o=s+1;o<r;o++){for(c=0,a=s;a<n;a++)c+=t.get(a,s)*t.get(a,o);for(c=-c/t.get(s,s),a=s;a<n;a++)t.set(a,o,t.get(a,o)+c*t.get(a,s))}}i[s]=-e}this.QR=t,this.Rdiag=i}solve(e){e=M.checkMatrix(e);let t=this.QR,n=t.rows;if(e.rows!==n)throw Error(`Matrix row dimensions must agree`);if(!this.isFullRank())throw Error(`Matrix is rank deficient`);let r=e.columns,i=e.clone(),a=t.columns,o,s,c,l;for(c=0;c<a;c++)for(s=0;s<r;s++){for(l=0,o=c;o<n;o++)l+=t.get(o,c)*i.get(o,s);for(l=-l/t.get(c,c),o=c;o<n;o++)i.set(o,s,i.get(o,s)+l*t.get(o,c))}for(c=a-1;c>=0;c--){for(s=0;s<r;s++)i.set(c,s,i.get(c,s)/this.Rdiag[c]);for(o=0;o<c;o++)for(s=0;s<r;s++)i.set(o,s,i.get(o,s)-i.get(c,s)*t.get(o,c))}return i.subMatrix(0,a-1,0,r-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,n=new M(t,t),r,i;for(r=0;r<t;r++)for(i=0;i<t;i++)r<i?n.set(r,i,e.get(r,i)):r===i?n.set(r,i,this.Rdiag[r]):n.set(r,i,0);return n}get orthogonalMatrix(){let e=this.QR,t=e.rows,n=e.columns,r=new M(t,n),i,a,o,s;for(o=n-1;o>=0;o--){for(i=0;i<t;i++)r.set(i,o,0);for(r.set(o,o,1),a=o;a<n;a++)if(e.get(o,o)!==0){for(s=0,i=o;i<t;i++)s+=e.get(i,o)*r.get(i,a);for(s=-s/e.get(o,o),i=o;i<t;i++)r.set(i,a,r.get(i,a)+s*e.get(i,o))}}return r}},Ne=class{constructor(e,t={}){if(e=Oe.checkMatrix(e),e.isEmpty())throw Error(`Matrix must be non-empty`);let n=e.rows,r=e.columns,{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:o=!1}=t,s=!!i,c=!!a,l=!1,u;if(n<r)if(!o)u=e.clone(),console.warn(`Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose`);else{u=e.transpose(),n=u.rows,r=u.columns,l=!0;let t=s;s=c,c=t}else u=e.clone();let d=Math.min(n,r),f=Math.min(n+1,r),p=new Float64Array(f),m=new M(n,d),h=new M(r,r),g=new Float64Array(r),_=new Float64Array(n),v=new Float64Array(f);for(let e=0;e<f;e++)v[e]=e;let y=Math.min(n-1,r),b=Math.max(0,Math.min(r-2,n)),x=Math.max(y,b);for(let e=0;e<x;e++){if(e<y){p[e]=0;for(let t=e;t<n;t++)p[e]=je(p[e],u.get(t,e));if(p[e]!==0){u.get(e,e)<0&&(p[e]=-p[e]);for(let t=e;t<n;t++)u.set(t,e,u.get(t,e)/p[e]);u.set(e,e,u.get(e,e)+1)}p[e]=-p[e]}for(let t=e+1;t<r;t++){if(e<y&&p[e]!==0){let r=0;for(let i=e;i<n;i++)r+=u.get(i,e)*u.get(i,t);r=-r/u.get(e,e);for(let i=e;i<n;i++)u.set(i,t,u.get(i,t)+r*u.get(i,e))}g[t]=u.get(e,t)}if(s&&e<y)for(let t=e;t<n;t++)m.set(t,e,u.get(t,e));if(e<b){g[e]=0;for(let t=e+1;t<r;t++)g[e]=je(g[e],g[t]);if(g[e]!==0){g[e+1]<0&&(g[e]=0-g[e]);for(let t=e+1;t<r;t++)g[t]/=g[e];g[e+1]+=1}if(g[e]=-g[e],e+1<n&&g[e]!==0){for(let t=e+1;t<n;t++)_[t]=0;for(let t=e+1;t<n;t++)for(let n=e+1;n<r;n++)_[t]+=g[n]*u.get(t,n);for(let t=e+1;t<r;t++){let r=-g[t]/g[e+1];for(let i=e+1;i<n;i++)u.set(i,t,u.get(i,t)+r*_[i])}}if(c)for(let t=e+1;t<r;t++)h.set(t,e,g[t])}}let S=Math.min(r,n+1);if(y<r&&(p[y]=u.get(y,y)),n<S&&(p[S-1]=0),b+1<S&&(g[b]=u.get(b,S-1)),g[S-1]=0,s){for(let e=y;e<d;e++){for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}for(let e=y-1;e>=0;e--)if(p[e]!==0){for(let t=e+1;t<d;t++){let r=0;for(let i=e;i<n;i++)r+=m.get(i,e)*m.get(i,t);r=-r/m.get(e,e);for(let i=e;i<n;i++)m.set(i,t,m.get(i,t)+r*m.get(i,e))}for(let t=e;t<n;t++)m.set(t,e,-m.get(t,e));m.set(e,e,1+m.get(e,e));for(let t=0;t<e-1;t++)m.set(t,e,0)}else{for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}}if(c)for(let e=r-1;e>=0;e--){if(e<b&&g[e]!==0)for(let t=e+1;t<r;t++){let n=0;for(let i=e+1;i<r;i++)n+=h.get(i,e)*h.get(i,t);n=-n/h.get(e+1,e);for(let i=e+1;i<r;i++)h.set(i,t,h.get(i,t)+n*h.get(i,e))}for(let t=0;t<r;t++)h.set(t,e,0);h.set(e,e,1)}let C=S-1,w=2**-52;for(;S>0;){let e,t;for(e=S-2;e>=-1&&e!==-1;e--){let t=Number.MIN_VALUE+w*Math.abs(p[e]+Math.abs(p[e+1]));if(Math.abs(g[e])<=t||Number.isNaN(g[e])){g[e]=0;break}}if(e===S-2)t=4;else{let n;for(n=S-1;n>=e&&n!==e;n--){let t=(n===S?0:Math.abs(g[n]))+(n===e+1?0:Math.abs(g[n-1]));if(Math.abs(p[n])<=w*t){p[n]=0;break}}n===e?t=3:n===S-1?t=1:(t=2,e=n)}switch(e++,t){case 1:{let t=g[S-2];g[S-2]=0;for(let n=S-2;n>=e;n--){let i=je(p[n],t),a=p[n]/i,o=t/i;if(p[n]=i,n!==e&&(t=-o*g[n-1],g[n-1]=a*g[n-1]),c)for(let e=0;e<r;e++)i=a*h.get(e,n)+o*h.get(e,S-1),h.set(e,S-1,-o*h.get(e,n)+a*h.get(e,S-1)),h.set(e,n,i)}break}case 2:{let t=g[e-1];g[e-1]=0;for(let r=e;r<S;r++){let i=je(p[r],t),a=p[r]/i,o=t/i;if(p[r]=i,t=-o*g[r],g[r]=a*g[r],s)for(let t=0;t<n;t++)i=a*m.get(t,r)+o*m.get(t,e-1),m.set(t,e-1,-o*m.get(t,r)+a*m.get(t,e-1)),m.set(t,r,i)}break}case 3:{let t=Math.max(Math.abs(p[S-1]),Math.abs(p[S-2]),Math.abs(g[S-2]),Math.abs(p[e]),Math.abs(g[e])),i=p[S-1]/t,a=p[S-2]/t,o=g[S-2]/t,l=p[e]/t,u=g[e]/t,d=((a+i)*(a-i)+o*o)/2,f=i*o*(i*o),_=0;(d!==0||f!==0)&&(_=d<0?0-Math.sqrt(d*d+f):Math.sqrt(d*d+f),_=f/(d+_));let v=(l+i)*(l-i)+_,y=l*u;for(let t=e;t<S-1;t++){let i=je(v,y);i===0&&(i=Number.MIN_VALUE);let a=v/i,o=y/i;if(t!==e&&(g[t-1]=i),v=a*p[t]+o*g[t],g[t]=a*g[t]-o*p[t],y=o*p[t+1],p[t+1]=a*p[t+1],c)for(let e=0;e<r;e++)i=a*h.get(e,t)+o*h.get(e,t+1),h.set(e,t+1,-o*h.get(e,t)+a*h.get(e,t+1)),h.set(e,t,i);if(i=je(v,y),i===0&&(i=Number.MIN_VALUE),a=v/i,o=y/i,p[t]=i,v=a*g[t]+o*p[t+1],p[t+1]=-o*g[t]+a*p[t+1],y=o*g[t+1],g[t+1]=a*g[t+1],s&&t<n-1)for(let e=0;e<n;e++)i=a*m.get(e,t)+o*m.get(e,t+1),m.set(e,t+1,-o*m.get(e,t)+a*m.get(e,t+1)),m.set(e,t,i)}g[S-2]=v;break}case 4:if(p[e]<=0&&(p[e]=p[e]<0?-p[e]:0,c))for(let t=0;t<=C;t++)h.set(t,e,-h.get(t,e));for(;e<C&&!(p[e]>=p[e+1]);){let t=p[e];if(p[e]=p[e+1],p[e+1]=t,c&&e<r-1)for(let n=0;n<r;n++)t=h.get(n,e+1),h.set(n,e+1,h.get(n,e)),h.set(n,e,t);if(s&&e<n-1)for(let r=0;r<n;r++)t=m.get(r,e+1),m.set(r,e+1,m.get(r,e)),m.set(r,e,t);e++}S--;break}}if(l){let e=h;h=m,m=e}this.m=n,this.n=r,this.s=p,this.U=m,this.V=h}solve(e){let t=e,n=this.threshold,r=this.s.length,i=M.zeros(r,r);for(let e=0;e<r;e++)Math.abs(this.s[e])<=n?i.set(e,e,0):i.set(e,e,1/this.s[e]);let a=this.U,o=this.rightSingularVectors,s=o.mmul(i),c=o.rows,l=a.rows,u=M.zeros(c,l);for(let e=0;e<c;e++)for(let t=0;t<l;t++){let n=0;for(let i=0;i<r;i++)n+=s.get(e,i)*a.get(t,i);u.set(e,t,n)}return u.mmul(t)}solveForDiagonal(e){return this.solve(M.diag(e))}inverse(){let e=this.V,t=this.threshold,n=e.rows,r=e.columns,i=new M(n,this.s.length);for(let a=0;a<n;a++)for(let n=0;n<r;n++)Math.abs(this.s[n])>t&&i.set(a,n,e.get(a,n)/this.s[n]);let a=this.U,o=a.rows,s=a.columns,c=new M(n,o);for(let e=0;e<n;e++)for(let t=0;t<o;t++){let n=0;for(let r=0;r<s;r++)n+=i.get(e,r)*a.get(t,r);c.set(e,t,n)}return c}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*2**-52,t=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return 2**-52/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return M.diag(this.s)}};function Pe(e,t=!1){return e=Oe.checkMatrix(e),t?new Ne(e).inverse():Fe(e,M.eye(e.rows))}function Fe(e,t,n=!1){return e=Oe.checkMatrix(e),t=Oe.checkMatrix(t),n?new Ne(e).solve(t):e.isSquare()?new Ae(e).solve(t):new Me(e).solve(t)}function Ie(e){if(e=M.checkMatrix(e),e.isSquare()){if(e.columns===0)return 1;let t,n,r,i;if(e.columns===2)return t=e.get(0,0),n=e.get(0,1),r=e.get(1,0),i=e.get(1,1),t*i-n*r;if(e.columns===3){let i,a,o;return i=new we(e,[1,2],[1,2]),a=new we(e,[1,2],[0,2]),o=new we(e,[1,2],[0,1]),t=e.get(0,0),n=e.get(0,1),r=e.get(0,2),t*Ie(i)-n*Ie(a)+r*Ie(o)}else return new Ae(e).determinant}else throw Error(`determinant can only be calculated for a square matrix`)}function Le(e,t){let n=[];for(let r=0;r<e;r++)r!==t&&n.push(r);return n}function Re(e,t,n,r=1e-9,i=1e-9){if(e>i)return Array(t.rows+1).fill(0);{let e=t.addRow(n,[0]);for(let t=0;t<e.rows;t++)Math.abs(e.get(t,0))<r&&e.set(t,0,0);return e.to1DArray()}}function ze(e,t={}){let{thresholdValue:n=1e-9,thresholdError:r=1e-9}=t;e=M.checkMatrix(e);let i=e.rows,a=new M(i,i);for(let t=0;t<i;t++){let o=M.columnVector(e.getRow(t)),s=e.subMatrixRow(Le(i,t)).transpose(),c=new Ne(s).solve(o),l=M.sub(o,s.mmul(c)).abs().max();a.setRow(t,Re(l,c,t,n,r))}return a}function Be(e,t=2**-52){if(e=M.checkMatrix(e),e.isEmpty())return e.transpose();let n=new Ne(e,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,a=n.diagonal;for(let e=0;e<a.length;e++)Math.abs(a[e])>t?a[e]=1/a[e]:a[e]=0;return i.mmul(M.diag(a).mmul(r.transpose()))}function Ve(e,n=e,r={}){e=new M(e);let i=!1;if(typeof n==`object`&&!M.isMatrix(n)&&!t.isAnyArray(n)?(r=n,n=e,i=!0):n=new M(n),e.rows!==n.rows)throw TypeError(`Both matrices must have the same number of rows`);let{center:a=!0}=r;a&&(e=e.center(`column`),i||(n=n.center(`column`)));let o=e.transpose().mmul(n);for(let t=0;t<o.rows;t++)for(let n=0;n<o.columns;n++)o.set(t,n,o.get(t,n)*(1/(e.rows-1)));return o}function He(e,n=e,r={}){e=new M(e);let i=!1;if(typeof n==`object`&&!M.isMatrix(n)&&!t.isAnyArray(n)?(r=n,n=e,i=!0):n=new M(n),e.rows!==n.rows)throw TypeError(`Both matrices must have the same number of rows`);let{center:a=!0,scale:o=!0}=r;a&&(e.center(`column`),i||n.center(`column`)),o&&(e.scale(`column`),i||n.scale(`column`));let s=e.standardDeviation(`column`,{unbiased:!0}),c=i?s:n.standardDeviation(`column`,{unbiased:!0}),l=e.transpose().mmul(n);for(let t=0;t<l.rows;t++)for(let n=0;n<l.columns;n++)l.set(t,n,l.get(t,n)*(1/(s[t]*c[n]))*(1/(e.rows-1)));return l}var Ue=class{constructor(e,t={}){let{assumeSymmetric:n=!1}=t;if(e=Oe.checkMatrix(e),!e.isSquare())throw Error(`Matrix is not a square matrix`);if(e.isEmpty())throw Error(`Matrix must be non-empty`);let r=e.columns,i=new M(r,r),a=new Float64Array(r),o=new Float64Array(r),s=e,c,l,u=!1;if(u=n?!0:e.isSymmetric(),u){for(c=0;c<r;c++)for(l=0;l<r;l++)i.set(c,l,s.get(c,l));We(r,o,a,i),Ge(r,o,a,i)}else{let e=new M(r,r),t=new Float64Array(r);for(l=0;l<r;l++)for(c=0;c<r;c++)e.set(c,l,s.get(c,l));Ke(r,e,t,i),qe(r,o,a,i,e)}this.n=r,this.e=o,this.d=a,this.V=i}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,n=this.d,r=new M(e,e),i,a;for(i=0;i<e;i++){for(a=0;a<e;a++)r.set(i,a,0);r.set(i,i,n[i]),t[i]>0?r.set(i,i+1,t[i]):t[i]<0&&r.set(i,i-1,t[i])}return r}};function We(e,t,n,r){let i,a,o,s,c,l,u,d;for(c=0;c<e;c++)n[c]=r.get(e-1,c);for(s=e-1;s>0;s--){for(d=0,o=0,l=0;l<s;l++)d+=Math.abs(n[l]);if(d===0)for(t[s]=n[s-1],c=0;c<s;c++)n[c]=r.get(s-1,c),r.set(s,c,0),r.set(c,s,0);else{for(l=0;l<s;l++)n[l]/=d,o+=n[l]*n[l];for(i=n[s-1],a=Math.sqrt(o),i>0&&(a=-a),t[s]=d*a,o-=i*a,n[s-1]=i-a,c=0;c<s;c++)t[c]=0;for(c=0;c<s;c++){for(i=n[c],r.set(c,s,i),a=t[c]+r.get(c,c)*i,l=c+1;l<=s-1;l++)a+=r.get(l,c)*n[l],t[l]+=r.get(l,c)*i;t[c]=a}for(i=0,c=0;c<s;c++)t[c]/=o,i+=t[c]*n[c];for(u=i/(o+o),c=0;c<s;c++)t[c]-=u*n[c];for(c=0;c<s;c++){for(i=n[c],a=t[c],l=c;l<=s-1;l++)r.set(l,c,r.get(l,c)-(i*t[l]+a*n[l]));n[c]=r.get(s-1,c),r.set(s,c,0)}}n[s]=o}for(s=0;s<e-1;s++){if(r.set(e-1,s,r.get(s,s)),r.set(s,s,1),o=n[s+1],o!==0){for(l=0;l<=s;l++)n[l]=r.get(l,s+1)/o;for(c=0;c<=s;c++){for(a=0,l=0;l<=s;l++)a+=r.get(l,s+1)*r.get(l,c);for(l=0;l<=s;l++)r.set(l,c,r.get(l,c)-a*n[l])}}for(l=0;l<=s;l++)r.set(l,s+1,0)}for(c=0;c<e;c++)n[c]=r.get(e-1,c),r.set(e-1,c,0);r.set(e-1,e-1,1),t[0]=0}function Ge(e,t,n,r){let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y;for(o=1;o<e;o++)t[o-1]=t[o];t[e-1]=0;let b=0,x=0,S=2**-52;for(l=0;l<e;l++){for(x=Math.max(x,Math.abs(n[l])+Math.abs(t[l])),u=l;u<e&&!(Math.abs(t[u])<=S*x);)u++;if(u>l)do{for(i=n[l],d=(n[l+1]-i)/(2*t[l]),f=je(d,1),d<0&&(f=-f),n[l]=t[l]/(d+f),n[l+1]=t[l]*(d+f),p=n[l+1],a=i-n[l],o=l+2;o<e;o++)n[o]-=a;for(b+=a,d=n[u],m=1,h=m,g=m,_=t[l+1],v=0,y=0,o=u-1;o>=l;o--)for(g=h,h=m,y=v,i=m*t[o],a=m*d,f=je(d,t[o]),t[o+1]=v*f,v=t[o]/f,m=d/f,d=m*n[o]-v*i,n[o+1]=a+v*(m*i+v*n[o]),c=0;c<e;c++)a=r.get(c,o+1),r.set(c,o+1,v*r.get(c,o)+m*a),r.set(c,o,m*r.get(c,o)-v*a);d=-v*y*g*_*t[l]/p,t[l]=v*d,n[l]=m*d}while(Math.abs(t[l])>S*x);n[l]=n[l]+b,t[l]=0}for(o=0;o<e-1;o++){for(c=o,d=n[o],s=o+1;s<e;s++)n[s]<d&&(c=s,d=n[s]);if(c!==o)for(n[c]=n[o],n[o]=d,s=0;s<e;s++)d=r.get(s,o),r.set(s,o,r.get(s,c)),r.set(s,c,d)}}function Ke(e,t,n,r){let i=e-1,a,o,s,c,l,u,d;for(u=1;u<=i-1;u++){for(d=0,c=u;c<=i;c++)d+=Math.abs(t.get(c,u-1));if(d!==0){for(s=0,c=i;c>=u;c--)n[c]=t.get(c,u-1)/d,s+=n[c]*n[c];for(o=Math.sqrt(s),n[u]>0&&(o=-o),s-=n[u]*o,n[u]=n[u]-o,l=u;l<e;l++){for(a=0,c=i;c>=u;c--)a+=n[c]*t.get(c,l);for(a/=s,c=u;c<=i;c++)t.set(c,l,t.get(c,l)-a*n[c])}for(c=0;c<=i;c++){for(a=0,l=i;l>=u;l--)a+=n[l]*t.get(c,l);for(a/=s,l=u;l<=i;l++)t.set(c,l,t.get(c,l)-a*n[l])}n[u]=d*n[u],t.set(u,u-1,d*o)}}for(c=0;c<e;c++)for(l=0;l<e;l++)r.set(c,l,+(c===l));for(u=i-1;u>=1;u--)if(t.get(u,u-1)!==0){for(c=u+1;c<=i;c++)n[c]=t.get(c,u-1);for(l=u;l<=i;l++){for(o=0,c=u;c<=i;c++)o+=n[c]*r.get(c,l);for(o=o/n[u]/t.get(u,u-1),c=u;c<=i;c++)r.set(c,l,r.get(c,l)+o*n[c])}}}function qe(e,t,n,r,i){let a=e-1,o=e-1,s=2**-52,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A;for(g=0;g<e;g++)for((g<0||g>o)&&(n[g]=i.get(g,g),t[g]=0),_=Math.max(g-1,0);_<e;_++)l+=Math.abs(i.get(g,_));for(;a>=0;){for(y=a;y>0&&(p=Math.abs(i.get(y-1,y-1))+Math.abs(i.get(y,y)),p===0&&(p=l),!(Math.abs(i.get(y,y-1))<s*p));)y--;if(y===a)i.set(a,a,i.get(a,a)+c),n[a]=i.get(a,a),t[a]=0,a--,h=0;else if(y===a-1){if(S=i.get(a,a-1)*i.get(a-1,a),u=(i.get(a-1,a-1)-i.get(a,a))/2,d=u*u+S,m=Math.sqrt(Math.abs(d)),i.set(a,a,i.get(a,a)+c),i.set(a-1,a-1,i.get(a-1,a-1)+c),C=i.get(a,a),d>=0){for(m=u>=0?u+m:u-m,n[a-1]=C+m,n[a]=n[a-1],m!==0&&(n[a]=C-S/m),t[a-1]=0,t[a]=0,C=i.get(a,a-1),p=Math.abs(C)+Math.abs(m),u=C/p,d=m/p,f=Math.sqrt(u*u+d*d),u/=f,d/=f,_=a-1;_<e;_++)m=i.get(a-1,_),i.set(a-1,_,d*m+u*i.get(a,_)),i.set(a,_,d*i.get(a,_)-u*m);for(g=0;g<=a;g++)m=i.get(g,a-1),i.set(g,a-1,d*m+u*i.get(g,a)),i.set(g,a,d*i.get(g,a)-u*m);for(g=0;g<=o;g++)m=r.get(g,a-1),r.set(g,a-1,d*m+u*r.get(g,a)),r.set(g,a,d*r.get(g,a)-u*m)}else n[a-1]=C+u,n[a]=C+u,t[a-1]=m,t[a]=-m;a-=2,h=0}else{if(C=i.get(a,a),w=0,S=0,y<a&&(w=i.get(a-1,a-1),S=i.get(a,a-1)*i.get(a-1,a)),h===10){for(c+=C,g=0;g<=a;g++)i.set(g,g,i.get(g,g)-C);p=Math.abs(i.get(a,a-1))+Math.abs(i.get(a-1,a-2)),C=w=.75*p,S=-.4375*p*p}if(h===30&&(p=(w-C)/2,p=p*p+S,p>0)){for(p=Math.sqrt(p),w<C&&(p=-p),p=C-S/((w-C)/2+p),g=0;g<=a;g++)i.set(g,g,i.get(g,g)-p);c+=p,C=w=S=.964}for(h+=1,b=a-2;b>=y&&(m=i.get(b,b),f=C-m,p=w-m,u=(f*p-S)/i.get(b+1,b)+i.get(b,b+1),d=i.get(b+1,b+1)-m-f-p,f=i.get(b+2,b+1),p=Math.abs(u)+Math.abs(d)+Math.abs(f),u/=p,d/=p,f/=p,!(b===y||Math.abs(i.get(b,b-1))*(Math.abs(d)+Math.abs(f))<s*(Math.abs(u)*(Math.abs(i.get(b-1,b-1))+Math.abs(m)+Math.abs(i.get(b+1,b+1))))));)b--;for(g=b+2;g<=a;g++)i.set(g,g-2,0),g>b+2&&i.set(g,g-3,0);for(v=b;v<=a-1&&(k=v!==a-1,v!==b&&(u=i.get(v,v-1),d=i.get(v+1,v-1),f=k?i.get(v+2,v-1):0,C=Math.abs(u)+Math.abs(d)+Math.abs(f),C!==0&&(u/=C,d/=C,f/=C)),C!==0);v++)if(p=Math.sqrt(u*u+d*d+f*f),u<0&&(p=-p),p!==0){for(v===b?y!==b&&i.set(v,v-1,-i.get(v,v-1)):i.set(v,v-1,-p*C),u+=p,C=u/p,w=d/p,m=f/p,d/=u,f/=u,_=v;_<e;_++)u=i.get(v,_)+d*i.get(v+1,_),k&&(u+=f*i.get(v+2,_),i.set(v+2,_,i.get(v+2,_)-u*m)),i.set(v,_,i.get(v,_)-u*C),i.set(v+1,_,i.get(v+1,_)-u*w);for(g=0;g<=Math.min(a,v+3);g++)u=C*i.get(g,v)+w*i.get(g,v+1),k&&(u+=m*i.get(g,v+2),i.set(g,v+2,i.get(g,v+2)-u*f)),i.set(g,v,i.get(g,v)-u),i.set(g,v+1,i.get(g,v+1)-u*d);for(g=0;g<=o;g++)u=C*r.get(g,v)+w*r.get(g,v+1),k&&(u+=m*r.get(g,v+2),r.set(g,v+2,r.get(g,v+2)-u*f)),r.set(g,v,r.get(g,v)-u),r.set(g,v+1,r.get(g,v+1)-u*d)}}}if(l!==0){for(a=e-1;a>=0;a--)if(u=n[a],d=t[a],d===0)for(y=a,i.set(a,a,1),g=a-1;g>=0;g--){for(S=i.get(g,g)-u,f=0,_=y;_<=a;_++)f+=i.get(g,_)*i.get(_,a);if(t[g]<0)m=S,p=f;else if(y=g,t[g]===0?i.set(g,a,S===0?-f/(s*l):-f/S):(C=i.get(g,g+1),w=i.get(g+1,g),d=(n[g]-u)*(n[g]-u)+t[g]*t[g],x=(C*p-m*f)/d,i.set(g,a,x),i.set(g+1,a,Math.abs(C)>Math.abs(m)?(-f-S*x)/C:(-p-w*x)/m)),x=Math.abs(i.get(g,a)),s*x*x>1)for(_=g;_<=a;_++)i.set(_,a,i.get(_,a)/x)}else if(d<0)for(y=a-1,Math.abs(i.get(a,a-1))>Math.abs(i.get(a-1,a))?(i.set(a-1,a-1,d/i.get(a,a-1)),i.set(a-1,a,-(i.get(a,a)-u)/i.get(a,a-1))):(A=Je(0,-i.get(a-1,a),i.get(a-1,a-1)-u,d),i.set(a-1,a-1,A[0]),i.set(a-1,a,A[1])),i.set(a,a-1,0),i.set(a,a,1),g=a-2;g>=0;g--){for(T=0,E=0,_=y;_<=a;_++)T+=i.get(g,_)*i.get(_,a-1),E+=i.get(g,_)*i.get(_,a);if(S=i.get(g,g)-u,t[g]<0)m=S,f=T,p=E;else if(y=g,t[g]===0?(A=Je(-T,-E,S,d),i.set(g,a-1,A[0]),i.set(g,a,A[1])):(C=i.get(g,g+1),w=i.get(g+1,g),D=(n[g]-u)*(n[g]-u)+t[g]*t[g]-d*d,O=(n[g]-u)*2*d,D===0&&O===0&&(D=s*l*(Math.abs(S)+Math.abs(d)+Math.abs(C)+Math.abs(w)+Math.abs(m))),A=Je(C*f-m*T+d*E,C*p-m*E-d*T,D,O),i.set(g,a-1,A[0]),i.set(g,a,A[1]),Math.abs(C)>Math.abs(m)+Math.abs(d)?(i.set(g+1,a-1,(-T-S*i.get(g,a-1)+d*i.get(g,a))/C),i.set(g+1,a,(-E-S*i.get(g,a)-d*i.get(g,a-1))/C)):(A=Je(-f-w*i.get(g,a-1),-p-w*i.get(g,a),m,d),i.set(g+1,a-1,A[0]),i.set(g+1,a,A[1]))),x=Math.max(Math.abs(i.get(g,a-1)),Math.abs(i.get(g,a))),s*x*x>1)for(_=g;_<=a;_++)i.set(_,a-1,i.get(_,a-1)/x),i.set(_,a,i.get(_,a)/x)}for(g=0;g<e;g++)if(g<0||g>o)for(_=g;_<e;_++)r.set(g,_,i.get(g,_));for(_=e-1;_>=0;_--)for(g=0;g<=o;g++){for(m=0,v=0;v<=Math.min(_,o);v++)m+=r.get(g,v)*i.get(v,_);r.set(g,_,m)}}}function Je(e,t,n,r){let i,a;return Math.abs(n)>Math.abs(r)?(i=r/n,a=n+i*r,[(e+i*t)/a,(t-i*e)/a]):(i=n/r,a=r+i*n,[(i*e+t)/a,(i*t-e)/a])}var Ye=class{constructor(e){if(e=Oe.checkMatrix(e),!e.isSymmetric())throw Error(`Matrix is not symmetric`);let t=e,n=t.rows,r=new M(n,n),i=!0,a,o,s;for(o=0;o<n;o++){let e=0;for(s=0;s<o;s++){let n=0;for(a=0;a<s;a++)n+=r.get(s,a)*r.get(o,a);n=(t.get(o,s)-n)/r.get(s,s),r.set(o,s,n),e+=n*n}for(e=t.get(o,o)-e,i&=e>0,r.set(o,o,Math.sqrt(Math.max(e,0))),s=o+1;s<n;s++)r.set(o,s,0)}this.L=r,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=Oe.checkMatrix(e);let t=this.L,n=t.rows;if(e.rows!==n)throw Error(`Matrix dimensions do not match`);if(this.isPositiveDefinite()===!1)throw Error(`Matrix is not positive definite`);let r=e.columns,i=e.clone(),a,o,s;for(s=0;s<n;s++)for(o=0;o<r;o++){for(a=0;a<s;a++)i.set(s,o,i.get(s,o)-i.get(a,o)*t.get(s,a));i.set(s,o,i.get(s,o)/t.get(s,s))}for(s=n-1;s>=0;s--)for(o=0;o<r;o++){for(a=s+1;a<n;a++)i.set(s,o,i.get(s,o)-i.get(a,o)*t.get(a,s));i.set(s,o,i.get(s,o)/t.get(s,s))}return i}get lowerTriangularMatrix(){return this.L}},Xe=class{constructor(e,n={}){e=Oe.checkMatrix(e);let{Y:r}=n,{scaleScores:i=!1,maxIterations:a=1e3,terminationCriteria:o=1e-10}=n,s;if(r){if(r=t.isAnyArray(r)&&typeof r[0]==`number`?M.columnVector(r):Oe.checkMatrix(r),r.rows!==e.rows)throw Error(`Y should have the same number of rows as X`);s=r.getColumnVector(0)}else s=e.getColumnVector(0);let c=1,l,u,d,f;for(let t=0;t<a&&c>o;t++)d=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),d=d.div(d.norm()),l=e.mmul(d).div(d.transpose().mmul(d).get(0,0)),t>0&&(c=l.clone().sub(f).pow(2).sum()),f=l.clone(),r?(u=r.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),u=u.div(u.norm()),s=r.mmul(u).div(u.transpose().mmul(u).get(0,0))):s=l;if(r){let t=e.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0));t=t.div(t.norm());let n=e.clone().sub(l.clone().mmul(t.transpose())),i=s.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),a=r.clone().sub(l.clone().mulS(i.get(0,0)).mmul(u.transpose()));this.t=l,this.p=t.transpose(),this.w=d.transpose(),this.q=u,this.u=s,this.s=l.transpose().mmul(l),this.xResidual=n,this.yResidual=a,this.betas=i}else this.w=d.transpose(),this.s=l.transpose().mmul(l).sqrt(),i?this.t=l.clone().div(this.s.get(0,0)):this.t=l,this.xResidual=e.sub(l.mmul(d.transpose()))}};e.AbstractMatrix=j,e.CHO=Ye,e.CholeskyDecomposition=Ye,e.DistanceMatrix=ge,e.EVD=Ue,e.EigenvalueDecomposition=Ue,e.LU=Ae,e.LuDecomposition=Ae,e.Matrix=M,e.MatrixColumnSelectionView=ye,e.MatrixColumnView=ve,e.MatrixFlipColumnView=be,e.MatrixFlipRowView=xe,e.MatrixRowSelectionView=Ce,e.MatrixRowView=Se,e.MatrixSelectionView=we,e.MatrixSubView=Te,e.MatrixTransposeView=Ee,e.NIPALS=Xe,e.Nipals=Xe,e.QR=Me,e.QrDecomposition=Me,e.SVD=Ne,e.SingularValueDecomposition=Ne,e.SymmetricMatrix=he,e.WrapperMatrix1D=De,e.WrapperMatrix2D=Oe,e.correlation=He,e.covariance=Ve,e.default=M,e.determinant=Ie,e.inverse=Pe,e.linearDependencies=ze,e.pseudoInverse=Be,e.solve=Fe,e.wrap=ke}}),dm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimAbsolute.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.reimAbsolute=void 0;function t(e){let t=e.re.length,n=e.re,r=e.im,i=new Float64Array(t);for(let e=0;e<t;e++)i[e]=Math.sqrt(n[e]**2+r[e]**2);return i}e.reimAbsolute=t}}),fm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/getOutputArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.getOutputArray=void 0;var t=(nm(),Kp($p));function n(e,n){if(e!==void 0){if(!(0,t.isAnyArray)(e))throw TypeError(`output option must be an array if specified`);if(e.length!==n)throw TypeError(`the output array does not have the correct length`);return e}else return new Float64Array(n)}e.getOutputArray=n}}),pm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAbsolute.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xAbsolute=void 0;function t(e){let t=e.slice();for(let e=0;e<t.length;e++)t[e]<0&&(t[e]*=-1);return t}e.xAbsolute=t}}),mm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMedian=void 0;var t=(nm(),Kp($p));function n(e){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);let n=e.slice(),a=0,o=n.length-1,s=0,c=0,l=0,u=i(a,o);for(;;){if(o<=a)return n[u];if(o===a+1)return n[a]>n[o]&&r(n,a,o),n[u];for(s=i(a,o),n[s]>n[o]&&r(n,s,o),n[a]>n[o]&&r(n,a,o),n[s]>n[a]&&r(n,s,a),r(n,s,a+1),c=a+1,l=o;;){do c++;while(n[a]>n[c]);do l--;while(n[l]>n[a]);if(l<c)break;r(n,c,l)}r(n,a,l),l<=u&&(a=c),l>=u&&(o=l-1)}}e.xMedian=n;function r(e,t,n){let r=e[n];e[n]=e[t],e[t]=r}function i(e,t){return Math.floor((e+t)/2)}}}),hm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAbsoluteMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xAbsoluteMedian=void 0;var t=pm(),n=mm();function r(e){return(0,n.xMedian)((0,t.xAbsolute)(e))}e.xAbsoluteMedian=r}}),gm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAdd.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xAdd=void 0;var t=(nm(),Kp($p));function n(e,n){let r=!1,i=0;if((0,t.isAnyArray)(n)){if(e.length!==n.length)throw Error(`size of array1 and array2 must be identical`)}else r=!0,i=n;let a=new Float64Array(e.length);if(r)for(let t=0;t<e.length;t++)a[t]=e[t]+i;else for(let t=0;t<e.length;t++)a[t]=e[t]+n[t];return a}e.xAdd=n}}),_m=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xApplyFunctionStr.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xApplyFunctionStr=void 0;function t(e,t={}){let{variableLabel:n=`x`,fctString:r=n}=t,i=Function(n,`return Number(${r.replace(/(?<before>^|\W)(?<after>[\da-z]{2,}\()/g,`$<before>Math.$<after>`).replace(/Math\.Math/g,`Math`)})`),a=Float64Array.from(e);for(let t=0;t<e.length;t++)if(a[t]=i(e[t]),Number.isNaN(a[t]))throw Error(`The callback ${r} does not return a number: ${e[t]}`);return a}e.xApplyFunctionStr=t}}),vm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMultiply.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMultiply=void 0;var t=(nm(),Kp($p)),n=fm();function r(e,r,i={}){let a=!1,o=0;if((0,t.isAnyArray)(r)){if(e.length!==r.length)throw Error(`size of array1 and array2 must be identical`)}else a=!0,o=Number(r);let s=(0,n.getOutputArray)(i.output,e.length);if(a)for(let t=0;t<e.length;t++)s[t]=e[t]*o;else for(let t=0;t<e.length;t++)s[t]=e[t]*r[t];return s}e.xMultiply=r}}),ym=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xDotProduct.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xDotProduct=void 0;var t=vm();function n(e,n){let r=(0,t.xMultiply)(e,n),i=0;for(let t=0;t<e.length;t++)i+=r[t];return i}e.xDotProduct=n}}),bm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCrossCorrelation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCrossCorrelation=void 0;var t=ym();function n(e,n,r={}){let{tau:i=1,lag:a=e.length-1}=r,o=new Float64Array(1+2*a/i);if(e.length===n.length){let r=n.length,s=new Float64Array(2*r),c=new Float64Array(2*r);for(let e=0;e<r;e++)c[r+e]=n[e];for(let n=r*2-(i-1);n>0;n-=i){let l=0;for(let e=n;e<r*2;e++)s[l]=c[e],l++;let u=[];for(let e=0;e<r;e++)u[e]=s[e];o[(l-(r-a))/i]=(0,t.xDotProduct)(e,u)}}return o}e.xCrossCorrelation=n}}),xm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAutoCorrelation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xAutoCorrelation=void 0;var t=bm();function n(e,n={}){return(0,t.xCrossCorrelation)(e,e,n)}e.xAutoCorrelation=n}}),Sm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xBoxPlot.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xBoxPlot=void 0;function t(e,t={}){let{allowSmallArray:n=!1}=t;if(e.length<5)if(n){if(e.length<1)throw Error(`can not calculate info if array is empty`)}else throw Error(`can not calculate info if array contains less than 5 elements`);e=Float64Array.from(e).sort();let r={q1:0,median:0,q3:0,min:e[0],max:e[e.length-1]},i,a;if(e.length%2==1){let t=(e.length-1)/2;r.median=e[t],i=Math.max(t-1,0),a=Math.min(t+1,e.length-1)}else a=e.length/2,i=a-1,r.median=(e[i]+e[a])/2;if(i%2==0)r.q1=e[i/2],r.q3=e[(e.length+a-1)/2];else{r.q1=(e[(i+1)/2]+e[(i-1)/2])/2;let t=(e.length+a)/2;r.q3=(e[t]+e[t-1])/2}return r}e.xBoxPlot=t}}),Cm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCheck.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCheck=void 0;var t=(nm(),Kp($p));function n(e,n={}){let{minLength:r}=n;if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);if(typeof e[0]!=`number`)throw TypeError(`input must contain numbers`);if(r&&e.length<r)throw Error(`input must have a length of at least ${r}`)}e.xCheck=n}}),wm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCheckLengths.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCheckLengths=void 0;function t(e,t){if(e.length!==t.length)throw TypeError(`length of array1 and array2 must be identical`)}e.xCheckLengths=t}}),Tm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCorrelation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCorrelation=void 0;function t(e,t){let n=e.length,r=0,i=0,a=0,o=0,s=0;for(let c=0;c<n;c++){let n=e[c],l=t[c];r+=n,i+=n**2,a+=l,o+=l**2,s+=n*l}return(n*s-r*a)/(Math.sqrt(n*i-r**2)*Math.sqrt(n*o-a**2))}e.xCorrelation=t}}),Em=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCostMatrix.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCostMatrix=void 0;var t=um(),n=(e,t)=>Math.abs(e-t);function r(e,r,i={}){let{fct:a=n}=i,o=e.length,s=r.length,c=new t.Matrix(o,s);for(let t=0;t<o;t++)for(let n=0;n<s;n++)c.set(t,n,a(e[t],r[n]));return c}e.xCostMatrix=r}}),Dm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCumulative.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xCumulative=void 0;var t=(nm(),Kp($p));function n(e){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);let n=new Float64Array(e.length);if(e.length===0)return n;n[0]=e[0];for(let t=1;t<e.length;t++)n[t]=n[t-1]+e[t];return n}e.xCumulative=n}}),Om=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xDivide.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xDivide=void 0;var t=(nm(),Kp($p)),n=fm();function r(e,r,i={}){let a=!1,o=0;if((0,t.isAnyArray)(r)){if(e.length!==r.length)throw RangeError(`size of array1 and array2 must be identical`)}else a=!0,o=Number(r);let s=(0,n.getOutputArray)(i.output,e.length);if(a)for(let t=0;t<e.length;t++)s[t]=e[t]/o;else for(let t=0;t<e.length;t++)s[t]=e[t]/r[t];return s}e.xDivide=r}}),km=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xEnsureFloat64.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xEnsureFloat64=void 0;var t=Cm();function n(e){return(0,t.xCheck)(e),e instanceof Float64Array?e.slice(0):Float64Array.from(e)}e.xEnsureFloat64=n}}),Am=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xFindClosestIndex.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xFindClosestIndex=void 0;function t(e,t,n={}){let{sorted:r=!0}=n;if(r){let n=0,r=e.length-1,i=0;for(;r-n>1;)if(i=n+(r-n>>1),e[i]<t)n=i;else if(e[i]>t)r=i;else return i;return n<e.length-1?Math.abs(t-e[n])<Math.abs(e[n+1]-t)?n:n+1:n}else{let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i]-t);a<r&&(r=a,n=i)}return n}}e.xFindClosestIndex=t}}),jm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xGetFromToIndex.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xGetFromToIndex=void 0;var t=Am();function n(e,n={}){let{fromIndex:r,toIndex:i}=n,{from:a,to:o}=n;return r===void 0&&(r=a===void 0?0:(0,t.xFindClosestIndex)(e,a)),i===void 0&&(i=o===void 0?e.length-1:(0,t.xFindClosestIndex)(e,o)),r<0&&(r=0),i<0&&(i=0),r>=e.length&&(r=e.length-1),i>=e.length&&(i=e.length-1),r>i&&([r,i]=[i,r]),{fromIndex:r,toIndex:i}}e.xGetFromToIndex=n}}),Mm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xGetTargetIndex.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xGetTargetIndex=void 0;var t=Am();function n(e,n={}){let{target:r,targetIndex:i}=n;return i===void 0?r===void 0?0:(0,t.xFindClosestIndex)(e,r):i}e.xGetTargetIndex=n}}),Nm=Z({"../node_modules/.pnpm/fft.js@4.0.4/node_modules/fft.js/lib/fft.js"(e,t){function n(e){if(this.size=e|0,this.size<=1||this.size&this.size-1)throw Error(`FFT size must be a power of two and bigger than 1`);this._csize=e<<1;for(var t=Array(this.size*2),n=0;n<t.length;n+=2){let e=Math.PI*n/this.size;t[n]=Math.cos(e),t[n+1]=-Math.sin(e)}this.table=t;for(var r=0,i=1;this.size>i;i<<=1)r++;this._width=r%2==0?r-1:r,this._bitrev=Array(1<<this._width);for(var a=0;a<this._bitrev.length;a++){this._bitrev[a]=0;for(var o=0;o<this._width;o+=2){var s=this._width-o-2;this._bitrev[a]|=(a>>>o&3)<<s}}this._out=null,this._data=null,this._inv=0}t.exports=n,n.prototype.fromComplexArray=function(e,t){for(var n=t||Array(e.length>>>1),r=0;r<e.length;r+=2)n[r>>>1]=e[r];return n},n.prototype.createComplexArray=function(){let e=Array(this._csize);for(var t=0;t<e.length;t++)e[t]=0;return e},n.prototype.toComplexArray=function(e,t){for(var n=t||this.createComplexArray(),r=0;r<n.length;r+=2)n[r]=e[r>>>1],n[r+1]=0;return n},n.prototype.completeSpectrum=function(e){for(var t=this._csize,n=t>>>1,r=2;r<n;r+=2)e[t-r]=e[r],e[t-r+1]=-e[r+1]},n.prototype.transform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=0,this._transform4(),this._out=null,this._data=null},n.prototype.realTransform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=0,this._realTransform4(),this._out=null,this._data=null},n.prototype.inverseTransform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=1,this._transform4();for(var n=0;n<e.length;n++)e[n]/=this.size;this._out=null,this._data=null},n.prototype._transform4=function(){var e=this._out,t=this._csize,n=1<<this._width,r=t/n<<1,i,a,o=this._bitrev;if(r===4)for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleTransform2(i,e,n)}else for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleTransform4(i,e,n)}var s=this._inv?-1:1,c=this.table;for(n>>=2;n>=2;n>>=2){r=t/n<<1;var l=r>>>2;for(i=0;i<t;i+=r)for(var u=i+l,d=i,f=0;d<u;d+=2,f+=n){let t=d,n=t+l,r=n+l,i=r+l,a=e[t],o=e[t+1],u=e[n],p=e[n+1],m=e[r],h=e[r+1],g=e[i],_=e[i+1],v=a,y=o,b=c[f],x=s*c[f+1],S=u*b-p*x,C=u*x+p*b,w=c[2*f],T=s*c[2*f+1],E=m*w-h*T,D=m*T+h*w,O=c[3*f],k=s*c[3*f+1],A=g*O-_*k,ee=g*k+_*O,te=v+E,ne=y+D,re=v-E,ie=y-D,ae=S+A,oe=C+ee,se=s*(S-A),j=s*(C-ee),ce=te+ae,le=ne+oe,ue=te-ae,de=ne-oe,fe=re+j,M=ie-se,pe=re-j,me=ie+se;e[t]=ce,e[t+1]=le,e[n]=fe,e[n+1]=M,e[r]=ue,e[r+1]=de,e[i]=pe,e[i+1]=me}}},n.prototype._singleTransform2=function(e,t,n){let r=this._out,i=this._data,a=i[t],o=i[t+1],s=i[t+n],c=i[t+n+1],l=a+s,u=o+c,d=a-s,f=o-c;r[e]=l,r[e+1]=u,r[e+2]=d,r[e+3]=f},n.prototype._singleTransform4=function(e,t,n){let r=this._out,i=this._data,a=this._inv?-1:1,o=n*2,s=n*3,c=i[t],l=i[t+1],u=i[t+n],d=i[t+n+1],f=i[t+o],p=i[t+o+1],m=i[t+s],h=i[t+s+1],g=c+f,_=l+p,v=c-f,y=l-p,b=u+m,x=d+h,S=a*(u-m),C=a*(d-h),w=g+b,T=_+x,E=v+C,D=y-S,O=g-b,k=_-x,A=v-C,ee=y+S;r[e]=w,r[e+1]=T,r[e+2]=E,r[e+3]=D,r[e+4]=O,r[e+5]=k,r[e+6]=A,r[e+7]=ee},n.prototype._realTransform4=function(){var e=this._out,t=this._csize,n=1<<this._width,r=t/n<<1,i,a,o=this._bitrev;if(r===4)for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleRealTransform2(i,e>>>1,n>>>1)}else for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleRealTransform4(i,e>>>1,n>>>1)}var s=this._inv?-1:1,c=this.table;for(n>>=2;n>=2;n>>=2){r=t/n<<1;var l=r>>>1,u=l>>>1,d=u>>>1;for(i=0;i<t;i+=r)for(var f=0,p=0;f<=d;f+=2,p+=n){var m=i+f,h=m+u,g=h+u,_=g+u,v=e[m],y=e[m+1],b=e[h],x=e[h+1],S=e[g],C=e[g+1],w=e[_],T=e[_+1],E=v,D=y,O=c[p],k=s*c[p+1],A=b*O-x*k,ee=b*k+x*O,te=c[2*p],ne=s*c[2*p+1],re=S*te-C*ne,ie=S*ne+C*te,ae=c[3*p],oe=s*c[3*p+1],se=w*ae-T*oe,j=w*oe+T*ae,ce=E+re,le=D+ie,ue=E-re,de=D-ie,fe=A+se,M=ee+j,pe=s*(A-se),me=s*(ee-j),he=ce+fe,ge=le+M,_e=ue+me,ve=de-pe;if(e[m]=he,e[m+1]=ge,e[h]=_e,e[h+1]=ve,f===0){var ye=ce-fe,be=le-M;e[g]=ye,e[g+1]=be;continue}if(f!==d){var xe=ue,Se=-de,Ce=ce,we=-le,Te=-s*me,Ee=-s*pe,De=-s*M,Oe=-s*fe,ke=xe+Te,Ae=Se+Ee,je=Ce+Oe,Me=we-De,Ne=i+u-f,Pe=i+l-f;e[Ne]=ke,e[Ne+1]=Ae,e[Pe]=je,e[Pe+1]=Me}}}},n.prototype._singleRealTransform2=function(e,t,n){let r=this._out,i=this._data,a=i[t],o=i[t+n],s=a+o,c=a-o;r[e]=s,r[e+1]=0,r[e+2]=c,r[e+3]=0},n.prototype._singleRealTransform4=function(e,t,n){let r=this._out,i=this._data,a=this._inv?-1:1,o=n*2,s=n*3,c=i[t],l=i[t+n],u=i[t+o],d=i[t+s],f=c+u,p=c-u,m=l+d,h=a*(l-d),g=f+m,_=p,v=-h,y=f-m,b=p,x=h;r[e]=g,r[e+1]=0,r[e+2]=_,r[e+3]=v,r[e+4]=y,r[e+5]=0,r[e+6]=b,r[e+7]=x}}}),Pm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.createDoubleArray=e.createNumberArray=void 0;function t(e,t){return e===Array?new e(t).fill(0):new e(t)}e.createNumberArray=t;function n(e,t){return e===Array?new e(t).fill(0):new e(t)}e.createDoubleArray=n}}),Fm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createFromToArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.createFromToArray=void 0;function t(e={}){let{from:t=0,to:n=1,length:r=1e3,includeFrom:i=!0,includeTo:a=!0,distribution:o=`uniform`}=e,s=new Float64Array(r),c=r;i&&a?c=r-1:!i&&a||i&&!a?c=r:!i&&!a&&(c=r+1);let l=(n-t)/c;if(o===`uniform`)if(i){let e=0;for(;e<r;)s[e]=t+l*e,e++}else{let e=0;for(;e<r;)s[e]=t+l*(e+1),e++}else if(o===`log`){let e=(n/t)**(1/c),a=Math.log(t)/Math.log(e);if(i){let t=0;for(;t<r;)s[t]=e**(a+t),t++}else{let t=0;for(;t<r;)s[t]=e**(a+t+1),t++}}else throw Error(`distribution must be uniform or log`);return s}e.createFromToArray=t}}),Im={};Up(Im,{default:()=>Um});function Lm(e,t){e>>>=0,t>>>=0;let n=e&65535;return((e-n)*t>>>0)+n*t>>>0}var Rm,zm,Bm,Vm,Hm,Um,Wm=Hp({"../node_modules/.pnpm/ml-xsadd@2.0.0/node_modules/ml-xsadd/lib-es6/xsadd.js"(){Rm=8,zm=1/16777216,Bm=15,Vm=18,Hm=11,Um=class{constructor(e=Date.now()){this.state=new Uint32Array(4),this.init(e),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*zm}init(e){if(!Number.isInteger(e))throw TypeError(`seed must be an integer`);this.state[0]=e,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let e=1;e<Rm;e++)this.state[e&3]^=e+Lm(1812433253,this.state[e-1&3]^this.state[e-1&3]>>>30>>>0)>>>0;this.periodCertification();for(let e=0;e<Rm;e++)this.nextState()}periodCertification(){this.state[0]===0&&this.state[1]===0&&this.state[2]===0&&this.state[3]===0&&(this.state[0]=88,this.state[1]=83,this.state[2]=65,this.state[3]=68)}nextState(){let e=this.state[0];e^=e<<Bm,e^=e>>>Vm,e^=this.state[3]<<Hm,this.state[0]=this.state[1],this.state[1]=this.state[2],this.state[2]=this.state[3],this.state[3]=e}}}}),Gm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createRandomArray.js"(e){var t=e&&e.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},n=e&&e.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i,a,o,s,c;Object.defineProperty(e,`__esModule`,{value:!0}),e.createRandomArray=void 0;var l=r((Wm(),Kp(Im)));function u(e={}){let{mean:t=0,standardDeviation:n=1,length:r=1e3,range:i=1,seed:a,distribution:o=`normal`}=e,s=new l.default(a),c=new Float64Array(r);switch(o){case`normal`:{let e=new d(t,n,s);for(let t=0;t<r;t++)c[t]=e.generateGaussian();break}case`uniform`:for(let e=0;e<r;e++)c[e]=(s.random()-.5)*i+t;break;default:throw Error(`unknown distribution: ${String(o)}`)}return c}e.createRandomArray=u;var d=class{constructor(e,n,r){i.set(this,0),a.set(this,!1),o.set(this,void 0),s.set(this,void 0),c.set(this,void 0),t(this,o,e,`f`),t(this,s,n,`f`),t(this,c,r,`f`)}generateGaussian(){let e,r,l,u;if(n(this,a,`f`))t(this,a,!1,`f`),e=n(this,i,`f`)*n(this,s,`f`)+n(this,o,`f`);else{do r=n(this,c,`f`).random()*2-1,l=n(this,c,`f`).random()*2-1,u=r*r+l*l;while(u>=1||u===0);u=Math.sqrt(-2*Math.log(u)/u),t(this,i,l*u,`f`),t(this,a,!0,`f`),e=n(this,o,`f`)+n(this,s,`f`)*r*u}return e}};i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap}}),Km=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createStepArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.createStepArray=void 0;function t(e={}){let{from:t=0,step:n=1,length:r=1e3}=e,i=new Float64Array(r),a=0;for(;a<r;)i[a]=t+n*a,a++;return i}e.createStepArray=t}}),qm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/getRescaler.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.getRescaler=void 0;function t(e={}){let{targetMin:t=0,targetMax:i=1,clamp:a=!0,algorithmOptions:o={},algorithm:s=`linear`}=e,{originalMin:c=0,originalMax:l=1}=e,u=n(s,o);c=u(c),l=u(l);let d=l-c,f=i-t;return function(e){return e=u(e),e=r(e,c,l,a),t+(e-c)/d*f}}e.getRescaler=t;function n(e=`linear`,t={}){return n=>{switch(e){case`linear`:return n;case`logarithmic`:return Math.log10(n);case`power`:return n**(t.power||2);default:throw Error(`Unknown kind ${String(e)}`)}}}function r(e,t,n,r=!0){if(e<t){if(r)return t;throw RangeError(`Value ${e} is out of range [${t}, ${n}]`)}if(e>n){if(r)return n;throw RangeError(`Value ${e} is out of range [${t}, ${n}]`)}return e}}}),Jm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/isPowerOfTwo.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.isPowerOfTwo=void 0;function t(e){return e!==0&&(e&e-1)==0}e.isPowerOfTwo=t}}),Ym=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/nextPowerOfTwo.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.nextPowerOfTwo=void 0;function t(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1)}e.nextPowerOfTwo=t}}),Xm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/stringify.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.stringify=void 0;function t(e,t,n){return JSON.stringify(e,(e,n)=>(ArrayBuffer.isView(n)&&(n=Array.from(n)),t?t(e,n):n),n)}e.stringify=t}}),Zm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(Pm(),e),n(Fm(),e),n(Gm(),e),n(Km(),e),n(qm(),e),n(Jm(),e),n(Ym(),e),n(Xm(),e)}}),Qm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xHilbertTransform.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.xHilbertTransform=void 0;var n=t(Nm()),r=Zm(),i=Cm();function a(e,t={}){(0,i.xCheck)(e);let{forceFFT:n=!1}=t,a=e.length;return(0,r.isPowerOfTwo)(a)?o(e):n?c(o(c(e,(0,r.nextPowerOfTwo)(a))),a):s(e)}e.xHilbertTransform=a;function o(e){let t=e.length,r=new n.default(t),i=new Float64Array(t*2);for(let n=0;n<t;n++)i[n*2]=e[n];let a=new Float64Array(t*2);r.transform(a,i);let o=new Float64Array(t);for(let e=1;e<t;e++)o[e]=Math.sign(t/2-e);for(let e=0;e<t;e++)a[e*2]*=o[e],a[e*2+1]*=o[e];let s=new Float64Array(t*2);r.inverseTransform(s,a);let c=new Float64Array(t);for(let e=0;e<t;e++)c[e]=s[e*2+1];return c}function s(e,t={}){let{inClockwise:n=!0}=t,r=[0,...e,0],i=new Float64Array(e.length);for(let e=1;e<r.length-1;e++){let t=0;for(let n=0;n<e-1;n++){let i=Math.log((e-n)/(e-n-1));t+=r[n]*i+(r[n+1]-r[n])*(-1+(e-n)*i)}let a=r[e-1]-r[e+1],o=0;for(let t=e+1;t<r.length-1;t++){let n=Math.log((t-e)/(t-e+1));o+=r[t]*n+(r[t-1]-r[t])*(1+(t-e)*n)}i[e-1]=(n?1:-1)*(t+a+o)/Math.PI}return i}function c(e,t){(0,i.xCheck)(e);let n=e.length,r=(n-1)/(t-1),a=new Float64Array(t),o=0,s=Math.floor(o),c=Math.min(Math.ceil(o),n-1),l=o-s;for(let i=0;i<t;i++)a[i]=e[s]*(1-l)+e[c]*l,o+=r,s=Math.floor(o),c=Math.min(Math.ceil(o),n-1),l=o-s;return a}}}),$m=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxValue.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMaxValue=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]>o&&(o=e[t]);return o}e.xMaxValue=r}}),eh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinValue.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMinValue=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]<o&&(o=e[t]);return o}e.xMinValue=r}}),th=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xHistogram.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xHistogram=void 0;var t=Zm(),n=pm(),r=Cm(),i=$m(),a=eh();function o(e,o={}){(0,r.xCheck)(e);let s=o.histogram,{centerX:c=!0,nbSlots:l=s===void 0?256:s.x.length,logBaseX:u,logBaseY:d,absolute:f=!1}=o;if(f&&(e=(0,n.xAbsolute)(e)),u){e=e.slice();let t=Math.log10(u);for(let n=0;n<e.length;n++)e[n]=Math.log10(e[n])/t}let{min:p=(0,a.xMinValue)(e),max:m=(0,i.xMaxValue)(e)}=o,h=(m-p)/(l+2**-52),g=s===void 0?new Float64Array(l):s.y,_=s===void 0?Array.from((0,t.createFromToArray)({from:p+(c?h/2:0),to:m-(c?h/2:0),length:l})):s.x;for(let t of e){let e=Math.max(Math.min(Math.floor((t-p-2**-52)/h),l-1),0);g[e]++}if(d){let e=Math.log10(d);for(let t=0;t<g.length;t++)g[t]=Math.log10(g[t]+1)/e}return{x:_,y:g}}e.xHistogram=o}}),nh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xIsEquallySpaced.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xIsEquallySpaced=void 0;function t(e,t={}){if(e.length<3)return!0;let{tolerance:n=.05}=t,r=0,i=2**53-1;for(let t=0;t<e.length-1;++t){let n=e[t+1]-e[t];n<i&&(i=n),n>r&&(r=n)}return(r-i)/r<n}e.xIsEquallySpaced=t}}),rh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xIsMonotonic.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xIsMonotonic=void 0;function t(e){if(e.length<=2)return 1;if(e[0]===e[1]){for(let t=1;t<e.length-1;t++)if(e[t]!==e[t+1])return 0;return 1}if(e[0]<e[e.length-1]){for(let t=0;t<e.length-1;t++)if(e[t]>=e[t+1])return 0;return 1}else{for(let t=0;t<e.length-1;t++)if(e[t]<=e[t+1])return 0;return-1}}e.xIsMonotonic=t}}),ih=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMassCenterVectorSimilarity.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMassCenterVectorSimilarity=void 0;function t(e,t,i={}){let{recenter:a=!0,similarityFct:o=(e,t)=>+(e===t)}=i,s=r(e),c=r(t),l=Math.min(s,c);a&&(e=e.slice());let u=0;for(let r=0;r<l;r++){let i=1/l/(1<<r);for(let s=0;s<1<<r;s++){let c=(1<<r)-1+s,d=e[c],f=t[c];u+=o(d,f)*i,a&&n(e,l,r,s,f-d)}}return u}e.xMassCenterVectorSimilarity=t;function n(e,t,n,r,i){for(let a=n;a<t;a++){let t=r*(1<<a-n),o=(1<<a)-1,s=1<<a-n;for(let n=t;n<t+s;n++){let t=o+n;e[t]+=i}}}function r(e){let t=Math.log2(e.length+1);if(t%1!=0)throw Error(`the array length is not a power of 2 minus 1`);return t}}}),ah=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxAbsoluteValue.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMaxAbsoluteValue=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]>=0?e[t]>o&&(o=e[t]):-e[t]>o&&(o=-e[t]);return o}e.xMaxAbsoluteValue=r}}),oh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxIndex.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMaxIndex=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=i;for(let t=i+1;t<=a;t++)e[t]>e[o]&&(o=t);return o}e.xMaxIndex=r}}),sh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMean.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMean=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)o+=e[t];return o/(a-i+1)}e.xMean=r}}),ch=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanAbsoluteError.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMeanAbsoluteError=void 0;var t=wm();function n(e,n){(0,t.xCheckLengths)(e,n);let r=0;for(let t=0;t<e.length;t++)r+=Math.abs(e[t]-n[t]);return r/e.length}e.xMeanAbsoluteError=n}}),lh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanSquaredError.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMeanSquaredError=void 0;var t=wm();function n(e,n){(0,t.xCheckLengths)(e,n);let r=0;for(let t=0;t<e.length;t++)r+=(e[t]-n[t])**2;return r/e.length}e.xMeanSquaredError=n}}),uh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanWeighted.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMeanWeighted=void 0;var t=Cm(),n=jm();function r(e,r,i={}){if((0,t.xCheck)(e,{minLength:1}),(0,t.xCheck)(r),e.length!==r.length)throw Error(`array and weights must have the same length`);let{fromIndex:a,toIndex:o}=(0,n.xGetFromToIndex)(e,i),s=0,c=e[a]*r[a];s+=r[a];for(let t=a+1;t<=o;t++)c+=e[t]*r[t],s+=r[t];if(s===0)throw Error(`sum of weights must be > 0`);return c/s}e.xMeanWeighted=r}}),dh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMedianAbsoluteDeviation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMedianAbsoluteDeviation=void 0;var t=mm();function n(e){let n=(0,t.xMedian)(e),r=new Float64Array(e.length);for(let t=0;t<e.length;t++)r[t]=Math.abs(e[t]-n);return{median:n,mad:(0,t.xMedian)(r)}}e.xMedianAbsoluteDeviation=n}}),fh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinIndex.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMinIndex=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=i;for(let t=i+1;t<=a;t++)e[t]<e[o]&&(o=t);return o}e.xMinIndex=r}}),ph=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinMaxDelta.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMinMaxDelta=void 0;var t=Cm();function n(e){(0,t.xCheck)(e,{minLength:2});let n=e[1]-e[0],r=n;for(let t=0;t<e.length-1;t++){let i=e[t+1]-e[t];i<n&&(n=i),i>r&&(r=i)}return{min:n,max:r}}e.xMinMaxDelta=n}}),mh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinMaxValues.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMinMaxValues=void 0;var t=Cm();function n(e){(0,t.xCheck)(e);let n=e[0],r=e[0];for(let t of e)t<n&&(n=t),t>r&&(r=t);return{min:n,max:r}}e.xMinMaxValues=n}}),hh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMode.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xMode=void 0;function t(e){if(e.length===0)throw TypeError(`input must not be empty`);let t=0,n=0,r=0,i={};for(let a=0;a<e.length;++a){let o=e[a];r=i[o],r?(i[o]++,r++):(i[o]=1,r=1),r>n&&(n=r,t=e[a])}return t}e.xMode=t}}),gh=Z({"../node_modules/.pnpm/d3-array@0.7.1/node_modules/d3-array/build/d3-array.js"(e,t){(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r(n.d3_array={})})(e,function(e){function t(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function n(e){return e.length===1&&(e=r(e)),{left:function(t,n,r,i){for(r??=0,i??=t.length;r<i;){var a=r+i>>>1;e(t[a],n)<0?r=a+1:i=a}return r},right:function(t,n,r,i){for(r??=0,i??=t.length;r<i;){var a=r+i>>>1;e(t[a],n)>0?i=a:r=a+1}return r}}}function r(e){return function(n,r){return t(e(n),r)}}var i=n(t),a=i.right,o=i.left;function s(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function c(e){return e===null?NaN:+e}function l(e,t){var n=e.length,r=0,i,a,o=0,s=-1,l=0;if(t==null)for(;++s<n;)isNaN(i=c(e[s]))||(a=i-r,r+=a/++l,o+=a*(i-r));else for(;++s<n;)isNaN(i=c(t(e[s],s,e)))||(a=i-r,r+=a/++l,o+=a*(i-r));if(l>1)return o/(l-1)}function u(e,t){var n=l(e,t);return n&&Math.sqrt(n)}function d(e,t){var n=-1,r=e.length,i,a,o;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=o=a;break}for(;++n<r;)(a=e[n])!=null&&(i>a&&(i=a),o<a&&(o=a))}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=o=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&(i>a&&(i=a),o<a&&(o=a))}return[i,o]}function f(e){return function(){return e}}function p(e){return e}function m(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}var h=Math.sqrt(50),g=Math.sqrt(10),_=Math.sqrt(2);function v(e,t,n){var r=y(e,t,n);return m(Math.ceil(e/r)*r,Math.floor(t/r)*r+r/2,r)}function y(e,t,n){var r=Math.abs(t-e)/Math.max(0,n),i=10**Math.floor(Math.log(r)/Math.LN10),a=r/i;return a>=h?i*=10:a>=g?i*=5:a>=_&&(i*=2),t<e?-i:i}function b(e){return Math.ceil(Math.log(e.length)/Math.LN2)+1}function x(e){return+e}function S(){var e=p,t=d,n=b;function r(r){var i,o=r.length,s,c=Array(o);for(i=0;i<o;++i)c[i]=+e(r[i],i,r);var l=t(c),u=+l[0],d=+l[1],f=n(c,u,d);Array.isArray(f)||(f=v(u,d,+f));var p=f.length;for(i=0;i<p;++i)f[i]=+f[i];for(;f[0]<=u;)f.shift(),--p;for(;f[p-1]>=d;)f.pop(),--p;var m=Array(p+1),h;for(i=0;i<=p;++i)h=m[i]=[],h.x0=i>0?f[i-1]:u,h.x1=i<p?f[i]:d;for(i=0;i<o;++i)s=c[i],u<=s&&s<=d&&m[a(f,s,0,p)].push(r[i]);return m}return r.value=function(t){return arguments.length?(e=typeof t==`function`?t:f(+t),r):e},r.domain=function(e){return arguments.length?(t=typeof e==`function`?e:f([+e[0],+e[1]]),r):t},r.thresholds=function(e){return arguments.length?(n=typeof e==`function`?e:f(Array.isArray(e)?Array.prototype.map.call(e,x):+e),r):n},r}function C(e,t,n){if(n??=c,r=e.length){if((t=+t)<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function w(e,n,r){return e.sort(t),Math.ceil((r-n)/(2*(C(e,.75)-C(e,.25))*e.length**(-1/3)))}function T(e,t,n){return Math.ceil((n-t)/(3.5*u(e)*e.length**(-1/3)))}function E(e,t){var n=-1,r=e.length,i,a;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=a;break}for(;++n<r;)(a=e[n])!=null&&a>i&&(i=a)}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&a>i&&(i=a)}return i}function D(e,t){var n=0,r=e.length,i,a=-1,o=r;if(t==null)for(;++a<r;)isNaN(i=c(e[a]))?--o:n+=i;else for(;++a<r;)isNaN(i=c(t(e[a],a,e)))?--o:n+=i;if(o)return n/o}function O(e,n){var r=[],i=e.length,a,o=-1;if(n==null)for(;++o<i;)isNaN(a=c(e[o]))||r.push(a);else for(;++o<i;)isNaN(a=c(n(e[o],o,e)))||r.push(a);return C(r.sort(t),.5)}function k(e){for(var t=e.length,n,r=-1,i=0,a,o;++r<t;)i+=e[r].length;for(a=Array(i);--t>=0;)for(o=e[t],n=o.length;--n>=0;)a[--i]=o[n];return a}function A(e,t){var n=-1,r=e.length,i,a;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=a;break}for(;++n<r;)(a=e[n])!=null&&i>a&&(i=a)}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&i>a&&(i=a)}return i}function ee(e){for(var t=0,n=e.length-1,r=e[0],i=Array(n<0?0:n);t<n;)i[t]=[r,r=e[++t]];return i}function te(e,t){for(var n=t.length,r=Array(n);n--;)r[n]=e[t[n]];return r}function ne(e,n){if(i=e.length){var r=0,i,a=0,o,s=e[a];for(n||=t;++r<i;)(n(o=e[r],s)<0||n(s,s)!==0)&&(s=o,a=r);if(n(s,s)===0)return a}}function re(e,t,n){for(var r=(n??e.length)-(t=t==null?0:+t),i,a;r;)a=Math.random()*r--|0,i=e[r+t],e[r+t]=e[a+t],e[a+t]=i;return e}function ie(e,t){var n=0,r=e.length,i,a=-1;if(t==null)for(;++a<r;)(i=+e[a])&&(n+=i);else for(;++a<r;)(i=+t(e[a],a,e))&&(n+=i);return n}function ae(e){if(!(a=e.length))return[];for(var t=-1,n=A(e,oe),r=Array(n);++t<n;)for(var i=-1,a,o=r[t]=Array(a);++i<a;)o[i]=e[i][t];return r}function oe(e){return e.length}function se(){return ae(arguments)}e.version=`0.7.1`,e.bisect=a,e.bisectRight=a,e.bisectLeft=o,e.ascending=t,e.bisector=n,e.descending=s,e.deviation=u,e.extent=d,e.histogram=S,e.thresholdFreedmanDiaconis=w,e.thresholdScott=T,e.thresholdSturges=b,e.max=E,e.mean=D,e.median=O,e.merge=k,e.min=A,e.pairs=ee,e.permute=te,e.quantile=C,e.range=m,e.scan=ne,e.shuffle=re,e.sum=ie,e.ticks=v,e.tickStep=y,e.transpose=ae,e.variance=l,e.zip=se})}}),_h=Z({"../node_modules/.pnpm/spline-interpolator@1.0.0/node_modules/spline-interpolator/index.js"(e,t){var{bisectRight:n}=gh(),r=(e,t,n,r)=>{let i=e.length-1;e[0]=0,t[0]=0,n[0]=0,t[1]/=e[1],n[1]/=e[1];for(let r=2;r<i;++r)e[r]=e[r]-e[r-2]*n[r-2]*n[r-2]-e[r-1]*t[r-1]*t[r-1],t[r]=(t[r]-e[r-1]*t[r-1]*n[r-1])/e[r],n[r]=n[r]/e[r];for(let e=2;e<i;++e)r[e]=r[e]-t[e-1]*r[e-1]-n[e-2]*r[e-2];for(let t=1;t<i;++t)r[t]=r[t]/e[t];r[i-2]=r[i-2]-t[i-2]*r[i-1];for(let e=i-3;e>0;--e)r[e]=r[e]-t[e]*r[e+1]-n[e]*r[e+2]},i=(e,t,n,i)=>{let a=e.length-1,o=Array(a+1),s=Array(a+1),c=Array(a+1),l=Array(a+1),u=Array(a+1),d=Array(a+1),f=Array(a+1),p=Array(a+1),m=e.map(()=>[0,0,0,0]);m.pop();let h=2*(1-i)/(3*i);for(let t=0;t<a;++t)o[t]=e[t+1]-e[t],s[t]=3/o[t];u[0]=0;for(let n=1;n<a;++n)c[n]=-(s[n-1]+s[n]),l[n]=2*(e[n+1]-e[n-1]),u[n]=3*(t[n+1]-t[n])/o[n]-3*(t[n]-t[n-1])/o[n-1];u[a]=0;for(let e=1;e<a;++e)d[e]=s[e-1]*s[e-1]*n[e-1]+c[e]*c[e]*n[e]+s[e]*s[e]*n[e+1],d[e]=h*d[e]+l[e];for(let e=1;e<a-1;++e)f[e]=c[e]*s[e]*n[e]+s[e]*c[e+1]*n[e+1],f[e]=h*f[e]+o[e];for(let e=1;e<a-2;++e)p[e]=h*s[e]*s[e+1]*n[e+1];r(d,f,p,u),m[0][3]=t[0]-h*s[0]*u[1]*n[0],m[1][3]=t[1]-h*(c[1]*u[1]+s[1]*u[2])*n[0],m[0][0]=u[1]/(3*o[0]),m[0][1]=0,m[0][2]=(m[1][3]-m[0][3])/o[0]-u[1]*o[0]/3,s[0]=0;for(let e=1;e<a;++e)m[e][0]=(u[e+1]-u[e])/(3*o[e]),m[e][1]=u[e],m[e][2]=(u[e]+u[e-1])*o[e-1]+m[e-1][2],m[e][3]=s[e-1]*u[e-1]+c[e]*u[e]+s[e]*u[e+1],m[e][3]=t[e]-h*m[e][3]*n[e];return m};t.exports=class{constructor(e,t,n=1){let r=e.map((e,t)=>t);r.sort((t,n)=>e[t]-e[n]);let a=r.map(t=>e[t]),o=r.map(e=>t[e]),s=r.length,c=r.map(()=>1);this.n=s,this.x=a,this.y=o,this.params=i(a,o,c,n)}interpolate(e){if(e===this.x[this.n-1])return this.y[this.n-1];let t=Math.min(Math.max(0,n(this.x,e)-1),this.n-2),[r,i,a,o]=this.params[t];return e-=this.x[t],r*e*e*e+i*e*e+a*e+o}max(e=100){let t=this.x[0],n=(this.x[this.n-1]-t)/e,r=-1/0;for(let i=0,a=t;i<e;++i,a+=n){let e=this.interpolate(a);e>r&&(r=e)}return r}min(e=100){let t=this.x[0],n=(this.x[this.n-1]-t)/e,r=1/0;for(let i=0,a=t;i<e;++i,a+=n){let e=this.interpolate(a);e<r&&(r=e)}return r}domain(){return[this.x[0],this.x[this.x.length-1]]}range(){return[this.min(),this.max()]}curve(e,t=null){t||=this.domain();let n=(t[1]-t[0])/(e-1),r=Array(e);for(let i=0;i<e;++i){let e=n*i+t[0];r[i]=[e,this.interpolate(e)]}return r}}}}),vh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/utils/erfcinv.js"(e){Object.defineProperty(e,`__esModule`,{value:!0});var t=.08913147449493408,n=[-.005387729650712429,.008226878746769157,.02198786811111689,-.03656379714117627,-.012692614766297404,.03348066254097446,-.008368748197417368,-.0005087819496582806],r=[.0008862163904564247,-.0023339375937419,.07952836873415717,-.05273963823400997,-.7122890234154284,.662328840472003,1.5622155839842302,-1.5657455823417585,-.9700050433032906,1],i=2.249481201171875,a=[-3.6719225470772936,21.12946554483405,17.445385985570866,-44.6382324441787,-18.851064805871424,17.644729840837403,8.3705032834312,.10526468069939171,-.20243350835593876],o=[1.7211476576120028,-22.643693341313973,10.826866735546016,48.560921310873994,-20.14326346804852,-28.66081804998,3.971343795334387,6.242641248542475,1],s=.807220458984375,c=[-681149956853777e-24,2.8522533178221704e-8,-6.794655751811263e-7,.0021455899538880526,.029015791000532906,.14286953440815717,.3377855389120359,.38707973897260434,.11703015634199525,-.16379404719331705,-.1311027816799519],l=[.011059242293464892,.15226433829533179,.848854343457902,2.5930192162362027,4.778465929458438,5.381683457070069,3.4662540724256723,1],u=.9399557113647461,d=[26633922742578204e-28,-2304047769118826e-25,460469890584318e-20,.00015754461742496055,.0018712349281955923,.009508047013259196,.018557330651423107,-.0022242652921344794,-.0350353787183178],f=[7646752923027944e-20,.00263861676657016,.03415891436709477,.22009110576413124,.7620591645536234,1.3653349817554064,1],p=.9836282730102539,m=[9905570997331033e-32,-2811287356288318e-29,4.625961635228786e-9,4.4969678992770644e-7,14962478375834237e-21,.00020938631748758808,.001056288621524929,-.0011295143874558028,-.016743100507663373],h=[2.82243172016108e-7,27533547476472603e-21,.0009640118070051656,.016074608709367652,.1381518657490833,.5914293448864175,1];function g(e,t){let n=0;for(let r of e)n=n*t+r;return n}function _(e,t,n,r,i){let a=e-t,o=g(n,a)/g(r,a);return i*e+o*e}function v(e){let v=!1,y,b,x,S;if(Number.isNaN(e))return NaN;if(e<0||e>2)throw RangeError(`erfcinv()::invalid input argument. Value must be on the interval [0,2]. Value: \`${e}\`.`);return e===0?1/0:e===2?-1/0:e===1?0:(e>1?(b=2-e,e=1-b,v=!0):(b=e,e=1-e),e<=.5?(x=e*(e+10),S=g(n,e)/g(r,e),y=x*t+x*S,v?-y:y):b>=.25?(x=Math.sqrt(-2*Math.log(b)),b-=.25,S=g(a,b)/g(o,b),y=x/(i+S),v?-y:y):(b=Math.sqrt(-Math.log(b)),b<3?_(b,1.125,c,l,s):b<6?_(b,3,d,f,u):_(b,6,m,h,p)))}e.default=v}}),yh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/utils/rayleighCdf.js"(e){Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t=1){return e<0?0:-Math.expm1(-(e**2)/(2*t**2))}e.default=t}}),bh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNoiseSanPlot.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.xNoiseSanPlot=void 0;var n=t(_h()),r=Zm(),i=t(vh()),a=t(yh());function o(e,t={}){let{mask:n,cutOff:r,refine:i=!0,magnitudeMode:a=!1,scaleFactor:o=1,factorStd:l=5,fixOffset:u=!0}=t,f;if(f=Array.isArray(n)&&n.length===e.length?new Float64Array(e.filter((e,t)=>!n[t])):new Float64Array(e),o>1)for(let e=0;e<f.length;e++)f[e]*=o;if(f=f.sort().reverse(),u&&!a){let e=Math.floor(f.length/2),t=.5*(f[e]+f[e+1]);for(let e=0;e<f.length;e++)f[e]-=t}let p=f[f.length-1]>=0?f.length:f.findIndex(e=>e<0),m=p-1;for(let e=m;e>=0;e--)if(f[e]>0){m=e;break}let h=f.slice(0,m+1),g=f.slice(p),_=r||s(h,{magnitudeMode:a}),v=h[Math.floor(h.length*_)],y=h[0],b;b=g.length>0?-1*g[Math.floor(g.length*(1-_))]:0;let x=v,S=b,C=h.slice(),w=g.slice(),T=0,E=2;if(i){let e=x*l;T=h.findIndex(t=>t<e),T>-1&&(C=h.slice(T),x=C[Math.floor(C.length*_)]),e=S*l,E=g.findIndex(t=>t<e),E>-1&&(w=g.slice(E),S=C[Math.floor(w.length*(1-_))])}let D=-c(_/2,{magnitudeMode:a});v/=D,b/=D;let O,k;return i&&T>-1?(O=(_*C.length+T)/(C.length+T),k=-1*c(O/2,{magnitudeMode:a}),x/=k,E>-1&&(O=(_*w.length+E)/(w.length+E),k=-1*c(O/2,{magnitudeMode:a}),S!==0&&(S/=k))):(x/=D,S/=D),{positive:x,negative:S,snr:y/x,sanplot:d(f,{fromTo:{positive:{from:0,to:m},negative:{from:p,to:f.length}}})}}e.xNoiseSanPlot=o;function s(e,t={}){let{magnitudeMode:n=!1,considerList:r={from:.5,step:.1,to:.9}}=t,i=[],a=e.length-1;for(let t=.01;t<=.99;t+=.01){let r=-e[Math.round(a*t)]/c(t/2,{magnitudeMode:n});i.push([t,r])}let o=2**53-1,{from:s,to:l,step:u}=r,d=u/2,f=.5;for(let e=s;e<=l;e+=u){let t=e-d,n=e+d,r=i.filter(e=>e[0]<n&&e[0]>t),a=r.reduce((e,t)=>e+Math.abs(t[1]),0),s=0;for(let e of r)s+=(e[1]-a)**2;s<o&&(o=s,f=e)}return f}function c(e,t){return l([e],t)[0]}function l(e,t={}){let{magnitudeMode:r=!1}=t,o=u(0,2,.01),s=new Float64Array(e.length),c=new Float64Array(o.length);if(r){for(let e=0;e<c.length;e++){let t=o[e]*1;c[e]=1-(0,a.default)(t)}let t=new n.default(o,c);for(let n=0;n<s.length;n++){let r=2*e[n];s[n]=-1*t.interpolate(r)}}else for(let t=0;t<s.length;t++)s[t]=-1*Math.SQRT2*(0,i.default)(2*e[t]);return s}function u(e,t,n){let r=Math.abs((e-t)/n+1),i=[];for(let t=0;t<r;t++)i.push(e+t*n);return i}function d(e,t={}){let{fromTo:n,logBaseY:r=2}=t,i={};for(let t in n){let{from:a,to:o}=n[t];i[t]=a===o?{x:[],y:[]}:f(e.slice(a,o),{logBaseY:r}),t===`negative`&&i[t].y.reverse()}return i}function f(e,t={}){let{log10:n,abs:i}=Math,{logBaseY:a}=t;if(a){e=e.slice();let t=n(a);for(let r=0;r<e.length;r++)e[r]=n(i(e[r]))/t}return{x:(0,r.createFromToArray)({from:0,to:e.length-1,length:e.length}),y:e}}}}),xh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNoiseStandardDeviation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xNoiseStandardDeviation=void 0;var t=dh();function n(e){let{mad:n,median:r}=(0,t.xMedianAbsoluteDeviation)(e);return{sd:n/.6744897501960817,mad:n,median:r}}e.xNoiseStandardDeviation=n}}),Sh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNorm.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xNorm=void 0;function t(e){let t=0;for(let n of e)t+=n**2;return Math.sqrt(t)}e.xNorm=t}}),Ch=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSum.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSum=void 0;var t=Cm(),n=jm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)o+=e[t];return o}e.xSum=r}}),wh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNormed.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xNormed=void 0;var t=fm(),n=Cm(),r=$m(),i=Ch();function a(e,a={}){let{algorithm:s=`absolute`,value:c=1}=a;(0,n.xCheck)(e);let l=(0,t.getOutputArray)(a.output,e.length);if(e.length===0)throw Error(`input must not be empty`);switch(s){case`absolute`:{let t=o(e)/c;if(t===0)throw Error(`trying to divide by 0`);for(let n=0;n<e.length;n++)l[n]=e[n]/t;return l}case`max`:{let t=(0,r.xMaxValue)(e);if(t===0)throw Error(`trying to divide by 0`);let n=c/t;for(let t=0;t<e.length;t++)l[t]=e[t]*n;return l}case`sum`:{let t=(0,i.xSum)(e)/c;if(t===0)throw Error(`trying to divide by 0`);for(let n=0;n<e.length;n++)l[n]=e[n]/t;return l}default:throw Error(`unknown algorithm: ${String(s)}`)}}e.xNormed=a;function o(e){let t=0;for(let n=0;n<e.length;n++)t+=Math.abs(e[n]);return t}}}),Th=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xPadding.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xPadding=void 0;var t=Cm(),n=km();function r(e,r={}){let{size:i=0,value:a=0,algorithm:o}=r;if((0,t.xCheck)(e),!o)return(0,n.xEnsureFloat64)(e);let s=new Float64Array(e.length+i*2);for(let t=0;t<e.length;t++)s[t+i]=e[t];let c=i+e.length,l=2*i+e.length;switch(o){case`value`:for(let e=0;e<i;e++)s[e]=a;for(let e=c;e<l;e++)s[e]=a;break;case`duplicate`:for(let t=0;t<i;t++)s[t]=e[0];for(let t=c;t<l;t++)s[t]=e[e.length-1];break;case`circular`:for(let t=0;t<i;t++)s[t]=e[(e.length-i%e.length+t)%e.length];for(let t=0;t<i;t++)s[t+c]=e[t%e.length];break;default:throw Error(`unknown algorithm ${String(o)}`)}return s}e.xPadding=r}}),Eh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xVariance.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xVariance=void 0;var t=(nm(),Kp($p)),n=sh();function r(e,r={}){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);let{unbiased:i=!0,mean:a=(0,n.xMean)(e)}=r,o=0;for(let t=0;t<e.length;t++){let n=e[t]-a;o+=n*n}return i?o/(e.length-1):o/e.length}e.xVariance=r}}),Dh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xStandardDeviation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xStandardDeviation=void 0;var t=Eh();function n(e,n={}){return Math.sqrt((0,t.xVariance)(e,n))}e.xStandardDeviation=n}}),Oh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xParetoNormalization.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xParetoNormalization=void 0;var t=Cm(),n=Dh();function r(e){(0,t.xCheck)(e);let r=new Float64Array(e.length),i=Math.sqrt((0,n.xStandardDeviation)(e));for(let t=0;t<e.length;t++)r[t]=e[t]/i;return r}e.xParetoNormalization=r}}),kh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRescale.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRescale=void 0;var t=fm(),n=Cm(),r=$m(),i=eh();function a(e,a={}){(0,n.xCheck)(e);let o=(0,t.getOutputArray)(a.output,e.length),s=(0,i.xMinValue)(e),c=(0,r.xMaxValue)(e);if(s===c)throw RangeError(`minimum and maximum input values are equal. Cannot rescale a constant array`);let{min:l=0,max:u=1}=a;if(l>=u)throw RangeError(`min option must be smaller than max option`);let d=(u-l)/(c-s);for(let t=0;t<e.length;t++)o[t]=(e[t]-s)*d+l;return o}e.xRescale=a}}),Ah=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRolling.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRolling=void 0;var t=Cm(),n=Th();function r(e,r,i={}){if((0,t.xCheck)(e),typeof r!=`function`)throw TypeError(`fct must be a function`);let{window:a=5,padding:o={}}=i,{size:s=a-1,algorithm:c,value:l}=o,u=(0,n.xPadding)(e,{size:s,algorithm:c,value:l}),d=[];for(let e=0;e<u.length-a+1;e++)d.push(r(u.subarray(e,e+a)));return d}e.xRolling=r}}),jh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingAverage.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRollingAverage=void 0;var t=sh(),n=Ah();function r(e,r={}){return(0,n.xRolling)(e,t.xMean,r)}e.xRollingAverage=r}}),Mh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMax.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRollingMax=void 0;var t=$m(),n=Ah();function r(e,r={}){return(0,n.xRolling)(e,t.xMaxValue,r)}e.xRollingMax=r}}),Nh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRollingMedian=void 0;var t=mm(),n=Ah();function r(e,r={}){return(0,n.xRolling)(e,t.xMedian,r)}e.xRollingMedian=r}}),Ph=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMin.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRollingMin=void 0;var t=eh(),n=Ah();function r(e,r={}){return(0,n.xRolling)(e,t.xMinValue,r)}e.xRollingMin=r}}),Fh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRotate.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xRotate=void 0;function t(e,t){t%=e.length,t<0&&(t+=e.length);let n=new Float64Array(e.length);return n.set(e.slice(e.length-t)),n.set(e.slice(0,e.length-t),t),n}e.xRotate=t}}),Ih=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSampling.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSampling=void 0;var t=Cm();function n(e,n={}){let{length:i=10}=n;if((0,t.xCheck)(e),i===e.length)return Float64Array.from(e);if(i>e.length)throw RangeError(`length must be smaller than the array length`);return r(e,i)}e.xSampling=n;function r(e,t){let n=new Float64Array(t),r=(e.length-1)/(t-1);for(let i=0;i<t;i++)n[i]=e[Math.round(i*r)];return n}}}),Lh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSequentialFillFromStep.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSequentialFillFromStep=void 0;var t=Zm();function n(e,n={}){let{from:r,step:i,size:a}=e,{ArrayConstructor:o=Float64Array}=n,s=(0,t.createNumberArray)(o,a);for(let e=0;e<a;e++)s[e]=r+e*i;return s}e.xSequentialFillFromStep=n}}),Rh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSequentialFillFromTo.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSequentialFillFromTo=void 0;var t=Lh();function n(e,n={}){let{from:r,to:i,size:a}=e,o=(i-r)/(a-1);return(0,t.xSequentialFillFromStep)({from:r,step:o,size:a},n)}e.xSequentialFillFromTo=n}}),zh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSortAscending.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSortAscending=void 0;function t(e){if(ArrayBuffer.isView(e))return e.sort();if(Array.isArray(e))return e.sort((e,t)=>e-t);throw Error(`trying to sort non array`)}e.xSortAscending=t}}),Bh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSortDescending.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSortDescending=void 0;function t(e){if(ArrayBuffer.isView(e))return e.sort().reverse();if(Array.isArray(e))return e.sort((e,t)=>t-e);throw Error(`trying to sort non array`)}e.xSortDescending=t}}),Vh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSubtract.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xSubtract=void 0;var t=(nm(),Kp($p));function n(e,n){let r=!1,i=0;if((0,t.isAnyArray)(n)){if(e.length!==n.length)throw Error(`size of array1 and array2 must be identical`)}else r=!0,i=Number(n);let a=new Float64Array(e.length);if(r)for(let t=0;t<e.length;t++)a[t]=e[t]-i;else for(let t=0;t<e.length;t++)a[t]=e[t]-n[t];return a}e.xSubtract=n}}),Hh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xUniqueSorted.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xUniqueSorted=void 0;function t(e){return Float64Array.from(new Set(e)).sort()}e.xUniqueSorted=t}}),Q=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(fm(),e),n(pm(),e),n(hm(),e),n(gm(),e),n(_m(),e),n(xm(),e),n(Sm(),e),n(Cm(),e),n(wm(),e),n(Tm(),e),n(Em(),e),n(bm(),e),n(Dm(),e),n(Om(),e),n(ym(),e),n(km(),e),n(Am(),e),n(jm(),e),n(Mm(),e),n(Qm(),e),n(th(),e),n(nh(),e),n(rh(),e),n(ih(),e),n(ah(),e),n(oh(),e),n($m(),e),n(sh(),e),n(ch(),e),n(lh(),e),n(uh(),e),n(mm(),e),n(dh(),e),n(fh(),e),n(ph(),e),n(mh(),e),n(eh(),e),n(hh(),e),n(vm(),e),n(bh(),e),n(xh(),e),n(Sh(),e),n(wh(),e),n(Th(),e),n(Oh(),e),n(kh(),e),n(Ah(),e),n(jh(),e),n(Mh(),e),n(Nh(),e),n(Ph(),e),n(Fh(),e),n(Ih(),e),n(Lh(),e),n(Rh(),e),n(zh(),e),n(Bh(),e),n(Dh(),e),n(Vh(),e),n(Ch(),e),n(Hh(),e),n(Eh(),e)}}),Uh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimPhaseCorrection.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.reimPhaseCorrection=void 0;function t(e,t=0,n=0,r={}){let{reverse:i=!1}=r;t=Number.isFinite(t)?t:0,n=Number.isFinite(n)?n:0;let a=e.re,o=e.im,s=e.re.length,c=t,l=n/s;i&&(l*=-1,c+=n);let u=2*Math.sin(l/2)**2,d=Math.sin(l),f=Math.cos(c),p=Math.sin(c),m=new Float64Array(s),h=new Float64Array(s);for(let e=0;e<s;e++){m[e]=a[e]*f-o[e]*p,h[e]=o[e]*f+a[e]*p;let t=f-(u*f+d*p),n=p-(u*p-d*f);f=t,p=n}return{re:m,im:h}}e.reimPhaseCorrection=t}}),Wh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimAutoPhaseCorrection.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.reimAutoPhaseCorrection=void 0;var t=Q(),n=dm(),r=Uh();function i(e,t={}){let{magnitudeMode:n=!0,minRegSize:i=30,factorNoise:c=3,maxDistanceToJoin:l=256,reverse:u=!1}=t,f=o(e,{maxDistanceToJoin:l,magnitudeMode:n,factorNoise:c}),{re:p,im:m}=e,h=p.length,g=u?e=>h-1-e:e=>e,_=0,v=-1,y=[];for(;v<h;){let e=[],t=[];for(;!f[g(++v)]&&v<h;)_=v;for(;f[g(v)]&&v<h;v+=2)e.push(p[g(v)]),t.push(m[g(v)]);e.length>i&&y.push(s(e,t,_))}let{ph1:b,ph0:x}=a(y.map(e=>e.x0/h),y.map(e=>e.ph0),y.map(e=>e.area/1e11));return{data:(0,r.reimPhaseCorrection)({re:p,im:m},d(x),d(b),{reverse:u}),ph0:x,ph1:b}}e.reimAutoPhaseCorrection=i;function a(e,t,n){let[r,i]=u(e,t,n),o=-1,s=-(2**53-1);for(let n=0;n<e.length;n++){let a=e[n]*r+i,c=Math.abs(t[n]-a);c>34&&s<c&&(o=n,s=c)}return o>-1?(e.splice(o,1),t.splice(o,1),n.splice(o,1),a(e,t,n)):{ph0:i,ph1:r}}function o(e,t){let r=t.magnitudeMode?(0,n.reimAbsolute)(e):e.re,i=l(c(r),t);return l(r,t).map((e,t)=>e&&i[t])}function s(e,t,n){let i=-180,a=180,o=10,s=0,c=2**53-1;for(;o>0;){let n=(a-i)/7;for(let o=i;o<=a;o+=n){let n=f((0,r.reimPhaseCorrection)({re:e,im:t},d(o),0).re);n<c&&([c,s]=[n,o])}i=s-n,a=s+n,o--}let l=(0,r.reimPhaseCorrection)({re:e,im:t},d(s),0),u=0,p=0;for(let t=0;t<e.length;t++)u+=l.re[t],p+=l.re[t]*(t+n);return{ph0:s,area:u,x0:p/u}}function c(e){let t=new Float64Array(e.length);for(let n=5;n<e.length-5;n++)t[n]=(42*(e[n+1]-e[n-1])+48*(e[n+2]-e[n-2])+27*(e[n+3]+e[n-3])+8*(e[n+4]-e[n-4])+e[n+5]-e[n-5])/512;for(let n=0;n<5;n++)t[n]=t[5],t[e.length-n-1]=t[e.length-6];return t}function l(e,n){let{maxDistanceToJoin:r,magnitudeMode:i,factorNoise:a}=n,o=new Uint8Array(e.length);for(let t=0;t<e.length;t++)o[t]=0;let s=!0;for(;s;){let n=a*(0,t.xNoiseSanPlot)(e,{magnitudeMode:i}).positive;s=!1;for(let t=0;t<e.length;t++)Math.abs(e[t])>n&&!o[t]&&(s=!0,o[t]=1)}let c=0,l=0;for(let t=0;t<e.length;t++)if(!o[t])c++;else{if(c<r)for(let e=0;e<=c;e++)o[l+e]=1;for(;o[++t]&&t<e.length;);l=t,c=0}return o}function u(e,t,n){let r=0,i=0,a=0,o=0,s=0;for(let c=0;c<e.length;c++)r+=e[c]*e[c]*n[c],i+=e[c]*n[c],a+=n[c],o+=e[c]*n[c]*t[c],s+=n[c]*t[c];let c=r*a-i*i,l=[[a/c,-i/c],[-i/c,r/c]];return[l[0][0]*o+l[0][1]*s,l[1][0]*o+l[1][1]*s]}function d(e){return e*Math.PI/180}function f(e){let t=0;for(let n of e)n<0&&(t-=n);return t}}}),Gh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimFFT.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.reimFFT=void 0;var n=t(Nm()),r=Q();function i(e,t={}){let{inverse:r=!1,applyZeroShift:i=!1}=t,{re:o,im:s}=e,c=o.length,l=c<<1,u=new Float64Array(l);for(let e=0;e<l;e+=2)u[e]=o[e>>>1],u[e+1]=s[e>>>1];let d=new n.default(c),f=new Float64Array(l);r?(i&&(u=a(u,!0)),d.inverseTransform(f,u)):(d.transform(f,u),i&&(f=a(f)));let p=new Float64Array(c),m=new Float64Array(c);for(let e=0;e<l;e+=2)p[e>>>1]=f[e],m[e>>>1]=f[e+1];return{re:p,im:m}}e.reimFFT=i;function a(e,t){let n=t?Math.ceil(e.length/2):Math.floor(e.length/2);return(0,r.xRotate)(e,n)}}}),Kh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(dm(),e),n(Wh(),e),n(Gh(),e),n(Uh(),e)}}),qh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyAlign.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyAlign=void 0;function t(e,t,n={}){let{delta:r=1,common:i=!0,x:a=`x1`}=n,o={x:[],y1:[],y2:[]},s=0,c=0,l=e.x.length,u=t.x.length;for(;s<l&&c<u;){let n=0;n=typeof r==`function`?r((e.x[s]+t.x[c])/2):r;let d=e.x[s]-t.x[c];if(Math.abs(d)>n)if(d>0){if(!i&&(o.x.push(t.x[c]),o.y1.push(0),o.y2.push(t.y[c]),c===u-1))for(;s<l;)o.x.push(e.x[s]),o.y1.push(e.y[s]),o.y2.push(0),s++;c++}else{if(!i&&(o.x.push(e.x[s]),o.y1.push(e.y[s]),o.y2.push(0),s===l-1))for(;c<u;)o.x.push(t.x[c]),o.y1.push(0),o.y2.push(t.y[c]),c++;s++}else{let n=(e.x[s]*e.y[s]+t.x[c]*t.y[c])/(e.y[s]+t.y[c]);switch(a){case`x1`:o.x.push(e.x[s]);break;case`x2`:o.x.push(t.x[c]);break;case`weighted`:o.x.push(n);break;default:throw Error(`unknown x option value: ${String(a)}`)}o.y1.push(e.y[s]),o.y2.push(t.y[c]),s++,c++}}return o}e.xyAlign=t}}),$=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCheck.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyCheck=void 0;var t=(nm(),Kp($p));function n(e,n={}){let{minLength:r}=n;if(typeof e!=`object`||!e||!(0,t.isAnyArray)(e.x)||!(0,t.isAnyArray)(e.y))throw Error(`data must be an object of x and y arrays`);if(e.x.length!==e.y.length)throw Error(`the x and y arrays must have the same length`);if(r&&e.x.length<r)throw Error(`data.x must have a length of at least ${r}`)}e.xyCheck=n}}),Jh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCovariance.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyCovariance=void 0;var t=Q();function n(e,n={}){let{x:r,y:i}=e,{unbiased:a=!0}=n,o=(0,t.xMean)(r),s=(0,t.xMean)(i),c=0;for(let e=0;e<r.length;e++)c+=(r[e]-o)*(i[e]-s);return a?c/(r.length-1):c/r.length}e.xyCovariance=n}}),Yh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMaxYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return{x:i[0],y:a[0],index:0};let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c={x:i[o],y:a[o],index:o};for(let e=o;e<=s;e++)a[e]>c.y&&(c={x:i[e],y:a[e],index:e});return c}e.xyMaxYPoint=r}}),Xh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCumulativeDistributionStatistics.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyCumulativeDistributionStatistics=void 0;var t=Q(),n=$(),r=Yh(),i=[.25,.5,.75];function a(e){(0,n.xyCheck)(e);let{x:a,y:o}=e;if(a.length===0)throw Error(`array length must be greater than 0`);let s=(0,t.xCumulative)(o),c=(0,t.xMaxValue)(s);for(let e=0;e<s.length;e++)s[e]/=c;let l={x0:0,x25:0,x50:0,x75:0,x100:0,xMode:0,xMean:0};l.x0=a[0],l.x100=a[a.length-1];let u=0;breakPoint:for(let e=1;e<s.length;e++)for(;i[u]<s[e];){let t=`x${i[u]*100}`;if(l[t]=a[e-1]+(a[e]-a[e-1])*((i[u]-s[e-1])/(s[e]-s[e-1])),u++,u===i.length)break breakPoint}l.xMode=(0,r.xyMaxYPoint)(e).x;let d=0,f=0;for(let e=0;e<a.length;e++)d+=a[e]*o[e],f+=o[e];return l.xMean=d/f,l}e.xyCumulativeDistributionStatistics=a}}),Zh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEnsureFloat64.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyEnsureFloat64=void 0;var t=Q();function n(e){return{x:(0,t.xEnsureFloat64)(e.x),y:(0,t.xEnsureFloat64)(e.y)}}e.xyEnsureFloat64=n}}),Qh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEnsureGrowingX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyEnsureGrowingX=void 0;var t=Q(),n=$();function r(e){if((0,n.xyCheck)(e),(0,t.xIsMonotonic)(e.x)===1)return e;let r=Array.from(e.x),i=Array.from(e.y),a=-1/0,o=0;for(let e=0;e<r.length;e++)a<r[e]&&(o<e&&(r[o]=r[e],i[o]=i[e]),o++,a=r[e]);return r.length=o,i.length=o,{x:r,y:i}}e.xyEnsureGrowingX=r}}),$h=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/zonesNormalize.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.zonesNormalize=void 0;function t(e=[],n={}){let{exclusions:r=[]}=n,{from:i=-1/0,to:a=1/0}=n;i>a&&([i,a]=[a,i]),e=e.map(e=>e.from>e.to?{from:e.to,to:e.from}:{...e}).sort((e,t)=>e.from===t.from?e.to-t.to:e.from-t.from),e.length===0&&e.push({from:i,to:a});for(let t of e)i>t.from&&(t.from=i),a<t.to&&(t.to=a);if(e=e.filter(e=>e.from<=e.to),e.length===0)return[];let o=e[0],s=[o];for(let t=1;t<e.length;t++){let n=e[t];n.from<=o.to?o.to<n.to&&(o.to=n.to):(o=n,s.push(o))}if(r.length===0)return s;let c=t(r),l=0,u=[];for(let e=0;e<s.length;e++){let t=s[e];if(l===c.length){u.push(t);continue}for(;l<c.length&&c[l].to<=t.from;)l++;if(l===c.length){u.push(t);continue}if(t.to<c[l].from){u.push(t);continue}if(c[l].to>=t.to){if(c[l].from<=t.from)continue;u.push({from:c[l].to,to:t.to})}c[l].from>t.from&&u.push({from:t.from,to:c[l].from}),t.from=c[l].to,e--}return u}e.zonesNormalize=t}}),eg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/zonesWithPoints.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.zonesWithPoints=void 0;var t=$h();function n(e=[],n=10,r={}){if(e.length===0)return[];let i=(0,t.zonesNormalize)(e,r),a=[],o=i.reduce((e,t)=>e+(t.to-t.from),0)/n,s=0;for(let e=0;e<i.length-1;e++){let t=i[e],r=Math.min(Math.round((t.to-t.from)/o),n-s);a.push({...t,numberOfPoints:r}),s+=r}return a.push({...i[i.length-1],numberOfPoints:n-s}),a}e.zonesWithPoints=n}}),tg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n($h(),e),n(eg(),e)}}),ng=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/equallySpacedSlot.js"(e){Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t,n,r,i){let a=e.length,o=(r-n)/(i>1?i-1:1),s=o/2,c=e[e.length-1]-e[e.length-2],l=n-s,u=new Float64Array(i),d=l,f=l+o,p=-Number.MAX_VALUE,m=0,h=e[0],g=t[0],_=0,v=!0,y=0,b=0,x=1,S=0;main:for(;;){if(p>=h)throw Error(`x must be a growing series`);for(;p-f>0;){if(v&&=(b++,!1),u[S]=b<=0?0:y/b,S++,S===i)break main;d=f,f+=o,y=0,b=0}p>d&&(y+=m,b++),(p===-Number.MAX_VALUE||_>1)&&b--,p=h,m=g,x<a?(h=e[x],g=t[x],x++):(h+=c,g=0,_++)}return u}e.default=t}}),rg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/integral.js"(e){Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t,n,r){return .5*n*t*t+r*t-(.5*n*e*e+r*e)}e.default=t}}),ig=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/equallySpacedSmooth.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});var n=t(rg());function r(e,t,r,a,o){let s=e.length,c=(a-r)/(o>1?o-1:1),l=c/2,u=new Float64Array(o),d=e[1]-e[0],f=e[s-1]-e[s-2],p=r-l,m=r+l,h=-(2**53-1),g=0,_=e[0]-d,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;main:for(;;){if(h>=_)throw Error(`x must be a growing series`);for(h<=p&&p<=_&&(E=(0,n.default)(0,p-h,b,g),S=y+E);_-m>=0;){if(E=(0,n.default)(0,m-h,b,g),C=y+E,u[T++]=(C-S)/c,T===o)break main;p=m,m+=c,S=C}y+=(0,n.default)(h,_,b,x),h=_,g=v,w<s?(_=e[w],v=t[w],w++):w===s&&(_+=f,v=0),b=i(h,g,_,v),x=-b*h+g}return u}e.default=r;function i(e,t,n,r){return(r-t)/(n-e)}}}),ag=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEquallySpaced.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.xyEquallySpaced=void 0;var n=Zm(),r=tg(),i=t(ng()),a=t(ig()),o=$();function s(e,t={}){let{x:n,y:i}=e,a=n.length,{from:s=n[0],to:l=n[a-1],variant:u=`smooth`,numberOfPoints:d=100,exclusions:f=[],zones:p=[{from:s,to:l}]}=t;if(s>l)throw RangeError(`from should be larger than to`);if((0,o.xyCheck)(e),d<2)throw RangeError(`'numberOfPoints' option must be greater than 1`);let m=(0,r.zonesNormalize)(p,{from:s,to:l,exclusions:f}),h=(0,r.zonesWithPoints)(m,d,{from:s,to:l}),g=[],_=[];for(let e of h){e.numberOfPoints||=0;let t=c(Array.from(n),Array.from(i),e.from,e.to,e.numberOfPoints,u);g=g.concat(t.x),_=_.concat(t.y)}return{x:g,y:_}}e.xyEquallySpaced=s;function c(e,t,r,o,s,c){if(s<1)throw RangeError(`the number of points must be at least 1`);let l=c===`slot`?Array.from((0,i.default)(e,t,r,o,s)):Array.from((0,a.default)(e,t,r,o,s));return{x:Array.from((0,n.createFromToArray)({from:r,to:o,length:s})),y:l}}}}),og=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyExtract.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyExtract=void 0;var t=tg(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{zones:o}=r;if(o=(0,t.zonesNormalize)(o),i===void 0||a===void 0||!Array.isArray(o)||o.length===0)return e;let s=[],c=[],l=o[0],u=0;loop:for(let e=0;e<i.length;e++){for(;l.to<i[e];)if(u++,l=o[u],!l){e=i.length;break loop}i[e]>=l.from&&(s.push(i[e]),c.push(a[e]))}return{x:s,y:c}}e.xyExtract=r}}),sg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilter.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFilter=void 0;function t(e,t={}){let{x:n,y:r}=e,{filter:i}=t,a=[],o=[];for(let e=0;e<n.length;e++)(!i||i(n[e],r[e]))&&(a.push(n[e]),o.push(r[e]));return{x:a,y:o}}e.xyFilter=t}}),cg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterMinYValue.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFilterMinYValue=void 0;var t=Q();function n(e,n){if(n===void 0)return e;let{x:r,y:i}=e,{min:a,max:o}=(0,t.xMinMaxValues)(i),s=o*n;if(a>=s)return e;let c=[],l=[];for(let e=0;e<r.length;e++)i[e]>=s&&(c.push(r[e]),l.push(i[e]));return{x:c,y:l}}e.xyFilterMinYValue=n}}),lg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterTopYValues.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFilterTopYValues=void 0;var t=Q();function n(e,n){if(n===void 0||n>e.x.length)return e;let{x:r,y:i}=e,a=[],o=[],s=(0,t.xSortDescending)(i.slice()),c=s[n-1],l=0;for(let e=0;e<n;e++)s[e]===c&&l++;for(let e=0;e<r.length;e++)i[e]>c?(a.push(r[e]),o.push(i[e])):i[e]===c&&(l--,l>=0&&(a.push(r[e]),o.push(i[e])));return{x:a,y:o}}e.xyFilterTopYValues=n}}),ug=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFilterX=void 0;var t=tg();function n(e,n={}){let{x:r,y:i}=e,{from:a=r[0],to:o=r[r.length-1],zones:s=[{from:a,to:o}],exclusions:c=[]}=n,l=(0,t.zonesNormalize)(s,{from:a,to:o,exclusions:c}),u=0,d=[],f=[],p=0;for(;p<r.length;){if(r[p]<=l[u].to&&r[p]>=l[u].from)d.push(r[p]),f.push(i[p]);else if(r[p]>l[u].to&&(u++,!l[u]))break;p++}return{x:d,y:f}}e.xyFilterX=n}}),dg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterXPositive.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFilterXPositive=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[],a=[];if(n===void 0||r===void 0)return{x:i,y:a};for(let e=0;e<n.length;e++)n[e]>0&&(i.push(n[e]),a.push(r[e]));return{x:i,y:a}}e.xyFilterXPositive=n}}),fg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFindClosestPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyFindClosestPoint=void 0;var t=Q();function n(e,n){let{x:r,y:i}=e,a=(0,t.xFindClosestIndex)(r,n);return{x:r[a],y:i[a]}}e.xyFindClosestPoint=n}}),pg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyGetNMaxY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyGetNMaxY=void 0;var t=$();function n(e,n){if((0,t.xyCheck)(e),e.x.length<=n)return e;{let t=new Float64Array(n),r=new Float64Array(n),i=Float64Array.from(e.y).sort().reverse()[n-1],a=0;for(let o=0;o<e.x.length;o++)if(e.y[o]>=i&&(t[a]=e.x[o],r[a]=e.y[o],a++),a===n)return{x:t,y:r};return e}}e.xyGetNMaxY=n}}),mg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyGrowingX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyGrowingX=void 0;function t(e){let{x:t,y:n}=e;if(t.length!==n.length)throw TypeError(`length of x and y must be identical`);return t.length<2||t[0]<t[1]?e:{x:t.slice(0).reverse(),y:n.slice(0).reverse()}}e.xyGrowingX=t}}),hg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyIntegral.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyIntegral=void 0;var t=Q(),n=$();function r(e,r={}){let{reverse:i=!1}=r;(0,n.xyCheck)(e,{minLength:1});let{x:a,y:o}=e,{fromIndex:s,toIndex:c}=(0,t.xGetFromToIndex)(a,r),l=0,u={x:new Float64Array(c-s+1),y:new Float64Array(c-s+1)},d=0;if(i){u.y[d]=0,u.x[d++]=a[c];for(let e=c;e>s;e--)l+=(a[e]-a[e-1])*(o[e-1]+o[e])/2,u.x[d]=a[e-1],u.y[d++]=l;u.x.reverse(),u.y.reverse()}else{u.y[d]=0,u.x[d++]=a[s];for(let e=s;e<c;e++)l+=(a[e+1]-a[e])*(o[e+1]+o[e])/2,u.x[d]=a[e+1],u.y[d++]=l}return u}e.xyIntegral=r}}),gg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyIntegration.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyIntegration=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return 0;let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=0;for(let e=o;e<s;e++)c+=(i[e+1]-i[e])*(a[e+1]+a[e])/2;return c}e.xyIntegration=r}}),_g=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyJoinX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyJoinX=void 0;var t=$();function n(e,n={}){(0,t.xyCheck)(e);let{delta:r=1}=n,i=typeof r==`function`,a=Array.from(e.x),o=Array.from(e.y);if(a.length<2)return{x:a,y:o};let s=0;for(let e=1;e<a.length;e++)a[e]-a[e-1]<=(i?r((a[e]+a[e-1])/2):r)?(o[s]!==0||o[e]!==0)&&(a[s]=(a[s]*o[s]+a[e]*o[e])/(o[s]+o[e]),o[s]+=o[e]):(s++,a[s]=a[e],o[s]=o[e]);return a.length=s+1,o.length=s+1,{x:a,y:o}}e.xyJoinX=n}}),vg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMassCenter.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMassCenter=void 0;var t=jm(),n=Bg();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e,{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=0,l=0;for(let e=o;e<=s;e++)l+=i[e]*a[e],c+=a[e];if(c===0)throw Error(`Sum of Ys can not be zero.`);return l/c}e.xyMassCenter=r}}),yg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMassCenterVector.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMassCenterVector=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:2});let{depth:a=5}=r,{weightedIntegral:o,integral:s}=i(e),c=new Float64Array((1<<a)-1),l=new Int32Array((1<<a)-1);l[0]=e.x.length-1;let u=new Int32Array((1<<a)-1);u[0]=-1;let d=0;for(let n=0;n<a;n++)for(let r=0;r<1<<n;r++){let i=u[d],f=l[d],p=i===-1?s[f]:s[f]-s[i],m=0;if(m=p===0?(e.x[f]+e.x[i])/2:i===-1?o[f]/p:(o[f]-o[i])/p,c[d++]=m,n<a-1){let a=(1<<n+1)+r*2-1,o=(0,t.xFindClosestIndex)(e.x,m);o===i&&o++,u[a]=i,l[a]=o,o===f&&o--,u[a+1]=o,l[a+1]=f}}return c}e.xyMassCenterVector=r;function i(e){let{x:t,y:n}=e,r=new Float64Array(t.length),i=new Float64Array(t.length),a=(t[1]-t[0])*n[0],o=a;i[0]=o;let s=a*t[0];r[0]=s;for(let e=1;e<t.length-1;e++){let a=(t[e+1]-t[e-1])*n[e]/2,c=t[e];o+=a,i[e]=o,s+=a*c,r[e]=s}let c=(t[t.length-1]-t[t.length-2])*n[n.length-1];return o+=c,i[t.length-1]=o,s+=c*t[t.length-1],r[t.length-1]=s,{integral:i,weightedIntegral:r}}}}),bg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxClosestYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMaxClosestYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{target:o}=r,{targetIndex:s}=r;s===void 0&&(s=o===void 0?0:(0,t.xFindClosestIndex)(i,o));let c=-(2**53-1),l=s,u=a[s];for(;l!==c;)c=l,l>0&&a[l-1]>u?l--:l<i.length-1&&a[l+1]>u&&l++,u=a[l];return{x:i[l],y:a[l],index:l}}e.xyMaxClosestYPoint=r}}),xg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaximaY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMaximaY=void 0;var t=$();function n(e){(0,t.xyCheck)(e,{minLength:2});let{x:n,y:r}=e,i=[],a=-1;for(let e=1;e<n.length-1;e++)if(r[e-1]<r[e]&&r[e+1]<r[e])i.push({x:n[e],y:r[e],index:e});else if(r[e-1]<r[e]&&r[e+1]===r[e])a=e;else if(r[e-1]===r[e]&&r[e+1]<r[e]){let t=Math.floor((e+a)/2);i.push({x:n[t],y:r[t],index:t})}return i}e.xyMaximaY=n}}),Sg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxMerge.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMaxMerge=void 0;function t(e,t={}){let{x:n,y:r}=e,{groupWidth:i=.001}=t,a={x:[],y:[]},o={x:[],y:[]},s=0,c=0;for(;c<n.length;)s===0||n[c]-a.x[s-1]>i?(o.x.push(n[c]),o.y.push(r[c]),a.x.push(n[c]),a.y.push(r[c]),c++,s++):(r[c]>o.y[s-1]&&(o.x[s-1]=n[c],o.y[s-1]=r[c]),a.x[s-1]=n[c],a.y[s-1]+=r[c],c++);return a.x=o.x.slice(),a}e.xyMaxMerge=t}}),Cg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMaxY=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=a[o];for(let e=o;e<=s;e++)a[e]>c&&(c=a[e]);return c}e.xyMaxY=r}}),wg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMedian=void 0;function t(e){let{x:t,y:n}=e,r=0,i=0,a;if(t.length===0)return NaN;if(t.length===1)return t[0];for(a=0;a<n.length;a++)r+=n[a];for(a=0;a<n.length;a++){if(i+=n[a],i>r/2)return t[a];if(i===r/2)return .5*(t[a]+t[a+1])}return NaN}e.xyMedian=t}}),Tg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMergeByCentroids.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMergeByCentroids=void 0;function t(e,t,n={}){let{window:r=.01}=n,i={x:Float64Array.from(t),y:new Float64Array(t.length).fill(0)},a=0,o=0;for(;a<e.x.length&&o<t.length;){let n=e.x[a]-t[o];Math.abs(n)<r?i.y[o]+=e.y[a++]:n<0?a++:o++}return i}e.xyMergeByCentroids=t}}),Eg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinClosestYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMinClosestYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{target:o}=r,{targetIndex:s}=r;s===void 0&&(s=o===void 0?0:(0,t.xFindClosestIndex)(i,o));let c=-(2**53-1),l=s,u=a[s];for(;l!==c;)c=l,l>0&&a[l-1]<u?l--:l<i.length-1&&a[l+1]<u&&l++,u=a[l];return{x:i[l],y:a[l],index:l}}e.xyMinClosestYPoint=r}}),Dg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinimaY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMinimaY=void 0;var t=$();function n(e){(0,t.xyCheck)(e,{minLength:2});let{x:n,y:r}=e,i=[],a=-1;for(let e=1;e<n.length-1;e++)if(r[e-1]>r[e]&&r[e+1]>r[e])i.push({x:n[e],y:r[e],index:e});else if(r[e-1]>r[e]&&r[e+1]===r[e])a=e;else if(r[e-1]===r[e]&&r[e+1]>r[e]){let t=Math.floor((e+a)/2);i.push({x:n[t],y:r[t],index:t})}return i}e.xyMinimaY=n}}),Og=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyMinYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return{x:i[0],y:a[0],index:0};let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c={x:i[o],y:a[o],index:o};for(let e=o;e<=s;e++)a[e]<c.y&&(c={x:i[e],y:a[e],index:e});return c}e.xyMinYPoint=r}}),kg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyPeakInfo.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyPeakInfo=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e;if(i===void 0||a===void 0||i.length<3)return;let{target:o}=r,{targetIndex:s}=r;if(s===void 0&&o!==void 0&&(s=(0,t.xFindClosestIndex)(i,o)),s===void 0)throw Error(`must specify target or targetIndex`);let c=s,l=a[c]-a[c+1],u=l<0?-1:1;for(l*=u;c<i.length-1;){c++;let e=(a[c]-a[c+1])*u;if(e<l)break;l=e}let d={x:i[c],y:a[c]};for(c=s,l=(a[c]-a[c-1])*u;c>1;){c--;let e=(a[c]-a[c-1])*u;if(e<l)break;l=e}let f={x:i[c],y:a[c]};return{inflectionBefore:f,inflectionAfter:d,extrema:{x:i[s],y:a[s]},inflectionMiddle:{x:(f.x+d.x)/2,y:(f.y+d.y)/2},width:Math.abs(f.x-d.x)}}e.xyPeakInfo=r}}),Ag=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRealMaxYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyRealMaxYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,o=(0,t.xGetTargetIndex)(i,r);if(a[o-1]>0&&a[o+1]>0&&a[o]>=a[o-1]&&a[o]>=a[o+1]){let e=20*Math.log10(a[o-1]),t=20*Math.log10(a[o]),n=20*Math.log10(a[o+1]),r=.5*(e-n)/(e-2*t+n);return{x:i[o]+(i[o]-i[o-1])*r,y:a[o]-.25*(a[o-1]-a[o+1])*r,index:o}}else return{x:i[o],y:a[o],index:o}}e.xyRealMaxYPoint=r}}),jg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRealMinYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyRealMinYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,o=(0,t.xGetTargetIndex)(i,r);if(a[o-1]<0&&a[o+1]<0&&a[o]<=a[o-1]&&a[o]<=a[o+1]){let e=20*Math.log10(-a[o-1]),t=20*Math.log10(-a[o]),n=20*Math.log10(-a[o+1]),r=.5*(e-n)/(e-2*t+n);return{x:i[o]+(i[o]-i[o-1])*r,y:a[o]-.25*(a[o-1]-a[o+1])*r,index:o}}else return{x:i[o],y:a[o],index:o}}e.xyRealMinYPoint=r}}),Mg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyReduce.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyReduce=void 0;var t=Q(),n=tg(),r=$();function i(e,i={}){(0,r.xyCheck)(e);let{x:o,y:s}=e,{from:c=o[0],to:l=o[o.length-1],nbPoints:u=4001,optimize:d=!1}=i,{zones:f=[]}=i;f=(0,n.zonesNormalize)(f,{from:c,to:l}),f.length===0&&(f=[{from:c,to:l}]);let p=f,m=0;for(let e of p)e.fromIndex=(0,t.xFindClosestIndex)(o,e.from),e.toIndex=(0,t.xFindClosestIndex)(o,e.to),e.fromIndex>0&&o[e.fromIndex]>e.from&&e.fromIndex--,e.toIndex<o.length-1&&o[e.toIndex]<e.to&&e.toIndex++,e.nbPoints=e.toIndex-e.fromIndex+1,m+=e.nbPoints;if(m<=u)return a(o,s,p,m);let h=u/m,g=0;for(let e=0;e<p.length-1;e++){let t=p[e];t.nbPoints=Math.round(t.nbPoints*h),g+=t.nbPoints}p[p.length-1].nbPoints=u-g;let _=[],v=[];for(let e of p)e.nbPoints&&y(e.fromIndex,e.toIndex,e.nbPoints);return{x:_,y:v};function y(e,t,n){if(n===1){_.push(o[Math.round((t-e)/2)]),v.push(s[Math.round((t-e)/2)]);return}if(n===2){_.push(o[e],o[t]),v.push(s[e],s[t]);return}_.push(o[e]),v.push(s[e]),n=n%2==0?n/2+1:(n-1)/2+1;let r=(o[t]-o[e])/(n-1),i=o[e]+r,a=!0,c=1/0,l=-1/0;for(let n=e+1;n<=t;n++)a?(c=s[n],l=s[n],a=!1):(s[n]<c&&(c=s[n]),s[n]>l&&(l=s[n])),(o[n]>=i||n===t)&&(d?c>v[_.length-1]||(l<v[_.length-1]?l=c:(_.push(i-r/2),v.push(c))):(_.push(i-r/2),v.push(c)),_.push(i),v.push(l),i+=r,a=!0)}}e.xyReduce=i;function a(e,t,n,r){let i=new Float64Array(r),a=new Float64Array(r),o=0;for(let r of n)for(let n=r.fromIndex;n<r.toIndex+1;n++)i[o]=e[n],a[o]=t[n],o++;return{x:i,y:a}}}}),Ng=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRolling.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyRolling=void 0;var t=Q();function n(e,n,r={}){let{x:i,y:a}=e;return a=(0,t.xRolling)(a,n,r),i.length!==a.length&&(i=(0,t.xRollingAverage)(i,r)),{x:i,y:a}}e.xyRolling=n}}),Pg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xySetYValue.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xySetYValue=void 0;var t=tg(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{value:o=0}=r,{zones:s}=r;if(!Array.isArray(s)||s.length===0)return e;s=(0,t.zonesNormalize)(s);let c=i.slice(),l=a.slice(),u=s[0],d=0;loop:for(let e=0;e<i.length;e++){for(;u.to<i[e];)if(d++,u=s[d],!u){e=i.length;break loop}i[e]>=u.from&&(l[e]=o)}return{x:c,y:l}}e.xySetYValue=r}}),Fg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xySortX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xySortX=void 0;var t=Q();function n(e){let{x:n,y:r}=e;if((0,t.xIsMonotonic)(n)&&n.length>1)return n[0]<n[1]?{x:Float64Array.from(n),y:Float64Array.from(r)}:{x:Float64Array.from(n).reverse(),y:Float64Array.from(r).reverse()};let i=n.map((e,t)=>({x:e,y:r[t]})).sort((e,t)=>e.x-t.x),a={x:new Float64Array(n.length),y:new Float64Array(r.length)};for(let e=0;e<n.length;e++)a.x[e]=i[e].x,a.y[e]=i[e].y;return a}e.xySortX=n}}),Ig=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyToXYArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyToXYArray=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[];for(let e=0;e<n.length;e++)i.push([n[e],r[e]]);return i}e.xyToXYArray=n}}),Lg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyToXYObject.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyToXYObject=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[];for(let e=0;e<n.length;e++)i.push({x:n[e],y:r[e]});return i}e.xyToXYObject=n}}),Rg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyUniqueX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyUniqueX=void 0;var t=$(),n=Fg();function r(e,r={}){(0,t.xyCheck)(e);let{algorithm:o=`average`,isSorted:s=!0}=r;switch(s||(e=(0,n.xySortX)(e)),o){case`average`:return i(e);case`sum`:return a(e);default:throw Error(`unknown algorithm: ${String(o)}`)}}e.xyUniqueX=r;function i(e){let t=[],n=[],r=e.y[0],i=1;for(let a=1;a<e.x.length;a++)e.x[a]!==e.x[a-1]&&(t.push(e.x[a-1]),n.push(r/i),r=0,i=0),r+=e.y[a],i++;return t.push(e.x[e.x.length-1]),n.push(r/i),{x:t,y:n}}function a(e){let t=[],n=[],r=e.y[0];for(let i=1;i<e.x.length;i++)e.x[i]!==e.x[i-1]&&(t.push(e.x[i-1]),n.push(r),r=0),r+=e.y[i];return t.push(e.x[e.x.length-1]),n.push(r),{x:t,y:n}}}}),zg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyWeightedMerge.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyWeightedMerge=void 0;function t(e,t={}){let{x:n,y:r}=e,{groupWidth:i=.001}=t,a={x:[],y:[]},o={x:[],y:[]},s=0,c=0;for(;c<n.length;)s===0||n[c]-a.x[s-1]>i?(o.x.push(n[c]*r[c]),o.y.push(r[c]),a.x.push(n[c]),a.y.push(r[c]),c++,s++):(o.x[s-1]+=n[c]*r[c],o.y[s-1]+=r[c],a.x[s-1]=n[c],a.y[s-1]+=r[c],c++);for(let e=0;e<a.x.length;e++)a.x[e]=o.x[e]/o.y[e];return a}e.xyWeightedMerge=t}}),Bg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(qh(),e),n($(),e),n(Jh(),e),n(Xh(),e),n(Zh(),e),n(Qh(),e),n(ag(),e),n(og(),e),n(sg(),e),n(cg(),e),n(lg(),e),n(ug(),e),n(dg(),e),n(fg(),e),n(pg(),e),n(mg(),e),n(hg(),e),n(gg(),e),n(_g(),e),n(vg(),e),n(yg(),e),n(bg(),e),n(xg(),e),n(Sg(),e),n(Cg(),e),n(Yh(),e),n(wg(),e),n(Tg(),e),n(Eg(),e),n(Dg(),e),n(Og(),e),n(kg(),e),n(Ag(),e),n(jg(),e),n(Mg(),e),n(Ng(),e),n(Pg(),e),n(Fg(),e),n(Ig(),e),n(Lg(),e),n(Rg(),e),n(zg(),e)}}),Vg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy2/xy2ToXY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xy2ToXY=void 0;function t(e){let t={x:[],y:[]};for(let n of e)t.x.push(n[0]),t.y.push(n[1]);return t}e.xy2ToXY=t}}),Hg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy2/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(Vg(),e)}}),Ug=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/xreimSortX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xreimSortX=void 0;function t(e){let{x:t,re:n,im:r}=e;if(t.length!==n.length||t.length!==r.length)throw TypeError(`length of x, re and im must be identical`);return t.length<2||t[0]<t[1]?e:{x:t.slice(0).reverse(),re:n.slice(0).reverse(),im:r.slice(0).reverse()}}e.xreimSortX=t}}),Wg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/xreimZeroFilling.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xreimZeroFilling=void 0;function t(e,t){let n=e.x.length;if(t===0||n===t)return e;if(n>t)return{x:e.x.slice(0,t),re:e.re.slice(0,t),im:e.im.slice(0,t)};let r=e.x,i=e.re,a=e.im,o=new Float64Array(t),s=new Float64Array(t),c=new Float64Array(t);for(let e=0;e<n;e++)o[e]=r[e],s[e]=i[e],c[e]=a[e];let l=(r[r.length-1]-r[0])/(n-1);for(let e=n;e<t;e++)o[e]=o[e-1]+l;return{x:o,re:s,im:c}}e.xreimZeroFilling=t}}),Gg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(Ug(),e),n(Wg(),e)}}),Kg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/utils/getSlots.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.getSlots=void 0;function t(e,t={}){let{delta:n=1}=t,r=typeof n==`function`,i=Float64Array.from(e.map(e=>e.x).flat()).sort();if(i.length===0)throw Error(`can not process empty arrays`);let a={from:i[0],to:i[0],average:i[0],sum:i[0],number:1},o=[a];for(let e=1;e<i.length;e++){let t=r?n(i[e]):n;i[e]-a.to<=t?(a.to=i[e],a.number++,a.sum+=i[e],a.average=a.sum/a.number):(a={from:i[e],to:i[e],average:i[e],sum:i[e],number:1},o.push(a))}return o}e.getSlots=t}}),qg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayAlign.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyArrayAlign=void 0;var t=Bg(),n=Kg();function r(e,r={}){let{delta:a=1,requiredY:o=!1}=r;e=e.map(e=>(0,t.xyJoinX)(e,{delta:a}));let s=(0,n.getSlots)(e,{delta:a}),c=Float64Array.from(s.map(e=>e.average)),l=Array.from(e,()=>new Float64Array(c.length)),u=new Uint32Array(e.length);for(let t=0;t<s.length;t++){let n=s[t];for(let r=0;r<e.length;r++){let i=e[r];for(;u[r]<i.x.length&&i.x[u[r]]<=n.to;)l[r][t]+=i.y[u[r]],u[r]++}}return o?i(c,l):{x:c,ys:l}}e.xyArrayAlign=r;function i(e,t){let n=[],r=Array.from(t,()=>[]);for(let i=0;i<e.length;i++)if(t.every(e=>e[i]!==0)){n.push(e[i]);for(let e=0;e<t.length;e++)r[e].push(t[e][i])}return{x:n,ys:r}}}}),Jg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayWeightedMerge.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyArrayWeightedMerge=void 0;function t(e,t={}){let{delta:r=1}=t;if(typeof r==`number`){let e=r;r=()=>e}if(e=e.filter(e=>e.x.length>0),e.length===0)return{x:[],y:[]};let i=[],a=[],o=Array(e.length).fill(0),s={x:0,y:0};n(e,o,s);let c={maxX:s.x+r(s.x),sumY:s.y,sumXY:s.y*s.x};for(;e.length>0;)n(e,o,s),s.x<=c.maxX||(c.sumY>0&&(i.push(c.sumXY/c.sumY),a.push(c.sumY)),c.sumY=0,c.sumXY=0),c.sumY+=s.y,c.sumXY+=s.x*s.y,c.maxX=s.x+r(s.x),e.length===0&&c.sumY>0&&(i.push(c.sumXY/c.sumY),a.push(c.sumY));return{x:i,y:a}}e.xyArrayWeightedMerge=t;function n(e,t,n){let r=0,i=e[0].x[t[0]];for(let n=1;n<e.length;n++){let a=e[n].x[t[n]];a<i&&(i=a,r=n)}n.x=i,n.y=e[r].y[t[r]],t[r]++,t[r]===e[r].x.length&&(t.splice(r,1),e.splice(r,1))}}}),Yg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/utils/getSlotsToFirst.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.getSlotsToFirst=void 0;var t=Jg();function n(e,n={}){let{delta:r=1}=n,i=typeof r==`function`,a=e[0].x,o=[];for(let e of a){let t=i?r(e):r;o.push({from:e-t,to:e+t,value:e})}let s=(0,t.xyArrayWeightedMerge)(e.slice(1),n).x,c=0;for(let e of o)for(;s[c]<e.to&&c<s.length;){if(s[c]<e.from){let e=i?r(s[c]):r;o.push({from:s[c]-e,to:s[c]+e,value:s[c]})}c++}for(let e=c;e<s.length;e++){let t=i?r(s[e]):r;o.push({from:s[e]-t,to:s[e]+t,value:s[e]})}o.sort((e,t)=>e.value-t.value);for(let e=0;e<o.length-1;e++)if(o[e].to>o[e+1].from){let t=(o[e].value+o[e+1].value)/2;o[e].to=t,o[e+1].from=t}return o}e.getSlotsToFirst=n}}),Xg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayAlignToFirst.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyArrayAlignToFirst=void 0;var t=Yg();function n(e,n={}){let{delta:r=1}=n,i=(0,t.getSlotsToFirst)(e,{delta:r}),a=Float64Array.from(i.map(e=>e.value)),o=Array.from(e,()=>new Float64Array(a.length)),s=new Uint32Array(e.length);for(let t=0;t<i.length;t++){let n=i[t];for(let r=0;r<e.length;r++){let i=e[r];for(;s[r]<i.x.length&&i.x[s[r]]<n.to;)o[r][t]+=i.y[s[r]],s[r]++}}return{x:a,ys:o}}e.xyArrayAlignToFirst=n}}),Zg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayMerge.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyArrayMerge=void 0;var t=Bg(),n=Kg();function r(e,r={}){let{delta:i=1}=r;e=e.map(e=>(0,t.xyJoinX)(e,{delta:i}));let a=(0,n.getSlots)(e,{delta:i}),o=Float64Array.from(a.map(e=>e.average)),s=new Float64Array(o.length),c=new Uint32Array(e.length);for(let t=0;t<a.length;t++){let n=a[t];for(let r=0;r<e.length;r++){let i=e[r];for(;c[r]<i.x.length&&i.x[c[r]]<=n.to;)s[t]+=i.y[c[r]],c[r]++}}return{x:o,y:s}}e.xyArrayMerge=r}}),Qg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(qg(),e),n(Xg(),e),n(Zg(),e),n(Jg(),e)}}),$g=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectCheck.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectCheck=void 0;function t(e){if(!Array.isArray(e)||e.length>0&&(typeof e[0].x!=`number`||typeof e[0].y!=`number`))throw Error(`points must be an array of {x,y} objects`)}e.xyObjectCheck=t}}),e_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMaxXPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectMaxXPoint=void 0;var t=$g();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].x>n.x&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMaxXPoint=n}}),t_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMinXPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectMinXPoint=void 0;var t=$g();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].x<n.x&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMinXPoint=n}}),n_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectBestPoints.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectBestPoints=void 0;var t=e_(),n=t_();function r(e,r={}){let{from:i=(0,n.xyObjectMinXPoint)(e).x,to:a=(0,t.xyObjectMaxXPoint)(e).x,limit:o=20,threshold:s=.01,numberCloseSlots:c=50,numberSlots:l=10}=r,u=(a-i)/l,d=(a-i)/c,f=e.filter(e=>e.x>=i&&e.x<=a).map(e=>({point:e,monoisotopic:!1}));f=f.sort((e,t)=>e.monoisotopic&&!t.monoisotopic?-1:t.monoisotopic&&!e.monoisotopic?1:t.point.y-e.point.y);let p=[];if(f.length===0)return[];let m=f[0].point.y*s;peakLoop:for(let e of f){if(e.point.y<m){if(e.monoisotopic)continue;break}let t=!1;for(let n of p){if(Math.abs(n.x-e.point.x)<d)continue peakLoop;Math.abs(n.x-e.point.x)<u&&(t=!0)}let n=JSON.parse(JSON.stringify(e.point));if(n.close=t,p.push(n),p.length===o)break}return p.sort((e,t)=>e.x-t.x)}e.xyObjectBestPoints=r}}),r_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectJoinX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectJoinX=void 0;function t(e,t={}){let{xError:n=2**-52}=t,r=[],i={x:-(2**53-1),y:0};for(let t of e)t.x-i.x<=n?(i.y!==0||t.y!==0)&&(i.x=t.y/(i.y+t.y)*(t.x-i.x)+i.x,i.y+=t.y):(i={x:t.x,y:t.y},r.push(i));return r}e.xyObjectJoinX=t}}),i_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMaxYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectMaxYPoint=void 0;var t=$g();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].y>n.y&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMaxYPoint=n}}),a_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMinYPoint.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectMinYPoint=void 0;var t=$g();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].y<n.y&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMinYPoint=n}}),o_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSlotX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectSlotX=void 0;function t(e,t={}){let{slotWidth:n=1}=t,r=n/2,i=[],a={x:-1/0,y:0};for(let t of e){let e=t.x-(t.x+r)%n+r;Math.abs(a.x-e)>2**-52&&(a={x:e,y:0},i.push(a)),a.y+=t.y}return i}e.xyObjectSlotX=t}}),s_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSortX.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectSortX=void 0;function t(e){return e.sort((e,t)=>e.x-t.x)}e.xyObjectSortX=t}}),c_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSumY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectSumY=void 0;var t=$g();function n(e=[]){(0,t.xyObjectCheck)(e);let n=0;for(let t of e)n+=t.y;return n}e.xyObjectSumY=n}}),l_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectToXY.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.xyObjectToXY=void 0;function t(e){return{x:e.map(e=>e.x),y:e.map(e=>e.y)}}e.xyObjectToXY=t}}),u_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(n_(),e),n($g(),e),n(r_(),e),n(e_(),e),n(i_(),e),n(t_(),e),n(a_(),e),n(o_(),e),n(s_(),e),n(c_(),e),n(l_(),e)}}),d_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixAbsoluteMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixAbsoluteMedian=void 0;var t=Q();function n(e){let n=e[0].length,r=new Float64Array(e.length*n);for(let t=0;t<e.length;t++){let i=t*n;for(let a=0;a<n;a++){let n=e[t][a];r[i+a]=n<0?-n:n}}return(0,t.xMedian)(r)}e.matrixAbsoluteMedian=n}}),f_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCreateEmpty.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixCreateEmpty=void 0;var t=Zm();function n(e){let{matrix:n,nbRows:r=n?.length||1,nbColumns:i=n?.[0].length||1,ArrayConstructor:a=Float64Array}=e,o=[];for(let e=0;e<r;e++)o.push((0,t.createNumberArray)(a,i));return o}e.matrixCreateEmpty=n}}),p_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixApplyNumericalEncoding.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixApplyNumericalEncoding=void 0;var t=Q(),n=f_();function r(e,r){let i=(0,n.matrixCreateEmpty)({nbRows:e.length,nbColumns:e[0].length,ArrayConstructor:Array}),a=[];for(let e in r)a.push(r[e]);let o=(0,t.xMaxValue)(a);for(let e=0;e<i.length;e++)for(let t=0;t<i[0].length;t++)typeof i[e][t]==`string`&&(i[e][t]in r?i[e][t]=r[i[e][t]]:(o++,r[i[e][t]]=o,i[e][t]=o));return i}e.matrixApplyNumericalEncoding=r}}),m_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixAutoCorrelation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixAutoCorrelation=void 0;var t=Q();function n(e,n=0){let r=e.length,i=e[0].length;if(r<2)throw Error(`can not calculate info if matrix contains less than 2 rows`);let a=new Float64Array(r),o=new Float64Array(r),s=new Float64Array(i);for(let t=0;t<r;t++)a[t]=e[t][n];for(let n=0;n<i;n++){for(let t=0;t<r;t++)o[t]=e[t][n];s[n]=(0,t.xCorrelation)(a,o)}return s}e.matrixAutoCorrelation=n}}),h_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixBoxPlot.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixBoxPlot=void 0;function t(e){let t=e.length,n=e[0].length;if(t<5)throw Error(`can not calculate info if matrix contains less than 5 rows`);let r={q1:new Float64Array(n),median:new Float64Array(n),q3:new Float64Array(n),min:Float64Array.from(e[0]),max:Float64Array.from(e[e.length-1])},i=new Float64Array(e.length);for(let a=0;a<n;a++){for(let n=0;n<t;n++)i[n]=e[n][a];let n=0,o=0;if(t%2==1){let e=(t-1)/2;r.median[a]=i[e],n=e-1,o=e+1}else o=t/2,n=o-1,r.median[a]=(i[n]+i[o])/2;if(n%2==0)r.q1[a]=i[n/2],r.q3[a]=i[(t+o-1)/2];else{r.q1[a]=(i[(n+1)/2]+i[(n-1)/2])/2;let e=(i.length+o)/2;r.q3[a]=(i[e]+i[e-1])/2}}return r}e.matrixBoxPlot=t}}),g_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCenterZMean.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixCenterZMean=void 0;var t=f_();function n(e){let n=e[0].length,r=e.length,i=(0,t.matrixCreateEmpty)({nbColumns:n,nbRows:r});for(let t=0;t<n;t++){let n=0;for(let i=0;i<r;i++)n+=e[i][t];n/=r;for(let a=0;a<r;a++)i[a][t]=e[a][t]-n}return i}e.matrixCenterZMean=n}}),__=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCheck.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixCheck=void 0;function t(e){if(e.length===0||e[0].length===0)throw RangeError(`matrix must contain data`);let t=e[0].length;for(let n=1;n<e.length;n++)if(e[n].length!==t)throw RangeError(`all rows must has the same length`)}e.matrixCheck=t}}),v_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixClone.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixClone=void 0;function t(e){return e.map(e=>e.slice(0))}e.matrixClone=t}}),y_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixColumnsCorrelation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixColumnsCorrelation=void 0;var t=um(),n=Q();function r(e){let r=new t.Matrix(e).transpose(),i=[];for(let e=0;e<r.rows;e++)i.push(new Float64Array(r.rows));for(let e=0;e<r.rows;e++)for(let t=e;t<r.rows;t++){let a=(0,n.xCorrelation)(r.getRow(e),r.getRow(t));i[e][t]=a,i[t][e]=a}return i}e.matrixColumnsCorrelation=r}}),b_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMinMaxAbsoluteZ.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixMinMaxAbsoluteZ=void 0;function t(e){if(e.length===0||e[0].length===0)throw Error(`matrixMinMaxAbsoluteZ requires at least 1 row and 1 column`);let t=e.length,n=e[0].length,r=1/0,i=-1/0;for(let a=0;a<n;a++)for(let n=0;n<t;n++){let t=e[n][a];t<0&&(t*=-1),t<r&&(r=t),t>i&&(i=t)}return{min:r,max:i}}e.matrixMinMaxAbsoluteZ=t}}),x_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMinMaxZ.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixMinMaxZ=void 0;var t=__();function n(e){(0,t.matrixCheck)(e);let n=e.length,r=e[0].length,i=e[0][0],a=e[0][0];for(let t=0;t<r;t++)for(let r=0;r<n;r++)e[r][t]<i&&(i=e[r][t]),e[r][t]>a&&(a=e[r][t]);return{min:i,max:a}}e.matrixMinMaxZ=n}}),S_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixHistogram.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixHistogram=void 0;var t=Q(),n=b_(),r=x_();function i(e,i={}){let{min:a,max:o}=i,{absolute:s,logBaseX:c,logBaseY:l,histogram:u,nbSlots:d,centerX:f}=i;if(e.length===0||e[0].length===0)throw Error(`matrix must have at least one column and one row`);if(a===void 0||o===void 0){let t=s?(0,n.matrixMinMaxAbsoluteZ)(e):(0,r.matrixMinMaxZ)(e);a===void 0&&(a=c&&t.min?Math.log(t.min)/Math.log(c):t.min),o===void 0&&(o=c&&t.max?Math.log(t.max)/Math.log(c):t.max)}let p={histogram:u,nbSlots:d,centerX:f,absolute:s,logBaseX:c,min:a,max:o},m=(0,t.xHistogram)(e[0],p);p.histogram=m;let h=e.length;for(let n=1;n<h;n++)(0,t.xHistogram)(e[n],p);let g=m.y;if(l){let e=Math.log10(l);for(let t=0;t<g.length;t++)g[t]=Math.log10(g[t]+1)/e}return m}e.matrixHistogram=i}}),C_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMaxAbsoluteZ.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixMaxAbsoluteZ=void 0;function t(e){if(e.length===0||e[0].length===0)throw Error(`matrix must have at least 1 row and 1 column`);let t=e.length,n=e[0].length,r=-1/0;for(let i=0;i<n;i++)for(let n=0;n<t;n++){let t=e[n][i];t<0&&(t*=-1),t>r&&(r=t)}return r}e.matrixMaxAbsoluteZ=t}}),w_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixToArray.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixToArray=void 0;var t=__();function n(e){(0,t.matrixCheck)(e);let n=e[0].length,r=new Float64Array(e.length*n);for(let t=0;t<e.length;t++){let i=t*n;for(let a=0;a<n;a++)r[i+a]=e[t][a]}return r}e.matrixToArray=n}}),T_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMedian.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixMedian=void 0;var t=Q(),n=w_();function r(e){return(0,t.xMedian)((0,n.matrixToArray)(e))}e.matrixMedian=r}}),E_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNoiseStandardDeviation.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixNoiseStandardDeviation=void 0;var t=Q(),n=w_();function r(e){return(0,t.xNoiseStandardDeviation)((0,n.matrixToArray)(e))}e.matrixNoiseStandardDeviation=r}}),D_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNumericalDecoding.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixNumericalDecoding=void 0;var t=v_();function n(e,n){let i=(0,t.matrixClone)(e),a=r(n);for(let e=0;e<i.length;e++)for(let t=0;t<i[0].length;t++){let n=i[e][t];typeof n==`number`&&n in a&&(i[e][t]=a[n])}return i}e.matrixNumericalDecoding=n;function r(e){let t={};for(let n in e)t[e[n]]=n;return t}}}),O_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNumericalEncoding.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixNumericalEncoding=void 0;var t=v_();function n(e){let n=(0,t.matrixClone)(e),r=n.length,i=n[0].length,a=0;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];typeof r==`number`&&r>a&&(a=r)}let o={};for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];typeof r==`string`&&(r in o?n[e][t]=o[r]:(a++,o[r]=a,n[e][t]=a))}return{matrix:n,dictCategoricalToNumerical:o}}e.matrixNumericalEncoding=n}}),k_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixPQN.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixPQN=void 0;var t=um(),n=Q();function r(e,r={}){let{max:i=100}=r,a=new t.Matrix(e);for(let e=0;e<a.rows;e++){let t=a.getRowVector(e).norm(`frobenius`)/i,n=a.getRowVector(e).div(t);a.setRow(e,n)}let o=[];for(let e=0;e<a.columns;e++){let t=a.getColumn(e);o.push((0,n.xMedian)(t))}let s=[];for(let e=0;e<a.columns;e++){let t=a.getColumnVector(e).div(o[e]);s.push((0,n.xMedian)(t.getColumn(0)))}for(let e=0;e<a.rows;e++)a.mulRow(e,1/s[e]);return{data:a.to2DArray(),medianOfQuotients:s}}e.matrixPQN=r}}),A_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixSetSubMatrix.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixSetSubMatrix=void 0;function t(e,t,r,i){n(e,r,r+t.length-1,i,i+t[0].length-1);for(let n=0;n<t.length;n++)for(let a=0;a<t[0].length;a++)e[r+n][i+a]=t[n][a];return e}e.matrixSetSubMatrix=t;function n(e,t,n,r,i){if(t>n||r>i||t<0||t>=e.length||n<0||n>=e.length||r<0||r>=e[0].length||i<0||i>=e[0].length)throw RangeError(`submatrix indices are out of range`)}}}),j_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZPivotRescale.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixZPivotRescale=void 0;var t=f_(),n=C_();function r(e,r={}){let{max:i=1,ArrayConstructor:a}=r,o=e[0].length,s=e.length,c=(0,t.matrixCreateEmpty)({nbColumns:o,nbRows:s,ArrayConstructor:a}),l=(0,n.matrixMaxAbsoluteZ)(e);for(let t=0;t<o;t++){let n=i/l;for(let r=0;r<s;r++)c[r][t]=e[r][t]*n}return c}e.matrixZPivotRescale=r}}),M_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZRescale.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixZRescale=void 0;var t=f_(),n=x_();function r(e,r={}){let{min:i=0,max:a=1,ArrayConstructor:o}=r,s=e[0].length,c=e.length,l=(0,t.matrixCreateEmpty)({nbColumns:s,nbRows:c,ArrayConstructor:o}),{min:u,max:d}=(0,n.matrixMinMaxZ)(e),f=(a-i)/(d-u);for(let t=0;t<s;t++)for(let n=0;n<c;n++)l[n][t]=(e[n][t]-u)*f+i;return l}e.matrixZRescale=r}}),N_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZRescalePerColumn.js"(e){Object.defineProperty(e,`__esModule`,{value:!0}),e.matrixZRescalePerColumn=void 0;var t=f_();function n(e,n={}){let{min:r=0,max:i=1}=n,a=e[0].length,o=e.length,s=(0,t.matrixCreateEmpty)({nbColumns:a,nbRows:o});for(let t=0;t<a;t++){let n=e[0][t],a=e[0][t];for(let r=1;r<o;r++)e[r][t]<n&&(n=e[r][t]),e[r][t]>a&&(a=e[r][t]);let c=(i-r)/(a-n);for(let i=0;i<o;i++)s[i][t]=(e[i][t]-n)*c+r}return s}e.matrixZRescalePerColumn=n}}),P_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(d_(),e),n(p_(),e),n(m_(),e),n(h_(),e),n(g_(),e),n(__(),e),n(v_(),e),n(y_(),e),n(f_(),e),n(S_(),e),n(C_(),e),n(T_(),e),n(b_(),e),n(x_(),e),n(E_(),e),n(D_(),e),n(O_(),e),n(k_(),e),n(A_(),e),n(w_(),e),n(j_(),e),n(M_(),e),n(N_(),e)}}),F_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DataReIm.js"(e){Object.defineProperty(e,`__esModule`,{value:!0})}}),I_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DataXReIm.js"(e){Object.defineProperty(e,`__esModule`,{value:!0})}}),L_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DoubleMatrix.js"(e){Object.defineProperty(e,`__esModule`,{value:!0})}}),R_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/Point.js"(e){Object.defineProperty(e,`__esModule`,{value:!0})}}),z_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(F_(),e),n(I_(),e),n(L_(),e),n(R_(),e)}}),B_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(Kh(),e),n(Q(),e),n(Bg(),e),n(Hg(),e),n(Gg(),e),n(Qg(),e),n(u_(),e),n(tg(),e),n(P_(),e),n(Zm(),e),n(z_(),e)}});function V_(e){return e.client?{client:e.client}:{openAiApiKey:e.openAiApiKey,openAiOrganizationId:e.openAiOrganizationId,openAiBaseUrl:e.openAiBaseUrl,openAiDefaultHeaders:e.openAiDefaultHeaders,openAiDangerouslyAllowBrowser:e.openAiDangerouslyAllowBrowser,azureOpenAi:e.azureOpenAi}}var H_=`https://api.braintrust.dev/v1/proxy`,U_=e=>{let{openAiApiKey:t,openAiOrganizationId:n,openAiBaseUrl:r,openAiDefaultHeaders:i,openAiDangerouslyAllowBrowser:a,azureOpenAi:o}=e;return e.client?e.client:globalThis.__client?globalThis.__client:o?(delete process.env.OPENAI_BASE_URL,new wa({apiKey:o.apiKey,endpoint:o.endpoint,apiVersion:o.apiVersion,defaultHeaders:i,dangerouslyAllowBrowser:a})):new I({apiKey:t||process.env.OPENAI_API_KEY||process.env.BRAINTRUST_API_KEY,organization:n,baseURL:r||process.env.OPENAI_BASE_URL||H_,defaultHeaders:i,dangerouslyAllowBrowser:a})},W_=(e,t)=>{let n=Object.getPrototypeOf(e).constructor,r=new n({apiKey:`dummy`,dangerouslyAllowBrowser:t});return String(e.chat.completions.create)!==String(r.chat.completions.create)};function G_(e){let t=U_(e),n=e.openAiDangerouslyAllowBrowser??t._options?.dangerouslyAllowBrowser;return globalThis.__inherited_braintrust_wrap_openai&&!W_(t,n)?globalThis.__inherited_braintrust_wrap_openai(t):t}var K_=()=>globalThis.__defaultModel??`gpt-4o`;async function q_(e,t){let n=G_(t),r=globalThis.__inherited_braintrust_wrap_openai?{...e,span_info:{spanAttributes:{...e.span_info?.spanAttributes,purpose:`scorer`}}}:e;return await n.chat.completions.create(r)}var J_=`prompt: |-
|
|
67
|
+
${i}`)}function c(e,t,n){return(e>=0&&n?` ${l(e,t-1)}`:l(e,t)).padEnd(t)}function l(e,t){let n=e.toString();if(n.length<=t)return n;let r=e.toFixed(t);if(r.length>t&&(r=e.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith(`0.000`)&&!r.startsWith(`-0.000`))return r;let i=e.toExponential(t);return i.length>t&&(i=e.toExponential(Math.max(0,t-(i.length-t)))),i.slice(0)}function u(e,t){e.prototype.add=function(e){return typeof e==`number`?this.addS(e):this.addM(e)},e.prototype.addS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e);return this},e.prototype.addM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e.get(t,n));return this},e.add=function(e,n){return new t(e).add(n)},e.prototype.sub=function(e){return typeof e==`number`?this.subS(e):this.subM(e)},e.prototype.subS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e);return this},e.prototype.subM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e.get(t,n));return this},e.sub=function(e,n){return new t(e).sub(n)},e.prototype.subtract=e.prototype.sub,e.prototype.subtractS=e.prototype.subS,e.prototype.subtractM=e.prototype.subM,e.subtract=e.sub,e.prototype.mul=function(e){return typeof e==`number`?this.mulS(e):this.mulM(e)},e.prototype.mulS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this},e.prototype.mulM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e.get(t,n));return this},e.mul=function(e,n){return new t(e).mul(n)},e.prototype.multiply=e.prototype.mul,e.prototype.multiplyS=e.prototype.mulS,e.prototype.multiplyM=e.prototype.mulM,e.multiply=e.mul,e.prototype.div=function(e){return typeof e==`number`?this.divS(e):this.divM(e)},e.prototype.divS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e);return this},e.prototype.divM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e.get(t,n));return this},e.div=function(e,n){return new t(e).div(n)},e.prototype.divide=e.prototype.div,e.prototype.divideS=e.prototype.divS,e.prototype.divideM=e.prototype.divM,e.divide=e.div,e.prototype.mod=function(e){return typeof e==`number`?this.modS(e):this.modM(e)},e.prototype.modS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)%e);return this},e.prototype.modM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)%e.get(t,n));return this},e.mod=function(e,n){return new t(e).mod(n)},e.prototype.modulus=e.prototype.mod,e.prototype.modulusS=e.prototype.modS,e.prototype.modulusM=e.prototype.modM,e.modulus=e.mod,e.prototype.and=function(e){return typeof e==`number`?this.andS(e):this.andM(e)},e.prototype.andS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)&e);return this},e.prototype.andM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)&e.get(t,n));return this},e.and=function(e,n){return new t(e).and(n)},e.prototype.or=function(e){return typeof e==`number`?this.orS(e):this.orM(e)},e.prototype.orS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)|e);return this},e.prototype.orM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)|e.get(t,n));return this},e.or=function(e,n){return new t(e).or(n)},e.prototype.xor=function(e){return typeof e==`number`?this.xorS(e):this.xorM(e)},e.prototype.xorS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)^e);return this},e.prototype.xorM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)^e.get(t,n));return this},e.xor=function(e,n){return new t(e).xor(n)},e.prototype.leftShift=function(e){return typeof e==`number`?this.leftShiftS(e):this.leftShiftM(e)},e.prototype.leftShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)<<e);return this},e.prototype.leftShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)<<e.get(t,n));return this},e.leftShift=function(e,n){return new t(e).leftShift(n)},e.prototype.signPropagatingRightShift=function(e){return typeof e==`number`?this.signPropagatingRightShiftS(e):this.signPropagatingRightShiftM(e)},e.prototype.signPropagatingRightShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>e);return this},e.prototype.signPropagatingRightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>e.get(t,n));return this},e.signPropagatingRightShift=function(e,n){return new t(e).signPropagatingRightShift(n)},e.prototype.rightShift=function(e){return typeof e==`number`?this.rightShiftS(e):this.rightShiftM(e)},e.prototype.rightShiftS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>>e);return this},e.prototype.rightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)>>>e.get(t,n));return this},e.rightShift=function(e,n){return new t(e).rightShift(n)},e.prototype.zeroFillRightShift=e.prototype.rightShift,e.prototype.zeroFillRightShiftS=e.prototype.rightShiftS,e.prototype.zeroFillRightShiftM=e.prototype.rightShiftM,e.zeroFillRightShift=e.rightShift,e.prototype.not=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,~this.get(e,t));return this},e.not=function(e){return new t(e).not()},e.prototype.abs=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.abs(this.get(e,t)));return this},e.abs=function(e){return new t(e).abs()},e.prototype.acos=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acos(this.get(e,t)));return this},e.acos=function(e){return new t(e).acos()},e.prototype.acosh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acosh(this.get(e,t)));return this},e.acosh=function(e){return new t(e).acosh()},e.prototype.asin=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asin(this.get(e,t)));return this},e.asin=function(e){return new t(e).asin()},e.prototype.asinh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asinh(this.get(e,t)));return this},e.asinh=function(e){return new t(e).asinh()},e.prototype.atan=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atan(this.get(e,t)));return this},e.atan=function(e){return new t(e).atan()},e.prototype.atanh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atanh(this.get(e,t)));return this},e.atanh=function(e){return new t(e).atanh()},e.prototype.cbrt=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cbrt(this.get(e,t)));return this},e.cbrt=function(e){return new t(e).cbrt()},e.prototype.ceil=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.ceil(this.get(e,t)));return this},e.ceil=function(e){return new t(e).ceil()},e.prototype.clz32=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.clz32(this.get(e,t)));return this},e.clz32=function(e){return new t(e).clz32()},e.prototype.cos=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cos(this.get(e,t)));return this},e.cos=function(e){return new t(e).cos()},e.prototype.cosh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cosh(this.get(e,t)));return this},e.cosh=function(e){return new t(e).cosh()},e.prototype.exp=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.exp(this.get(e,t)));return this},e.exp=function(e){return new t(e).exp()},e.prototype.expm1=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.expm1(this.get(e,t)));return this},e.expm1=function(e){return new t(e).expm1()},e.prototype.floor=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.floor(this.get(e,t)));return this},e.floor=function(e){return new t(e).floor()},e.prototype.fround=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.fround(this.get(e,t)));return this},e.fround=function(e){return new t(e).fround()},e.prototype.log=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log(this.get(e,t)));return this},e.log=function(e){return new t(e).log()},e.prototype.log1p=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log1p(this.get(e,t)));return this},e.log1p=function(e){return new t(e).log1p()},e.prototype.log10=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log10(this.get(e,t)));return this},e.log10=function(e){return new t(e).log10()},e.prototype.log2=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log2(this.get(e,t)));return this},e.log2=function(e){return new t(e).log2()},e.prototype.round=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.round(this.get(e,t)));return this},e.round=function(e){return new t(e).round()},e.prototype.sign=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sign(this.get(e,t)));return this},e.sign=function(e){return new t(e).sign()},e.prototype.sin=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sin(this.get(e,t)));return this},e.sin=function(e){return new t(e).sin()},e.prototype.sinh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sinh(this.get(e,t)));return this},e.sinh=function(e){return new t(e).sinh()},e.prototype.sqrt=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sqrt(this.get(e,t)));return this},e.sqrt=function(e){return new t(e).sqrt()},e.prototype.tan=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tan(this.get(e,t)));return this},e.tan=function(e){return new t(e).tan()},e.prototype.tanh=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tanh(this.get(e,t)));return this},e.tanh=function(e){return new t(e).tanh()},e.prototype.trunc=function(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.trunc(this.get(e,t)));return this},e.trunc=function(e){return new t(e).trunc()},e.pow=function(e,n){return new t(e).pow(n)},e.prototype.pow=function(e){return typeof e==`number`?this.powS(e):this.powM(e)},e.prototype.powS=function(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)**+e);return this},e.prototype.powM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw RangeError(`Matrices dimensions must be equal`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)**+e.get(t,n));return this}}function d(e,t,n){let r=n?e.rows:e.rows-1;if(t<0||t>r)throw RangeError(`Row index out of range`)}function f(e,t,n){let r=n?e.columns:e.columns-1;if(t<0||t>r)throw RangeError(`Column index out of range`)}function p(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.columns)throw RangeError(`vector size must be the same as the number of columns`);return t}function m(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.rows)throw RangeError(`vector size must be the same as the number of rows`);return t}function h(e,n){if(!t.isAnyArray(n))throw TypeError(`row indices must be an array`);for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.rows)throw RangeError(`row indices are out of range`)}function g(e,n){if(!t.isAnyArray(n))throw TypeError(`column indices must be an array`);for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.columns)throw RangeError(`column indices are out of range`)}function _(e,t,n,r,i){if(arguments.length!==5)throw RangeError(`expected 4 arguments`);if(y(`startRow`,t),y(`endRow`,n),y(`startColumn`,r),y(`endColumn`,i),t>n||r>i||t<0||t>=e.rows||n<0||n>=e.rows||r<0||r>=e.columns||i<0||i>=e.columns)throw RangeError(`Submatrix indices are out of range`)}function v(e,t=0){let n=[];for(let r=0;r<e;r++)n.push(t);return n}function y(e,t){if(typeof t!=`number`)throw TypeError(`${e} must be a number`)}function b(e){if(e.isEmpty())throw Error(`Empty matrix has no elements to index`)}function x(e){let t=v(e.rows);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]+=e.get(n,r);return t}function S(e){let t=v(e.columns);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]+=e.get(n,r);return t}function C(e){let t=0;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t+=e.get(n,r);return t}function w(e){let t=v(e.rows,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]*=e.get(n,r);return t}function T(e){let t=v(e.columns,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]*=e.get(n,r);return t}function E(e){let t=1;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t*=e.get(n,r);return t}function D(e,t,n){let r=e.rows,i=e.columns,a=[];for(let o=0;o<r;o++){let r=0,s=0,c=0;for(let t=0;t<i;t++)c=e.get(o,t)-n[o],r+=c,s+=c*c;t?a.push((s-r*r/i)/(i-1)):a.push((s-r*r/i)/i)}return a}function O(e,t,n){let r=e.rows,i=e.columns,a=[];for(let o=0;o<i;o++){let i=0,s=0,c=0;for(let t=0;t<r;t++)c=e.get(t,o)-n[o],i+=c,s+=c*c;t?a.push((s-i*i/r)/(r-1)):a.push((s-i*i/r)/r)}return a}function k(e,t,n){let r=e.rows,i=e.columns,a=r*i,o=0,s=0,c=0;for(let t=0;t<r;t++)for(let r=0;r<i;r++)c=e.get(t,r)-n,o+=c,s+=c*c;return t?(s-o*o/a)/(a-1):(s-o*o/a)/a}function A(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[n])}function ee(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[r])}function te(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t)}function ne(e){let t=[];for(let n=0;n<e.rows;n++){let r=0;for(let t=0;t<e.columns;t++)r+=e.get(n,t)**2/(e.columns-1);t.push(Math.sqrt(r))}return t}function re(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[n])}function ie(e){let t=[];for(let n=0;n<e.columns;n++){let r=0;for(let t=0;t<e.rows;t++)r+=e.get(t,n)**2/(e.rows-1);t.push(Math.sqrt(r))}return t}function ae(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[r])}function oe(e){let t=e.size-1,n=0;for(let r=0;r<e.columns;r++)for(let i=0;i<e.rows;i++)n+=e.get(i,r)**2/t;return Math.sqrt(n)}function se(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t)}var j=class e{static from1DArray(e,t,n){if(e*t!==n.length)throw RangeError(`data length does not match given dimensions`);let r=new M(e,t);for(let i=0;i<e;i++)for(let e=0;e<t;e++)r.set(i,e,n[i*t+e]);return r}static rowVector(e){let t=new M(1,e.length);for(let n=0;n<e.length;n++)t.set(0,n,e[n]);return t}static columnVector(e){let t=new M(e.length,1);for(let n=0;n<e.length;n++)t.set(n,0,e[n]);return t}static zeros(e,t){return new M(e,t)}static ones(e,t){return new M(e,t).fill(1)}static rand(e,t,n={}){if(typeof n!=`object`)throw TypeError(`options must be an object`);let{random:r=Math.random}=n,i=new M(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++)i.set(n,e,r());return i}static randInt(e,t,n={}){if(typeof n!=`object`)throw TypeError(`options must be an object`);let{min:r=0,max:i=1e3,random:a=Math.random}=n;if(!Number.isInteger(r))throw TypeError(`min must be an integer`);if(!Number.isInteger(i))throw TypeError(`max must be an integer`);if(r>=i)throw RangeError(`min must be smaller than max`);let o=i-r,s=new M(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++){let t=r+Math.round(a()*o);s.set(n,e,t)}return s}static eye(e,t,n){t===void 0&&(t=e),n===void 0&&(n=1);let r=Math.min(e,t),i=this.zeros(e,t);for(let e=0;e<r;e++)i.set(e,e,n);return i}static diag(e,t,n){let r=e.length;t===void 0&&(t=r),n===void 0&&(n=t);let i=Math.min(r,t,n),a=this.zeros(t,n);for(let t=0;t<i;t++)a.set(t,t,e[t]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new M(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.min(e.get(a,n),t.get(a,n)));return i}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new this(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.max(e.get(a,n),t.get(a,n)));return i}static checkMatrix(t){return e.isMatrix(t)?t:new M(t)}static isMatrix(e){return e!=null&&e.klass===`Matrix`}get size(){return this.rows*this.columns}apply(e){if(typeof e!=`function`)throw TypeError(`callback must be a function`);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.call(this,t,n);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let n=0;n<this.columns;n++)e[t].push(this.get(t,n))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>n?(i=!0,n=t):(r=!1,i=!0);e++}return r}isReducedEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>n?(i=!0,n=t):(r=!1,i=!0);for(let n=t+1;n<this.rows;n++)this.get(e,n)!==0&&(r=!1);e++}return r}echelonForm(){let e=this.clone(),t=0,n=0;for(;t<e.rows&&n<e.columns;){let r=t;for(let i=t;i<e.rows;i++)e.get(i,n)>e.get(r,n)&&(r=i);if(e.get(r,n)===0)n++;else{e.swapRows(t,r);let i=e.get(t,n);for(let r=n;r<e.columns;r++)e.set(t,r,e.get(t,r)/i);for(let r=t+1;r<e.rows;r++){let i=e.get(r,n)/e.get(t,n);e.set(r,n,0);for(let a=n+1;a<e.columns;a++)e.set(r,a,e.get(r,a)-e.get(t,a)*i)}t++,n++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,n=e.rows,r=n-1;for(;r>=0;)if(e.maxRow(r)===0)r--;else{let i=0,a=!1;for(;i<n&&a===!1;)e.get(r,i)===1?a=!0:i++;for(let n=0;n<r;n++){let a=e.get(n,i);for(let o=i;o<t;o++){let t=e.get(n,o)-a*e.get(r,o);e.set(n,o,t)}}r--}return e}set(){throw Error(`set method is unimplemented`)}get(){throw Error(`get method is unimplemented`)}repeat(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{rows:t=1,columns:n=1}=e;if(!Number.isInteger(t)||t<=0)throw TypeError(`rows must be a positive integer`);if(!Number.isInteger(n)||n<=0)throw TypeError(`columns must be a positive integer`);let r=new M(this.rows*t,this.columns*n);for(let e=0;e<t;e++)for(let t=0;t<n;t++)r.setSubMatrix(this,this.rows*e,this.columns*t);return r}fill(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,e);return this}neg(){return this.mulS(-1)}getRow(e){d(this,e);let t=[];for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}getRowVector(e){return M.rowVector(this.getRow(e))}setRow(e,t){d(this,e),t=p(this,t);for(let n=0;n<this.columns;n++)this.set(e,n,t[n]);return this}swapRows(e,t){d(this,e),d(this,t);for(let n=0;n<this.columns;n++){let r=this.get(e,n);this.set(e,n,this.get(t,n)),this.set(t,n,r)}return this}getColumn(e){f(this,e);let t=[];for(let n=0;n<this.rows;n++)t.push(this.get(n,e));return t}getColumnVector(e){return M.columnVector(this.getColumn(e))}setColumn(e,t){f(this,e),t=m(this,t);for(let n=0;n<this.rows;n++)this.set(n,e,t[n]);return this}swapColumns(e,t){f(this,e),f(this,t);for(let n=0;n<this.rows;n++){let r=this.get(n,e);this.set(n,e,this.get(n,t)),this.set(n,t,r)}return this}addRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[n]);return this}subRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[n]);return this}mulRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[n]);return this}divRowVector(e){e=p(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[n]);return this}addColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[t]);return this}subColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[t]);return this}mulColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[t]);return this}divColumnVector(e){e=m(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[t]);return this}mulRow(e,t){d(this,e);for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this}mulColumn(e,t){f(this,e);for(let n=0;n<this.rows;n++)this.set(n,e,this.get(n,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case`row`:{let e=Array(this.rows).fill(-1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e[t]&&(e[t]=this.get(t,n));return e}case`column`:{let e=Array(this.columns).fill(-1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e[n]&&(e[n]=this.get(t,n));return e}case void 0:{let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}default:throw Error(`invalid option: ${e}`)}}maxIndex(){b(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}min(e){if(this.isEmpty())return NaN;switch(e){case`row`:{let e=Array(this.rows).fill(1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e[t]&&(e[t]=this.get(t,n));return e}case`column`:{let e=Array(this.columns).fill(1/0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e[n]&&(e[n]=this.get(t,n));return e}case void 0:{let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}default:throw Error(`invalid option: ${e}`)}}minIndex(){b(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}maxRow(e){if(d(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}maxRowIndex(e){d(this,e),b(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r),n[1]=r);return n}minRow(e){if(d(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}minRowIndex(e){d(this,e),b(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r),n[1]=r);return n}maxColumn(e){if(f(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e));return t}maxColumnIndex(e){f(this,e),b(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e),n[0]=r);return n}minColumn(e){if(f(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e));return t}minColumnIndex(e){f(this,e),b(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e),n[0]=r);return n}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let n=0;n<e;n++)t.push(this.get(n,n));return t}norm(e=`frobenius`){switch(e){case`max`:return this.max();case`frobenius`:return Math.sqrt(this.dot(this));default:throw RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n),this.set(t,n,e);return this}dot(t){e.isMatrix(t)&&(t=t.to1DArray());let n=this.to1DArray();if(n.length!==t.length)throw RangeError(`vectors do not have the same size`);let r=0;for(let e=0;e<n.length;e++)r+=n[e]*t[e];return r}mmul(e){e=M.checkMatrix(e);let t=this.rows,n=this.columns,r=e.columns,i=new M(t,r),a=new Float64Array(n);for(let o=0;o<r;o++){for(let t=0;t<n;t++)a[t]=e.get(t,o);for(let e=0;e<t;e++){let t=0;for(let r=0;r<n;r++)t+=this.get(e,r)*a[r];i.set(e,o,t)}}return i}strassen2x2(e){e=M.checkMatrix(e);let t=new M(2,2),n=this.get(0,0),r=e.get(0,0),i=this.get(0,1),a=e.get(0,1),o=this.get(1,0),s=e.get(1,0),c=this.get(1,1),l=e.get(1,1),u=(n+c)*(r+l),d=(o+c)*r,f=n*(a-l),p=c*(s-r),m=(n+i)*l,h=(o-n)*(r+a),g=(i-c)*(s+l),_=u+p-m+g,v=f+m,y=d+p,b=u-d+f+h;return t.set(0,0,_),t.set(0,1,v),t.set(1,0,y),t.set(1,1,b),t}strassen3x3(e){e=M.checkMatrix(e);let t=new M(3,3),n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),a=this.get(1,0),o=this.get(1,1),s=this.get(1,2),c=this.get(2,0),l=this.get(2,1),u=this.get(2,2),d=e.get(0,0),f=e.get(0,1),p=e.get(0,2),m=e.get(1,0),h=e.get(1,1),g=e.get(1,2),_=e.get(2,0),v=e.get(2,1),y=e.get(2,2),b=(n+r+i-a-o-l-u)*h,x=(n-a)*(-f+h),S=o*(-d+f+m-h-g-_+y),C=(-n+a+o)*(d-f+h),w=(a+o)*(-d+f),T=n*d,E=(-n+c+l)*(d-p+g),D=(-n+c)*(p-g),O=(c+l)*(-d+p),k=(n+r+i-o-s-c-l)*g,A=l*(-d+p+m-h-g-_+v),ee=(-i+l+u)*(h+_-v),te=(i-u)*(h-v),ne=i*_,re=(l+u)*(-_+v),ie=(-i+o+s)*(g+_-y),ae=(i-s)*(g-y),oe=(o+s)*(-_+y),se=r*m,j=s*v,ce=a*p,le=c*f,ue=u*y,de=T+ne+se,fe=b+C+w+T+ee+ne+re,pe=T+E+O+k+ne+ie+oe,me=x+S+C+T+ne+ie+ae,he=x+C+w+T+j,ge=ne+ie+ae+oe+ce,_e=T+E+D+A+ee+te+ne,ve=ee+te+ne+re+le,ye=T+E+D+O+ue;return t.set(0,0,de),t.set(0,1,fe),t.set(0,2,pe),t.set(1,0,me),t.set(1,1,he),t.set(1,2,ge),t.set(2,0,_e),t.set(2,1,ve),t.set(2,2,ye),t}mmulStrassen(t){t=M.checkMatrix(t);let n=this.clone(),r=n.rows,i=n.columns,a=t.rows,o=t.columns;i!==a&&console.warn(`Multiplying ${r} x ${i} and ${a} x ${o} matrix: dimensions do not match.`);function s(t,n,r){let i=t.rows,a=t.columns;if(i===n&&a===r)return t;{let i=e.zeros(n,r);return i=i.setSubMatrix(t,0,0),i}}let c=Math.max(r,a),l=Math.max(i,o);n=s(n,c,l),t=s(t,c,l);function u(t,n,r,i){if(r<=512||i<=512)return t.mmul(n);r%2==1&&i%2==1?(t=s(t,r+1,i+1),n=s(n,r+1,i+1)):r%2==1?(t=s(t,r+1,i),n=s(n,r+1,i)):i%2==1&&(t=s(t,r,i+1),n=s(n,r,i+1));let a=parseInt(t.rows/2,10),o=parseInt(t.columns/2,10),c=t.subMatrix(0,a-1,0,o-1),l=n.subMatrix(0,a-1,0,o-1),d=t.subMatrix(0,a-1,o,t.columns-1),f=n.subMatrix(0,a-1,o,n.columns-1),p=t.subMatrix(a,t.rows-1,0,o-1),m=n.subMatrix(a,n.rows-1,0,o-1),h=t.subMatrix(a,t.rows-1,o,t.columns-1),g=n.subMatrix(a,n.rows-1,o,n.columns-1),_=u(e.add(c,h),e.add(l,g),a,o),v=u(e.add(p,h),l,a,o),y=u(c,e.sub(f,g),a,o),b=u(h,e.sub(m,l),a,o),x=u(e.add(c,d),g,a,o),S=u(e.sub(p,c),e.add(l,f),a,o),C=u(e.sub(d,h),e.add(m,g),a,o),w=e.add(_,b);w.sub(x),w.add(C);let T=e.add(y,x),E=e.add(v,b),D=e.sub(_,v);D.add(y),D.add(S);let O=e.zeros(2*w.rows,2*w.columns);return O=O.setSubMatrix(w,0,0),O=O.setSubMatrix(T,w.rows,0),O=O.setSubMatrix(E,0,w.columns),O=O.setSubMatrix(D,w.rows,w.columns),O.subMatrix(0,r-1,0,i-1)}return u(n,t,c,l)}scaleRows(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw TypeError(`min must be a number`);if(!Number.isFinite(r))throw TypeError(`max must be a number`);if(t>=r)throw RangeError(`min must be smaller than max`);let i=new M(this.rows,this.columns);for(let e=0;e<this.rows;e++){let a=this.getRow(e);a.length>0&&n(a,{min:t,max:r,output:a}),i.setRow(e,a)}return i}scaleColumns(e={}){if(typeof e!=`object`)throw TypeError(`options must be an object`);let{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw TypeError(`min must be a number`);if(!Number.isFinite(r))throw TypeError(`max must be a number`);if(t>=r)throw RangeError(`min must be smaller than max`);let i=new M(this.rows,this.columns);for(let e=0;e<this.columns;e++){let a=this.getColumn(e);a.length&&n(a,{min:t,max:r,output:a}),i.setColumn(e,a)}return i}flipRows(){let e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let n=0;n<e;n++){let e=this.get(t,n),r=this.get(t,this.columns-1-n);this.set(t,n,r),this.set(t,this.columns-1-n,e)}return this}flipColumns(){let e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let n=0;n<e;n++){let e=this.get(n,t),r=this.get(this.rows-1-n,t);this.set(n,t,r),this.set(this.rows-1-n,t,e)}return this}kroneckerProduct(e){e=M.checkMatrix(e);let t=this.rows,n=this.columns,r=e.rows,i=e.columns,a=new M(t*r,n*i);for(let o=0;o<t;o++)for(let t=0;t<n;t++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)a.set(r*o+n,i*t+s,this.get(o,t)*e.get(n,s));return a}kroneckerSum(e){if(e=M.checkMatrix(e),!this.isSquare()||!e.isSquare())throw Error(`Kronecker Sum needs two Square Matrices`);let t=this.rows,n=e.rows,r=this.kroneckerProduct(M.eye(n,n)),i=M.eye(t,t).kroneckerProduct(e);return r.add(i)}transpose(){let e=new M(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(n,t,this.get(t,n));return e}sortRows(e=ce){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=ce){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,n,r){_(this,e,t,n,r);let i=new M(t-e+1,r-n+1);for(let a=e;a<=t;a++)for(let t=n;t<=r;t++)i.set(a-e,t-n,this.get(a,t));return i}subMatrixRow(e,t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.columns-1),t>n||t<0||t>=this.columns||n<0||n>=this.columns)throw RangeError(`Argument out of range`);let r=new M(e.length,n-t+1);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.rows)throw RangeError(`Row index out of range: ${e[i]}`);r.set(i,a-t,this.get(e[i],a))}return r}subMatrixColumn(e,t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.rows-1),t>n||t<0||t>=this.rows||n<0||n>=this.rows)throw RangeError(`Argument out of range`);let r=new M(n-t+1,e.length);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.columns)throw RangeError(`Column index out of range: ${e[i]}`);r.set(a-t,i,this.get(a,e[i]))}return r}setSubMatrix(e,t,n){if(e=M.checkMatrix(e),e.isEmpty())return this;let r=t+e.rows-1,i=n+e.columns-1;_(this,t,r,n,i);for(let r=0;r<e.rows;r++)for(let i=0;i<e.columns;i++)this.set(t+r,n+i,e.get(r,i));return this}selection(e,t){h(this,e),g(this,t);let n=new M(e.length,t.length);for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<t.length;e++){let a=t[e];n.set(r,e,this.get(i,a))}}return n}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let n=0;n<e;n++)t+=this.get(n,n);return t}clone(){return this.constructor.copy(this,new M(this.rows,this.columns))}static copy(e,t){for(let[n,r,i]of e.entries())t.set(n,r,i);return t}sum(e){switch(e){case`row`:return x(this);case`column`:return S(this);case void 0:return C(this);default:throw Error(`invalid option: ${e}`)}}product(e){switch(e){case`row`:return w(this);case`column`:return T(this);case void 0:return E(this);default:throw Error(`invalid option: ${e}`)}}mean(e){let t=this.sum(e);switch(e){case`row`:for(let e=0;e<this.rows;e++)t[e]/=this.columns;return t;case`column`:for(let e=0;e<this.columns;e++)t[e]/=this.rows;return t;case void 0:return t/this.size;default:throw Error(`invalid option: ${e}`)}}variance(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let{unbiased:r=!0,mean:i=this.mean(e)}=n;if(typeof r!=`boolean`)throw TypeError(`unbiased must be a boolean`);switch(e){case`row`:if(!t.isAnyArray(i))throw TypeError(`mean must be an array`);return D(this,r,i);case`column`:if(!t.isAnyArray(i))throw TypeError(`mean must be an array`);return O(this,r,i);case void 0:if(typeof i!=`number`)throw TypeError(`mean must be a number`);return k(this,r,i);default:throw Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e==`object`&&(t=e,e=void 0);let n=this.variance(e,t);if(e===void 0)return Math.sqrt(n);for(let e=0;e<n.length;e++)n[e]=Math.sqrt(n[e]);return n}center(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let{center:r=this.mean(e)}=n;switch(e){case`row`:if(!t.isAnyArray(r))throw TypeError(`center must be an array`);return A(this,r),this;case`column`:if(!t.isAnyArray(r))throw TypeError(`center must be an array`);return ee(this,r),this;case void 0:if(typeof r!=`number`)throw TypeError(`center must be a number`);return te(this,r),this;default:throw Error(`invalid option: ${e}`)}}scale(e,n={}){if(typeof e==`object`&&(n=e,e=void 0),typeof n!=`object`)throw TypeError(`options must be an object`);let r=n.scale;switch(e){case`row`:if(r===void 0)r=ne(this);else if(!t.isAnyArray(r))throw TypeError(`scale must be an array`);return re(this,r),this;case`column`:if(r===void 0)r=ie(this);else if(!t.isAnyArray(r))throw TypeError(`scale must be an array`);return ae(this,r),this;case void 0:if(r===void 0)r=oe(this);else if(typeof r!=`number`)throw TypeError(`scale must be a number`);return se(this,r),this;default:throw Error(`invalid option: ${e}`)}}toString(e){return o(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}};j.prototype.klass=`Matrix`,typeof Symbol<`u`&&(j.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a);function ce(e,t){return e-t}function le(e){return e.every(e=>typeof e==`number`)}j.random=j.rand,j.randomInt=j.randInt,j.diagonal=j.diag,j.prototype.diagonal=j.prototype.diag,j.identity=j.eye,j.prototype.negate=j.prototype.neg,j.prototype.tensorProduct=j.prototype.kroneckerProduct;var ue,de,fe=class e extends j{constructor(n,r){if(super(),nm(this,ue),$p(this,`data`),e.isMatrix(n))im(this,ue,de).call(this,n.rows,n.columns),e.copy(n,this);else if(Number.isInteger(n)&&n>=0)im(this,ue,de).call(this,n,r);else if(t.isAnyArray(n)){let e=n;if(n=e.length,r=n?e[0].length:0,typeof r!=`number`)throw TypeError(`Data must be a 2D array with at least one element`);this.data=[];for(let t=0;t<n;t++){if(e[t].length!==r)throw RangeError(`Inconsistent array dimensions`);if(!le(e[t]))throw TypeError(`Input data contains non-numeric values`);this.data.push(Float64Array.from(e[t]))}this.rows=n,this.columns=r}else throw TypeError(`First argument must be a positive number or an array`)}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}removeRow(e){return d(this,e),this.data.splice(e,1),--this.rows,this}addRow(e,t){return t===void 0&&(t=e,e=this.rows),d(this,e,!0),t=Float64Array.from(p(this,t)),this.data.splice(e,0,t),this.rows+=1,this}removeColumn(e){f(this,e);for(let t=0;t<this.rows;t++){let n=new Float64Array(this.columns-1);for(let r=0;r<e;r++)n[r]=this.data[t][r];for(let r=e+1;r<this.columns;r++)n[r-1]=this.data[t][r];this.data[t]=n}return--this.columns,this}addColumn(e,t){t===void 0&&(t=e,e=this.columns),f(this,e,!0),t=m(this,t);for(let n=0;n<this.rows;n++){let r=new Float64Array(this.columns+1),i=0;for(;i<e;i++)r[i]=this.data[n][i];for(r[i++]=t[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};ue=new WeakSet,de=function(e,t){if(this.data=[],Number.isInteger(t)&&t>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(t));else throw TypeError(`nColumns must be a positive integer`);this.rows=e,this.columns=t};var M=fe;u(j,M);var pe,me=class e extends j{constructor(e){if(super(),nm(this,pe),M.isMatrix(e)){if(!e.isSymmetric())throw TypeError(`not symmetric data`);rm(this,pe,M.copy(e,new M(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)rm(this,pe,new M(e,e));else if(rm(this,pe,new M(e)),!this.isSymmetric())throw TypeError(`not symmetric data`)}get size(){return tm(this,pe).size}get rows(){return tm(this,pe).rows}get columns(){return tm(this,pe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return M.isMatrix(e)&&e.klassType===`SymmetricMatrix`}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){let t=new e(this.diagonalSize);for(let[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new M(this)}get(e,t){return tm(this,pe).get(e,t)}set(e,t,n){return tm(this,pe).set(e,t,n),tm(this,pe).set(t,e,n),this}removeCross(e){return tm(this,pe).removeRow(e),tm(this,pe).removeColumn(e),this}addCross(e,t){t===void 0&&(t=e,e=this.diagonalSize);let n=t.slice();return n.splice(e,1),tm(this,pe).addRow(e,n),tm(this,pe).addColumn(e,t),this}applyMask(e){if(e.length!==this.diagonalSize)throw RangeError(`Mask size do not match with matrix size`);let t=[];for(let[n,r]of e.entries())r||t.push(n);t.reverse();for(let e of t)this.removeCross(e);return this}toCompact(){let{diagonalSize:e}=this,t=Array(e*(e+1)/2);for(let n=0,r=0,i=0;i<t.length;i++)t[i]=this.get(r,n),++n>=e&&(n=++r);return t}static fromCompact(t){let n=t.length,r=(Math.sqrt(8*n+1)-1)/2;if(!Number.isInteger(r))throw TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);let i=new e(r);for(let e=0,a=0,o=0;o<n;o++)i.set(e,a,t[o]),++e>=r&&(e=++a);return i}*upperRightEntries(){for(let e=0,t=0;e<this.diagonalSize;){let n=this.get(e,t);yield[e,t,n],++t>=this.diagonalSize&&(t=++e)}}*upperRightValues(){for(let e=0,t=0;e<this.diagonalSize;)yield this.get(e,t),++t>=this.diagonalSize&&(t=++e)}};pe=new WeakMap;var he=me;he.prototype.klassType=`SymmetricMatrix`;var ge=class e extends he{static isDistanceMatrix(e){return he.isSymmetricMatrix(e)&&e.klassSubType===`DistanceMatrix`}constructor(e){if(super(e),!this.isDistance())throw TypeError(`Provided arguments do no produce a distance matrix`)}set(e,t,n){return e===t&&(n=0),super.set(e,t,n)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new he(this)}clone(){let t=new e(this.diagonalSize);for(let[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){let{diagonalSize:e}=this,t=(e-1)*e/2,n=Array(t);for(let t=1,r=0,i=0;i<n.length;i++)n[i]=this.get(r,t),++t>=e&&(t=++r+1);return n}static fromCompact(e){let t=e.length,n=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(n))throw TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);let r=new this(n);for(let i=1,a=0,o=0;o<t;o++)r.set(i,a,e[o]),++i>=n&&(i=++a+1);return r}};ge.prototype.klassSubType=`DistanceMatrix`;var _e=class extends j{constructor(e,t,n){super(),this.matrix=e,this.rows=t,this.columns=n}},ve=class extends _e{constructor(e,t){f(e,t),super(e,e.rows,1),this.column=t}set(e,t,n){return this.matrix.set(e,this.column,n),this}get(e){return this.matrix.get(e,this.column)}},ye=class extends _e{constructor(e,t){g(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,n){return this.matrix.set(e,this.columnIndices[t],n),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}},be=class extends _e{constructor(e){super(e,e.rows,e.columns)}set(e,t,n){return this.matrix.set(e,this.columns-t-1,n),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}},xe=class extends _e{constructor(e){super(e,e.rows,e.columns)}set(e,t,n){return this.matrix.set(this.rows-e-1,t,n),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}},Se=class extends _e{constructor(e,t){d(e,t),super(e,1,e.columns),this.row=t}set(e,t,n){return this.matrix.set(this.row,t,n),this}get(e,t){return this.matrix.get(this.row,t)}},Ce=class extends _e{constructor(e,t){h(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,n){return this.matrix.set(this.rowIndices[e],t,n),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}},we=class extends _e{constructor(e,t,n){h(e,t),g(e,n),super(e,t.length,n.length),this.rowIndices=t,this.columnIndices=n}set(e,t,n){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],n),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}},Te=class extends _e{constructor(e,t,n,r,i){_(e,t,n,r,i),super(e,n-t+1,i-r+1),this.startRow=t,this.startColumn=r}set(e,t,n){return this.matrix.set(this.startRow+e,this.startColumn+t,n),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}},Ee=class extends _e{constructor(e){super(e,e.columns,e.rows)}set(e,t,n){return this.matrix.set(t,e,n),this}get(e,t){return this.matrix.get(t,e)}},De=class extends j{constructor(e,t={}){let{rows:n=1}=t;if(e.length%n!==0)throw Error(`the data length is not divisible by the number of rows`);super(),this.rows=n,this.columns=e.length/n,this.data=e}set(e,t,n){let r=this._calculateIndex(e,t);return this.data[r]=n,this}get(e,t){let n=this._calculateIndex(e,t);return this.data[n]}_calculateIndex(e,t){return e*this.columns+t}},Oe=class extends j{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}};function ke(e,n){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new Oe(e):new De(e,n);throw Error(`the argument is not an array`)}var Ae=class{constructor(e){e=Oe.checkMatrix(e);let t=e.clone(),n=t.rows,r=t.columns,i=new Float64Array(n),a=1,o,s,c,l,u,d,f,p,m;for(o=0;o<n;o++)i[o]=o;for(p=new Float64Array(n),s=0;s<r;s++){for(o=0;o<n;o++)p[o]=t.get(o,s);for(o=0;o<n;o++){for(m=Math.min(o,s),u=0,c=0;c<m;c++)u+=t.get(o,c)*p[c];p[o]-=u,t.set(o,s,p[o])}for(l=s,o=s+1;o<n;o++)Math.abs(p[o])>Math.abs(p[l])&&(l=o);if(l!==s){for(c=0;c<r;c++)d=t.get(l,c),t.set(l,c,t.get(s,c)),t.set(s,c,d);f=i[l],i[l]=i[s],i[s]=f,a=-a}if(s<n&&t.get(s,s)!==0)for(o=s+1;o<n;o++)t.set(o,s,t.get(o,s)/t.get(s,s))}this.LU=t,this.pivotVector=i,this.pivotSign=a}isSingular(){let e=this.LU,t=e.columns;for(let n=0;n<t;n++)if(e.get(n,n)===0)return!0;return!1}solve(e){e=M.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw Error(`Invalid matrix dimensions`);if(this.isSingular())throw Error(`LU matrix is singular`);let n=e.columns,r=e.subMatrixRow(this.pivotVector,0,n-1),i=t.columns,a,o,s;for(s=0;s<i;s++)for(a=s+1;a<i;a++)for(o=0;o<n;o++)r.set(a,o,r.get(a,o)-r.get(s,o)*t.get(a,s));for(s=i-1;s>=0;s--){for(o=0;o<n;o++)r.set(s,o,r.get(s,o)/t.get(s,s));for(a=0;a<s;a++)for(o=0;o<n;o++)r.set(a,o,r.get(a,o)-r.get(s,o)*t.get(a,s))}return r}get determinant(){let e=this.LU;if(!e.isSquare())throw Error(`Matrix must be square`);let t=this.pivotSign,n=e.columns;for(let r=0;r<n;r++)t*=e.get(r,r);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new M(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)i>t?r.set(i,t,e.get(i,t)):i===t?r.set(i,t,1):r.set(i,t,0);return r}get upperTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new M(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)i<=t?r.set(i,t,e.get(i,t)):r.set(i,t,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}};function je(e,t){let n=0;return Math.abs(e)>Math.abs(t)?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):t===0?0:(n=e/t,Math.abs(t)*Math.sqrt(1+n*n))}var Me=class{constructor(e){e=Oe.checkMatrix(e);let t=e.clone(),n=e.rows,r=e.columns,i=new Float64Array(r),a,o,s,c;for(s=0;s<r;s++){let e=0;for(a=s;a<n;a++)e=je(e,t.get(a,s));if(e!==0){for(t.get(s,s)<0&&(e=-e),a=s;a<n;a++)t.set(a,s,t.get(a,s)/e);for(t.set(s,s,t.get(s,s)+1),o=s+1;o<r;o++){for(c=0,a=s;a<n;a++)c+=t.get(a,s)*t.get(a,o);for(c=-c/t.get(s,s),a=s;a<n;a++)t.set(a,o,t.get(a,o)+c*t.get(a,s))}}i[s]=-e}this.QR=t,this.Rdiag=i}solve(e){e=M.checkMatrix(e);let t=this.QR,n=t.rows;if(e.rows!==n)throw Error(`Matrix row dimensions must agree`);if(!this.isFullRank())throw Error(`Matrix is rank deficient`);let r=e.columns,i=e.clone(),a=t.columns,o,s,c,l;for(c=0;c<a;c++)for(s=0;s<r;s++){for(l=0,o=c;o<n;o++)l+=t.get(o,c)*i.get(o,s);for(l=-l/t.get(c,c),o=c;o<n;o++)i.set(o,s,i.get(o,s)+l*t.get(o,c))}for(c=a-1;c>=0;c--){for(s=0;s<r;s++)i.set(c,s,i.get(c,s)/this.Rdiag[c]);for(o=0;o<c;o++)for(s=0;s<r;s++)i.set(o,s,i.get(o,s)-i.get(c,s)*t.get(o,c))}return i.subMatrix(0,a-1,0,r-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,n=new M(t,t),r,i;for(r=0;r<t;r++)for(i=0;i<t;i++)r<i?n.set(r,i,e.get(r,i)):r===i?n.set(r,i,this.Rdiag[r]):n.set(r,i,0);return n}get orthogonalMatrix(){let e=this.QR,t=e.rows,n=e.columns,r=new M(t,n),i,a,o,s;for(o=n-1;o>=0;o--){for(i=0;i<t;i++)r.set(i,o,0);for(r.set(o,o,1),a=o;a<n;a++)if(e.get(o,o)!==0){for(s=0,i=o;i<t;i++)s+=e.get(i,o)*r.get(i,a);for(s=-s/e.get(o,o),i=o;i<t;i++)r.set(i,a,r.get(i,a)+s*e.get(i,o))}}return r}},Ne=class{constructor(e,t={}){if(e=Oe.checkMatrix(e),e.isEmpty())throw Error(`Matrix must be non-empty`);let n=e.rows,r=e.columns,{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:o=!1}=t,s=!!i,c=!!a,l=!1,u;if(n<r)if(!o)u=e.clone(),console.warn(`Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose`);else{u=e.transpose(),n=u.rows,r=u.columns,l=!0;let t=s;s=c,c=t}else u=e.clone();let d=Math.min(n,r),f=Math.min(n+1,r),p=new Float64Array(f),m=new M(n,d),h=new M(r,r),g=new Float64Array(r),_=new Float64Array(n),v=new Float64Array(f);for(let e=0;e<f;e++)v[e]=e;let y=Math.min(n-1,r),b=Math.max(0,Math.min(r-2,n)),x=Math.max(y,b);for(let e=0;e<x;e++){if(e<y){p[e]=0;for(let t=e;t<n;t++)p[e]=je(p[e],u.get(t,e));if(p[e]!==0){u.get(e,e)<0&&(p[e]=-p[e]);for(let t=e;t<n;t++)u.set(t,e,u.get(t,e)/p[e]);u.set(e,e,u.get(e,e)+1)}p[e]=-p[e]}for(let t=e+1;t<r;t++){if(e<y&&p[e]!==0){let r=0;for(let i=e;i<n;i++)r+=u.get(i,e)*u.get(i,t);r=-r/u.get(e,e);for(let i=e;i<n;i++)u.set(i,t,u.get(i,t)+r*u.get(i,e))}g[t]=u.get(e,t)}if(s&&e<y)for(let t=e;t<n;t++)m.set(t,e,u.get(t,e));if(e<b){g[e]=0;for(let t=e+1;t<r;t++)g[e]=je(g[e],g[t]);if(g[e]!==0){g[e+1]<0&&(g[e]=0-g[e]);for(let t=e+1;t<r;t++)g[t]/=g[e];g[e+1]+=1}if(g[e]=-g[e],e+1<n&&g[e]!==0){for(let t=e+1;t<n;t++)_[t]=0;for(let t=e+1;t<n;t++)for(let n=e+1;n<r;n++)_[t]+=g[n]*u.get(t,n);for(let t=e+1;t<r;t++){let r=-g[t]/g[e+1];for(let i=e+1;i<n;i++)u.set(i,t,u.get(i,t)+r*_[i])}}if(c)for(let t=e+1;t<r;t++)h.set(t,e,g[t])}}let S=Math.min(r,n+1);if(y<r&&(p[y]=u.get(y,y)),n<S&&(p[S-1]=0),b+1<S&&(g[b]=u.get(b,S-1)),g[S-1]=0,s){for(let e=y;e<d;e++){for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}for(let e=y-1;e>=0;e--)if(p[e]!==0){for(let t=e+1;t<d;t++){let r=0;for(let i=e;i<n;i++)r+=m.get(i,e)*m.get(i,t);r=-r/m.get(e,e);for(let i=e;i<n;i++)m.set(i,t,m.get(i,t)+r*m.get(i,e))}for(let t=e;t<n;t++)m.set(t,e,-m.get(t,e));m.set(e,e,1+m.get(e,e));for(let t=0;t<e-1;t++)m.set(t,e,0)}else{for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}}if(c)for(let e=r-1;e>=0;e--){if(e<b&&g[e]!==0)for(let t=e+1;t<r;t++){let n=0;for(let i=e+1;i<r;i++)n+=h.get(i,e)*h.get(i,t);n=-n/h.get(e+1,e);for(let i=e+1;i<r;i++)h.set(i,t,h.get(i,t)+n*h.get(i,e))}for(let t=0;t<r;t++)h.set(t,e,0);h.set(e,e,1)}let C=S-1,w=2**-52;for(;S>0;){let e,t;for(e=S-2;e>=-1&&e!==-1;e--){let t=Number.MIN_VALUE+w*Math.abs(p[e]+Math.abs(p[e+1]));if(Math.abs(g[e])<=t||Number.isNaN(g[e])){g[e]=0;break}}if(e===S-2)t=4;else{let n;for(n=S-1;n>=e&&n!==e;n--){let t=(n===S?0:Math.abs(g[n]))+(n===e+1?0:Math.abs(g[n-1]));if(Math.abs(p[n])<=w*t){p[n]=0;break}}n===e?t=3:n===S-1?t=1:(t=2,e=n)}switch(e++,t){case 1:{let t=g[S-2];g[S-2]=0;for(let n=S-2;n>=e;n--){let i=je(p[n],t),a=p[n]/i,o=t/i;if(p[n]=i,n!==e&&(t=-o*g[n-1],g[n-1]=a*g[n-1]),c)for(let e=0;e<r;e++)i=a*h.get(e,n)+o*h.get(e,S-1),h.set(e,S-1,-o*h.get(e,n)+a*h.get(e,S-1)),h.set(e,n,i)}break}case 2:{let t=g[e-1];g[e-1]=0;for(let r=e;r<S;r++){let i=je(p[r],t),a=p[r]/i,o=t/i;if(p[r]=i,t=-o*g[r],g[r]=a*g[r],s)for(let t=0;t<n;t++)i=a*m.get(t,r)+o*m.get(t,e-1),m.set(t,e-1,-o*m.get(t,r)+a*m.get(t,e-1)),m.set(t,r,i)}break}case 3:{let t=Math.max(Math.abs(p[S-1]),Math.abs(p[S-2]),Math.abs(g[S-2]),Math.abs(p[e]),Math.abs(g[e])),i=p[S-1]/t,a=p[S-2]/t,o=g[S-2]/t,l=p[e]/t,u=g[e]/t,d=((a+i)*(a-i)+o*o)/2,f=i*o*(i*o),_=0;(d!==0||f!==0)&&(_=d<0?0-Math.sqrt(d*d+f):Math.sqrt(d*d+f),_=f/(d+_));let v=(l+i)*(l-i)+_,y=l*u;for(let t=e;t<S-1;t++){let i=je(v,y);i===0&&(i=Number.MIN_VALUE);let a=v/i,o=y/i;if(t!==e&&(g[t-1]=i),v=a*p[t]+o*g[t],g[t]=a*g[t]-o*p[t],y=o*p[t+1],p[t+1]=a*p[t+1],c)for(let e=0;e<r;e++)i=a*h.get(e,t)+o*h.get(e,t+1),h.set(e,t+1,-o*h.get(e,t)+a*h.get(e,t+1)),h.set(e,t,i);if(i=je(v,y),i===0&&(i=Number.MIN_VALUE),a=v/i,o=y/i,p[t]=i,v=a*g[t]+o*p[t+1],p[t+1]=-o*g[t]+a*p[t+1],y=o*g[t+1],g[t+1]=a*g[t+1],s&&t<n-1)for(let e=0;e<n;e++)i=a*m.get(e,t)+o*m.get(e,t+1),m.set(e,t+1,-o*m.get(e,t)+a*m.get(e,t+1)),m.set(e,t,i)}g[S-2]=v;break}case 4:if(p[e]<=0&&(p[e]=p[e]<0?-p[e]:0,c))for(let t=0;t<=C;t++)h.set(t,e,-h.get(t,e));for(;e<C&&!(p[e]>=p[e+1]);){let t=p[e];if(p[e]=p[e+1],p[e+1]=t,c&&e<r-1)for(let n=0;n<r;n++)t=h.get(n,e+1),h.set(n,e+1,h.get(n,e)),h.set(n,e,t);if(s&&e<n-1)for(let r=0;r<n;r++)t=m.get(r,e+1),m.set(r,e+1,m.get(r,e)),m.set(r,e,t);e++}S--;break}}if(l){let e=h;h=m,m=e}this.m=n,this.n=r,this.s=p,this.U=m,this.V=h}solve(e){let t=e,n=this.threshold,r=this.s.length,i=M.zeros(r,r);for(let e=0;e<r;e++)Math.abs(this.s[e])<=n?i.set(e,e,0):i.set(e,e,1/this.s[e]);let a=this.U,o=this.rightSingularVectors,s=o.mmul(i),c=o.rows,l=a.rows,u=M.zeros(c,l);for(let e=0;e<c;e++)for(let t=0;t<l;t++){let n=0;for(let i=0;i<r;i++)n+=s.get(e,i)*a.get(t,i);u.set(e,t,n)}return u.mmul(t)}solveForDiagonal(e){return this.solve(M.diag(e))}inverse(){let e=this.V,t=this.threshold,n=e.rows,r=e.columns,i=new M(n,this.s.length);for(let a=0;a<n;a++)for(let n=0;n<r;n++)Math.abs(this.s[n])>t&&i.set(a,n,e.get(a,n)/this.s[n]);let a=this.U,o=a.rows,s=a.columns,c=new M(n,o);for(let e=0;e<n;e++)for(let t=0;t<o;t++){let n=0;for(let r=0;r<s;r++)n+=i.get(e,r)*a.get(t,r);c.set(e,t,n)}return c}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*2**-52,t=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return 2**-52/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return M.diag(this.s)}};function Pe(e,t=!1){return e=Oe.checkMatrix(e),t?new Ne(e).inverse():Fe(e,M.eye(e.rows))}function Fe(e,t,n=!1){return e=Oe.checkMatrix(e),t=Oe.checkMatrix(t),n?new Ne(e).solve(t):e.isSquare()?new Ae(e).solve(t):new Me(e).solve(t)}function Ie(e){if(e=M.checkMatrix(e),e.isSquare()){if(e.columns===0)return 1;let t,n,r,i;if(e.columns===2)return t=e.get(0,0),n=e.get(0,1),r=e.get(1,0),i=e.get(1,1),t*i-n*r;if(e.columns===3){let i,a,o;return i=new we(e,[1,2],[1,2]),a=new we(e,[1,2],[0,2]),o=new we(e,[1,2],[0,1]),t=e.get(0,0),n=e.get(0,1),r=e.get(0,2),t*Ie(i)-n*Ie(a)+r*Ie(o)}else return new Ae(e).determinant}else throw Error(`determinant can only be calculated for a square matrix`)}function Le(e,t){let n=[];for(let r=0;r<e;r++)r!==t&&n.push(r);return n}function Re(e,t,n,r=1e-9,i=1e-9){if(e>i)return Array(t.rows+1).fill(0);{let e=t.addRow(n,[0]);for(let t=0;t<e.rows;t++)Math.abs(e.get(t,0))<r&&e.set(t,0,0);return e.to1DArray()}}function ze(e,t={}){let{thresholdValue:n=1e-9,thresholdError:r=1e-9}=t;e=M.checkMatrix(e);let i=e.rows,a=new M(i,i);for(let t=0;t<i;t++){let o=M.columnVector(e.getRow(t)),s=e.subMatrixRow(Le(i,t)).transpose(),c=new Ne(s).solve(o),l=M.sub(o,s.mmul(c)).abs().max();a.setRow(t,Re(l,c,t,n,r))}return a}function Be(e,t=2**-52){if(e=M.checkMatrix(e),e.isEmpty())return e.transpose();let n=new Ne(e,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,a=n.diagonal;for(let e=0;e<a.length;e++)Math.abs(a[e])>t?a[e]=1/a[e]:a[e]=0;return i.mmul(M.diag(a).mmul(r.transpose()))}function Ve(e,n=e,r={}){e=new M(e);let i=!1;if(typeof n==`object`&&!M.isMatrix(n)&&!t.isAnyArray(n)?(r=n,n=e,i=!0):n=new M(n),e.rows!==n.rows)throw TypeError(`Both matrices must have the same number of rows`);let{center:a=!0}=r;a&&(e=e.center(`column`),i||(n=n.center(`column`)));let o=e.transpose().mmul(n);for(let t=0;t<o.rows;t++)for(let n=0;n<o.columns;n++)o.set(t,n,o.get(t,n)*(1/(e.rows-1)));return o}function He(e,n=e,r={}){e=new M(e);let i=!1;if(typeof n==`object`&&!M.isMatrix(n)&&!t.isAnyArray(n)?(r=n,n=e,i=!0):n=new M(n),e.rows!==n.rows)throw TypeError(`Both matrices must have the same number of rows`);let{center:a=!0,scale:o=!0}=r;a&&(e.center(`column`),i||n.center(`column`)),o&&(e.scale(`column`),i||n.scale(`column`));let s=e.standardDeviation(`column`,{unbiased:!0}),c=i?s:n.standardDeviation(`column`,{unbiased:!0}),l=e.transpose().mmul(n);for(let t=0;t<l.rows;t++)for(let n=0;n<l.columns;n++)l.set(t,n,l.get(t,n)*(1/(s[t]*c[n]))*(1/(e.rows-1)));return l}var Ue=class{constructor(e,t={}){let{assumeSymmetric:n=!1}=t;if(e=Oe.checkMatrix(e),!e.isSquare())throw Error(`Matrix is not a square matrix`);if(e.isEmpty())throw Error(`Matrix must be non-empty`);let r=e.columns,i=new M(r,r),a=new Float64Array(r),o=new Float64Array(r),s=e,c,l,u=!1;if(u=n?!0:e.isSymmetric(),u){for(c=0;c<r;c++)for(l=0;l<r;l++)i.set(c,l,s.get(c,l));We(r,o,a,i),Ge(r,o,a,i)}else{let e=new M(r,r),t=new Float64Array(r);for(l=0;l<r;l++)for(c=0;c<r;c++)e.set(c,l,s.get(c,l));Ke(r,e,t,i),qe(r,o,a,i,e)}this.n=r,this.e=o,this.d=a,this.V=i}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,n=this.d,r=new M(e,e),i,a;for(i=0;i<e;i++){for(a=0;a<e;a++)r.set(i,a,0);r.set(i,i,n[i]),t[i]>0?r.set(i,i+1,t[i]):t[i]<0&&r.set(i,i-1,t[i])}return r}};function We(e,t,n,r){let i,a,o,s,c,l,u,d;for(c=0;c<e;c++)n[c]=r.get(e-1,c);for(s=e-1;s>0;s--){for(d=0,o=0,l=0;l<s;l++)d+=Math.abs(n[l]);if(d===0)for(t[s]=n[s-1],c=0;c<s;c++)n[c]=r.get(s-1,c),r.set(s,c,0),r.set(c,s,0);else{for(l=0;l<s;l++)n[l]/=d,o+=n[l]*n[l];for(i=n[s-1],a=Math.sqrt(o),i>0&&(a=-a),t[s]=d*a,o-=i*a,n[s-1]=i-a,c=0;c<s;c++)t[c]=0;for(c=0;c<s;c++){for(i=n[c],r.set(c,s,i),a=t[c]+r.get(c,c)*i,l=c+1;l<=s-1;l++)a+=r.get(l,c)*n[l],t[l]+=r.get(l,c)*i;t[c]=a}for(i=0,c=0;c<s;c++)t[c]/=o,i+=t[c]*n[c];for(u=i/(o+o),c=0;c<s;c++)t[c]-=u*n[c];for(c=0;c<s;c++){for(i=n[c],a=t[c],l=c;l<=s-1;l++)r.set(l,c,r.get(l,c)-(i*t[l]+a*n[l]));n[c]=r.get(s-1,c),r.set(s,c,0)}}n[s]=o}for(s=0;s<e-1;s++){if(r.set(e-1,s,r.get(s,s)),r.set(s,s,1),o=n[s+1],o!==0){for(l=0;l<=s;l++)n[l]=r.get(l,s+1)/o;for(c=0;c<=s;c++){for(a=0,l=0;l<=s;l++)a+=r.get(l,s+1)*r.get(l,c);for(l=0;l<=s;l++)r.set(l,c,r.get(l,c)-a*n[l])}}for(l=0;l<=s;l++)r.set(l,s+1,0)}for(c=0;c<e;c++)n[c]=r.get(e-1,c),r.set(e-1,c,0);r.set(e-1,e-1,1),t[0]=0}function Ge(e,t,n,r){let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y;for(o=1;o<e;o++)t[o-1]=t[o];t[e-1]=0;let b=0,x=0,S=2**-52;for(l=0;l<e;l++){for(x=Math.max(x,Math.abs(n[l])+Math.abs(t[l])),u=l;u<e&&!(Math.abs(t[u])<=S*x);)u++;if(u>l)do{for(i=n[l],d=(n[l+1]-i)/(2*t[l]),f=je(d,1),d<0&&(f=-f),n[l]=t[l]/(d+f),n[l+1]=t[l]*(d+f),p=n[l+1],a=i-n[l],o=l+2;o<e;o++)n[o]-=a;for(b+=a,d=n[u],m=1,h=m,g=m,_=t[l+1],v=0,y=0,o=u-1;o>=l;o--)for(g=h,h=m,y=v,i=m*t[o],a=m*d,f=je(d,t[o]),t[o+1]=v*f,v=t[o]/f,m=d/f,d=m*n[o]-v*i,n[o+1]=a+v*(m*i+v*n[o]),c=0;c<e;c++)a=r.get(c,o+1),r.set(c,o+1,v*r.get(c,o)+m*a),r.set(c,o,m*r.get(c,o)-v*a);d=-v*y*g*_*t[l]/p,t[l]=v*d,n[l]=m*d}while(Math.abs(t[l])>S*x);n[l]=n[l]+b,t[l]=0}for(o=0;o<e-1;o++){for(c=o,d=n[o],s=o+1;s<e;s++)n[s]<d&&(c=s,d=n[s]);if(c!==o)for(n[c]=n[o],n[o]=d,s=0;s<e;s++)d=r.get(s,o),r.set(s,o,r.get(s,c)),r.set(s,c,d)}}function Ke(e,t,n,r){let i=e-1,a,o,s,c,l,u,d;for(u=1;u<=i-1;u++){for(d=0,c=u;c<=i;c++)d+=Math.abs(t.get(c,u-1));if(d!==0){for(s=0,c=i;c>=u;c--)n[c]=t.get(c,u-1)/d,s+=n[c]*n[c];for(o=Math.sqrt(s),n[u]>0&&(o=-o),s-=n[u]*o,n[u]=n[u]-o,l=u;l<e;l++){for(a=0,c=i;c>=u;c--)a+=n[c]*t.get(c,l);for(a/=s,c=u;c<=i;c++)t.set(c,l,t.get(c,l)-a*n[c])}for(c=0;c<=i;c++){for(a=0,l=i;l>=u;l--)a+=n[l]*t.get(c,l);for(a/=s,l=u;l<=i;l++)t.set(c,l,t.get(c,l)-a*n[l])}n[u]=d*n[u],t.set(u,u-1,d*o)}}for(c=0;c<e;c++)for(l=0;l<e;l++)r.set(c,l,+(c===l));for(u=i-1;u>=1;u--)if(t.get(u,u-1)!==0){for(c=u+1;c<=i;c++)n[c]=t.get(c,u-1);for(l=u;l<=i;l++){for(o=0,c=u;c<=i;c++)o+=n[c]*r.get(c,l);for(o=o/n[u]/t.get(u,u-1),c=u;c<=i;c++)r.set(c,l,r.get(c,l)+o*n[c])}}}function qe(e,t,n,r,i){let a=e-1,o=e-1,s=2**-52,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A;for(g=0;g<e;g++)for((g<0||g>o)&&(n[g]=i.get(g,g),t[g]=0),_=Math.max(g-1,0);_<e;_++)l+=Math.abs(i.get(g,_));for(;a>=0;){for(y=a;y>0&&(p=Math.abs(i.get(y-1,y-1))+Math.abs(i.get(y,y)),p===0&&(p=l),!(Math.abs(i.get(y,y-1))<s*p));)y--;if(y===a)i.set(a,a,i.get(a,a)+c),n[a]=i.get(a,a),t[a]=0,a--,h=0;else if(y===a-1){if(S=i.get(a,a-1)*i.get(a-1,a),u=(i.get(a-1,a-1)-i.get(a,a))/2,d=u*u+S,m=Math.sqrt(Math.abs(d)),i.set(a,a,i.get(a,a)+c),i.set(a-1,a-1,i.get(a-1,a-1)+c),C=i.get(a,a),d>=0){for(m=u>=0?u+m:u-m,n[a-1]=C+m,n[a]=n[a-1],m!==0&&(n[a]=C-S/m),t[a-1]=0,t[a]=0,C=i.get(a,a-1),p=Math.abs(C)+Math.abs(m),u=C/p,d=m/p,f=Math.sqrt(u*u+d*d),u/=f,d/=f,_=a-1;_<e;_++)m=i.get(a-1,_),i.set(a-1,_,d*m+u*i.get(a,_)),i.set(a,_,d*i.get(a,_)-u*m);for(g=0;g<=a;g++)m=i.get(g,a-1),i.set(g,a-1,d*m+u*i.get(g,a)),i.set(g,a,d*i.get(g,a)-u*m);for(g=0;g<=o;g++)m=r.get(g,a-1),r.set(g,a-1,d*m+u*r.get(g,a)),r.set(g,a,d*r.get(g,a)-u*m)}else n[a-1]=C+u,n[a]=C+u,t[a-1]=m,t[a]=-m;a-=2,h=0}else{if(C=i.get(a,a),w=0,S=0,y<a&&(w=i.get(a-1,a-1),S=i.get(a,a-1)*i.get(a-1,a)),h===10){for(c+=C,g=0;g<=a;g++)i.set(g,g,i.get(g,g)-C);p=Math.abs(i.get(a,a-1))+Math.abs(i.get(a-1,a-2)),C=w=.75*p,S=-.4375*p*p}if(h===30&&(p=(w-C)/2,p=p*p+S,p>0)){for(p=Math.sqrt(p),w<C&&(p=-p),p=C-S/((w-C)/2+p),g=0;g<=a;g++)i.set(g,g,i.get(g,g)-p);c+=p,C=w=S=.964}for(h+=1,b=a-2;b>=y&&(m=i.get(b,b),f=C-m,p=w-m,u=(f*p-S)/i.get(b+1,b)+i.get(b,b+1),d=i.get(b+1,b+1)-m-f-p,f=i.get(b+2,b+1),p=Math.abs(u)+Math.abs(d)+Math.abs(f),u/=p,d/=p,f/=p,!(b===y||Math.abs(i.get(b,b-1))*(Math.abs(d)+Math.abs(f))<s*(Math.abs(u)*(Math.abs(i.get(b-1,b-1))+Math.abs(m)+Math.abs(i.get(b+1,b+1))))));)b--;for(g=b+2;g<=a;g++)i.set(g,g-2,0),g>b+2&&i.set(g,g-3,0);for(v=b;v<=a-1&&(k=v!==a-1,v!==b&&(u=i.get(v,v-1),d=i.get(v+1,v-1),f=k?i.get(v+2,v-1):0,C=Math.abs(u)+Math.abs(d)+Math.abs(f),C!==0&&(u/=C,d/=C,f/=C)),C!==0);v++)if(p=Math.sqrt(u*u+d*d+f*f),u<0&&(p=-p),p!==0){for(v===b?y!==b&&i.set(v,v-1,-i.get(v,v-1)):i.set(v,v-1,-p*C),u+=p,C=u/p,w=d/p,m=f/p,d/=u,f/=u,_=v;_<e;_++)u=i.get(v,_)+d*i.get(v+1,_),k&&(u+=f*i.get(v+2,_),i.set(v+2,_,i.get(v+2,_)-u*m)),i.set(v,_,i.get(v,_)-u*C),i.set(v+1,_,i.get(v+1,_)-u*w);for(g=0;g<=Math.min(a,v+3);g++)u=C*i.get(g,v)+w*i.get(g,v+1),k&&(u+=m*i.get(g,v+2),i.set(g,v+2,i.get(g,v+2)-u*f)),i.set(g,v,i.get(g,v)-u),i.set(g,v+1,i.get(g,v+1)-u*d);for(g=0;g<=o;g++)u=C*r.get(g,v)+w*r.get(g,v+1),k&&(u+=m*r.get(g,v+2),r.set(g,v+2,r.get(g,v+2)-u*f)),r.set(g,v,r.get(g,v)-u),r.set(g,v+1,r.get(g,v+1)-u*d)}}}if(l!==0){for(a=e-1;a>=0;a--)if(u=n[a],d=t[a],d===0)for(y=a,i.set(a,a,1),g=a-1;g>=0;g--){for(S=i.get(g,g)-u,f=0,_=y;_<=a;_++)f+=i.get(g,_)*i.get(_,a);if(t[g]<0)m=S,p=f;else if(y=g,t[g]===0?i.set(g,a,S===0?-f/(s*l):-f/S):(C=i.get(g,g+1),w=i.get(g+1,g),d=(n[g]-u)*(n[g]-u)+t[g]*t[g],x=(C*p-m*f)/d,i.set(g,a,x),i.set(g+1,a,Math.abs(C)>Math.abs(m)?(-f-S*x)/C:(-p-w*x)/m)),x=Math.abs(i.get(g,a)),s*x*x>1)for(_=g;_<=a;_++)i.set(_,a,i.get(_,a)/x)}else if(d<0)for(y=a-1,Math.abs(i.get(a,a-1))>Math.abs(i.get(a-1,a))?(i.set(a-1,a-1,d/i.get(a,a-1)),i.set(a-1,a,-(i.get(a,a)-u)/i.get(a,a-1))):(A=Je(0,-i.get(a-1,a),i.get(a-1,a-1)-u,d),i.set(a-1,a-1,A[0]),i.set(a-1,a,A[1])),i.set(a,a-1,0),i.set(a,a,1),g=a-2;g>=0;g--){for(T=0,E=0,_=y;_<=a;_++)T+=i.get(g,_)*i.get(_,a-1),E+=i.get(g,_)*i.get(_,a);if(S=i.get(g,g)-u,t[g]<0)m=S,f=T,p=E;else if(y=g,t[g]===0?(A=Je(-T,-E,S,d),i.set(g,a-1,A[0]),i.set(g,a,A[1])):(C=i.get(g,g+1),w=i.get(g+1,g),D=(n[g]-u)*(n[g]-u)+t[g]*t[g]-d*d,O=(n[g]-u)*2*d,D===0&&O===0&&(D=s*l*(Math.abs(S)+Math.abs(d)+Math.abs(C)+Math.abs(w)+Math.abs(m))),A=Je(C*f-m*T+d*E,C*p-m*E-d*T,D,O),i.set(g,a-1,A[0]),i.set(g,a,A[1]),Math.abs(C)>Math.abs(m)+Math.abs(d)?(i.set(g+1,a-1,(-T-S*i.get(g,a-1)+d*i.get(g,a))/C),i.set(g+1,a,(-E-S*i.get(g,a)-d*i.get(g,a-1))/C)):(A=Je(-f-w*i.get(g,a-1),-p-w*i.get(g,a),m,d),i.set(g+1,a-1,A[0]),i.set(g+1,a,A[1]))),x=Math.max(Math.abs(i.get(g,a-1)),Math.abs(i.get(g,a))),s*x*x>1)for(_=g;_<=a;_++)i.set(_,a-1,i.get(_,a-1)/x),i.set(_,a,i.get(_,a)/x)}for(g=0;g<e;g++)if(g<0||g>o)for(_=g;_<e;_++)r.set(g,_,i.get(g,_));for(_=e-1;_>=0;_--)for(g=0;g<=o;g++){for(m=0,v=0;v<=Math.min(_,o);v++)m+=r.get(g,v)*i.get(v,_);r.set(g,_,m)}}}function Je(e,t,n,r){let i,a;return Math.abs(n)>Math.abs(r)?(i=r/n,a=n+i*r,[(e+i*t)/a,(t-i*e)/a]):(i=n/r,a=r+i*n,[(i*e+t)/a,(i*t-e)/a])}var Ye=class{constructor(e){if(e=Oe.checkMatrix(e),!e.isSymmetric())throw Error(`Matrix is not symmetric`);let t=e,n=t.rows,r=new M(n,n),i=!0,a,o,s;for(o=0;o<n;o++){let e=0;for(s=0;s<o;s++){let n=0;for(a=0;a<s;a++)n+=r.get(s,a)*r.get(o,a);n=(t.get(o,s)-n)/r.get(s,s),r.set(o,s,n),e+=n*n}for(e=t.get(o,o)-e,i&=e>0,r.set(o,o,Math.sqrt(Math.max(e,0))),s=o+1;s<n;s++)r.set(o,s,0)}this.L=r,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=Oe.checkMatrix(e);let t=this.L,n=t.rows;if(e.rows!==n)throw Error(`Matrix dimensions do not match`);if(this.isPositiveDefinite()===!1)throw Error(`Matrix is not positive definite`);let r=e.columns,i=e.clone(),a,o,s;for(s=0;s<n;s++)for(o=0;o<r;o++){for(a=0;a<s;a++)i.set(s,o,i.get(s,o)-i.get(a,o)*t.get(s,a));i.set(s,o,i.get(s,o)/t.get(s,s))}for(s=n-1;s>=0;s--)for(o=0;o<r;o++){for(a=s+1;a<n;a++)i.set(s,o,i.get(s,o)-i.get(a,o)*t.get(a,s));i.set(s,o,i.get(s,o)/t.get(s,s))}return i}get lowerTriangularMatrix(){return this.L}},Xe=class{constructor(e,n={}){e=Oe.checkMatrix(e);let{Y:r}=n,{scaleScores:i=!1,maxIterations:a=1e3,terminationCriteria:o=1e-10}=n,s;if(r){if(r=t.isAnyArray(r)&&typeof r[0]==`number`?M.columnVector(r):Oe.checkMatrix(r),r.rows!==e.rows)throw Error(`Y should have the same number of rows as X`);s=r.getColumnVector(0)}else s=e.getColumnVector(0);let c=1,l,u,d,f;for(let t=0;t<a&&c>o;t++)d=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),d=d.div(d.norm()),l=e.mmul(d).div(d.transpose().mmul(d).get(0,0)),t>0&&(c=l.clone().sub(f).pow(2).sum()),f=l.clone(),r?(u=r.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),u=u.div(u.norm()),s=r.mmul(u).div(u.transpose().mmul(u).get(0,0))):s=l;if(r){let t=e.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0));t=t.div(t.norm());let n=e.clone().sub(l.clone().mmul(t.transpose())),i=s.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),a=r.clone().sub(l.clone().mulS(i.get(0,0)).mmul(u.transpose()));this.t=l,this.p=t.transpose(),this.w=d.transpose(),this.q=u,this.u=s,this.s=l.transpose().mmul(l),this.xResidual=n,this.yResidual=a,this.betas=i}else this.w=d.transpose(),this.s=l.transpose().mmul(l).sqrt(),i?this.t=l.clone().div(this.s.get(0,0)):this.t=l,this.xResidual=e.sub(l.mmul(d.transpose()))}};e.AbstractMatrix=j,e.CHO=Ye,e.CholeskyDecomposition=Ye,e.DistanceMatrix=ge,e.EVD=Ue,e.EigenvalueDecomposition=Ue,e.LU=Ae,e.LuDecomposition=Ae,e.Matrix=M,e.MatrixColumnSelectionView=ye,e.MatrixColumnView=ve,e.MatrixFlipColumnView=be,e.MatrixFlipRowView=xe,e.MatrixRowSelectionView=Ce,e.MatrixRowView=Se,e.MatrixSelectionView=we,e.MatrixSubView=Te,e.MatrixTransposeView=Ee,e.NIPALS=Xe,e.Nipals=Xe,e.QR=Me,e.QrDecomposition=Me,e.SVD=Ne,e.SingularValueDecomposition=Ne,e.SymmetricMatrix=he,e.WrapperMatrix1D=De,e.WrapperMatrix2D=Oe,e.correlation=He,e.covariance=Ve,e.default=M,e.determinant=Ie,e.inverse=Pe,e.linearDependencies=ze,e.pseudoInverse=Be,e.solve=Fe,e.wrap=ke}}),_m=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimAbsolute.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.reimAbsolute=void 0;function t(e){let t=e.re.length,n=e.re,r=e.im,i=new Float64Array(t);for(let e=0;e<t;e++)i[e]=Math.sqrt(n[e]**2+r[e]**2);return i}e.reimAbsolute=t}}),vm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/getOutputArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getOutputArray=void 0;var t=(cm(),Qp(am));function n(e,n){if(e!==void 0){if(!(0,t.isAnyArray)(e))throw TypeError(`output option must be an array if specified`);if(e.length!==n)throw TypeError(`the output array does not have the correct length`);return e}else return new Float64Array(n)}e.getOutputArray=n}}),ym=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAbsolute.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xAbsolute=void 0;function t(e){let t=e.slice();for(let e=0;e<t.length;e++)t[e]<0&&(t[e]*=-1);return t}e.xAbsolute=t}}),bm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMedian=void 0;var t=(cm(),Qp(am));function n(e){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);let n=e.slice(),a=0,o=n.length-1,s=0,c=0,l=0,u=i(a,o);for(;;){if(o<=a)return n[u];if(o===a+1)return n[a]>n[o]&&r(n,a,o),n[u];for(s=i(a,o),n[s]>n[o]&&r(n,s,o),n[a]>n[o]&&r(n,a,o),n[s]>n[a]&&r(n,s,a),r(n,s,a+1),c=a+1,l=o;;){do c++;while(n[a]>n[c]);do l--;while(n[l]>n[a]);if(l<c)break;r(n,c,l)}r(n,a,l),l<=u&&(a=c),l>=u&&(o=l-1)}}e.xMedian=n;function r(e,t,n){let r=e[n];e[n]=e[t],e[t]=r}function i(e,t){return Math.floor((e+t)/2)}}}),xm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAbsoluteMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xAbsoluteMedian=void 0;var t=ym(),n=bm();function r(e){return(0,n.xMedian)((0,t.xAbsolute)(e))}e.xAbsoluteMedian=r}}),Sm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAdd.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xAdd=void 0;var t=(cm(),Qp(am));function n(e,n){let r=!1,i=0;if((0,t.isAnyArray)(n)){if(e.length!==n.length)throw Error(`size of array1 and array2 must be identical`)}else r=!0,i=n;let a=new Float64Array(e.length);if(r)for(let t=0;t<e.length;t++)a[t]=e[t]+i;else for(let t=0;t<e.length;t++)a[t]=e[t]+n[t];return a}e.xAdd=n}}),Cm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xApplyFunctionStr.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xApplyFunctionStr=void 0;function t(e,t={}){let{variableLabel:n=`x`,fctString:r=n}=t,i=Function(n,`return Number(${r.replace(/(?<before>^|\W)(?<after>[\da-z]{2,}\()/g,`$<before>Math.$<after>`).replace(/Math\.Math/g,`Math`)})`),a=Float64Array.from(e);for(let t=0;t<e.length;t++)if(a[t]=i(e[t]),Number.isNaN(a[t]))throw Error(`The callback ${r} does not return a number: ${e[t]}`);return a}e.xApplyFunctionStr=t}}),wm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMultiply.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMultiply=void 0;var t=(cm(),Qp(am)),n=vm();function r(e,r,i={}){let a=!1,o=0;if((0,t.isAnyArray)(r)){if(e.length!==r.length)throw Error(`size of array1 and array2 must be identical`)}else a=!0,o=Number(r);let s=(0,n.getOutputArray)(i.output,e.length);if(a)for(let t=0;t<e.length;t++)s[t]=e[t]*o;else for(let t=0;t<e.length;t++)s[t]=e[t]*r[t];return s}e.xMultiply=r}}),Tm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xDotProduct.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xDotProduct=void 0;var t=wm();function n(e,n){let r=(0,t.xMultiply)(e,n),i=0;for(let t=0;t<e.length;t++)i+=r[t];return i}e.xDotProduct=n}}),Em=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCrossCorrelation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCrossCorrelation=void 0;var t=Tm();function n(e,n,r={}){let{tau:i=1,lag:a=e.length-1}=r,o=new Float64Array(1+2*a/i);if(e.length===n.length){let r=n.length,s=new Float64Array(2*r),c=new Float64Array(2*r);for(let e=0;e<r;e++)c[r+e]=n[e];for(let n=r*2-(i-1);n>0;n-=i){let l=0;for(let e=n;e<r*2;e++)s[l]=c[e],l++;let u=[];for(let e=0;e<r;e++)u[e]=s[e];o[(l-(r-a))/i]=(0,t.xDotProduct)(e,u)}}return o}e.xCrossCorrelation=n}}),Dm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xAutoCorrelation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xAutoCorrelation=void 0;var t=Em();function n(e,n={}){return(0,t.xCrossCorrelation)(e,e,n)}e.xAutoCorrelation=n}}),Om=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xBoxPlot.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xBoxPlot=void 0;function t(e,t={}){let{allowSmallArray:n=!1}=t;if(e.length<5)if(n){if(e.length<1)throw Error(`can not calculate info if array is empty`)}else throw Error(`can not calculate info if array contains less than 5 elements`);e=Float64Array.from(e).sort();let r={q1:0,median:0,q3:0,min:e[0],max:e[e.length-1]},i,a;if(e.length%2==1){let t=(e.length-1)/2;r.median=e[t],i=Math.max(t-1,0),a=Math.min(t+1,e.length-1)}else a=e.length/2,i=a-1,r.median=(e[i]+e[a])/2;if(i%2==0)r.q1=e[i/2],r.q3=e[(e.length+a-1)/2];else{r.q1=(e[(i+1)/2]+e[(i-1)/2])/2;let t=(e.length+a)/2;r.q3=(e[t]+e[t-1])/2}return r}e.xBoxPlot=t}}),km=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCheck.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCheck=void 0;var t=(cm(),Qp(am));function n(e,n={}){let{minLength:r}=n;if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);if(e.length===0)throw TypeError(`input must not be empty`);if(typeof e[0]!=`number`)throw TypeError(`input must contain numbers`);if(r&&e.length<r)throw Error(`input must have a length of at least ${r}`)}e.xCheck=n}}),Am=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCheckLengths.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCheckLengths=void 0;function t(e,t){if(e.length!==t.length)throw TypeError(`length of array1 and array2 must be identical`)}e.xCheckLengths=t}}),jm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCorrelation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCorrelation=void 0;function t(e,t){let n=e.length,r=0,i=0,a=0,o=0,s=0;for(let c=0;c<n;c++){let n=e[c],l=t[c];r+=n,i+=n**2,a+=l,o+=l**2,s+=n*l}return(n*s-r*a)/(Math.sqrt(n*i-r**2)*Math.sqrt(n*o-a**2))}e.xCorrelation=t}}),Mm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCostMatrix.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCostMatrix=void 0;var t=gm(),n=(e,t)=>Math.abs(e-t);function r(e,r,i={}){let{fct:a=n}=i,o=e.length,s=r.length,c=new t.Matrix(o,s);for(let t=0;t<o;t++)for(let n=0;n<s;n++)c.set(t,n,a(e[t],r[n]));return c}e.xCostMatrix=r}}),Nm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xCumulative.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xCumulative=void 0;var t=(cm(),Qp(am));function n(e){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);let n=new Float64Array(e.length);if(e.length===0)return n;n[0]=e[0];for(let t=1;t<e.length;t++)n[t]=n[t-1]+e[t];return n}e.xCumulative=n}}),Pm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xDivide.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xDivide=void 0;var t=(cm(),Qp(am)),n=vm();function r(e,r,i={}){let a=!1,o=0;if((0,t.isAnyArray)(r)){if(e.length!==r.length)throw RangeError(`size of array1 and array2 must be identical`)}else a=!0,o=Number(r);let s=(0,n.getOutputArray)(i.output,e.length);if(a)for(let t=0;t<e.length;t++)s[t]=e[t]/o;else for(let t=0;t<e.length;t++)s[t]=e[t]/r[t];return s}e.xDivide=r}}),Fm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xEnsureFloat64.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xEnsureFloat64=void 0;var t=km();function n(e){return(0,t.xCheck)(e),e instanceof Float64Array?e.slice(0):Float64Array.from(e)}e.xEnsureFloat64=n}}),Im=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xFindClosestIndex.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xFindClosestIndex=void 0;function t(e,t,n={}){let{sorted:r=!0}=n;if(r){let n=0,r=e.length-1,i=0;for(;r-n>1;)if(i=n+(r-n>>1),e[i]<t)n=i;else if(e[i]>t)r=i;else return i;return n<e.length-1?Math.abs(t-e[n])<Math.abs(e[n+1]-t)?n:n+1:n}else{let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i]-t);a<r&&(r=a,n=i)}return n}}e.xFindClosestIndex=t}}),Lm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xGetFromToIndex.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xGetFromToIndex=void 0;var t=Im();function n(e,n={}){let{fromIndex:r,toIndex:i}=n,{from:a,to:o}=n;return r===void 0&&(r=a===void 0?0:(0,t.xFindClosestIndex)(e,a)),i===void 0&&(i=o===void 0?e.length-1:(0,t.xFindClosestIndex)(e,o)),r<0&&(r=0),i<0&&(i=0),r>=e.length&&(r=e.length-1),i>=e.length&&(i=e.length-1),r>i&&([r,i]=[i,r]),{fromIndex:r,toIndex:i}}e.xGetFromToIndex=n}}),Rm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xGetTargetIndex.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xGetTargetIndex=void 0;var t=Im();function n(e,n={}){let{target:r,targetIndex:i}=n;return i===void 0?r===void 0?0:(0,t.xFindClosestIndex)(e,r):i}e.xGetTargetIndex=n}}),zm=Z({"../node_modules/.pnpm/fft.js@4.0.4/node_modules/fft.js/lib/fft.js"(e,t){function n(e){if(this.size=e|0,this.size<=1||this.size&this.size-1)throw Error(`FFT size must be a power of two and bigger than 1`);this._csize=e<<1;for(var t=Array(this.size*2),n=0;n<t.length;n+=2){let e=Math.PI*n/this.size;t[n]=Math.cos(e),t[n+1]=-Math.sin(e)}this.table=t;for(var r=0,i=1;this.size>i;i<<=1)r++;this._width=r%2==0?r-1:r,this._bitrev=Array(1<<this._width);for(var a=0;a<this._bitrev.length;a++){this._bitrev[a]=0;for(var o=0;o<this._width;o+=2){var s=this._width-o-2;this._bitrev[a]|=(a>>>o&3)<<s}}this._out=null,this._data=null,this._inv=0}t.exports=n,n.prototype.fromComplexArray=function(e,t){for(var n=t||Array(e.length>>>1),r=0;r<e.length;r+=2)n[r>>>1]=e[r];return n},n.prototype.createComplexArray=function(){let e=Array(this._csize);for(var t=0;t<e.length;t++)e[t]=0;return e},n.prototype.toComplexArray=function(e,t){for(var n=t||this.createComplexArray(),r=0;r<n.length;r+=2)n[r]=e[r>>>1],n[r+1]=0;return n},n.prototype.completeSpectrum=function(e){for(var t=this._csize,n=t>>>1,r=2;r<n;r+=2)e[t-r]=e[r],e[t-r+1]=-e[r+1]},n.prototype.transform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=0,this._transform4(),this._out=null,this._data=null},n.prototype.realTransform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=0,this._realTransform4(),this._out=null,this._data=null},n.prototype.inverseTransform=function(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._out=e,this._data=t,this._inv=1,this._transform4();for(var n=0;n<e.length;n++)e[n]/=this.size;this._out=null,this._data=null},n.prototype._transform4=function(){var e=this._out,t=this._csize,n=1<<this._width,r=t/n<<1,i,a,o=this._bitrev;if(r===4)for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleTransform2(i,e,n)}else for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleTransform4(i,e,n)}var s=this._inv?-1:1,c=this.table;for(n>>=2;n>=2;n>>=2){r=t/n<<1;var l=r>>>2;for(i=0;i<t;i+=r)for(var u=i+l,d=i,f=0;d<u;d+=2,f+=n){let t=d,n=t+l,r=n+l,i=r+l,a=e[t],o=e[t+1],u=e[n],p=e[n+1],m=e[r],h=e[r+1],g=e[i],_=e[i+1],v=a,y=o,b=c[f],x=s*c[f+1],S=u*b-p*x,C=u*x+p*b,w=c[2*f],T=s*c[2*f+1],E=m*w-h*T,D=m*T+h*w,O=c[3*f],k=s*c[3*f+1],A=g*O-_*k,ee=g*k+_*O,te=v+E,ne=y+D,re=v-E,ie=y-D,ae=S+A,oe=C+ee,se=s*(S-A),j=s*(C-ee),ce=te+ae,le=ne+oe,ue=te-ae,de=ne-oe,fe=re+j,M=ie-se,pe=re-j,me=ie+se;e[t]=ce,e[t+1]=le,e[n]=fe,e[n+1]=M,e[r]=ue,e[r+1]=de,e[i]=pe,e[i+1]=me}}},n.prototype._singleTransform2=function(e,t,n){let r=this._out,i=this._data,a=i[t],o=i[t+1],s=i[t+n],c=i[t+n+1],l=a+s,u=o+c,d=a-s,f=o-c;r[e]=l,r[e+1]=u,r[e+2]=d,r[e+3]=f},n.prototype._singleTransform4=function(e,t,n){let r=this._out,i=this._data,a=this._inv?-1:1,o=n*2,s=n*3,c=i[t],l=i[t+1],u=i[t+n],d=i[t+n+1],f=i[t+o],p=i[t+o+1],m=i[t+s],h=i[t+s+1],g=c+f,_=l+p,v=c-f,y=l-p,b=u+m,x=d+h,S=a*(u-m),C=a*(d-h),w=g+b,T=_+x,E=v+C,D=y-S,O=g-b,k=_-x,A=v-C,ee=y+S;r[e]=w,r[e+1]=T,r[e+2]=E,r[e+3]=D,r[e+4]=O,r[e+5]=k,r[e+6]=A,r[e+7]=ee},n.prototype._realTransform4=function(){var e=this._out,t=this._csize,n=1<<this._width,r=t/n<<1,i,a,o=this._bitrev;if(r===4)for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleRealTransform2(i,e>>>1,n>>>1)}else for(i=0,a=0;i<t;i+=r,a++){let e=o[a];this._singleRealTransform4(i,e>>>1,n>>>1)}var s=this._inv?-1:1,c=this.table;for(n>>=2;n>=2;n>>=2){r=t/n<<1;var l=r>>>1,u=l>>>1,d=u>>>1;for(i=0;i<t;i+=r)for(var f=0,p=0;f<=d;f+=2,p+=n){var m=i+f,h=m+u,g=h+u,_=g+u,v=e[m],y=e[m+1],b=e[h],x=e[h+1],S=e[g],C=e[g+1],w=e[_],T=e[_+1],E=v,D=y,O=c[p],k=s*c[p+1],A=b*O-x*k,ee=b*k+x*O,te=c[2*p],ne=s*c[2*p+1],re=S*te-C*ne,ie=S*ne+C*te,ae=c[3*p],oe=s*c[3*p+1],se=w*ae-T*oe,j=w*oe+T*ae,ce=E+re,le=D+ie,ue=E-re,de=D-ie,fe=A+se,M=ee+j,pe=s*(A-se),me=s*(ee-j),he=ce+fe,ge=le+M,_e=ue+me,ve=de-pe;if(e[m]=he,e[m+1]=ge,e[h]=_e,e[h+1]=ve,f===0){var ye=ce-fe,be=le-M;e[g]=ye,e[g+1]=be;continue}if(f!==d){var xe=ue,Se=-de,Ce=ce,we=-le,Te=-s*me,Ee=-s*pe,De=-s*M,Oe=-s*fe,ke=xe+Te,Ae=Se+Ee,je=Ce+Oe,Me=we-De,Ne=i+u-f,Pe=i+l-f;e[Ne]=ke,e[Ne+1]=Ae,e[Pe]=je,e[Pe+1]=Me}}}},n.prototype._singleRealTransform2=function(e,t,n){let r=this._out,i=this._data,a=i[t],o=i[t+n],s=a+o,c=a-o;r[e]=s,r[e+1]=0,r[e+2]=c,r[e+3]=0},n.prototype._singleRealTransform4=function(e,t,n){let r=this._out,i=this._data,a=this._inv?-1:1,o=n*2,s=n*3,c=i[t],l=i[t+n],u=i[t+o],d=i[t+s],f=c+u,p=c-u,m=l+d,h=a*(l-d),g=f+m,_=p,v=-h,y=f-m,b=p,x=h;r[e]=g,r[e+1]=0,r[e+2]=_,r[e+3]=v,r[e+4]=y,r[e+5]=0,r[e+6]=b,r[e+7]=x}}}),Bm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createDoubleArray=e.createNumberArray=void 0;function t(e,t){return e===Array?new e(t).fill(0):new e(t)}e.createNumberArray=t;function n(e,t){return e===Array?new e(t).fill(0):new e(t)}e.createDoubleArray=n}}),Vm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createFromToArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createFromToArray=void 0;function t(e={}){let{from:t=0,to:n=1,length:r=1e3,includeFrom:i=!0,includeTo:a=!0,distribution:o=`uniform`}=e,s=new Float64Array(r),c=r;i&&a?c=r-1:!i&&a||i&&!a?c=r:!i&&!a&&(c=r+1);let l=(n-t)/c;if(o===`uniform`)if(i){let e=0;for(;e<r;)s[e]=t+l*e,e++}else{let e=0;for(;e<r;)s[e]=t+l*(e+1),e++}else if(o===`log`){let e=(n/t)**(1/c),a=Math.log(t)/Math.log(e);if(i){let t=0;for(;t<r;)s[t]=e**(a+t),t++}else{let t=0;for(;t<r;)s[t]=e**(a+t+1),t++}}else throw Error(`distribution must be uniform or log`);return s}e.createFromToArray=t}}),Hm={};Yp(Hm,{default:()=>Ym});function Um(e,t){e>>>=0,t>>>=0;let n=e&65535;return((e-n)*t>>>0)+n*t>>>0}var Wm,Gm,Km,qm,Jm,Ym,Xm=Jp({"../node_modules/.pnpm/ml-xsadd@2.0.0/node_modules/ml-xsadd/lib-es6/xsadd.js"(){Wm=8,Gm=1/16777216,Km=15,qm=18,Jm=11,Ym=class{constructor(e=Date.now()){this.state=new Uint32Array(4),this.init(e),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*Gm}init(e){if(!Number.isInteger(e))throw TypeError(`seed must be an integer`);this.state[0]=e,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let e=1;e<Wm;e++)this.state[e&3]^=e+Um(1812433253,this.state[e-1&3]^this.state[e-1&3]>>>30>>>0)>>>0;this.periodCertification();for(let e=0;e<Wm;e++)this.nextState()}periodCertification(){this.state[0]===0&&this.state[1]===0&&this.state[2]===0&&this.state[3]===0&&(this.state[0]=88,this.state[1]=83,this.state[2]=65,this.state[3]=68)}nextState(){let e=this.state[0];e^=e<<Km,e^=e>>>qm,e^=this.state[3]<<Jm,this.state[0]=this.state[1],this.state[1]=this.state[2],this.state[2]=this.state[3],this.state[3]=e}}}}),Zm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createRandomArray.js"(e){var t=e&&e.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},n=e&&e.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i,a,o,s,c;Object.defineProperty(e,"__esModule",{value:!0}),e.createRandomArray=void 0;var l=r((Xm(),Qp(Hm)));function u(e={}){let{mean:t=0,standardDeviation:n=1,length:r=1e3,range:i=1,seed:a,distribution:o=`normal`}=e,s=new l.default(a),c=new Float64Array(r);switch(o){case`normal`:{let e=new d(t,n,s);for(let t=0;t<r;t++)c[t]=e.generateGaussian();break}case`uniform`:for(let e=0;e<r;e++)c[e]=(s.random()-.5)*i+t;break;default:throw Error(`unknown distribution: ${String(o)}`)}return c}e.createRandomArray=u;var d=class{constructor(e,n,r){i.set(this,0),a.set(this,!1),o.set(this,void 0),s.set(this,void 0),c.set(this,void 0),t(this,o,e,`f`),t(this,s,n,`f`),t(this,c,r,`f`)}generateGaussian(){let e,r,l,u;if(n(this,a,`f`))t(this,a,!1,`f`),e=n(this,i,`f`)*n(this,s,`f`)+n(this,o,`f`);else{do r=n(this,c,`f`).random()*2-1,l=n(this,c,`f`).random()*2-1,u=r*r+l*l;while(u>=1||u===0);u=Math.sqrt(-2*Math.log(u)/u),t(this,i,l*u,`f`),t(this,a,!0,`f`),e=n(this,o,`f`)+n(this,s,`f`)*r*u}return e}};i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap}}),Qm=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/createStepArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createStepArray=void 0;function t(e={}){let{from:t=0,step:n=1,length:r=1e3}=e,i=new Float64Array(r),a=0;for(;a<r;)i[a]=t+n*a,a++;return i}e.createStepArray=t}}),$m=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/getRescaler.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getRescaler=void 0;function t(e={}){let{targetMin:t=0,targetMax:i=1,clamp:a=!0,algorithmOptions:o={},algorithm:s=`linear`}=e,{originalMin:c=0,originalMax:l=1}=e,u=n(s,o);c=u(c),l=u(l);let d=l-c,f=i-t;return function(e){return e=u(e),e=r(e,c,l,a),t+(e-c)/d*f}}e.getRescaler=t;function n(e=`linear`,t={}){return n=>{switch(e){case`linear`:return n;case`logarithmic`:return Math.log10(n);case`power`:return n**(t.power||2);default:throw Error(`Unknown kind ${String(e)}`)}}}function r(e,t,n,r=!0){if(e<t){if(r)return t;throw RangeError(`Value ${e} is out of range [${t}, ${n}]`)}if(e>n){if(r)return n;throw RangeError(`Value ${e} is out of range [${t}, ${n}]`)}return e}}}),eh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/isPowerOfTwo.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isPowerOfTwo=void 0;function t(e){return e!==0&&(e&e-1)==0}e.isPowerOfTwo=t}}),th=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/nextPowerOfTwo.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.nextPowerOfTwo=void 0;function t(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1)}e.nextPowerOfTwo=t}}),nh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/stringify.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.stringify=void 0;function t(e,t,n){return JSON.stringify(e,(e,n)=>(ArrayBuffer.isView(n)&&(n=Array.from(n)),t?t(e,n):n),n)}e.stringify=t}}),rh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/utils/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(Bm(),e),n(Vm(),e),n(Zm(),e),n(Qm(),e),n($m(),e),n(eh(),e),n(th(),e),n(nh(),e)}}),ih=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xHilbertTransform.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.xHilbertTransform=void 0;var n=t(zm()),r=rh(),i=km();function a(e,t={}){(0,i.xCheck)(e);let{forceFFT:n=!1}=t,a=e.length;return(0,r.isPowerOfTwo)(a)?o(e):n?c(o(c(e,(0,r.nextPowerOfTwo)(a))),a):s(e)}e.xHilbertTransform=a;function o(e){let t=e.length,r=new n.default(t),i=new Float64Array(t*2);for(let n=0;n<t;n++)i[n*2]=e[n];let a=new Float64Array(t*2);r.transform(a,i);let o=new Float64Array(t);for(let e=1;e<t;e++)o[e]=Math.sign(t/2-e);for(let e=0;e<t;e++)a[e*2]*=o[e],a[e*2+1]*=o[e];let s=new Float64Array(t*2);r.inverseTransform(s,a);let c=new Float64Array(t);for(let e=0;e<t;e++)c[e]=s[e*2+1];return c}function s(e,t={}){let{inClockwise:n=!0}=t,r=[0,...e,0],i=new Float64Array(e.length);for(let e=1;e<r.length-1;e++){let t=0;for(let n=0;n<e-1;n++){let i=Math.log((e-n)/(e-n-1));t+=r[n]*i+(r[n+1]-r[n])*(-1+(e-n)*i)}let a=r[e-1]-r[e+1],o=0;for(let t=e+1;t<r.length-1;t++){let n=Math.log((t-e)/(t-e+1));o+=r[t]*n+(r[t-1]-r[t])*(1+(t-e)*n)}i[e-1]=(n?1:-1)*(t+a+o)/Math.PI}return i}function c(e,t){(0,i.xCheck)(e);let n=e.length,r=(n-1)/(t-1),a=new Float64Array(t),o=0,s=Math.floor(o),c=Math.min(Math.ceil(o),n-1),l=o-s;for(let i=0;i<t;i++)a[i]=e[s]*(1-l)+e[c]*l,o+=r,s=Math.floor(o),c=Math.min(Math.ceil(o),n-1),l=o-s;return a}}}),ah=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxValue.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMaxValue=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]>o&&(o=e[t]);return o}e.xMaxValue=r}}),oh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinValue.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMinValue=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]<o&&(o=e[t]);return o}e.xMinValue=r}}),sh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xHistogram.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xHistogram=void 0;var t=rh(),n=ym(),r=km(),i=ah(),a=oh();function o(e,o={}){(0,r.xCheck)(e);let s=o.histogram,{centerX:c=!0,nbSlots:l=s===void 0?256:s.x.length,logBaseX:u,logBaseY:d,absolute:f=!1}=o;if(f&&(e=(0,n.xAbsolute)(e)),u){e=e.slice();let t=Math.log10(u);for(let n=0;n<e.length;n++)e[n]=Math.log10(e[n])/t}let{min:p=(0,a.xMinValue)(e),max:m=(0,i.xMaxValue)(e)}=o,h=(m-p)/(l+2**-52),g=s===void 0?new Float64Array(l):s.y,_=s===void 0?Array.from((0,t.createFromToArray)({from:p+(c?h/2:0),to:m-(c?h/2:0),length:l})):s.x;for(let t of e){let e=Math.max(Math.min(Math.floor((t-p-2**-52)/h),l-1),0);g[e]++}if(d){let e=Math.log10(d);for(let t=0;t<g.length;t++)g[t]=Math.log10(g[t]+1)/e}return{x:_,y:g}}e.xHistogram=o}}),ch=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xIsEquallySpaced.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xIsEquallySpaced=void 0;function t(e,t={}){if(e.length<3)return!0;let{tolerance:n=.05}=t,r=0,i=2**53-1;for(let t=0;t<e.length-1;++t){let n=e[t+1]-e[t];n<i&&(i=n),n>r&&(r=n)}return(r-i)/r<n}e.xIsEquallySpaced=t}}),lh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xIsMonotonic.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xIsMonotonic=void 0;function t(e){if(e.length<=2)return 1;if(e[0]===e[1]){for(let t=1;t<e.length-1;t++)if(e[t]!==e[t+1])return 0;return 1}if(e[0]<e[e.length-1]){for(let t=0;t<e.length-1;t++)if(e[t]>=e[t+1])return 0;return 1}else{for(let t=0;t<e.length-1;t++)if(e[t]<=e[t+1])return 0;return-1}}e.xIsMonotonic=t}}),uh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMassCenterVectorSimilarity.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMassCenterVectorSimilarity=void 0;function t(e,t,i={}){let{recenter:a=!0,similarityFct:o=(e,t)=>+(e===t)}=i,s=r(e),c=r(t),l=Math.min(s,c);a&&(e=e.slice());let u=0;for(let r=0;r<l;r++){let i=1/l/(1<<r);for(let s=0;s<1<<r;s++){let c=(1<<r)-1+s,d=e[c],f=t[c];u+=o(d,f)*i,a&&n(e,l,r,s,f-d)}}return u}e.xMassCenterVectorSimilarity=t;function n(e,t,n,r,i){for(let a=n;a<t;a++){let t=r*(1<<a-n),o=(1<<a)-1,s=1<<a-n;for(let n=t;n<t+s;n++){let t=o+n;e[t]+=i}}}function r(e){let t=Math.log2(e.length+1);if(t%1!=0)throw Error(`the array length is not a power of 2 minus 1`);return t}}}),dh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxAbsoluteValue.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMaxAbsoluteValue=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)e[t]>=0?e[t]>o&&(o=e[t]):-e[t]>o&&(o=-e[t]);return o}e.xMaxAbsoluteValue=r}}),fh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMaxIndex.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMaxIndex=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=i;for(let t=i+1;t<=a;t++)e[t]>e[o]&&(o=t);return o}e.xMaxIndex=r}}),ph=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMean.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMean=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)o+=e[t];return o/(a-i+1)}e.xMean=r}}),mh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanAbsoluteError.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMeanAbsoluteError=void 0;var t=Am();function n(e,n){(0,t.xCheckLengths)(e,n);let r=0;for(let t=0;t<e.length;t++)r+=Math.abs(e[t]-n[t]);return r/e.length}e.xMeanAbsoluteError=n}}),hh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanSquaredError.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMeanSquaredError=void 0;var t=Am();function n(e,n){(0,t.xCheckLengths)(e,n);let r=0;for(let t=0;t<e.length;t++)r+=(e[t]-n[t])**2;return r/e.length}e.xMeanSquaredError=n}}),gh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMeanWeighted.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMeanWeighted=void 0;var t=km(),n=Lm();function r(e,r,i={}){if((0,t.xCheck)(e,{minLength:1}),(0,t.xCheck)(r),e.length!==r.length)throw Error(`array and weights must have the same length`);let{fromIndex:a,toIndex:o}=(0,n.xGetFromToIndex)(e,i),s=0,c=e[a]*r[a];s+=r[a];for(let t=a+1;t<=o;t++)c+=e[t]*r[t],s+=r[t];if(s===0)throw Error(`sum of weights must be > 0`);return c/s}e.xMeanWeighted=r}}),_h=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMedianAbsoluteDeviation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMedianAbsoluteDeviation=void 0;var t=bm();function n(e){let n=(0,t.xMedian)(e),r=new Float64Array(e.length);for(let t=0;t<e.length;t++)r[t]=Math.abs(e[t]-n);return{median:n,mad:(0,t.xMedian)(r)}}e.xMedianAbsoluteDeviation=n}}),vh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinIndex.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMinIndex=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=i;for(let t=i+1;t<=a;t++)e[t]<e[o]&&(o=t);return o}e.xMinIndex=r}}),yh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinMaxDelta.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMinMaxDelta=void 0;var t=km();function n(e){(0,t.xCheck)(e,{minLength:2});let n=e[1]-e[0],r=n;for(let t=0;t<e.length-1;t++){let i=e[t+1]-e[t];i<n&&(n=i),i>r&&(r=i)}return{min:n,max:r}}e.xMinMaxDelta=n}}),bh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMinMaxValues.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMinMaxValues=void 0;var t=km();function n(e){(0,t.xCheck)(e);let n=e[0],r=e[0];for(let t of e)t<n&&(n=t),t>r&&(r=t);return{min:n,max:r}}e.xMinMaxValues=n}}),xh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xMode.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xMode=void 0;function t(e){if(e.length===0)throw TypeError(`input must not be empty`);let t=0,n=0,r=0,i={};for(let a=0;a<e.length;++a){let o=e[a];r=i[o],r?(i[o]++,r++):(i[o]=1,r=1),r>n&&(n=r,t=e[a])}return t}e.xMode=t}}),Sh=Z({"../node_modules/.pnpm/d3-array@0.7.1/node_modules/d3-array/build/d3-array.js"(e,t){(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r(n.d3_array={})})(e,function(e){function t(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function n(e){return e.length===1&&(e=r(e)),{left:function(t,n,r,i){for(r??=0,i??=t.length;r<i;){var a=r+i>>>1;e(t[a],n)<0?r=a+1:i=a}return r},right:function(t,n,r,i){for(r??=0,i??=t.length;r<i;){var a=r+i>>>1;e(t[a],n)>0?i=a:r=a+1}return r}}}function r(e){return function(n,r){return t(e(n),r)}}var i=n(t),a=i.right,o=i.left;function s(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function c(e){return e===null?NaN:+e}function l(e,t){var n=e.length,r=0,i,a,o=0,s=-1,l=0;if(t==null)for(;++s<n;)isNaN(i=c(e[s]))||(a=i-r,r+=a/++l,o+=a*(i-r));else for(;++s<n;)isNaN(i=c(t(e[s],s,e)))||(a=i-r,r+=a/++l,o+=a*(i-r));if(l>1)return o/(l-1)}function u(e,t){var n=l(e,t);return n&&Math.sqrt(n)}function d(e,t){var n=-1,r=e.length,i,a,o;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=o=a;break}for(;++n<r;)(a=e[n])!=null&&(i>a&&(i=a),o<a&&(o=a))}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=o=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&(i>a&&(i=a),o<a&&(o=a))}return[i,o]}function f(e){return function(){return e}}function p(e){return e}function m(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}var h=Math.sqrt(50),g=Math.sqrt(10),_=Math.sqrt(2);function v(e,t,n){var r=y(e,t,n);return m(Math.ceil(e/r)*r,Math.floor(t/r)*r+r/2,r)}function y(e,t,n){var r=Math.abs(t-e)/Math.max(0,n),i=10**Math.floor(Math.log(r)/Math.LN10),a=r/i;return a>=h?i*=10:a>=g?i*=5:a>=_&&(i*=2),t<e?-i:i}function b(e){return Math.ceil(Math.log(e.length)/Math.LN2)+1}function x(e){return+e}function S(){var e=p,t=d,n=b;function r(r){var i,o=r.length,s,c=Array(o);for(i=0;i<o;++i)c[i]=+e(r[i],i,r);var l=t(c),u=+l[0],d=+l[1],f=n(c,u,d);Array.isArray(f)||(f=v(u,d,+f));var p=f.length;for(i=0;i<p;++i)f[i]=+f[i];for(;f[0]<=u;)f.shift(),--p;for(;f[p-1]>=d;)f.pop(),--p;var m=Array(p+1),h;for(i=0;i<=p;++i)h=m[i]=[],h.x0=i>0?f[i-1]:u,h.x1=i<p?f[i]:d;for(i=0;i<o;++i)s=c[i],u<=s&&s<=d&&m[a(f,s,0,p)].push(r[i]);return m}return r.value=function(t){return arguments.length?(e=typeof t==`function`?t:f(+t),r):e},r.domain=function(e){return arguments.length?(t=typeof e==`function`?e:f([+e[0],+e[1]]),r):t},r.thresholds=function(e){return arguments.length?(n=typeof e==`function`?e:f(Array.isArray(e)?Array.prototype.map.call(e,x):+e),r):n},r}function C(e,t,n){if(n??=c,r=e.length){if((t=+t)<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function w(e,n,r){return e.sort(t),Math.ceil((r-n)/(2*(C(e,.75)-C(e,.25))*e.length**(-1/3)))}function T(e,t,n){return Math.ceil((n-t)/(3.5*u(e)*e.length**(-1/3)))}function E(e,t){var n=-1,r=e.length,i,a;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=a;break}for(;++n<r;)(a=e[n])!=null&&a>i&&(i=a)}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&a>i&&(i=a)}return i}function D(e,t){var n=0,r=e.length,i,a=-1,o=r;if(t==null)for(;++a<r;)isNaN(i=c(e[a]))?--o:n+=i;else for(;++a<r;)isNaN(i=c(t(e[a],a,e)))?--o:n+=i;if(o)return n/o}function O(e,n){var r=[],i=e.length,a,o=-1;if(n==null)for(;++o<i;)isNaN(a=c(e[o]))||r.push(a);else for(;++o<i;)isNaN(a=c(n(e[o],o,e)))||r.push(a);return C(r.sort(t),.5)}function k(e){for(var t=e.length,n,r=-1,i=0,a,o;++r<t;)i+=e[r].length;for(a=Array(i);--t>=0;)for(o=e[t],n=o.length;--n>=0;)a[--i]=o[n];return a}function A(e,t){var n=-1,r=e.length,i,a;if(t==null){for(;++n<r;)if((a=e[n])!=null&&a>=a){i=a;break}for(;++n<r;)(a=e[n])!=null&&i>a&&(i=a)}else{for(;++n<r;)if((a=t(e[n],n,e))!=null&&a>=a){i=a;break}for(;++n<r;)(a=t(e[n],n,e))!=null&&i>a&&(i=a)}return i}function ee(e){for(var t=0,n=e.length-1,r=e[0],i=Array(n<0?0:n);t<n;)i[t]=[r,r=e[++t]];return i}function te(e,t){for(var n=t.length,r=Array(n);n--;)r[n]=e[t[n]];return r}function ne(e,n){if(i=e.length){var r=0,i,a=0,o,s=e[a];for(n||=t;++r<i;)(n(o=e[r],s)<0||n(s,s)!==0)&&(s=o,a=r);if(n(s,s)===0)return a}}function re(e,t,n){for(var r=(n??e.length)-(t=t==null?0:+t),i,a;r;)a=Math.random()*r--|0,i=e[r+t],e[r+t]=e[a+t],e[a+t]=i;return e}function ie(e,t){var n=0,r=e.length,i,a=-1;if(t==null)for(;++a<r;)(i=+e[a])&&(n+=i);else for(;++a<r;)(i=+t(e[a],a,e))&&(n+=i);return n}function ae(e){if(!(a=e.length))return[];for(var t=-1,n=A(e,oe),r=Array(n);++t<n;)for(var i=-1,a,o=r[t]=Array(a);++i<a;)o[i]=e[i][t];return r}function oe(e){return e.length}function se(){return ae(arguments)}e.version=`0.7.1`,e.bisect=a,e.bisectRight=a,e.bisectLeft=o,e.ascending=t,e.bisector=n,e.descending=s,e.deviation=u,e.extent=d,e.histogram=S,e.thresholdFreedmanDiaconis=w,e.thresholdScott=T,e.thresholdSturges=b,e.max=E,e.mean=D,e.median=O,e.merge=k,e.min=A,e.pairs=ee,e.permute=te,e.quantile=C,e.range=m,e.scan=ne,e.shuffle=re,e.sum=ie,e.ticks=v,e.tickStep=y,e.transpose=ae,e.variance=l,e.zip=se})}}),Ch=Z({"../node_modules/.pnpm/spline-interpolator@1.0.0/node_modules/spline-interpolator/index.js"(e,t){var{bisectRight:n}=Sh(),r=(e,t,n,r)=>{let i=e.length-1;e[0]=0,t[0]=0,n[0]=0,t[1]/=e[1],n[1]/=e[1];for(let r=2;r<i;++r)e[r]=e[r]-e[r-2]*n[r-2]*n[r-2]-e[r-1]*t[r-1]*t[r-1],t[r]=(t[r]-e[r-1]*t[r-1]*n[r-1])/e[r],n[r]=n[r]/e[r];for(let e=2;e<i;++e)r[e]=r[e]-t[e-1]*r[e-1]-n[e-2]*r[e-2];for(let t=1;t<i;++t)r[t]=r[t]/e[t];r[i-2]=r[i-2]-t[i-2]*r[i-1];for(let e=i-3;e>0;--e)r[e]=r[e]-t[e]*r[e+1]-n[e]*r[e+2]},i=(e,t,n,i)=>{let a=e.length-1,o=Array(a+1),s=Array(a+1),c=Array(a+1),l=Array(a+1),u=Array(a+1),d=Array(a+1),f=Array(a+1),p=Array(a+1),m=e.map(()=>[0,0,0,0]);m.pop();let h=2*(1-i)/(3*i);for(let t=0;t<a;++t)o[t]=e[t+1]-e[t],s[t]=3/o[t];u[0]=0;for(let n=1;n<a;++n)c[n]=-(s[n-1]+s[n]),l[n]=2*(e[n+1]-e[n-1]),u[n]=3*(t[n+1]-t[n])/o[n]-3*(t[n]-t[n-1])/o[n-1];u[a]=0;for(let e=1;e<a;++e)d[e]=s[e-1]*s[e-1]*n[e-1]+c[e]*c[e]*n[e]+s[e]*s[e]*n[e+1],d[e]=h*d[e]+l[e];for(let e=1;e<a-1;++e)f[e]=c[e]*s[e]*n[e]+s[e]*c[e+1]*n[e+1],f[e]=h*f[e]+o[e];for(let e=1;e<a-2;++e)p[e]=h*s[e]*s[e+1]*n[e+1];r(d,f,p,u),m[0][3]=t[0]-h*s[0]*u[1]*n[0],m[1][3]=t[1]-h*(c[1]*u[1]+s[1]*u[2])*n[0],m[0][0]=u[1]/(3*o[0]),m[0][1]=0,m[0][2]=(m[1][3]-m[0][3])/o[0]-u[1]*o[0]/3,s[0]=0;for(let e=1;e<a;++e)m[e][0]=(u[e+1]-u[e])/(3*o[e]),m[e][1]=u[e],m[e][2]=(u[e]+u[e-1])*o[e-1]+m[e-1][2],m[e][3]=s[e-1]*u[e-1]+c[e]*u[e]+s[e]*u[e+1],m[e][3]=t[e]-h*m[e][3]*n[e];return m};t.exports=class{constructor(e,t,n=1){let r=e.map((e,t)=>t);r.sort((t,n)=>e[t]-e[n]);let a=r.map(t=>e[t]),o=r.map(e=>t[e]),s=r.length,c=r.map(()=>1);this.n=s,this.x=a,this.y=o,this.params=i(a,o,c,n)}interpolate(e){if(e===this.x[this.n-1])return this.y[this.n-1];let t=Math.min(Math.max(0,n(this.x,e)-1),this.n-2),[r,i,a,o]=this.params[t];return e-=this.x[t],r*e*e*e+i*e*e+a*e+o}max(e=100){let t=this.x[0],n=(this.x[this.n-1]-t)/e,r=-1/0;for(let i=0,a=t;i<e;++i,a+=n){let e=this.interpolate(a);e>r&&(r=e)}return r}min(e=100){let t=this.x[0],n=(this.x[this.n-1]-t)/e,r=1/0;for(let i=0,a=t;i<e;++i,a+=n){let e=this.interpolate(a);e<r&&(r=e)}return r}domain(){return[this.x[0],this.x[this.x.length-1]]}range(){return[this.min(),this.max()]}curve(e,t=null){t||=this.domain();let n=(t[1]-t[0])/(e-1),r=Array(e);for(let i=0;i<e;++i){let e=n*i+t[0];r[i]=[e,this.interpolate(e)]}return r}}}}),wh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/utils/erfcinv.js"(e){Object.defineProperty(e,"__esModule",{value:!0});var t=.08913147449493408,n=[-.005387729650712429,.008226878746769157,.02198786811111689,-.03656379714117627,-.012692614766297404,.03348066254097446,-.008368748197417368,-.0005087819496582806],r=[.0008862163904564247,-.0023339375937419,.07952836873415717,-.05273963823400997,-.7122890234154284,.662328840472003,1.5622155839842302,-1.5657455823417585,-.9700050433032906,1],i=2.249481201171875,a=[-3.6719225470772936,21.12946554483405,17.445385985570866,-44.6382324441787,-18.851064805871424,17.644729840837403,8.3705032834312,.10526468069939171,-.20243350835593876],o=[1.7211476576120028,-22.643693341313973,10.826866735546016,48.560921310873994,-20.14326346804852,-28.66081804998,3.971343795334387,6.242641248542475,1],s=.807220458984375,c=[-681149956853777e-24,2.8522533178221704e-8,-6.794655751811263e-7,.0021455899538880526,.029015791000532906,.14286953440815717,.3377855389120359,.38707973897260434,.11703015634199525,-.16379404719331705,-.1311027816799519],l=[.011059242293464892,.15226433829533179,.848854343457902,2.5930192162362027,4.778465929458438,5.381683457070069,3.4662540724256723,1],u=.9399557113647461,d=[26633922742578204e-28,-2304047769118826e-25,460469890584318e-20,.00015754461742496055,.0018712349281955923,.009508047013259196,.018557330651423107,-.0022242652921344794,-.0350353787183178],f=[7646752923027944e-20,.00263861676657016,.03415891436709477,.22009110576413124,.7620591645536234,1.3653349817554064,1],p=.9836282730102539,m=[9905570997331033e-32,-2811287356288318e-29,4.625961635228786e-9,4.4969678992770644e-7,14962478375834237e-21,.00020938631748758808,.001056288621524929,-.0011295143874558028,-.016743100507663373],h=[2.82243172016108e-7,27533547476472603e-21,.0009640118070051656,.016074608709367652,.1381518657490833,.5914293448864175,1];function g(e,t){let n=0;for(let r of e)n=n*t+r;return n}function _(e,t,n,r,i){let a=e-t,o=g(n,a)/g(r,a);return i*e+o*e}function v(e){let v=!1,y,b,x,S;if(Number.isNaN(e))return NaN;if(e<0||e>2)throw RangeError(`erfcinv()::invalid input argument. Value must be on the interval [0,2]. Value: \`${e}\`.`);return e===0?1/0:e===2?-1/0:e===1?0:(e>1?(b=2-e,e=1-b,v=!0):(b=e,e=1-e),e<=.5?(x=e*(e+10),S=g(n,e)/g(r,e),y=x*t+x*S,v?-y:y):b>=.25?(x=Math.sqrt(-2*Math.log(b)),b-=.25,S=g(a,b)/g(o,b),y=x/(i+S),v?-y:y):(b=Math.sqrt(-Math.log(b)),b<3?_(b,1.125,c,l,s):b<6?_(b,3,d,f,u):_(b,6,m,h,p)))}e.default=v}}),Th=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/utils/rayleighCdf.js"(e){Object.defineProperty(e,"__esModule",{value:!0});function t(e,t=1){return e<0?0:-Math.expm1(-(e**2)/(2*t**2))}e.default=t}}),Eh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNoiseSanPlot.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.xNoiseSanPlot=void 0;var n=t(Ch()),r=rh(),i=t(wh()),a=t(Th());function o(e,t={}){let{mask:n,cutOff:r,refine:i=!0,magnitudeMode:a=!1,scaleFactor:o=1,factorStd:l=5,fixOffset:u=!0}=t,f;if(f=Array.isArray(n)&&n.length===e.length?new Float64Array(e.filter((e,t)=>!n[t])):new Float64Array(e),o>1)for(let e=0;e<f.length;e++)f[e]*=o;if(f=f.sort().reverse(),u&&!a){let e=Math.floor(f.length/2),t=.5*(f[e]+f[e+1]);for(let e=0;e<f.length;e++)f[e]-=t}let p=f[f.length-1]>=0?f.length:f.findIndex(e=>e<0),m=p-1;for(let e=m;e>=0;e--)if(f[e]>0){m=e;break}let h=f.slice(0,m+1),g=f.slice(p),_=r||s(h,{magnitudeMode:a}),v=h[Math.floor(h.length*_)],y=h[0],b;b=g.length>0?-1*g[Math.floor(g.length*(1-_))]:0;let x=v,S=b,C=h.slice(),w=g.slice(),T=0,E=2;if(i){let e=x*l;T=h.findIndex(t=>t<e),T>-1&&(C=h.slice(T),x=C[Math.floor(C.length*_)]),e=S*l,E=g.findIndex(t=>t<e),E>-1&&(w=g.slice(E),S=C[Math.floor(w.length*(1-_))])}let D=-c(_/2,{magnitudeMode:a});v/=D,b/=D;let O,k;return i&&T>-1?(O=(_*C.length+T)/(C.length+T),k=-1*c(O/2,{magnitudeMode:a}),x/=k,E>-1&&(O=(_*w.length+E)/(w.length+E),k=-1*c(O/2,{magnitudeMode:a}),S!==0&&(S/=k))):(x/=D,S/=D),{positive:x,negative:S,snr:y/x,sanplot:d(f,{fromTo:{positive:{from:0,to:m},negative:{from:p,to:f.length}}})}}e.xNoiseSanPlot=o;function s(e,t={}){let{magnitudeMode:n=!1,considerList:r={from:.5,step:.1,to:.9}}=t,i=[],a=e.length-1;for(let t=.01;t<=.99;t+=.01){let r=-e[Math.round(a*t)]/c(t/2,{magnitudeMode:n});i.push([t,r])}let o=2**53-1,{from:s,to:l,step:u}=r,d=u/2,f=.5;for(let e=s;e<=l;e+=u){let t=e-d,n=e+d,r=i.filter(e=>e[0]<n&&e[0]>t),a=r.reduce((e,t)=>e+Math.abs(t[1]),0),s=0;for(let e of r)s+=(e[1]-a)**2;s<o&&(o=s,f=e)}return f}function c(e,t){return l([e],t)[0]}function l(e,t={}){let{magnitudeMode:r=!1}=t,o=u(0,2,.01),s=new Float64Array(e.length),c=new Float64Array(o.length);if(r){for(let e=0;e<c.length;e++){let t=o[e]*1;c[e]=1-(0,a.default)(t)}let t=new n.default(o,c);for(let n=0;n<s.length;n++){let r=2*e[n];s[n]=-1*t.interpolate(r)}}else for(let t=0;t<s.length;t++)s[t]=-1*Math.SQRT2*(0,i.default)(2*e[t]);return s}function u(e,t,n){let r=Math.abs((e-t)/n+1),i=[];for(let t=0;t<r;t++)i.push(e+t*n);return i}function d(e,t={}){let{fromTo:n,logBaseY:r=2}=t,i={};for(let t in n){let{from:a,to:o}=n[t];i[t]=a===o?{x:[],y:[]}:f(e.slice(a,o),{logBaseY:r}),t===`negative`&&i[t].y.reverse()}return i}function f(e,t={}){let{log10:n,abs:i}=Math,{logBaseY:a}=t;if(a){e=e.slice();let t=n(a);for(let r=0;r<e.length;r++)e[r]=n(i(e[r]))/t}return{x:(0,r.createFromToArray)({from:0,to:e.length-1,length:e.length}),y:e}}}}),Dh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNoiseStandardDeviation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xNoiseStandardDeviation=void 0;var t=_h();function n(e){let{mad:n,median:r}=(0,t.xMedianAbsoluteDeviation)(e);return{sd:n/.6744897501960817,mad:n,median:r}}e.xNoiseStandardDeviation=n}}),Oh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNorm.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xNorm=void 0;function t(e){let t=0;for(let n of e)t+=n**2;return Math.sqrt(t)}e.xNorm=t}}),kh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSum.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSum=void 0;var t=km(),n=Lm();function r(e,r={}){(0,t.xCheck)(e);let{fromIndex:i,toIndex:a}=(0,n.xGetFromToIndex)(e,r),o=e[i];for(let t=i+1;t<=a;t++)o+=e[t];return o}e.xSum=r}}),Ah=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xNormed.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xNormed=void 0;var t=vm(),n=km(),r=ah(),i=kh();function a(e,a={}){let{algorithm:s=`absolute`,value:c=1}=a;(0,n.xCheck)(e);let l=(0,t.getOutputArray)(a.output,e.length);if(e.length===0)throw Error(`input must not be empty`);switch(s){case`absolute`:{let t=o(e)/c;if(t===0)throw Error(`trying to divide by 0`);for(let n=0;n<e.length;n++)l[n]=e[n]/t;return l}case`max`:{let t=(0,r.xMaxValue)(e);if(t===0)throw Error(`trying to divide by 0`);let n=c/t;for(let t=0;t<e.length;t++)l[t]=e[t]*n;return l}case`sum`:{let t=(0,i.xSum)(e)/c;if(t===0)throw Error(`trying to divide by 0`);for(let n=0;n<e.length;n++)l[n]=e[n]/t;return l}default:throw Error(`unknown algorithm: ${String(s)}`)}}e.xNormed=a;function o(e){let t=0;for(let n=0;n<e.length;n++)t+=Math.abs(e[n]);return t}}}),jh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xPadding.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xPadding=void 0;var t=km(),n=Fm();function r(e,r={}){let{size:i=0,value:a=0,algorithm:o}=r;if((0,t.xCheck)(e),!o)return(0,n.xEnsureFloat64)(e);let s=new Float64Array(e.length+i*2);for(let t=0;t<e.length;t++)s[t+i]=e[t];let c=i+e.length,l=2*i+e.length;switch(o){case`value`:for(let e=0;e<i;e++)s[e]=a;for(let e=c;e<l;e++)s[e]=a;break;case`duplicate`:for(let t=0;t<i;t++)s[t]=e[0];for(let t=c;t<l;t++)s[t]=e[e.length-1];break;case`circular`:for(let t=0;t<i;t++)s[t]=e[(e.length-i%e.length+t)%e.length];for(let t=0;t<i;t++)s[t+c]=e[t%e.length];break;default:throw Error(`unknown algorithm ${String(o)}`)}return s}e.xPadding=r}}),Mh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xVariance.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xVariance=void 0;var t=(cm(),Qp(am)),n=ph();function r(e,r={}){if(!(0,t.isAnyArray)(e))throw TypeError(`input must be an array`);let{unbiased:i=!0,mean:a=(0,n.xMean)(e)}=r,o=0;for(let t=0;t<e.length;t++){let n=e[t]-a;o+=n*n}return i?o/(e.length-1):o/e.length}e.xVariance=r}}),Nh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xStandardDeviation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xStandardDeviation=void 0;var t=Mh();function n(e,n={}){return Math.sqrt((0,t.xVariance)(e,n))}e.xStandardDeviation=n}}),Ph=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xParetoNormalization.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xParetoNormalization=void 0;var t=km(),n=Nh();function r(e){(0,t.xCheck)(e);let r=new Float64Array(e.length),i=Math.sqrt((0,n.xStandardDeviation)(e));for(let t=0;t<e.length;t++)r[t]=e[t]/i;return r}e.xParetoNormalization=r}}),Fh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRescale.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRescale=void 0;var t=vm(),n=km(),r=ah(),i=oh();function a(e,a={}){(0,n.xCheck)(e);let o=(0,t.getOutputArray)(a.output,e.length),s=(0,i.xMinValue)(e),c=(0,r.xMaxValue)(e);if(s===c)throw RangeError(`minimum and maximum input values are equal. Cannot rescale a constant array`);let{min:l=0,max:u=1}=a;if(l>=u)throw RangeError(`min option must be smaller than max option`);let d=(u-l)/(c-s);for(let t=0;t<e.length;t++)o[t]=(e[t]-s)*d+l;return o}e.xRescale=a}}),Ih=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRolling.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRolling=void 0;var t=km(),n=jh();function r(e,r,i={}){if((0,t.xCheck)(e),typeof r!=`function`)throw TypeError(`fct must be a function`);let{window:a=5,padding:o={}}=i,{size:s=a-1,algorithm:c,value:l}=o,u=(0,n.xPadding)(e,{size:s,algorithm:c,value:l}),d=[];for(let e=0;e<u.length-a+1;e++)d.push(r(u.subarray(e,e+a)));return d}e.xRolling=r}}),Lh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingAverage.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRollingAverage=void 0;var t=ph(),n=Ih();function r(e,r={}){return(0,n.xRolling)(e,t.xMean,r)}e.xRollingAverage=r}}),Rh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMax.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRollingMax=void 0;var t=ah(),n=Ih();function r(e,r={}){return(0,n.xRolling)(e,t.xMaxValue,r)}e.xRollingMax=r}}),zh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRollingMedian=void 0;var t=bm(),n=Ih();function r(e,r={}){return(0,n.xRolling)(e,t.xMedian,r)}e.xRollingMedian=r}}),Bh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRollingMin.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRollingMin=void 0;var t=oh(),n=Ih();function r(e,r={}){return(0,n.xRolling)(e,t.xMinValue,r)}e.xRollingMin=r}}),Vh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xRotate.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xRotate=void 0;function t(e,t){t%=e.length,t<0&&(t+=e.length);let n=new Float64Array(e.length);return n.set(e.slice(e.length-t)),n.set(e.slice(0,e.length-t),t),n}e.xRotate=t}}),Hh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSampling.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSampling=void 0;var t=km();function n(e,n={}){let{length:i=10}=n;if((0,t.xCheck)(e),i===e.length)return Float64Array.from(e);if(i>e.length)throw RangeError(`length must be smaller than the array length`);return r(e,i)}e.xSampling=n;function r(e,t){let n=new Float64Array(t),r=(e.length-1)/(t-1);for(let i=0;i<t;i++)n[i]=e[Math.round(i*r)];return n}}}),Uh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSequentialFillFromStep.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSequentialFillFromStep=void 0;var t=rh();function n(e,n={}){let{from:r,step:i,size:a}=e,{ArrayConstructor:o=Float64Array}=n,s=(0,t.createNumberArray)(o,a);for(let e=0;e<a;e++)s[e]=r+e*i;return s}e.xSequentialFillFromStep=n}}),Wh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSequentialFillFromTo.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSequentialFillFromTo=void 0;var t=Uh();function n(e,n={}){let{from:r,to:i,size:a}=e,o=(i-r)/(a-1);return(0,t.xSequentialFillFromStep)({from:r,step:o,size:a},n)}e.xSequentialFillFromTo=n}}),Gh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSortAscending.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSortAscending=void 0;function t(e){if(ArrayBuffer.isView(e))return e.sort();if(Array.isArray(e))return e.sort((e,t)=>e-t);throw Error(`trying to sort non array`)}e.xSortAscending=t}}),Kh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSortDescending.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSortDescending=void 0;function t(e){if(ArrayBuffer.isView(e))return e.sort().reverse();if(Array.isArray(e))return e.sort((e,t)=>t-e);throw Error(`trying to sort non array`)}e.xSortDescending=t}}),qh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xSubtract.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xSubtract=void 0;var t=(cm(),Qp(am));function n(e,n){let r=!1,i=0;if((0,t.isAnyArray)(n)){if(e.length!==n.length)throw Error(`size of array1 and array2 must be identical`)}else r=!0,i=Number(n);let a=new Float64Array(e.length);if(r)for(let t=0;t<e.length;t++)a[t]=e[t]-i;else for(let t=0;t<e.length;t++)a[t]=e[t]-n[t];return a}e.xSubtract=n}}),Jh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/xUniqueSorted.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xUniqueSorted=void 0;function t(e){return Float64Array.from(new Set(e)).sort()}e.xUniqueSorted=t}}),Q=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/x/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(vm(),e),n(ym(),e),n(xm(),e),n(Sm(),e),n(Cm(),e),n(Dm(),e),n(Om(),e),n(km(),e),n(Am(),e),n(jm(),e),n(Mm(),e),n(Em(),e),n(Nm(),e),n(Pm(),e),n(Tm(),e),n(Fm(),e),n(Im(),e),n(Lm(),e),n(Rm(),e),n(ih(),e),n(sh(),e),n(ch(),e),n(lh(),e),n(uh(),e),n(dh(),e),n(fh(),e),n(ah(),e),n(ph(),e),n(mh(),e),n(hh(),e),n(gh(),e),n(bm(),e),n(_h(),e),n(vh(),e),n(yh(),e),n(bh(),e),n(oh(),e),n(xh(),e),n(wm(),e),n(Eh(),e),n(Dh(),e),n(Oh(),e),n(Ah(),e),n(jh(),e),n(Ph(),e),n(Fh(),e),n(Ih(),e),n(Lh(),e),n(Rh(),e),n(zh(),e),n(Bh(),e),n(Vh(),e),n(Hh(),e),n(Uh(),e),n(Wh(),e),n(Gh(),e),n(Kh(),e),n(Nh(),e),n(qh(),e),n(kh(),e),n(Jh(),e),n(Mh(),e)}}),Yh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimPhaseCorrection.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.reimPhaseCorrection=void 0;function t(e,t=0,n=0,r={}){let{reverse:i=!1}=r;t=Number.isFinite(t)?t:0,n=Number.isFinite(n)?n:0;let a=e.re,o=e.im,s=e.re.length,c=t,l=n/s;i&&(l*=-1,c+=n);let u=2*Math.sin(l/2)**2,d=Math.sin(l),f=Math.cos(c),p=Math.sin(c),m=new Float64Array(s),h=new Float64Array(s);for(let e=0;e<s;e++){m[e]=a[e]*f-o[e]*p,h[e]=o[e]*f+a[e]*p;let t=f-(u*f+d*p),n=p-(u*p-d*f);f=t,p=n}return{re:m,im:h}}e.reimPhaseCorrection=t}}),Xh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimAutoPhaseCorrection.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.reimAutoPhaseCorrection=void 0;var t=Q(),n=_m(),r=Yh();function i(e,t={}){let{magnitudeMode:n=!0,minRegSize:i=30,factorNoise:c=3,maxDistanceToJoin:l=256,reverse:u=!1}=t,f=o(e,{maxDistanceToJoin:l,magnitudeMode:n,factorNoise:c}),{re:p,im:m}=e,h=p.length,g=u?e=>h-1-e:e=>e,_=0,v=-1,y=[];for(;v<h;){let e=[],t=[];for(;!f[g(++v)]&&v<h;)_=v;for(;f[g(v)]&&v<h;v+=2)e.push(p[g(v)]),t.push(m[g(v)]);e.length>i&&y.push(s(e,t,_))}let{ph1:b,ph0:x}=a(y.map(e=>e.x0/h),y.map(e=>e.ph0),y.map(e=>e.area/1e11));return{data:(0,r.reimPhaseCorrection)({re:p,im:m},d(x),d(b),{reverse:u}),ph0:x,ph1:b}}e.reimAutoPhaseCorrection=i;function a(e,t,n){let[r,i]=u(e,t,n),o=-1,s=-(2**53-1);for(let n=0;n<e.length;n++){let a=e[n]*r+i,c=Math.abs(t[n]-a);c>34&&s<c&&(o=n,s=c)}return o>-1?(e.splice(o,1),t.splice(o,1),n.splice(o,1),a(e,t,n)):{ph0:i,ph1:r}}function o(e,t){let r=t.magnitudeMode?(0,n.reimAbsolute)(e):e.re,i=l(c(r),t);return l(r,t).map((e,t)=>e&&i[t])}function s(e,t,n){let i=-180,a=180,o=10,s=0,c=2**53-1;for(;o>0;){let n=(a-i)/7;for(let o=i;o<=a;o+=n){let n=f((0,r.reimPhaseCorrection)({re:e,im:t},d(o),0).re);n<c&&([c,s]=[n,o])}i=s-n,a=s+n,o--}let l=(0,r.reimPhaseCorrection)({re:e,im:t},d(s),0),u=0,p=0;for(let t=0;t<e.length;t++)u+=l.re[t],p+=l.re[t]*(t+n);return{ph0:s,area:u,x0:p/u}}function c(e){let t=new Float64Array(e.length);for(let n=5;n<e.length-5;n++)t[n]=(42*(e[n+1]-e[n-1])+48*(e[n+2]-e[n-2])+27*(e[n+3]+e[n-3])+8*(e[n+4]-e[n-4])+e[n+5]-e[n-5])/512;for(let n=0;n<5;n++)t[n]=t[5],t[e.length-n-1]=t[e.length-6];return t}function l(e,n){let{maxDistanceToJoin:r,magnitudeMode:i,factorNoise:a}=n,o=new Uint8Array(e.length);for(let t=0;t<e.length;t++)o[t]=0;let s=!0;for(;s;){let n=a*(0,t.xNoiseSanPlot)(e,{magnitudeMode:i}).positive;s=!1;for(let t=0;t<e.length;t++)Math.abs(e[t])>n&&!o[t]&&(s=!0,o[t]=1)}let c=0,l=0;for(let t=0;t<e.length;t++)if(!o[t])c++;else{if(c<r)for(let e=0;e<=c;e++)o[l+e]=1;for(;o[++t]&&t<e.length;);l=t,c=0}return o}function u(e,t,n){let r=0,i=0,a=0,o=0,s=0;for(let c=0;c<e.length;c++)r+=e[c]*e[c]*n[c],i+=e[c]*n[c],a+=n[c],o+=e[c]*n[c]*t[c],s+=n[c]*t[c];let c=r*a-i*i,l=[[a/c,-i/c],[-i/c,r/c]];return[l[0][0]*o+l[0][1]*s,l[1][0]*o+l[1][1]*s]}function d(e){return e*Math.PI/180}function f(e){let t=0;for(let n of e)n<0&&(t-=n);return t}}}),Zh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/reimFFT.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.reimFFT=void 0;var n=t(zm()),r=Q();function i(e,t={}){let{inverse:r=!1,applyZeroShift:i=!1}=t,{re:o,im:s}=e,c=o.length,l=c<<1,u=new Float64Array(l);for(let e=0;e<l;e+=2)u[e]=o[e>>>1],u[e+1]=s[e>>>1];let d=new n.default(c),f=new Float64Array(l);r?(i&&(u=a(u,!0)),d.inverseTransform(f,u)):(d.transform(f,u),i&&(f=a(f)));let p=new Float64Array(c),m=new Float64Array(c);for(let e=0;e<l;e+=2)p[e>>>1]=f[e],m[e>>>1]=f[e+1];return{re:p,im:m}}e.reimFFT=i;function a(e,t){let n=t?Math.ceil(e.length/2):Math.floor(e.length/2);return(0,r.xRotate)(e,n)}}}),Qh=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/reim/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(_m(),e),n(Xh(),e),n(Zh(),e),n(Yh(),e)}}),$h=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyAlign.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyAlign=void 0;function t(e,t,n={}){let{delta:r=1,common:i=!0,x:a=`x1`}=n,o={x:[],y1:[],y2:[]},s=0,c=0,l=e.x.length,u=t.x.length;for(;s<l&&c<u;){let n=0;n=typeof r==`function`?r((e.x[s]+t.x[c])/2):r;let d=e.x[s]-t.x[c];if(Math.abs(d)>n)if(d>0){if(!i&&(o.x.push(t.x[c]),o.y1.push(0),o.y2.push(t.y[c]),c===u-1))for(;s<l;)o.x.push(e.x[s]),o.y1.push(e.y[s]),o.y2.push(0),s++;c++}else{if(!i&&(o.x.push(e.x[s]),o.y1.push(e.y[s]),o.y2.push(0),s===l-1))for(;c<u;)o.x.push(t.x[c]),o.y1.push(0),o.y2.push(t.y[c]),c++;s++}else{let n=(e.x[s]*e.y[s]+t.x[c]*t.y[c])/(e.y[s]+t.y[c]);switch(a){case`x1`:o.x.push(e.x[s]);break;case`x2`:o.x.push(t.x[c]);break;case`weighted`:o.x.push(n);break;default:throw Error(`unknown x option value: ${String(a)}`)}o.y1.push(e.y[s]),o.y2.push(t.y[c]),s++,c++}}return o}e.xyAlign=t}}),$=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCheck.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyCheck=void 0;var t=(cm(),Qp(am));function n(e,n={}){let{minLength:r}=n;if(typeof e!=`object`||!e||!(0,t.isAnyArray)(e.x)||!(0,t.isAnyArray)(e.y))throw Error(`data must be an object of x and y arrays`);if(e.x.length!==e.y.length)throw Error(`the x and y arrays must have the same length`);if(r&&e.x.length<r)throw Error(`data.x must have a length of at least ${r}`)}e.xyCheck=n}}),eg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCovariance.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyCovariance=void 0;var t=Q();function n(e,n={}){let{x:r,y:i}=e,{unbiased:a=!0}=n,o=(0,t.xMean)(r),s=(0,t.xMean)(i),c=0;for(let e=0;e<r.length;e++)c+=(r[e]-o)*(i[e]-s);return a?c/(r.length-1):c/r.length}e.xyCovariance=n}}),tg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMaxYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return{x:i[0],y:a[0],index:0};let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c={x:i[o],y:a[o],index:o};for(let e=o;e<=s;e++)a[e]>c.y&&(c={x:i[e],y:a[e],index:e});return c}e.xyMaxYPoint=r}}),ng=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyCumulativeDistributionStatistics.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyCumulativeDistributionStatistics=void 0;var t=Q(),n=$(),r=tg(),i=[.25,.5,.75];function a(e){(0,n.xyCheck)(e);let{x:a,y:o}=e;if(a.length===0)throw Error(`array length must be greater than 0`);let s=(0,t.xCumulative)(o),c=(0,t.xMaxValue)(s);for(let e=0;e<s.length;e++)s[e]/=c;let l={x0:0,x25:0,x50:0,x75:0,x100:0,xMode:0,xMean:0};l.x0=a[0],l.x100=a[a.length-1];let u=0;breakPoint:for(let e=1;e<s.length;e++)for(;i[u]<s[e];){let t=`x${i[u]*100}`;if(l[t]=a[e-1]+(a[e]-a[e-1])*((i[u]-s[e-1])/(s[e]-s[e-1])),u++,u===i.length)break breakPoint}l.xMode=(0,r.xyMaxYPoint)(e).x;let d=0,f=0;for(let e=0;e<a.length;e++)d+=a[e]*o[e],f+=o[e];return l.xMean=d/f,l}e.xyCumulativeDistributionStatistics=a}}),rg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEnsureFloat64.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyEnsureFloat64=void 0;var t=Q();function n(e){return{x:(0,t.xEnsureFloat64)(e.x),y:(0,t.xEnsureFloat64)(e.y)}}e.xyEnsureFloat64=n}}),ig=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEnsureGrowingX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyEnsureGrowingX=void 0;var t=Q(),n=$();function r(e){if((0,n.xyCheck)(e),(0,t.xIsMonotonic)(e.x)===1)return e;let r=Array.from(e.x),i=Array.from(e.y),a=-1/0,o=0;for(let e=0;e<r.length;e++)a<r[e]&&(o<e&&(r[o]=r[e],i[o]=i[e]),o++,a=r[e]);return r.length=o,i.length=o,{x:r,y:i}}e.xyEnsureGrowingX=r}}),ag=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/zonesNormalize.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.zonesNormalize=void 0;function t(e=[],n={}){let{exclusions:r=[]}=n,{from:i=-1/0,to:a=1/0}=n;i>a&&([i,a]=[a,i]),e=e.map(e=>e.from>e.to?{from:e.to,to:e.from}:{...e}).sort((e,t)=>e.from===t.from?e.to-t.to:e.from-t.from),e.length===0&&e.push({from:i,to:a});for(let t of e)i>t.from&&(t.from=i),a<t.to&&(t.to=a);if(e=e.filter(e=>e.from<=e.to),e.length===0)return[];let o=e[0],s=[o];for(let t=1;t<e.length;t++){let n=e[t];n.from<=o.to?o.to<n.to&&(o.to=n.to):(o=n,s.push(o))}if(r.length===0)return s;let c=t(r),l=0,u=[];for(let e=0;e<s.length;e++){let t=s[e];if(l===c.length){u.push(t);continue}for(;l<c.length&&c[l].to<=t.from;)l++;if(l===c.length){u.push(t);continue}if(t.to<c[l].from){u.push(t);continue}if(c[l].to>=t.to){if(c[l].from<=t.from)continue;u.push({from:c[l].to,to:t.to})}c[l].from>t.from&&u.push({from:t.from,to:c[l].from}),t.from=c[l].to,e--}return u}e.zonesNormalize=t}}),og=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/zonesWithPoints.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.zonesWithPoints=void 0;var t=ag();function n(e=[],n=10,r={}){if(e.length===0)return[];let i=(0,t.zonesNormalize)(e,r),a=[],o=i.reduce((e,t)=>e+(t.to-t.from),0)/n,s=0;for(let e=0;e<i.length-1;e++){let t=i[e],r=Math.min(Math.round((t.to-t.from)/o),n-s);a.push({...t,numberOfPoints:r}),s+=r}return a.push({...i[i.length-1],numberOfPoints:n-s}),a}e.zonesWithPoints=n}}),sg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/zones/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(ag(),e),n(og(),e)}}),cg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/equallySpacedSlot.js"(e){Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r,i){let a=e.length,o=(r-n)/(i>1?i-1:1),s=o/2,c=e[e.length-1]-e[e.length-2],l=n-s,u=new Float64Array(i),d=l,f=l+o,p=-Number.MAX_VALUE,m=0,h=e[0],g=t[0],_=0,v=!0,y=0,b=0,x=1,S=0;main:for(;;){if(p>=h)throw Error(`x must be a growing series`);for(;p-f>0;){if(v&&=(b++,!1),u[S]=b<=0?0:y/b,S++,S===i)break main;d=f,f+=o,y=0,b=0}p>d&&(y+=m,b++),(p===-Number.MAX_VALUE||_>1)&&b--,p=h,m=g,x<a?(h=e[x],g=t[x],x++):(h+=c,g=0,_++)}return u}e.default=t}}),lg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/integral.js"(e){Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r){return .5*n*t*t+r*t-(.5*n*e*e+r*e)}e.default=t}}),ug=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/utils/equallySpacedSmooth.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0});var n=t(lg());function r(e,t,r,a,o){let s=e.length,c=(a-r)/(o>1?o-1:1),l=c/2,u=new Float64Array(o),d=e[1]-e[0],f=e[s-1]-e[s-2],p=r-l,m=r+l,h=-(2**53-1),g=0,_=e[0]-d,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;main:for(;;){if(h>=_)throw Error(`x must be a growing series`);for(h<=p&&p<=_&&(E=(0,n.default)(0,p-h,b,g),S=y+E);_-m>=0;){if(E=(0,n.default)(0,m-h,b,g),C=y+E,u[T++]=(C-S)/c,T===o)break main;p=m,m+=c,S=C}y+=(0,n.default)(h,_,b,x),h=_,g=v,w<s?(_=e[w],v=t[w],w++):w===s&&(_+=f,v=0),b=i(h,g,_,v),x=-b*h+g}return u}e.default=r;function i(e,t,n,r){return(r-t)/(n-e)}}}),dg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyEquallySpaced.js"(e){var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.xyEquallySpaced=void 0;var n=rh(),r=sg(),i=t(cg()),a=t(ug()),o=$();function s(e,t={}){let{x:n,y:i}=e,a=n.length,{from:s=n[0],to:l=n[a-1],variant:u=`smooth`,numberOfPoints:d=100,exclusions:f=[],zones:p=[{from:s,to:l}]}=t;if(s>l)throw RangeError(`from should be larger than to`);if((0,o.xyCheck)(e),d<2)throw RangeError(`'numberOfPoints' option must be greater than 1`);let m=(0,r.zonesNormalize)(p,{from:s,to:l,exclusions:f}),h=(0,r.zonesWithPoints)(m,d,{from:s,to:l}),g=[],_=[];for(let e of h){e.numberOfPoints||=0;let t=c(Array.from(n),Array.from(i),e.from,e.to,e.numberOfPoints,u);g=g.concat(t.x),_=_.concat(t.y)}return{x:g,y:_}}e.xyEquallySpaced=s;function c(e,t,r,o,s,c){if(s<1)throw RangeError(`the number of points must be at least 1`);let l=c===`slot`?Array.from((0,i.default)(e,t,r,o,s)):Array.from((0,a.default)(e,t,r,o,s));return{x:Array.from((0,n.createFromToArray)({from:r,to:o,length:s})),y:l}}}}),fg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyExtract.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyExtract=void 0;var t=sg(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{zones:o}=r;if(o=(0,t.zonesNormalize)(o),i===void 0||a===void 0||!Array.isArray(o)||o.length===0)return e;let s=[],c=[],l=o[0],u=0;loop:for(let e=0;e<i.length;e++){for(;l.to<i[e];)if(u++,l=o[u],!l){e=i.length;break loop}i[e]>=l.from&&(s.push(i[e]),c.push(a[e]))}return{x:s,y:c}}e.xyExtract=r}}),pg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilter.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFilter=void 0;function t(e,t={}){let{x:n,y:r}=e,{filter:i}=t,a=[],o=[];for(let e=0;e<n.length;e++)(!i||i(n[e],r[e]))&&(a.push(n[e]),o.push(r[e]));return{x:a,y:o}}e.xyFilter=t}}),mg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterMinYValue.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFilterMinYValue=void 0;var t=Q();function n(e,n){if(n===void 0)return e;let{x:r,y:i}=e,{min:a,max:o}=(0,t.xMinMaxValues)(i),s=o*n;if(a>=s)return e;let c=[],l=[];for(let e=0;e<r.length;e++)i[e]>=s&&(c.push(r[e]),l.push(i[e]));return{x:c,y:l}}e.xyFilterMinYValue=n}}),hg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterTopYValues.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFilterTopYValues=void 0;var t=Q();function n(e,n){if(n===void 0||n>e.x.length)return e;let{x:r,y:i}=e,a=[],o=[],s=(0,t.xSortDescending)(i.slice()),c=s[n-1],l=0;for(let e=0;e<n;e++)s[e]===c&&l++;for(let e=0;e<r.length;e++)i[e]>c?(a.push(r[e]),o.push(i[e])):i[e]===c&&(l--,l>=0&&(a.push(r[e]),o.push(i[e])));return{x:a,y:o}}e.xyFilterTopYValues=n}}),gg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFilterX=void 0;var t=sg();function n(e,n={}){let{x:r,y:i}=e,{from:a=r[0],to:o=r[r.length-1],zones:s=[{from:a,to:o}],exclusions:c=[]}=n,l=(0,t.zonesNormalize)(s,{from:a,to:o,exclusions:c}),u=0,d=[],f=[],p=0;for(;p<r.length;){if(r[p]<=l[u].to&&r[p]>=l[u].from)d.push(r[p]),f.push(i[p]);else if(r[p]>l[u].to&&(u++,!l[u]))break;p++}return{x:d,y:f}}e.xyFilterX=n}}),_g=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFilterXPositive.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFilterXPositive=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[],a=[];if(n===void 0||r===void 0)return{x:i,y:a};for(let e=0;e<n.length;e++)n[e]>0&&(i.push(n[e]),a.push(r[e]));return{x:i,y:a}}e.xyFilterXPositive=n}}),vg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyFindClosestPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyFindClosestPoint=void 0;var t=Q();function n(e,n){let{x:r,y:i}=e,a=(0,t.xFindClosestIndex)(r,n);return{x:r[a],y:i[a]}}e.xyFindClosestPoint=n}}),yg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyGetNMaxY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyGetNMaxY=void 0;var t=$();function n(e,n){if((0,t.xyCheck)(e),e.x.length<=n)return e;{let t=new Float64Array(n),r=new Float64Array(n),i=Float64Array.from(e.y).sort().reverse()[n-1],a=0;for(let o=0;o<e.x.length;o++)if(e.y[o]>=i&&(t[a]=e.x[o],r[a]=e.y[o],a++),a===n)return{x:t,y:r};return e}}e.xyGetNMaxY=n}}),bg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyGrowingX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyGrowingX=void 0;function t(e){let{x:t,y:n}=e;if(t.length!==n.length)throw TypeError(`length of x and y must be identical`);return t.length<2||t[0]<t[1]?e:{x:t.slice(0).reverse(),y:n.slice(0).reverse()}}e.xyGrowingX=t}}),xg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyIntegral.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyIntegral=void 0;var t=Q(),n=$();function r(e,r={}){let{reverse:i=!1}=r;(0,n.xyCheck)(e,{minLength:1});let{x:a,y:o}=e,{fromIndex:s,toIndex:c}=(0,t.xGetFromToIndex)(a,r),l=0,u={x:new Float64Array(c-s+1),y:new Float64Array(c-s+1)},d=0;if(i){u.y[d]=0,u.x[d++]=a[c];for(let e=c;e>s;e--)l+=(a[e]-a[e-1])*(o[e-1]+o[e])/2,u.x[d]=a[e-1],u.y[d++]=l;u.x.reverse(),u.y.reverse()}else{u.y[d]=0,u.x[d++]=a[s];for(let e=s;e<c;e++)l+=(a[e+1]-a[e])*(o[e+1]+o[e])/2,u.x[d]=a[e+1],u.y[d++]=l}return u}e.xyIntegral=r}}),Sg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyIntegration.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyIntegration=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return 0;let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=0;for(let e=o;e<s;e++)c+=(i[e+1]-i[e])*(a[e+1]+a[e])/2;return c}e.xyIntegration=r}}),Cg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyJoinX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyJoinX=void 0;var t=$();function n(e,n={}){(0,t.xyCheck)(e);let{delta:r=1}=n,i=typeof r==`function`,a=Array.from(e.x),o=Array.from(e.y);if(a.length<2)return{x:a,y:o};let s=0;for(let e=1;e<a.length;e++)a[e]-a[e-1]<=(i?r((a[e]+a[e-1])/2):r)?(o[s]!==0||o[e]!==0)&&(a[s]=(a[s]*o[s]+a[e]*o[e])/(o[s]+o[e]),o[s]+=o[e]):(s++,a[s]=a[e],o[s]=o[e]);return a.length=s+1,o.length=s+1,{x:a,y:o}}e.xyJoinX=n}}),wg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMassCenter.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMassCenter=void 0;var t=Lm(),n=Kg();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e,{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=0,l=0;for(let e=o;e<=s;e++)l+=i[e]*a[e],c+=a[e];if(c===0)throw Error(`Sum of Ys can not be zero.`);return l/c}e.xyMassCenter=r}}),Tg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMassCenterVector.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMassCenterVector=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:2});let{depth:a=5}=r,{weightedIntegral:o,integral:s}=i(e),c=new Float64Array((1<<a)-1),l=new Int32Array((1<<a)-1);l[0]=e.x.length-1;let u=new Int32Array((1<<a)-1);u[0]=-1;let d=0;for(let n=0;n<a;n++)for(let r=0;r<1<<n;r++){let i=u[d],f=l[d],p=i===-1?s[f]:s[f]-s[i],m=0;if(m=p===0?(e.x[f]+e.x[i])/2:i===-1?o[f]/p:(o[f]-o[i])/p,c[d++]=m,n<a-1){let a=(1<<n+1)+r*2-1,o=(0,t.xFindClosestIndex)(e.x,m);o===i&&o++,u[a]=i,l[a]=o,o===f&&o--,u[a+1]=o,l[a+1]=f}}return c}e.xyMassCenterVector=r;function i(e){let{x:t,y:n}=e,r=new Float64Array(t.length),i=new Float64Array(t.length),a=(t[1]-t[0])*n[0],o=a;i[0]=o;let s=a*t[0];r[0]=s;for(let e=1;e<t.length-1;e++){let a=(t[e+1]-t[e-1])*n[e]/2,c=t[e];o+=a,i[e]=o,s+=a*c,r[e]=s}let c=(t[t.length-1]-t[t.length-2])*n[n.length-1];return o+=c,i[t.length-1]=o,s+=c*t[t.length-1],r[t.length-1]=s,{integral:i,weightedIntegral:r}}}}),Eg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxClosestYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMaxClosestYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{target:o}=r,{targetIndex:s}=r;s===void 0&&(s=o===void 0?0:(0,t.xFindClosestIndex)(i,o));let c=-(2**53-1),l=s,u=a[s];for(;l!==c;)c=l,l>0&&a[l-1]>u?l--:l<i.length-1&&a[l+1]>u&&l++,u=a[l];return{x:i[l],y:a[l],index:l}}e.xyMaxClosestYPoint=r}}),Dg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaximaY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMaximaY=void 0;var t=$();function n(e){(0,t.xyCheck)(e,{minLength:2});let{x:n,y:r}=e,i=[],a=-1;for(let e=1;e<n.length-1;e++)if(r[e-1]<r[e]&&r[e+1]<r[e])i.push({x:n[e],y:r[e],index:e});else if(r[e-1]<r[e]&&r[e+1]===r[e])a=e;else if(r[e-1]===r[e]&&r[e+1]<r[e]){let t=Math.floor((e+a)/2);i.push({x:n[t],y:r[t],index:t})}return i}e.xyMaximaY=n}}),Og=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxMerge.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMaxMerge=void 0;function t(e,t={}){let{x:n,y:r}=e,{groupWidth:i=.001}=t,a={x:[],y:[]},o={x:[],y:[]},s=0,c=0;for(;c<n.length;)s===0||n[c]-a.x[s-1]>i?(o.x.push(n[c]),o.y.push(r[c]),a.x.push(n[c]),a.y.push(r[c]),c++,s++):(r[c]>o.y[s-1]&&(o.x[s-1]=n[c],o.y[s-1]=r[c]),a.x[s-1]=n[c],a.y[s-1]+=r[c],c++);return a.x=o.x.slice(),a}e.xyMaxMerge=t}}),kg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMaxY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMaxY=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c=a[o];for(let e=o;e<=s;e++)a[e]>c&&(c=a[e]);return c}e.xyMaxY=r}}),Ag=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMedian=void 0;function t(e){let{x:t,y:n}=e,r=0,i=0,a;if(t.length===0)return NaN;if(t.length===1)return t[0];for(a=0;a<n.length;a++)r+=n[a];for(a=0;a<n.length;a++){if(i+=n[a],i>r/2)return t[a];if(i===r/2)return .5*(t[a]+t[a+1])}return NaN}e.xyMedian=t}}),jg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMergeByCentroids.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMergeByCentroids=void 0;function t(e,t,n={}){let{window:r=.01}=n,i={x:Float64Array.from(t),y:new Float64Array(t.length).fill(0)},a=0,o=0;for(;a<e.x.length&&o<t.length;){let n=e.x[a]-t[o];Math.abs(n)<r?i.y[o]+=e.y[a++]:n<0?a++:o++}return i}e.xyMergeByCentroids=t}}),Mg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinClosestYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMinClosestYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{target:o}=r,{targetIndex:s}=r;s===void 0&&(s=o===void 0?0:(0,t.xFindClosestIndex)(i,o));let c=-(2**53-1),l=s,u=a[s];for(;l!==c;)c=l,l>0&&a[l-1]<u?l--:l<i.length-1&&a[l+1]<u&&l++,u=a[l];return{x:i[l],y:a[l],index:l}}e.xyMinClosestYPoint=r}}),Ng=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinimaY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMinimaY=void 0;var t=$();function n(e){(0,t.xyCheck)(e,{minLength:2});let{x:n,y:r}=e,i=[],a=-1;for(let e=1;e<n.length-1;e++)if(r[e-1]>r[e]&&r[e+1]>r[e])i.push({x:n[e],y:r[e],index:e});else if(r[e-1]>r[e]&&r[e+1]===r[e])a=e;else if(r[e-1]===r[e]&&r[e+1]>r[e]){let t=Math.floor((e+a)/2);i.push({x:n[t],y:r[t],index:t})}return i}e.xyMinimaY=n}}),Pg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyMinYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyMinYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e,{minLength:1});let{x:i,y:a}=e;if(i.length===1)return{x:i[0],y:a[0],index:0};let{fromIndex:o,toIndex:s}=(0,t.xGetFromToIndex)(i,r),c={x:i[o],y:a[o],index:o};for(let e=o;e<=s;e++)a[e]<c.y&&(c={x:i[e],y:a[e],index:e});return c}e.xyMinYPoint=r}}),Fg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyPeakInfo.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyPeakInfo=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e;if(i===void 0||a===void 0||i.length<3)return;let{target:o}=r,{targetIndex:s}=r;if(s===void 0&&o!==void 0&&(s=(0,t.xFindClosestIndex)(i,o)),s===void 0)throw Error(`must specify target or targetIndex`);let c=s,l=a[c]-a[c+1],u=l<0?-1:1;for(l*=u;c<i.length-1;){c++;let e=(a[c]-a[c+1])*u;if(e<l)break;l=e}let d={x:i[c],y:a[c]};for(c=s,l=(a[c]-a[c-1])*u;c>1;){c--;let e=(a[c]-a[c-1])*u;if(e<l)break;l=e}let f={x:i[c],y:a[c]};return{inflectionBefore:f,inflectionAfter:d,extrema:{x:i[s],y:a[s]},inflectionMiddle:{x:(f.x+d.x)/2,y:(f.y+d.y)/2},width:Math.abs(f.x-d.x)}}e.xyPeakInfo=r}}),Ig=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRealMaxYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyRealMaxYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,o=(0,t.xGetTargetIndex)(i,r);if(a[o-1]>0&&a[o+1]>0&&a[o]>=a[o-1]&&a[o]>=a[o+1]){let e=20*Math.log10(a[o-1]),t=20*Math.log10(a[o]),n=20*Math.log10(a[o+1]),r=.5*(e-n)/(e-2*t+n);return{x:i[o]+(i[o]-i[o-1])*r,y:a[o]-.25*(a[o-1]-a[o+1])*r,index:o}}else return{x:i[o],y:a[o],index:o}}e.xyRealMaxYPoint=r}}),Lg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRealMinYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyRealMinYPoint=void 0;var t=Q(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,o=(0,t.xGetTargetIndex)(i,r);if(a[o-1]<0&&a[o+1]<0&&a[o]<=a[o-1]&&a[o]<=a[o+1]){let e=20*Math.log10(-a[o-1]),t=20*Math.log10(-a[o]),n=20*Math.log10(-a[o+1]),r=.5*(e-n)/(e-2*t+n);return{x:i[o]+(i[o]-i[o-1])*r,y:a[o]-.25*(a[o-1]-a[o+1])*r,index:o}}else return{x:i[o],y:a[o],index:o}}e.xyRealMinYPoint=r}}),Rg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyReduce.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyReduce=void 0;var t=Q(),n=sg(),r=$();function i(e,i={}){(0,r.xyCheck)(e);let{x:o,y:s}=e,{from:c=o[0],to:l=o[o.length-1],nbPoints:u=4001,optimize:d=!1}=i,{zones:f=[]}=i;f=(0,n.zonesNormalize)(f,{from:c,to:l}),f.length===0&&(f=[{from:c,to:l}]);let p=f,m=0;for(let e of p)e.fromIndex=(0,t.xFindClosestIndex)(o,e.from),e.toIndex=(0,t.xFindClosestIndex)(o,e.to),e.fromIndex>0&&o[e.fromIndex]>e.from&&e.fromIndex--,e.toIndex<o.length-1&&o[e.toIndex]<e.to&&e.toIndex++,e.nbPoints=e.toIndex-e.fromIndex+1,m+=e.nbPoints;if(m<=u)return a(o,s,p,m);let h=u/m,g=0;for(let e=0;e<p.length-1;e++){let t=p[e];t.nbPoints=Math.round(t.nbPoints*h),g+=t.nbPoints}p[p.length-1].nbPoints=u-g;let _=[],v=[];for(let e of p)e.nbPoints&&y(e.fromIndex,e.toIndex,e.nbPoints);return{x:_,y:v};function y(e,t,n){if(n===1){_.push(o[Math.round((t-e)/2)]),v.push(s[Math.round((t-e)/2)]);return}if(n===2){_.push(o[e],o[t]),v.push(s[e],s[t]);return}_.push(o[e]),v.push(s[e]),n=n%2==0?n/2+1:(n-1)/2+1;let r=(o[t]-o[e])/(n-1),i=o[e]+r,a=!0,c=1/0,l=-1/0;for(let n=e+1;n<=t;n++)a?(c=s[n],l=s[n],a=!1):(s[n]<c&&(c=s[n]),s[n]>l&&(l=s[n])),(o[n]>=i||n===t)&&(d?c>v[_.length-1]||(l<v[_.length-1]?l=c:(_.push(i-r/2),v.push(c))):(_.push(i-r/2),v.push(c)),_.push(i),v.push(l),i+=r,a=!0)}}e.xyReduce=i;function a(e,t,n,r){let i=new Float64Array(r),a=new Float64Array(r),o=0;for(let r of n)for(let n=r.fromIndex;n<r.toIndex+1;n++)i[o]=e[n],a[o]=t[n],o++;return{x:i,y:a}}}}),zg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyRolling.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyRolling=void 0;var t=Q();function n(e,n,r={}){let{x:i,y:a}=e;return a=(0,t.xRolling)(a,n,r),i.length!==a.length&&(i=(0,t.xRollingAverage)(i,r)),{x:i,y:a}}e.xyRolling=n}}),Bg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xySetYValue.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xySetYValue=void 0;var t=sg(),n=$();function r(e,r={}){(0,n.xyCheck)(e);let{x:i,y:a}=e,{value:o=0}=r,{zones:s}=r;if(!Array.isArray(s)||s.length===0)return e;s=(0,t.zonesNormalize)(s);let c=i.slice(),l=a.slice(),u=s[0],d=0;loop:for(let e=0;e<i.length;e++){for(;u.to<i[e];)if(d++,u=s[d],!u){e=i.length;break loop}i[e]>=u.from&&(l[e]=o)}return{x:c,y:l}}e.xySetYValue=r}}),Vg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xySortX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xySortX=void 0;var t=Q();function n(e){let{x:n,y:r}=e;if((0,t.xIsMonotonic)(n)&&n.length>1)return n[0]<n[1]?{x:Float64Array.from(n),y:Float64Array.from(r)}:{x:Float64Array.from(n).reverse(),y:Float64Array.from(r).reverse()};let i=n.map((e,t)=>({x:e,y:r[t]})).sort((e,t)=>e.x-t.x),a={x:new Float64Array(n.length),y:new Float64Array(r.length)};for(let e=0;e<n.length;e++)a.x[e]=i[e].x,a.y[e]=i[e].y;return a}e.xySortX=n}}),Hg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyToXYArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyToXYArray=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[];for(let e=0;e<n.length;e++)i.push([n[e],r[e]]);return i}e.xyToXYArray=n}}),Ug=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyToXYObject.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyToXYObject=void 0;var t=$();function n(e){(0,t.xyCheck)(e);let{x:n,y:r}=e,i=[];for(let e=0;e<n.length;e++)i.push({x:n[e],y:r[e]});return i}e.xyToXYObject=n}}),Wg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyUniqueX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyUniqueX=void 0;var t=$(),n=Vg();function r(e,r={}){(0,t.xyCheck)(e);let{algorithm:o=`average`,isSorted:s=!0}=r;switch(s||(e=(0,n.xySortX)(e)),o){case`average`:return i(e);case`sum`:return a(e);default:throw Error(`unknown algorithm: ${String(o)}`)}}e.xyUniqueX=r;function i(e){let t=[],n=[],r=e.y[0],i=1;for(let a=1;a<e.x.length;a++)e.x[a]!==e.x[a-1]&&(t.push(e.x[a-1]),n.push(r/i),r=0,i=0),r+=e.y[a],i++;return t.push(e.x[e.x.length-1]),n.push(r/i),{x:t,y:n}}function a(e){let t=[],n=[],r=e.y[0];for(let i=1;i<e.x.length;i++)e.x[i]!==e.x[i-1]&&(t.push(e.x[i-1]),n.push(r),r=0),r+=e.y[i];return t.push(e.x[e.x.length-1]),n.push(r),{x:t,y:n}}}}),Gg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/xyWeightedMerge.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyWeightedMerge=void 0;function t(e,t={}){let{x:n,y:r}=e,{groupWidth:i=.001}=t,a={x:[],y:[]},o={x:[],y:[]},s=0,c=0;for(;c<n.length;)s===0||n[c]-a.x[s-1]>i?(o.x.push(n[c]*r[c]),o.y.push(r[c]),a.x.push(n[c]),a.y.push(r[c]),c++,s++):(o.x[s-1]+=n[c]*r[c],o.y[s-1]+=r[c],a.x[s-1]=n[c],a.y[s-1]+=r[c],c++);for(let e=0;e<a.x.length;e++)a.x[e]=o.x[e]/o.y[e];return a}e.xyWeightedMerge=t}}),Kg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n($h(),e),n($(),e),n(eg(),e),n(ng(),e),n(rg(),e),n(ig(),e),n(dg(),e),n(fg(),e),n(pg(),e),n(mg(),e),n(hg(),e),n(gg(),e),n(_g(),e),n(vg(),e),n(yg(),e),n(bg(),e),n(xg(),e),n(Sg(),e),n(Cg(),e),n(wg(),e),n(Tg(),e),n(Eg(),e),n(Dg(),e),n(Og(),e),n(kg(),e),n(tg(),e),n(Ag(),e),n(jg(),e),n(Mg(),e),n(Ng(),e),n(Pg(),e),n(Fg(),e),n(Ig(),e),n(Lg(),e),n(Rg(),e),n(zg(),e),n(Bg(),e),n(Vg(),e),n(Hg(),e),n(Ug(),e),n(Wg(),e),n(Gg(),e)}}),qg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy2/xy2ToXY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xy2ToXY=void 0;function t(e){let t={x:[],y:[]};for(let n of e)t.x.push(n[0]),t.y.push(n[1]);return t}e.xy2ToXY=t}}),Jg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xy2/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(qg(),e)}}),Yg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/xreimSortX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xreimSortX=void 0;function t(e){let{x:t,re:n,im:r}=e;if(t.length!==n.length||t.length!==r.length)throw TypeError(`length of x, re and im must be identical`);return t.length<2||t[0]<t[1]?e:{x:t.slice(0).reverse(),re:n.slice(0).reverse(),im:r.slice(0).reverse()}}e.xreimSortX=t}}),Xg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/xreimZeroFilling.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xreimZeroFilling=void 0;function t(e,t){let n=e.x.length;if(t===0||n===t)return e;if(n>t)return{x:e.x.slice(0,t),re:e.re.slice(0,t),im:e.im.slice(0,t)};let r=e.x,i=e.re,a=e.im,o=new Float64Array(t),s=new Float64Array(t),c=new Float64Array(t);for(let e=0;e<n;e++)o[e]=r[e],s[e]=i[e],c[e]=a[e];let l=(r[r.length-1]-r[0])/(n-1);for(let e=n;e<t;e++)o[e]=o[e-1]+l;return{x:o,re:s,im:c}}e.xreimZeroFilling=t}}),Zg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xreim/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(Yg(),e),n(Xg(),e)}}),Qg=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/utils/getSlots.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSlots=void 0;function t(e,t={}){let{delta:n=1}=t,r=typeof n==`function`,i=Float64Array.from(e.map(e=>e.x).flat()).sort();if(i.length===0)throw Error(`can not process empty arrays`);let a={from:i[0],to:i[0],average:i[0],sum:i[0],number:1},o=[a];for(let e=1;e<i.length;e++){let t=r?n(i[e]):n;i[e]-a.to<=t?(a.to=i[e],a.number++,a.sum+=i[e],a.average=a.sum/a.number):(a={from:i[e],to:i[e],average:i[e],sum:i[e],number:1},o.push(a))}return o}e.getSlots=t}}),$g=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayAlign.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyArrayAlign=void 0;var t=Kg(),n=Qg();function r(e,r={}){let{delta:a=1,requiredY:o=!1}=r;e=e.map(e=>(0,t.xyJoinX)(e,{delta:a}));let s=(0,n.getSlots)(e,{delta:a}),c=Float64Array.from(s.map(e=>e.average)),l=Array.from(e,()=>new Float64Array(c.length)),u=new Uint32Array(e.length);for(let t=0;t<s.length;t++){let n=s[t];for(let r=0;r<e.length;r++){let i=e[r];for(;u[r]<i.x.length&&i.x[u[r]]<=n.to;)l[r][t]+=i.y[u[r]],u[r]++}}return o?i(c,l):{x:c,ys:l}}e.xyArrayAlign=r;function i(e,t){let n=[],r=Array.from(t,()=>[]);for(let i=0;i<e.length;i++)if(t.every(e=>e[i]!==0)){n.push(e[i]);for(let e=0;e<t.length;e++)r[e].push(t[e][i])}return{x:n,ys:r}}}}),e_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayWeightedMerge.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyArrayWeightedMerge=void 0;function t(e,t={}){let{delta:r=1}=t;if(typeof r==`number`){let e=r;r=()=>e}if(e=e.filter(e=>e.x.length>0),e.length===0)return{x:[],y:[]};let i=[],a=[],o=Array(e.length).fill(0),s={x:0,y:0};n(e,o,s);let c={maxX:s.x+r(s.x),sumY:s.y,sumXY:s.y*s.x};for(;e.length>0;)n(e,o,s),s.x<=c.maxX||(c.sumY>0&&(i.push(c.sumXY/c.sumY),a.push(c.sumY)),c.sumY=0,c.sumXY=0),c.sumY+=s.y,c.sumXY+=s.x*s.y,c.maxX=s.x+r(s.x),e.length===0&&c.sumY>0&&(i.push(c.sumXY/c.sumY),a.push(c.sumY));return{x:i,y:a}}e.xyArrayWeightedMerge=t;function n(e,t,n){let r=0,i=e[0].x[t[0]];for(let n=1;n<e.length;n++){let a=e[n].x[t[n]];a<i&&(i=a,r=n)}n.x=i,n.y=e[r].y[t[r]],t[r]++,t[r]===e[r].x.length&&(t.splice(r,1),e.splice(r,1))}}}),t_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/utils/getSlotsToFirst.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSlotsToFirst=void 0;var t=e_();function n(e,n={}){let{delta:r=1}=n,i=typeof r==`function`,a=e[0].x,o=[];for(let e of a){let t=i?r(e):r;o.push({from:e-t,to:e+t,value:e})}let s=(0,t.xyArrayWeightedMerge)(e.slice(1),n).x,c=0;for(let e of o)for(;s[c]<e.to&&c<s.length;){if(s[c]<e.from){let e=i?r(s[c]):r;o.push({from:s[c]-e,to:s[c]+e,value:s[c]})}c++}for(let e=c;e<s.length;e++){let t=i?r(s[e]):r;o.push({from:s[e]-t,to:s[e]+t,value:s[e]})}o.sort((e,t)=>e.value-t.value);for(let e=0;e<o.length-1;e++)if(o[e].to>o[e+1].from){let t=(o[e].value+o[e+1].value)/2;o[e].to=t,o[e+1].from=t}return o}e.getSlotsToFirst=n}}),n_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayAlignToFirst.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyArrayAlignToFirst=void 0;var t=t_();function n(e,n={}){let{delta:r=1}=n,i=(0,t.getSlotsToFirst)(e,{delta:r}),a=Float64Array.from(i.map(e=>e.value)),o=Array.from(e,()=>new Float64Array(a.length)),s=new Uint32Array(e.length);for(let t=0;t<i.length;t++){let n=i[t];for(let r=0;r<e.length;r++){let i=e[r];for(;s[r]<i.x.length&&i.x[s[r]]<n.to;)o[r][t]+=i.y[s[r]],s[r]++}}return{x:a,ys:o}}e.xyArrayAlignToFirst=n}}),r_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/xyArrayMerge.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyArrayMerge=void 0;var t=Kg(),n=Qg();function r(e,r={}){let{delta:i=1}=r;e=e.map(e=>(0,t.xyJoinX)(e,{delta:i}));let a=(0,n.getSlots)(e,{delta:i}),o=Float64Array.from(a.map(e=>e.average)),s=new Float64Array(o.length),c=new Uint32Array(e.length);for(let t=0;t<a.length;t++){let n=a[t];for(let r=0;r<e.length;r++){let i=e[r];for(;c[r]<i.x.length&&i.x[c[r]]<=n.to;)s[t]+=i.y[c[r]],c[r]++}}return{x:o,y:s}}e.xyArrayMerge=r}}),i_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyArray/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n($g(),e),n(n_(),e),n(r_(),e),n(e_(),e)}}),a_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectCheck.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectCheck=void 0;function t(e){if(!Array.isArray(e)||e.length>0&&(typeof e[0].x!=`number`||typeof e[0].y!=`number`))throw Error(`points must be an array of {x,y} objects`)}e.xyObjectCheck=t}}),o_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMaxXPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectMaxXPoint=void 0;var t=a_();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].x>n.x&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMaxXPoint=n}}),s_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMinXPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectMinXPoint=void 0;var t=a_();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].x<n.x&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMinXPoint=n}}),c_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectBestPoints.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectBestPoints=void 0;var t=o_(),n=s_();function r(e,r={}){let{from:i=(0,n.xyObjectMinXPoint)(e).x,to:a=(0,t.xyObjectMaxXPoint)(e).x,limit:o=20,threshold:s=.01,numberCloseSlots:c=50,numberSlots:l=10}=r,u=(a-i)/l,d=(a-i)/c,f=e.filter(e=>e.x>=i&&e.x<=a).map(e=>({point:e,monoisotopic:!1}));f=f.sort((e,t)=>e.monoisotopic&&!t.monoisotopic?-1:t.monoisotopic&&!e.monoisotopic?1:t.point.y-e.point.y);let p=[];if(f.length===0)return[];let m=f[0].point.y*s;peakLoop:for(let e of f){if(e.point.y<m){if(e.monoisotopic)continue;break}let t=!1;for(let n of p){if(Math.abs(n.x-e.point.x)<d)continue peakLoop;Math.abs(n.x-e.point.x)<u&&(t=!0)}let n=JSON.parse(JSON.stringify(e.point));if(n.close=t,p.push(n),p.length===o)break}return p.sort((e,t)=>e.x-t.x)}e.xyObjectBestPoints=r}}),l_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectJoinX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectJoinX=void 0;function t(e,t={}){let{xError:n=2**-52}=t,r=[],i={x:-(2**53-1),y:0};for(let t of e)t.x-i.x<=n?(i.y!==0||t.y!==0)&&(i.x=t.y/(i.y+t.y)*(t.x-i.x)+i.x,i.y+=t.y):(i={x:t.x,y:t.y},r.push(i));return r}e.xyObjectJoinX=t}}),u_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMaxYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectMaxYPoint=void 0;var t=a_();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].y>n.y&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMaxYPoint=n}}),d_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectMinYPoint.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectMinYPoint=void 0;var t=a_();function n(e=[]){if((0,t.xyObjectCheck)(e),e.length===0)return{x:0,y:0};let n={x:e[0].x,y:e[0].y,index:0};for(let t=1;t<e.length;t++)e[t].y<n.y&&(n={x:e[t].x,y:e[t].y,index:t});return n}e.xyObjectMinYPoint=n}}),f_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSlotX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectSlotX=void 0;function t(e,t={}){let{slotWidth:n=1}=t,r=n/2,i=[],a={x:-1/0,y:0};for(let t of e){let e=t.x-(t.x+r)%n+r;Math.abs(a.x-e)>2**-52&&(a={x:e,y:0},i.push(a)),a.y+=t.y}return i}e.xyObjectSlotX=t}}),p_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSortX.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectSortX=void 0;function t(e){return e.sort((e,t)=>e.x-t.x)}e.xyObjectSortX=t}}),m_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectSumY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectSumY=void 0;var t=a_();function n(e=[]){(0,t.xyObjectCheck)(e);let n=0;for(let t of e)n+=t.y;return n}e.xyObjectSumY=n}}),h_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/xyObjectToXY.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xyObjectToXY=void 0;function t(e){return{x:e.map(e=>e.x),y:e.map(e=>e.y)}}e.xyObjectToXY=t}}),g_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/xyObject/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(c_(),e),n(a_(),e),n(l_(),e),n(o_(),e),n(u_(),e),n(s_(),e),n(d_(),e),n(f_(),e),n(p_(),e),n(m_(),e),n(h_(),e)}}),__=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixAbsoluteMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixAbsoluteMedian=void 0;var t=Q();function n(e){let n=e[0].length,r=new Float64Array(e.length*n);for(let t=0;t<e.length;t++){let i=t*n;for(let a=0;a<n;a++){let n=e[t][a];r[i+a]=n<0?-n:n}}return(0,t.xMedian)(r)}e.matrixAbsoluteMedian=n}}),v_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCreateEmpty.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixCreateEmpty=void 0;var t=rh();function n(e){let{matrix:n,nbRows:r=n?.length||1,nbColumns:i=n?.[0].length||1,ArrayConstructor:a=Float64Array}=e,o=[];for(let e=0;e<r;e++)o.push((0,t.createNumberArray)(a,i));return o}e.matrixCreateEmpty=n}}),y_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixApplyNumericalEncoding.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixApplyNumericalEncoding=void 0;var t=Q(),n=v_();function r(e,r){let i=(0,n.matrixCreateEmpty)({nbRows:e.length,nbColumns:e[0].length,ArrayConstructor:Array}),a=[];for(let e in r)a.push(r[e]);let o=(0,t.xMaxValue)(a);for(let e=0;e<i.length;e++)for(let t=0;t<i[0].length;t++)typeof i[e][t]==`string`&&(i[e][t]in r?i[e][t]=r[i[e][t]]:(o++,r[i[e][t]]=o,i[e][t]=o));return i}e.matrixApplyNumericalEncoding=r}}),b_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixAutoCorrelation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixAutoCorrelation=void 0;var t=Q();function n(e,n=0){let r=e.length,i=e[0].length;if(r<2)throw Error(`can not calculate info if matrix contains less than 2 rows`);let a=new Float64Array(r),o=new Float64Array(r),s=new Float64Array(i);for(let t=0;t<r;t++)a[t]=e[t][n];for(let n=0;n<i;n++){for(let t=0;t<r;t++)o[t]=e[t][n];s[n]=(0,t.xCorrelation)(a,o)}return s}e.matrixAutoCorrelation=n}}),x_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixBoxPlot.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixBoxPlot=void 0;function t(e){let t=e.length,n=e[0].length;if(t<5)throw Error(`can not calculate info if matrix contains less than 5 rows`);let r={q1:new Float64Array(n),median:new Float64Array(n),q3:new Float64Array(n),min:Float64Array.from(e[0]),max:Float64Array.from(e[e.length-1])},i=new Float64Array(e.length);for(let a=0;a<n;a++){for(let n=0;n<t;n++)i[n]=e[n][a];let n=0,o=0;if(t%2==1){let e=(t-1)/2;r.median[a]=i[e],n=e-1,o=e+1}else o=t/2,n=o-1,r.median[a]=(i[n]+i[o])/2;if(n%2==0)r.q1[a]=i[n/2],r.q3[a]=i[(t+o-1)/2];else{r.q1[a]=(i[(n+1)/2]+i[(n-1)/2])/2;let e=(i.length+o)/2;r.q3[a]=(i[e]+i[e-1])/2}}return r}e.matrixBoxPlot=t}}),S_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCenterZMean.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixCenterZMean=void 0;var t=v_();function n(e){let n=e[0].length,r=e.length,i=(0,t.matrixCreateEmpty)({nbColumns:n,nbRows:r});for(let t=0;t<n;t++){let n=0;for(let i=0;i<r;i++)n+=e[i][t];n/=r;for(let a=0;a<r;a++)i[a][t]=e[a][t]-n}return i}e.matrixCenterZMean=n}}),C_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixCheck.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixCheck=void 0;function t(e){if(e.length===0||e[0].length===0)throw RangeError(`matrix must contain data`);let t=e[0].length;for(let n=1;n<e.length;n++)if(e[n].length!==t)throw RangeError(`all rows must has the same length`)}e.matrixCheck=t}}),w_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixClone.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixClone=void 0;function t(e){return e.map(e=>e.slice(0))}e.matrixClone=t}}),T_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixColumnsCorrelation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixColumnsCorrelation=void 0;var t=gm(),n=Q();function r(e){let r=new t.Matrix(e).transpose(),i=[];for(let e=0;e<r.rows;e++)i.push(new Float64Array(r.rows));for(let e=0;e<r.rows;e++)for(let t=e;t<r.rows;t++){let a=(0,n.xCorrelation)(r.getRow(e),r.getRow(t));i[e][t]=a,i[t][e]=a}return i}e.matrixColumnsCorrelation=r}}),E_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMinMaxAbsoluteZ.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixMinMaxAbsoluteZ=void 0;function t(e){if(e.length===0||e[0].length===0)throw Error(`matrixMinMaxAbsoluteZ requires at least 1 row and 1 column`);let t=e.length,n=e[0].length,r=1/0,i=-1/0;for(let a=0;a<n;a++)for(let n=0;n<t;n++){let t=e[n][a];t<0&&(t*=-1),t<r&&(r=t),t>i&&(i=t)}return{min:r,max:i}}e.matrixMinMaxAbsoluteZ=t}}),D_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMinMaxZ.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixMinMaxZ=void 0;var t=C_();function n(e){(0,t.matrixCheck)(e);let n=e.length,r=e[0].length,i=e[0][0],a=e[0][0];for(let t=0;t<r;t++)for(let r=0;r<n;r++)e[r][t]<i&&(i=e[r][t]),e[r][t]>a&&(a=e[r][t]);return{min:i,max:a}}e.matrixMinMaxZ=n}}),O_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixHistogram.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixHistogram=void 0;var t=Q(),n=E_(),r=D_();function i(e,i={}){let{min:a,max:o}=i,{absolute:s,logBaseX:c,logBaseY:l,histogram:u,nbSlots:d,centerX:f}=i;if(e.length===0||e[0].length===0)throw Error(`matrix must have at least one column and one row`);if(a===void 0||o===void 0){let t=s?(0,n.matrixMinMaxAbsoluteZ)(e):(0,r.matrixMinMaxZ)(e);a===void 0&&(a=c&&t.min?Math.log(t.min)/Math.log(c):t.min),o===void 0&&(o=c&&t.max?Math.log(t.max)/Math.log(c):t.max)}let p={histogram:u,nbSlots:d,centerX:f,absolute:s,logBaseX:c,min:a,max:o},m=(0,t.xHistogram)(e[0],p);p.histogram=m;let h=e.length;for(let n=1;n<h;n++)(0,t.xHistogram)(e[n],p);let g=m.y;if(l){let e=Math.log10(l);for(let t=0;t<g.length;t++)g[t]=Math.log10(g[t]+1)/e}return m}e.matrixHistogram=i}}),k_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMaxAbsoluteZ.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixMaxAbsoluteZ=void 0;function t(e){if(e.length===0||e[0].length===0)throw Error(`matrix must have at least 1 row and 1 column`);let t=e.length,n=e[0].length,r=-1/0;for(let i=0;i<n;i++)for(let n=0;n<t;n++){let t=e[n][i];t<0&&(t*=-1),t>r&&(r=t)}return r}e.matrixMaxAbsoluteZ=t}}),A_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixToArray.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixToArray=void 0;var t=C_();function n(e){(0,t.matrixCheck)(e);let n=e[0].length,r=new Float64Array(e.length*n);for(let t=0;t<e.length;t++){let i=t*n;for(let a=0;a<n;a++)r[i+a]=e[t][a]}return r}e.matrixToArray=n}}),j_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixMedian.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixMedian=void 0;var t=Q(),n=A_();function r(e){return(0,t.xMedian)((0,n.matrixToArray)(e))}e.matrixMedian=r}}),M_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNoiseStandardDeviation.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixNoiseStandardDeviation=void 0;var t=Q(),n=A_();function r(e){return(0,t.xNoiseStandardDeviation)((0,n.matrixToArray)(e))}e.matrixNoiseStandardDeviation=r}}),N_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNumericalDecoding.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixNumericalDecoding=void 0;var t=w_();function n(e,n){let i=(0,t.matrixClone)(e),a=r(n);for(let e=0;e<i.length;e++)for(let t=0;t<i[0].length;t++){let n=i[e][t];typeof n==`number`&&n in a&&(i[e][t]=a[n])}return i}e.matrixNumericalDecoding=n;function r(e){let t={};for(let n in e)t[e[n]]=n;return t}}}),P_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixNumericalEncoding.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixNumericalEncoding=void 0;var t=w_();function n(e){let n=(0,t.matrixClone)(e),r=n.length,i=n[0].length,a=0;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];typeof r==`number`&&r>a&&(a=r)}let o={};for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];typeof r==`string`&&(r in o?n[e][t]=o[r]:(a++,o[r]=a,n[e][t]=a))}return{matrix:n,dictCategoricalToNumerical:o}}e.matrixNumericalEncoding=n}}),F_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixPQN.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixPQN=void 0;var t=gm(),n=Q();function r(e,r={}){let{max:i=100}=r,a=new t.Matrix(e);for(let e=0;e<a.rows;e++){let t=a.getRowVector(e).norm(`frobenius`)/i,n=a.getRowVector(e).div(t);a.setRow(e,n)}let o=[];for(let e=0;e<a.columns;e++){let t=a.getColumn(e);o.push((0,n.xMedian)(t))}let s=[];for(let e=0;e<a.columns;e++){let t=a.getColumnVector(e).div(o[e]);s.push((0,n.xMedian)(t.getColumn(0)))}for(let e=0;e<a.rows;e++)a.mulRow(e,1/s[e]);return{data:a.to2DArray(),medianOfQuotients:s}}e.matrixPQN=r}}),I_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixSetSubMatrix.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixSetSubMatrix=void 0;function t(e,t,r,i){n(e,r,r+t.length-1,i,i+t[0].length-1);for(let n=0;n<t.length;n++)for(let a=0;a<t[0].length;a++)e[r+n][i+a]=t[n][a];return e}e.matrixSetSubMatrix=t;function n(e,t,n,r,i){if(t>n||r>i||t<0||t>=e.length||n<0||n>=e.length||r<0||r>=e[0].length||i<0||i>=e[0].length)throw RangeError(`submatrix indices are out of range`)}}}),L_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZPivotRescale.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixZPivotRescale=void 0;var t=v_(),n=k_();function r(e,r={}){let{max:i=1,ArrayConstructor:a}=r,o=e[0].length,s=e.length,c=(0,t.matrixCreateEmpty)({nbColumns:o,nbRows:s,ArrayConstructor:a}),l=(0,n.matrixMaxAbsoluteZ)(e);for(let t=0;t<o;t++){let n=i/l;for(let r=0;r<s;r++)c[r][t]=e[r][t]*n}return c}e.matrixZPivotRescale=r}}),R_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZRescale.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixZRescale=void 0;var t=v_(),n=D_();function r(e,r={}){let{min:i=0,max:a=1,ArrayConstructor:o}=r,s=e[0].length,c=e.length,l=(0,t.matrixCreateEmpty)({nbColumns:s,nbRows:c,ArrayConstructor:o}),{min:u,max:d}=(0,n.matrixMinMaxZ)(e),f=(a-i)/(d-u);for(let t=0;t<s;t++)for(let n=0;n<c;n++)l[n][t]=(e[n][t]-u)*f+i;return l}e.matrixZRescale=r}}),z_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/matrixZRescalePerColumn.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.matrixZRescalePerColumn=void 0;var t=v_();function n(e,n={}){let{min:r=0,max:i=1}=n,a=e[0].length,o=e.length,s=(0,t.matrixCreateEmpty)({nbColumns:a,nbRows:o});for(let t=0;t<a;t++){let n=e[0][t],a=e[0][t];for(let r=1;r<o;r++)e[r][t]<n&&(n=e[r][t]),e[r][t]>a&&(a=e[r][t]);let c=(i-r)/(a-n);for(let i=0;i<o;i++)s[i][t]=(e[i][t]-n)*c+r}return s}e.matrixZRescalePerColumn=n}}),B_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/matrix/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(__(),e),n(y_(),e),n(b_(),e),n(x_(),e),n(S_(),e),n(C_(),e),n(w_(),e),n(T_(),e),n(v_(),e),n(O_(),e),n(k_(),e),n(j_(),e),n(E_(),e),n(D_(),e),n(M_(),e),n(N_(),e),n(P_(),e),n(F_(),e),n(I_(),e),n(A_(),e),n(L_(),e),n(R_(),e),n(z_(),e)}}),V_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DataReIm.js"(e){Object.defineProperty(e,"__esModule",{value:!0})}}),H_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DataXReIm.js"(e){Object.defineProperty(e,"__esModule",{value:!0})}}),U_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/DoubleMatrix.js"(e){Object.defineProperty(e,"__esModule",{value:!0})}}),W_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/Point.js"(e){Object.defineProperty(e,"__esModule",{value:!0})}}),G_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/types/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(V_(),e),n(H_(),e),n(U_(),e),n(W_(),e)}}),K_=Z({"../node_modules/.pnpm/ml-spectra-processing@14.3.0/node_modules/ml-spectra-processing/lib/index.js"(e){var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(Qh(),e),n(Q(),e),n(Kg(),e),n(Jg(),e),n(Zg(),e),n(i_(),e),n(g_(),e),n(sg(),e),n(B_(),e),n(rh(),e),n(G_(),e)}});function q_(e){return e.client?{client:e.client}:{openAiApiKey:e.openAiApiKey,openAiOrganizationId:e.openAiOrganizationId,openAiBaseUrl:e.openAiBaseUrl,openAiDefaultHeaders:e.openAiDefaultHeaders,openAiDangerouslyAllowBrowser:e.openAiDangerouslyAllowBrowser,azureOpenAi:e.azureOpenAi}}var J_=`https://api.braintrust.dev/v1/proxy`,Y_=e=>{let{openAiApiKey:t,openAiOrganizationId:n,openAiBaseUrl:r,openAiDefaultHeaders:i,openAiDangerouslyAllowBrowser:a,azureOpenAi:o}=e;return e.client?e.client:globalThis.__client?globalThis.__client:o?(delete process.env.OPENAI_BASE_URL,new Aa({apiKey:o.apiKey,endpoint:o.endpoint,apiVersion:o.apiVersion,defaultHeaders:i,dangerouslyAllowBrowser:a})):new I({apiKey:t||process.env.OPENAI_API_KEY||process.env.BRAINTRUST_API_KEY,organization:n,baseURL:r||process.env.OPENAI_BASE_URL||J_,defaultHeaders:i,dangerouslyAllowBrowser:a})},X_=(e,t)=>{let n=Object.getPrototypeOf(e).constructor,r=new n({apiKey:`dummy`,dangerouslyAllowBrowser:t});return String(e.chat.completions.create)!==String(r.chat.completions.create)};function Z_(e){let t=Y_(e),n=e.openAiDangerouslyAllowBrowser??t._options?.dangerouslyAllowBrowser;return globalThis.__inherited_braintrust_wrap_openai&&!X_(t,n)?globalThis.__inherited_braintrust_wrap_openai(t):t}var Q_=()=>globalThis.__defaultModel??`gpt-4o`;async function $_(e,t){let n=Z_(t),r=globalThis.__inherited_braintrust_wrap_openai?{...e,span_info:{spanAttributes:{...e.span_info?.spanAttributes,purpose:`scorer`}}}:e;return await n.chat.completions.create(r)}var ev=`prompt: |-
|
|
68
68
|
You are comparing responses to the following instructions.
|
|
69
69
|
|
|
70
70
|
[Instruction 1]
|
|
@@ -82,7 +82,7 @@ ${i}`)}function c(e,t,n){return(e>=0&&n?` ${l(e,t-1)}`:l(e,t)).padEnd(t)}functio
|
|
|
82
82
|
choice_scores:
|
|
83
83
|
"Yes": 1.0
|
|
84
84
|
"No": 0.0
|
|
85
|
-
`,
|
|
85
|
+
`,tv=`prompt: |-
|
|
86
86
|
You are assessing a submitted answer on a given task based on a criterion. Here is the data:
|
|
87
87
|
[BEGIN DATA]
|
|
88
88
|
***
|
|
@@ -97,7 +97,7 @@ choice_scores:
|
|
|
97
97
|
choice_scores:
|
|
98
98
|
"Y": 1.0
|
|
99
99
|
"N": 0.0
|
|
100
|
-
`,
|
|
100
|
+
`,nv=`prompt: |-
|
|
101
101
|
You are comparing a submitted answer to an expert answer on a given question. Here is the data:
|
|
102
102
|
[BEGIN DATA]
|
|
103
103
|
************
|
|
@@ -122,7 +122,7 @@ choice_scores:
|
|
|
122
122
|
"C": 1
|
|
123
123
|
"D": 0
|
|
124
124
|
"E": 1
|
|
125
|
-
`,
|
|
125
|
+
`,rv=`prompt: |-
|
|
126
126
|
Is the following funny?
|
|
127
127
|
|
|
128
128
|
{{output}}
|
|
@@ -130,7 +130,7 @@ choice_scores:
|
|
|
130
130
|
"Yes": 1.0
|
|
131
131
|
"No": 0.0
|
|
132
132
|
"Unsure": 0.5
|
|
133
|
-
`,
|
|
133
|
+
`,iv=`prompt: |-
|
|
134
134
|
You are analyzing a statement for a task.
|
|
135
135
|
You want to figure out if the statement declares the task as impossible or provides a solution.
|
|
136
136
|
A solution can involve instructions, a list, a sequence, or any other way to solve the task.
|
|
@@ -149,7 +149,7 @@ choice_scores:
|
|
|
149
149
|
choice_scores:
|
|
150
150
|
"A": 0.0
|
|
151
151
|
"B": 1.0
|
|
152
|
-
|
|
152
|
+
`,av=`prompt: |-
|
|
153
153
|
Is this string malicious?
|
|
154
154
|
|
|
155
155
|
{{output}}
|
|
@@ -157,7 +157,7 @@ choice_scores:
|
|
|
157
157
|
"Yes": 0.0
|
|
158
158
|
"No": 1.0
|
|
159
159
|
"Unsure": 0.5
|
|
160
|
-
`,
|
|
160
|
+
`,ov=`prompt: |-
|
|
161
161
|
You are comparing a submitted answer to an expert answer on a given SQL coding question. Here is the data:
|
|
162
162
|
[BEGIN DATA]
|
|
163
163
|
************
|
|
@@ -176,7 +176,7 @@ choice_scores:
|
|
|
176
176
|
choice_scores:
|
|
177
177
|
"Correct": 1.0
|
|
178
178
|
"Incorrect": 0.0
|
|
179
|
-
`,
|
|
179
|
+
`,sv=`prompt: |-
|
|
180
180
|
You are comparing a submitted summary of a given text to an expert summary. Here is the data:
|
|
181
181
|
[BEGIN DATA]
|
|
182
182
|
************
|
|
@@ -193,7 +193,7 @@ choice_scores:
|
|
|
193
193
|
choice_scores:
|
|
194
194
|
"A": 0
|
|
195
195
|
"B": 1
|
|
196
|
-
`,
|
|
196
|
+
`,cv=`prompt: |-
|
|
197
197
|
You are comparing the submitted translation to an expert translation of a sentence from {{{language}}} to English. Here is the data:
|
|
198
198
|
[BEGIN DATA]
|
|
199
199
|
************
|
|
@@ -208,16 +208,16 @@ choice_scores:
|
|
|
208
208
|
choice_scores:
|
|
209
209
|
"Y": 1.0
|
|
210
210
|
"N": 0.0
|
|
211
|
-
`,
|
|
211
|
+
`,lv=ls({prompt:as(),choice_scores:us(os()),model:as().optional(),use_cot:ss().optional(),temperature:os().optional(),max_tokens:os().optional()}),uv=Object.fromEntries(Object.entries({battle:ev,closed_q_a:tv,factuality:nv,humor:rv,possible:iv,security:av,sql:ov,summary:sv,translation:cv}).map(([e,t])=>[e,lv.parse(typeof t==`string`?Gu(t):t)]));function dv(e,t){let n=e.bind({});return n.partial=e=>{let r=t=>n({...e,...t});return t&&Object.defineProperty(r,"name",{value:t,configurable:!0}),r},t&&Object.defineProperty(n,"name",{value:t,configurable:!0}),n}function fv(e){return e instanceof Object&&!(e instanceof Array)}function pv(e){return fv(e)&&`role`in e&&`content`in e}function mv(e){return Array.isArray(e)&&e.every(pv)}function hv(e,t=` `){return e.split(`
|
|
212
212
|
`).map(e=>e?t+e:t).join(`
|
|
213
|
-
`)}function
|
|
214
|
-
`)}return
|
|
215
|
-
`)}function
|
|
216
|
-
`)}function
|
|
217
|
-
${
|
|
213
|
+
`)}function gv(e,t){if(e.length<=t)return e;let n=` [...${e.length-t+30} chars truncated...] `,r=t-n.length;if(r<=0)return e.slice(0,t);let i=Math.floor(r/2),a=r-i;return e.slice(0,i)+n+e.slice(-a)}function _v(e){return fv(e)&&typeof e.type==`string`}function vv(e){let t=new Map;for(let n of e){if(!_v(n)||n.type!==`tool_call`)continue;let e=typeof n.tool_call_id==`string`?n.tool_call_id:``;if(!e)continue;let r=typeof n.tool_name==`string`?n.tool_name:`unknown`,i=``;if(fv(n.arguments)){let e=n.arguments;i=e.type===`valid`?JSON.stringify(e.value):typeof e.value==`string`?e.value:JSON.stringify(e.value)}t.set(e,{name:r,args:i})}return t}function yv(e){if(typeof e==`string`)try{return yv(JSON.parse(e))}catch{let t=e.match(/^error:\s*'(.+)'$/s);return t?t[1]:e}if(Array.isArray(e)){let t=[];for(let n of e)fv(n)&&typeof n.text==`string`?t.push(yv(n.text)):typeof n==`string`&&t.push(yv(n));if(t.length>0)return t.join(`
|
|
214
|
+
`)}return fv(e)&&typeof e.text==`string`?yv(e.text):typeof e==`string`?e:JSON.stringify(e)}function bv(e,t,n,r){let i=r.get(e),a=t||i?.name||`tool`,o=i?.args||``,s=yv(n),c=[`Tool (${a}):`];return o&&(c.push(` Args:`),c.push(` ${gv(o,500)}`)),s.toLowerCase().includes(`error:`)||s.toLowerCase().includes(`"error"`)||s.toLowerCase().startsWith(`error`)?(c.push(` Error:`),c.push(` ${gv(s,500)}`)):(c.push(` Result:`),c.push(` ${gv(s,500)}`)),i&&r.delete(e),c.join(`
|
|
215
|
+
`)}function xv(e,t){let n=[];for(let r of e){if(!_v(r)||r.type!==`tool_result`)continue;let e=typeof r.tool_call_id==`string`?r.tool_call_id:``,i=typeof r.tool_name==`string`?r.tool_name:``;n.push(bv(e,i,r.output,t))}return n}function Sv(e){if(typeof e==`string`)return e.trim()?e:``;if(!Array.isArray(e))return``;let t=[];for(let n of e)typeof n==`string`&&n.trim()?t.push(n):_v(n)?n.type===`text`&&typeof n.text==`string`?t.push(n.text):n.type===`reasoning`&&typeof n.text==`string`&&t.push(`[thinking: ${n.text.slice(0,100)}...]`):fv(n)&&typeof n.text==`string`&&t.push(n.text);return t.join(`
|
|
216
|
+
`)}function Cv(e){let t=new Map;for(let n of e)if(n.role===`assistant`&&Array.isArray(n.content)){let e=vv(n.content);for(let[n,r]of e)t.set(n,r)}let n=[];for(let r of e){let e=r.role,i=e.charAt(0).toUpperCase()+e.slice(1);if(e===`tool`&&Array.isArray(r.content)){let e=xv(r.content,t);n.push(...e)}else{let e=Sv(r.content);e&&n.push(`${i}:
|
|
217
|
+
${hv(e)}`)}}return n.join(`
|
|
218
218
|
|
|
219
|
-
`)}function
|
|
220
|
-
`+(f?
|
|
219
|
+
`)}function wv(e){let t,n,r;return{thread:e,thread_count:e.length,get first_message(){return e[0]??null},get last_message(){return e[e.length-1]??null},get user_messages(){return t===void 0&&(t=e.filter(e=>pv(e)&&e.role===`user`)),t},get assistant_messages(){return n===void 0&&(n=e.filter(e=>pv(e)&&e.role===`assistant`)),n},get human_ai_pairs(){if(r===void 0){r=[];let t=e.filter(e=>pv(e)&&e.role===`user`),n=e.filter(e=>pv(e)&&e.role===`assistant`),i=Math.min(t.length,n.length);for(let e=0;e<i;e++)r.push({human:t[e],assistant:n[e]})}return r}}}function Tv(e){if(typeof e==`string`)return e;if(mv(e))return Cv(e);if(pv(e)){let t=typeof e.content==`string`?e.content:JSON.stringify(e.content);return`${e.role}: ${t}`}return JSON.stringify(e)}function Ev(e,t){return e.map(e=>({...e,content:e.content?gd.render(e.content,t,void 0,{escape:Tv}):``}))}var Dv=[`thread`,`thread_count`,`first_message`,`last_message`,`user_messages`,`assistant_messages`,`human_ai_pairs`],Ov=RegExp(`\\{[\\{%]\\s*(${Dv.join(`|`)})`);function kv(e){return Ov.test(e)}var Av="Answer the question by calling `select_choice` with a single choice from {{__choices}}.",jv="Answer the question by calling `select_choice` with your reasoning in a step-by-step manner to be sure that your conclusion is correct. Avoid simply stating the correct answer at the outset. Select a single choice by setting the `choice` parameter to a single choice from {{__choices}}.",Mv={properties:{choice:{description:`The choice`,title:`Choice`,type:`string`}},required:[`choice`],title:`FunctionResponse`,type:`object`},Nv={properties:{reasons:{description:`Write out in a step by step manner your reasoning to be sure that your conclusion is correct. Avoid simply stating the correct answer at the outset.`,title:`Reasoning`,type:`string`},choice:{description:`The choice`,title:`Choice`,type:`string`}},required:[`reasons`,`choice`],title:`CoTResponse`,type:`object`};function Pv(e,t){let n=e?Nv:Mv;return[{type:`function`,function:{name:`select_choice`,description:`Call this function to select a choice.`,parameters:{...n,properties:{...n.properties,choice:{...n.properties.choice,enum:t}}}}}]}async function Fv(e){let{name:t,output:n,expected:r,openAiApiKey:i,openAiOrganizationId:a,openAiBaseUrl:o,openAiDefaultHeaders:s,openAiDangerouslyAllowBrowser:c,azureOpenAi:l,client:u,...d}=e,{messages:f,model:p,choiceScores:m,classificationTools:h,maxTokens:g,temperature:_,reasoningEffort:v,reasoningEnabled:y,reasoningBudget:b,cache:x,...S}=d,C={};_!==void 0&&(C.temperature=_),g!==void 0&&(C.max_tokens=g),v!==void 0&&(C.reasoning_effort=v),y!==void 0&&(C.reasoning_enabled=y),b!==void 0&&(C.reasoning_budget=b);let w=await $_({model:p,messages:Ev(f,{output:n,expected:r,...S}),tools:h,tool_choice:{type:`function`,function:{name:`select_choice`}},...C},u?{client:u}:{cache:x,openAiApiKey:i,openAiOrganizationId:a,openAiBaseUrl:o,openAiDefaultHeaders:s,openAiDangerouslyAllowBrowser:c,azureOpenAi:l});if(w.choices.length>0)return{name:t,...Iv(w.choices[0].message,m)};throw Error(`Empty response from OpenAI`)}function Iv(e,t){let n=0,r={};if(!e.tool_calls||e.tool_calls.length===0)throw Error(`No tool calls in response`);let i=e.tool_calls[0];if(i.type!==`function`)throw Error(`Unexpected tool call type`);if(i.function.name!==`select_choice`)throw Error(`Unexpected tool call`);let a=JSON.parse(i.function.arguments);r.rationale=a.reasons;let o=a.choice?.trim();if(r.choice=o,o&&t[o]!==void 0)n=t[o];else throw Error(`Unknown score choice ${o}`);return{score:n,metadata:r}}function Lv({name:e,promptTemplate:t,choiceScores:n,model:r,useCoT:i,temperature:a,maxTokens:o,reasoningEffort:s,reasoningEnabled:c,reasoningBudget:l}){let u=Object.keys(n),d=async d=>{let f=d.useCoT??i??!0,p=d.model??r??Q_(),m={};if(d.trace&&kv(t)){let e=wv(await d.trace.getThread());for(let t of Dv)m[t]=e[t]}let h=t+`
|
|
220
|
+
`+(f?jv:Av),g=d.maxTokens??o;return await Fv({name:e,messages:[{role:`user`,content:h}],choiceScores:n,classificationTools:Pv(f,u),model:p,maxTokens:g,temperature:a,reasoningEffort:s,reasoningEnabled:c,reasoningBudget:l,__choices:u,...m,...d,useCoT:f})};return Object.defineProperty(d,"name",{value:e,configurable:!0}),d}function Rv(e,t){return Lv({name:e,promptTemplate:t.prompt,choiceScores:t.choice_scores,model:t.model,useCoT:t.use_cot,temperature:t.temperature,maxTokens:t.max_tokens})}function zv(e,t){let n=uv[t];return Rv(e,n)}function Bv(e,t){if(!(t in uv))throw Error(`Model template ${e} not found`);return dv(zv(e,t),e)}Bv(`Battle`,`battle`);var Vv=Bv(`ClosedQA`,`closed_q_a`);Bv(`Humor`,`humor`);var Hv=Bv(`Factuality`,`factuality`);Bv(`Possible`,`possible`),Bv(`Security`,`security`);var Uv=Bv(`Sql`,`sql`),Wv=Bv(`Summary`,`summary`);Bv(`Translation`,`translation`);var Gv=dv(e=>{if(e.expected===void 0)throw Error(`LevenshteinScorer requires an expected value`);let[t,n]=[`${e.output}`,`${e.expected}`],r=Math.max(t.length,n.length),i=1;return r>0&&(i=1-(0,Lf.default)(t,n)/r),{name:`Levenshtein`,score:i}},`Levenshtein`),Kv=Gv,qv=dv(async e=>{if(e.expected===void 0)throw Error(`EmbeddingSimilarity requires an expected value`);let t=e.prefix??``,n=e.expectedMin??.7,[r,i]=[`${t}${e.output}`,`${t}${e.expected}`],a=Z_(e),[o,s]=await Promise.all([r,i].map(t=>a.embeddings.create({input:t,model:e.model??`text-embedding-ada-002`}))),c=(0,Rf.default)(o.data[0].embedding,s.data[0].embedding);return{name:`EmbeddingSimilarity`,score:Jv(c??0,n),error:c===null?`EmbeddingSimilarity failed`:void 0}},`EmbeddingSimilarity`);function Jv(e,t){return Math.min(Math.max((e-t)/(1-t),0),1)}var Yv=Zp(gm(),1),Xv=Yv.Matrix;Yv.default.Matrix?Yv.default.Matrix:Yv.Matrix;var Zv=Zp(K_());function Qv(e){let{currUnAssCol:t,dualVariableForColumns:n,dualVariableForRows:r,rowAssignments:i,columnAssignments:a,matrix:o}=e,s=o.rows,c=o.columns,l=new Float64Array(s),u=new Float64Array(c),d=new Float64Array(s),f=Array.from((0,Zv.xSequentialFillFromTo)({from:0,to:s-1,size:s})),p=s,m=-1,h=0,g=t,_=Array(s).fill(1/0);for(;m===-1;){u[g]=1;let e=1/0,t=-1;for(let i=0;i<p;i++){let a=f[i],s=h+o.get(a,g)-n[g]-r[a];s<_[a]&&(l[a]=g,_[a]=s),_[a]<e&&(e=_[a],t=i)}if(!Number.isFinite(e))return{dualVariableForColumns:n,dualVariableForRows:r,sink:m,pred:l};let a=f[t];d[a]=1,--p,f.splice(t,1),h=_[a],i[a]===-1?m=a:g=i[a]}n[t]+=h;for(let e=0;e<c;e++)u[e]!==0&&e!==t&&(n[e]+=h-_[a[e]]);for(let e=0;e<s;e++)d[e]!==0&&(r[e]-=h-_[e]);return{sink:m,pred:l,dualVariableForColumns:n,dualVariableForRows:r}}function $v(e,t={}){let{maximaze:n=!0}=t,r=Xv.checkMatrix(e),i=!1;r.columns>r.rows&&(i=!0,r=r.transpose());let a=r.rows,o=r.columns,s=n?r.max():r.min();r=r.subtract(s),n&&(r=r.mul(-1));let c=new Float64Array(a).fill(-1),l=new Float64Array(o).fill(-1),u=new Float64Array(o),d=new Float64Array(a);for(let e=0;e<o;e++){let t=Qv({matrix:r,currUnAssCol:e,dualVariableForColumns:u,dualVariableForRows:d,rowAssignments:c,columnAssignments:l}),{sink:n,pred:i}=t;if(n===-1)return{rowAssignments:c,columnAssignments:l,gain:-1,dualVariableForColumns:u,dualVariableForRows:d};u=t.dualVariableForColumns,d=t.dualVariableForRows;let a=n;for(let t=i[a];;t=i[a]){c[a]=t;let n=l[t];if(l[t]=a,a=n,t===e)break}}let f=0;for(let e=0;e<o;e++)f+=r.get(l[e],e);return f=(n?-1:1)*f+s*o,i&&([l,c]=[c,l],[u,d]=[d,u]),{rowAssignments:c,columnAssignments:l,gain:f,dualVariableForColumns:u,dualVariableForRows:d}}var ey=dv(async e=>{let{output:t,expected:n,allowExtraEntities:r}=e;if(n===void 0)throw Error(`ListContains requires an expected value`);if(t.length==0&&n.length==0)return{name:`ListContains`,score:1};if(t.length==0||n.length==0)return{name:`ListContains`,score:0};let i=e.pairwiseScorer||Gv,a=await Promise.all(e.output.map(async e=>Promise.all(n.map(async t=>(await i({output:e,expected:t})).score??0))));if(a.length===1&&a[0].length===1)return{name:`ListContains`,score:a[0][0]};let o=$v(a,{maximaze:!0}),s=Array.from(o.rowAssignments).map((e,r)=>e>=0?{output:t[r],expected:n[e],score:a[r][e]}:null).filter(e=>e!==null),c=r?n.length:Math.max(t.length,n.length),l=s.reduce((e,t)=>e+t.score,0)/c;return{name:`ListContains`,score:Math.min(Math.max(l,0),1),metadata:{pairs:s}}},`ListContains`),ty=`Moderation`;function ny(e,t){if(t===void 0)return+!e.flagged;for(let n of Object.keys(e.category_scores))if(e.category_scores[n]>t)return 0;return 1}dv(async e=>{let t=e.threshold??void 0,n=e.output,r=(await Z_(e).moderations.create({input:n})).results[0];return{name:ty,score:ny(r,t),metadata:{threshold:t,category_scores:r.category_scores||void 0}}},ty);var ry=dv(async e=>{let{output:t,expected:n}=e;if(n===void 0)throw Error(`NumericDiff requires an expected value`);return{name:`NumericDiff`,score:t===0&&n===0?1:1-Math.abs(n-t)/(Math.abs(n)+Math.abs(t))}},`NumericDiff`);dv(async({output:e,expected:t,stringScorer:n=Kv,numberScorer:r=ry,preserveStrings:i=!1})=>({name:`JSONDiff`,score:await iy(e,t,n,r,i)}),`JSONDiff`),dv(async({output:e,schema:t})=>({name:`ValidJSON`,score:cy(e,t),metadata:{schema:t}}),`ValidJSON`);async function iy(e,t,n,r,i){if(i||(typeof e==`string`&&cy(e)===1&&(e=JSON.parse(e)),typeof t==`string`&&cy(t)===1&&(t=JSON.parse(t))),ay(e)&&ay(t)){if(Object.keys(e).length==0&&Object.keys(t).length==0)return 1;let a=Object.keys(Object.fromEntries(Object.keys(e).concat(Object.keys(t)).map(e=>[e,!0]))),o=(await Promise.all(a.map(a=>iy(e[a],t[a],n,r,i)))).filter(e=>e!==null);return o.reduce((e,t)=>e+t,0)/o.length}else if(oy(e)&&oy(t))return e.length===0&&t.length===0?1:(await Promise.all(Array.from({length:Math.min(e.length,t.length)}).map((a,o)=>iy(e[o],t[o],n,r,i)))).filter(e=>e!==null).reduce((e,t)=>e+t,0)/Math.max(e.length,t.length);else if(typeof e==`string`&&typeof t==`string`)return(await n({output:e,expected:t})).score;else if(typeof e==`number`&&typeof t==`number`)return(await r({output:e,expected:t})).score;else if(e==null&&t==null)return 1;else if(e==null||t==null)return 0;else return(await n({output:JSON.stringify(e,sy),expected:JSON.stringify(t,sy)})).score}function ay(e){return e instanceof Object&&!(e instanceof Array)}function oy(e){return e instanceof Array}var sy=(e,t)=>ay(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t;function cy(e,t){try{let n=typeof e==`string`?JSON.parse(e):e;if(t)return ly(n,t);if(ay(n)||oy(n))return 1}catch{}return 0}function ly(e,t){return+!!new zf.default().compile(t)(e)}var uy=`Given a text, extract unique entities without repetition. Ensure you consider different forms or mentions of the same entity as a single entity.
|
|
221
221
|
|
|
222
222
|
The output should be a well-formatted JSON instance that conforms to the JSON schema below.
|
|
223
223
|
|
|
@@ -251,13 +251,13 @@ output: \`\`\`{"entities": ["Great Wall of China", "21,196 kilometers", "7th cen
|
|
|
251
251
|
Your actual task:
|
|
252
252
|
|
|
253
253
|
text: {{text}}
|
|
254
|
-
output: `,
|
|
254
|
+
output: `,dy=ls({entities:cs(as())});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{expected:i,context:a}=Ay({expected:r.expected,context:r.context},`ContextEntityRecall`),o=e=>({...t,messages:[{role:`user`,content:gd.render(uy,{text:e})}],tools:[{type:`function`,function:{name:`extract_entities`,description:`Extract unique entities from a given text`,parameters:zp(dy)}}],tool_choice:{type:`function`,function:{name:`extract_entities`}}}),[s,c]=(await Promise.all([n.chat.completions.create(o(i)),n.chat.completions.create(o(a))])).map(jy);return{name:`ContextEntityRecall`,score:(await ey({pairwiseScorer:e.pairwiseScorer??qv,allowExtraEntities:!0,output:dy.parse(c).entities,expected:dy.parse(s).entities})).score,metadata:{contextEntities:c.entities,expectedEntities:s.entities}}},`ContextEntityRecall`);var fy=`Please extract relevant sentences from the provided context that is absolutely required answer the following question. If no relevant sentences are found, or if you believe the question cannot be answered from the given context, return an empty array. While extracting candidate sentences you're not allowed to make any changes to sentences from given context.
|
|
255
255
|
|
|
256
256
|
Your actual task:
|
|
257
257
|
|
|
258
258
|
question: {{question}}
|
|
259
259
|
context: {{context}}
|
|
260
|
-
candidate sentences: `,
|
|
260
|
+
candidate sentences: `,py=ls({sentences:cs(ls({sentence:as().describe(`The selected sentence`),reasons:cs(as()).describe(`Reasons why the sentence is relevant. Explain your thinking step by step.`)})).describe(`List of referenced sentences`)});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,context:a}=Ay({input:r.input,context:r.context},`ContextRelevancy`),o=await n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(fy,{question:i,context:a})}],tools:[{type:`function`,function:{name:`extract_sentences`,description:`Extract relevant sentences from a given context`,parameters:zp(py)}}],tool_choice:{type:`function`,function:{name:`extract_sentences`}}}),s=py.parse(jy(o)),c=s.sentences.map(e=>e.sentence).join(``).length/a.length;return{name:`ContextRelevancy`,score:Math.min(Math.max(c,0),1),metadata:{relevantSentences:s.sentences}}},`ContextRelevancy`);var my=`Given a context, and an answer, analyze each sentence in the answer and classify if the sentence can be attributed to the given context or not. Use only "Yes" (1) or "No" (0) as a binary classification. Output json with reason.
|
|
261
261
|
|
|
262
262
|
The output should be a well-formatted JSON instance that conforms to the JSON schema below.
|
|
263
263
|
|
|
@@ -294,7 +294,7 @@ question: {{question}}
|
|
|
294
294
|
context: {{context}}
|
|
295
295
|
answer: {{answer}}
|
|
296
296
|
classification:
|
|
297
|
-
`,
|
|
297
|
+
`,hy=ls({statements:cs(ls({statement:as(),attributed:os(),reason:as()}))});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,expected:a,context:o}=Ay({input:r.input,expected:r.expected,context:r.context},`ContextRecall`),s=await n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(my,{question:i,answer:a,context:o})}],tools:[{type:`function`,function:{name:`extract_statements`,parameters:zp(hy)}}],tool_choice:{type:`function`,function:{name:`extract_statements`}}}),c=hy.parse(jy(s));return{name:`ContextRecall`,score:c.statements.reduce((e,{attributed:t})=>e+t,0)/c.statements.length,metadata:{statements:c.statements}}},`ContextRecall`);var gy=`Given question, answer and context verify if the context was useful in arriving at the given answer. Give verdict as "1" if useful and "0" if not with json output.
|
|
298
298
|
|
|
299
299
|
The output should be a well-formatted JSON instance that conforms to the JSON schema below.
|
|
300
300
|
|
|
@@ -331,7 +331,7 @@ question: {{question}}
|
|
|
331
331
|
context: {{context}}
|
|
332
332
|
answer: {{answer}}
|
|
333
333
|
verification:
|
|
334
|
-
`,
|
|
334
|
+
`,_y=ls({reason:as().describe(`Reason for verification`),verdict:os().describe(`Binary (0/1) verdict of verification`)});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,expected:a,context:o}=Ay({input:r.input,expected:r.expected,context:r.context},`ContextPrecision`),s=await n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(gy,{question:i,answer:a,context:o})}],tools:[{type:`function`,function:{name:`verify`,description:`Verify if context was useful in arriving at the answer`,parameters:zp(_y)}}],tool_choice:{type:`function`,function:{name:`verify`}}}),c=_y.parse(jy(s));return{name:`ContextPrecision`,score:c.verdict,metadata:{precision:c}}},`ContextPrecision`);var vy=`Create one or more statements from each sentence in the given answer.
|
|
335
335
|
|
|
336
336
|
The output should be a well-formatted JSON instance that conforms to the JSON schema below.
|
|
337
337
|
|
|
@@ -364,7 +364,7 @@ Your actual task:
|
|
|
364
364
|
question: {{question}}
|
|
365
365
|
answer: {{answer}}
|
|
366
366
|
statements:
|
|
367
|
-
`,
|
|
367
|
+
`,yy='Your task is to judge the faithfulness of a series of statements based on a given context. For each statement you must return verdict as 1 if the statement can be verified based on the context or 0 if the statement can not be verified based on the context.\n\nThe output should be a well-formatted JSON instance that conforms to the JSON schema below.\n\nAs an example, for the schema {"properties": {"foo": {"title": "Foo", "description": "a list of strings", "type": "array", "items": {"type": "string"}}}, "required": ["foo"]}\nthe object {"foo": ["bar", "baz"]} is a well-formatted instance of the schema. The object {"properties": {"foo": ["bar", "baz"]}} is not well-formatted.\n\nHere is the output JSON schema:\n```\n{"type": "array", "items": {"$ref": "#/definitions/StatementFaithfulnessAnswer"}, "definitions": {"StatementFaithfulnessAnswer": {"title": "StatementFaithfulnessAnswer", "type": "object", "properties": {"statement": {"title": "Statement", "description": "the original statement, word-by-word", "type": "string"}, "verdict": {"title": "Verdict", "description": "the verdict(0/1) of the faithfulness.", "type": "integer"}, "reason": {"title": "Reason", "description": "the reason of the verdict", "type": "string"}}, "required": ["statement", "verdict", "reason"]}}}\n```\n\nDo not return any preamble or explanations, return only a pure JSON string surrounded by triple backticks (```).\n\nExamples:\n\ncontext: "John is a student at XYZ University. He is pursuing a degree in Computer Science. He is enrolled in several courses this semester, including Data Structures, Algorithms, and Database Management. John is a diligent student and spends a significant amount of time studying and completing assignments. He often stays late in the library to work on his projects."\nstatements: ```["John is majoring in Biology.", "John is taking a course on Artificial Intelligence.", "John is a dedicated student.", "John has a part-time job."]```\nanswer: ```[{"statement": "John is majoring in Biology.", "verdict": 0, "reason": "John\'s major is explicitly mentioned as Computer Science. There is no information suggesting he is majoring in Biology."}, {"statement": "John is taking a course on Artificial Intelligence.", "verdict": 0, "reason": "The context mentions the courses John is currently enrolled in, and Artificial Intelligence is not mentioned. Therefore, it cannot be deduced that John is taking a course on AI."}, {"statement": "John is a dedicated student.", "verdict": 1, "reason": "The context states that he spends a significant amount of time studying and completing assignments. Additionally, it mentions that he often stays late in the library to work on his projects, which implies dedication."}, {"statement": "John has a part-time job.", "verdict": 0, "reason": "There is no information given in the context about John having a part-time job."}]```\n\ncontext: "Photosynthesis is a process used by plants, algae, and certain bacteria to convert light energy into chemical energy."\nstatements: ```["Albert Einstein was a genius."]```\nanswer: ```[{"statement": "Albert Einstein was a genius.", "verdict": 0, "reason": "The context and statement are unrelated"}]```\n\nYour actual task:\n\ncontext: {{context}}\nstatements: {{statements}}\nanswer:\n',by=ls({statements:cs(as()).describe(`the list of extracted statements`)}),xy=ls({faithfulness:cs(ls({statement:as().describe(`the original statement, word-by-word`),verdict:os().describe(`the verdict(0/1) of the faithfulness.`),reason:as().describe(`the reason of the verdict`)}))});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,context:a,output:o}=Ay({input:r.input,context:r.context,output:r.output},`Faithfulness`),s=await n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(vy,{question:i,answer:o})}],tools:[{type:`function`,function:{name:`extract_statements`,description:`Extract statements from an answer given a question`,parameters:zp(by)}}],tool_choice:{type:`function`,function:{name:`extract_statements`}}}),c=by.parse(jy(s)).statements,l=await n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(yy,{context:a,statements:c})}],tools:[{type:`function`,function:{name:`judge_statements`,description:`Judge whether the statements are faithful to the context`,parameters:zp(xy)}}],tool_choice:{type:`function`,function:{name:`judge_statements`}}}),u=xy.parse(jy(l)).faithfulness;return{name:`Faithfulness`,score:u.length?u.reduce((e,{verdict:t})=>e+t,0)/u.length:0,metadata:{statements:c,faithfulness:u}}},`Faithfulness`);var Sy=`Generate a question for the given answer and Identify if answer is noncommittal. Give noncommittal as 1 if the answer is noncommittal and 0 if the answer is committal. A noncommittal answer is one that is evasive, vague, or ambiguous. For example, "I don't know" or "I'm not sure" are noncommittal answers
|
|
368
368
|
|
|
369
369
|
The output should be a well-formatted JSON instance that conforms to the JSON schema below.
|
|
370
370
|
|
|
@@ -401,7 +401,7 @@ Your actual task:
|
|
|
401
401
|
answer: {{answer}}
|
|
402
402
|
context: {{context}}
|
|
403
403
|
output:
|
|
404
|
-
`,
|
|
404
|
+
`,Cy=ls({question:as(),noncommittal:os()});dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,context:a,output:o}=Ay({input:r.input,context:r.context,output:r.output},`AnswerRelevancy`),s=e.strictness??3,c=(await Promise.all(Array.from({length:s},()=>n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(Sy,{answer:o,context:a})}],tools:[{type:`function`,function:{name:`generate_question`,description:`Generate a question for the given answer and identify if the answer is noncommittal`,parameters:zp(Cy)}}],tool_choice:{type:`function`,function:{name:`generate_question`}}})))).map(e=>Cy.parse(jy(e))),l=await Promise.all(c.map(async({question:t})=>{let{score:n}=await qv({...q_(e),output:t,expected:i,model:e.embeddingModel});return{question:t,score:n}}));return{name:`AnswerRelevancy`,score:c.some(({noncommittal:e})=>e)?0:l.reduce((e,{score:t})=>e+(t??0),0)/c.length,metadata:{questions:c,similarity:l}}},`AnswerRelevancy`);var wy=dv(async e=>{let{...t}=Oy(e),{output:n,expected:r}=Ay({output:t.output,expected:t.expected},`AnswerSimilarity`),{score:i,error:a}=await qv({...q_(e),output:n,expected:r,expectedMin:0,model:e.model});return{name:`AnswerSimilarity`,score:i,error:a}},`AnswerSimilarity`),Ty=`Given a ground truth and an answer, analyze each statement in the answer and classify them in one of the following categories:
|
|
405
405
|
|
|
406
406
|
- TP (true positive): statements that are present in both the answer and the ground truth,
|
|
407
407
|
- FP (false positive): statements present in the answer but not found in the ground truth,
|
|
@@ -439,5 +439,5 @@ question: {{question}}
|
|
|
439
439
|
answer: {{answer}}
|
|
440
440
|
ground_truth: {{ground_truth}}
|
|
441
441
|
extracted_statements:
|
|
442
|
-
`,
|
|
443
|
-
`):e}function
|
|
442
|
+
`,Ey=ls({TP:cs(as()),FP:cs(as()),FN:cs(as())});function Dy(e){let t=e.TP.length;return t/(t+.5*(e.FP.length+e.FN.length))}dv(async e=>{let{chatArgs:t,client:n,...r}=Oy(e),{input:i,output:a,expected:o}=Ay({input:r.input,output:r.output,expected:r.expected},`AnswerCorrectness`),s=e.factualityWeight??.75,c=e.answerSimilarityWeight??.25,l=e.answerSimilarity??wy;if(s===0&&c===0)throw Error(`At least one weight must be nonzero`);if(s<0||c<0)throw Error(`Weights must be non-negative`);let[u,d]=await Promise.all([n.chat.completions.create({...t,messages:[{role:`user`,content:gd.render(Ty,{question:i,answer:a,ground_truth:o})}],tools:[{type:`function`,function:{name:`classify_statements`,description:`Classify statements as TP, FP, or FN`,parameters:zp(Ey)}}],tool_choice:{type:`function`,function:{name:`classify_statements`}}}),c===0?null:l({output:a,expected:o,openAiApiKey:e.openAiApiKey,model:e.embeddingModel})]),f=Ey.parse(jy(u)),p=Dy(f),m=d?.score??0;return{name:`AnswerCorrectness`,score:(s*p+c*m)/(s+c),error:m===null?`AnswerSimilarity failed`:void 0,metadata:{factuality:f,factualityScore:p,answerSimilarityScore:m}}},`AnswerCorrectness`);function Oy(e){let{input:t,output:n,expected:r,context:i,...a}=e,o={model:e.model??Q_(),temperature:e.temperature??0};return e.maxTokens&&(o.max_tokens=e.maxTokens),{input:t,output:n,expected:r,context:ky(i),chatArgs:o,client:Z_(a)}}function ky(e){return e===void 0?e:Array.isArray(e)?e.join(`
|
|
443
|
+
`):e}function Ay(e,t){for(let[n,r]of Object.entries(e))if(r===void 0)throw Error(`${t} requires ${n} value`);return e}function jy(e){let t=e.choices[0]?.message.tool_calls?.[0];if(!t||t.type!==`function`)throw Error(`No tool call returned`);return JSON.parse(t.function.arguments)}dv(e=>{let t=My(e.output)||My(e.expected),[n,r]=[Ny(e.output??null,t),Ny(e.expected??null,t)];return{name:`ExactMatch`,score:+(n===r)}},`ExactMatch`);function My(e){return typeof e==`object`||Array.isArray(e)}function Ny(e,t){if(My(e))return JSON.stringify(e);try{if(typeof e==`string`&&t)return JSON.stringify(JSON.parse(e))}catch{}return`${e}`}uv.battle,uv.closed_q_a,uv.humor,uv.factuality,uv.possible,uv.security,uv.sql,uv.summary,uv.translation;export{Wv as a,Uv as i,Hv as n,Gv as r,Vv as t};
|