med-scribe-alliance-ts-sdk 2.0.49 → 2.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +37 -14
- package/dist/worker.bundle.js +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -383,10 +383,12 @@ function M() {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
|
-
//#region src/transport/
|
|
386
|
+
//#region src/transport/upload-body.ts
|
|
387
387
|
function N(e) {
|
|
388
388
|
return e.uploadBodyMode ? e.uploadBodyMode === "multipart" : !!e.uploadFormFields;
|
|
389
389
|
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/transport/http-transport.ts
|
|
390
392
|
var P = class {
|
|
391
393
|
constructor(e) {
|
|
392
394
|
this.tokenRefreshPromise = null, this.accessToken = e.accessToken, this.flavour = e.flavour, this.debug = e.debug ?? !1, this.onUnauthorized = e.onUnauthorized;
|
|
@@ -581,7 +583,7 @@ var P = class {
|
|
|
581
583
|
}
|
|
582
584
|
buildHeaders(e) {
|
|
583
585
|
let t = {}, n = e.isUpload === !0 && e.attachAuth === !1;
|
|
584
|
-
if (e.isUpload ? e
|
|
586
|
+
if (e.isUpload ? N(e) || (t["Content-Type"] = "audio/mp3") : (t["Content-Type"] = "application/json", t.Accept = "application/json"), !n) {
|
|
585
587
|
this.accessToken && (t.Authorization = `Bearer ${this.accessToken}`), this.flavour && (t.flavour = this.flavour);
|
|
586
588
|
let e = M();
|
|
587
589
|
e && (t[j] = e);
|
|
@@ -597,7 +599,7 @@ var P = class {
|
|
|
597
599
|
};
|
|
598
600
|
if (t.isUpload && t.uploadBlob) {
|
|
599
601
|
let e = await t.uploadBlob.arrayBuffer(), n = new Uint8Array(e);
|
|
600
|
-
r.blobData = this.uint8ArrayToBase64(n), t
|
|
602
|
+
r.blobData = this.uint8ArrayToBase64(n), N(t) && (r.uploadFormFields = t.uploadFormFields ?? {}, r.uploadFileFieldName = t.uploadFileFieldName ?? "file", r.uploadFileName = t.uploadFileName);
|
|
601
603
|
} else t.body !== void 0 && (r.body = t.body);
|
|
602
604
|
return r;
|
|
603
605
|
}
|
|
@@ -1286,7 +1288,29 @@ var De = e.object({
|
|
|
1286
1288
|
attachAuth: !1
|
|
1287
1289
|
};
|
|
1288
1290
|
}
|
|
1289
|
-
}, je = e.string().trim().min(1, "upload_url is required"), Me = "
|
|
1291
|
+
}, je = e.string().trim().min(1, "upload_url is required"), Me = "Content-Type", Ne = "audio/mp3", Pe = new Set([
|
|
1292
|
+
"audio/webm;codecs=opus",
|
|
1293
|
+
"audio/wav",
|
|
1294
|
+
"audio/ogg",
|
|
1295
|
+
"audio/ogg;codecs=opus",
|
|
1296
|
+
"audio/mp4",
|
|
1297
|
+
"audio/m4a",
|
|
1298
|
+
"audio/mp3"
|
|
1299
|
+
]), Fe = {
|
|
1300
|
+
mp3: "audio/mp3",
|
|
1301
|
+
webm: "audio/webm;codecs=opus",
|
|
1302
|
+
wav: "audio/wav",
|
|
1303
|
+
ogg: "audio/ogg",
|
|
1304
|
+
m4a: "audio/m4a",
|
|
1305
|
+
mp4: "audio/mp4"
|
|
1306
|
+
};
|
|
1307
|
+
function Ie(e, t) {
|
|
1308
|
+
let n = Fe[e.split(".").pop()?.toLowerCase() ?? ""];
|
|
1309
|
+
if (n) return n;
|
|
1310
|
+
let r = t?.type;
|
|
1311
|
+
return r && Pe.has(r) ? r : Ne;
|
|
1312
|
+
}
|
|
1313
|
+
var G = class {
|
|
1290
1314
|
constructor() {
|
|
1291
1315
|
this.name = "backend";
|
|
1292
1316
|
}
|
|
@@ -1296,9 +1320,8 @@ var De = e.object({
|
|
|
1296
1320
|
return {
|
|
1297
1321
|
url: `${r.data.replace(/\/+$/, "")}/${encodeURIComponent(e)}`,
|
|
1298
1322
|
method: "POST",
|
|
1299
|
-
bodyMode: "
|
|
1300
|
-
|
|
1301
|
-
headers: {},
|
|
1323
|
+
bodyMode: "binary",
|
|
1324
|
+
headers: { [Me]: Ie(e, t) },
|
|
1302
1325
|
attachAuth: !0
|
|
1303
1326
|
};
|
|
1304
1327
|
}
|
|
@@ -1309,7 +1332,7 @@ var De = e.object({
|
|
|
1309
1332
|
function q(e) {
|
|
1310
1333
|
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
1311
1334
|
}
|
|
1312
|
-
function
|
|
1335
|
+
function Le(e) {
|
|
1313
1336
|
return q(e) in K;
|
|
1314
1337
|
}
|
|
1315
1338
|
function J(e) {
|
|
@@ -1341,7 +1364,7 @@ async function Y(e, t) {
|
|
|
1341
1364
|
}
|
|
1342
1365
|
//#endregion
|
|
1343
1366
|
//#region src/worker/worker-manager.ts
|
|
1344
|
-
var
|
|
1367
|
+
var Re = class {
|
|
1345
1368
|
constructor(e, t, n, r) {
|
|
1346
1369
|
if (this.worker = null, this.port = null, this.useWorker = !1, this.uploadPayload = {}, this.storageProviderName = "", this.uploadHeaders = {}, this.refreshUploadUrl = null, this.inFlightRefresh = null, this.pendingUploads = /* @__PURE__ */ new Set(), this.allUploadsResolver = null, this.callbackRegistry = e, this.fileManager = t, this.transport = n, !r?.forceMainThread && typeof SharedWorker < "u" && r?.workerScriptUrl) try {
|
|
1347
1370
|
this.worker = new SharedWorker(r.workerScriptUrl, { name: "scribe-sdk-worker" }), this.port = this.worker.port, this.port.onmessage = (e) => {
|
|
@@ -1570,7 +1593,7 @@ var Pe = class {
|
|
|
1570
1593
|
shortSilenceThreshold: n?.shortSilenceThreshold,
|
|
1571
1594
|
longSilenceThreshold: n?.longSilenceThreshold
|
|
1572
1595
|
};
|
|
1573
|
-
this.vadClient = new Ce(i, e), this.workerManager = new
|
|
1596
|
+
this.vadClient = new Ce(i, e), this.workerManager = new Re(e, this.fileManager, t, r), this.wireVadCallbacks();
|
|
1574
1597
|
}
|
|
1575
1598
|
initialize(e, t) {
|
|
1576
1599
|
if (!t.upload || typeof t.upload != "object") throw Error("Chunked recording requires a presigned upload payload object, not a URL string.");
|
|
@@ -2197,7 +2220,7 @@ var Pe = class {
|
|
|
2197
2220
|
partialCleanupAfterFailedFinalize() {
|
|
2198
2221
|
this.recorder = null, this._isRecording = !1, this._isStarting = !1;
|
|
2199
2222
|
}
|
|
2200
|
-
},
|
|
2223
|
+
}, ze = class {
|
|
2201
2224
|
constructor(e) {
|
|
2202
2225
|
this.isInitialized = !1, this.validateConfig(e), this.config = {
|
|
2203
2226
|
debug: !1,
|
|
@@ -2438,7 +2461,7 @@ var Pe = class {
|
|
|
2438
2461
|
if (!e.baseUrl) throw new y("baseUrl is required");
|
|
2439
2462
|
}
|
|
2440
2463
|
}, $ = "worker.bundle.js";
|
|
2441
|
-
function
|
|
2464
|
+
function Be() {
|
|
2442
2465
|
if (typeof window < "u" && window.__MEDSCRIBE_WORKER_URL__) return window.__MEDSCRIBE_WORKER_URL__;
|
|
2443
2466
|
if (typeof document < "u" && document.currentScript) {
|
|
2444
2467
|
let e = document.currentScript.src;
|
|
@@ -2446,11 +2469,11 @@ function Ie() {
|
|
|
2446
2469
|
}
|
|
2447
2470
|
return `/${$}`;
|
|
2448
2471
|
}
|
|
2449
|
-
async function
|
|
2472
|
+
async function Ve(e) {
|
|
2450
2473
|
let t = e ?? `https://cdn.jsdelivr.net/npm/med-scribe-alliance-ts-sdk/dist/${$}`, n = await fetch(t);
|
|
2451
2474
|
if (!n.ok) throw Error(`Failed to fetch worker script: ${n.status} ${n.statusText}`);
|
|
2452
2475
|
let r = await n.text(), i = new Blob([r], { type: "application/javascript" });
|
|
2453
2476
|
return URL.createObjectURL(i);
|
|
2454
2477
|
}
|
|
2455
2478
|
//#endregion
|
|
2456
|
-
export { ve as AWS_STORAGE_PROVIDER, d as AudioEventType, x as AuthenticationError, W as AwsS3StorageProvider, I as BACKEND_STORAGE_PROVIDER, G as BackendStorageProvider, O as CallbackRegistry, c as CommunicationProtocol, h as DiscardReason, b as DiscoveryError, z as DiscoveryManager, g as ErrorCode, m as ErrorEventType, S as ForbiddenError, _ as HttpStatus, P as HttpTransport, F as IpcTransport, w as RateLimitError, Q as RecordingManager, u as RecordingState,
|
|
2479
|
+
export { ve as AWS_STORAGE_PROVIDER, d as AudioEventType, x as AuthenticationError, W as AwsS3StorageProvider, I as BACKEND_STORAGE_PROVIDER, G as BackendStorageProvider, O as CallbackRegistry, c as CommunicationProtocol, h as DiscardReason, b as DiscoveryError, z as DiscoveryManager, g as ErrorCode, m as ErrorEventType, S as ForbiddenError, _ as HttpStatus, P as HttpTransport, F as IpcTransport, w as RateLimitError, Q as RecordingManager, u as RecordingState, ze as ScribeClient, v as ScribeError, p as SessionEventType, te as SessionExpiredError, B as SessionManager, C as SessionNotFoundError, a as SessionStatus, o as TemplateStatus, T as TransportError, l as TransportMode, D as UnsupportedStorageProviderError, E as UploadError, f as UploadEventType, s as UploadType, y as ValidationError, k as Validator, ne as WorkerError, Ve as createWorkerBlobUrl, J as getStorageProvider, Be as getWorkerUrl, L as hasUploadPayload, Le as isStorageProviderSupported, R as resolveStorageProvider };
|
package/dist/worker.bundle.js
CHANGED
|
@@ -74,4 +74,4 @@ bitsperframe: %d
|
|
|
74
74
|
|
|
75
75
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=pr,s=!er.jitless,c=s&&mr.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ca([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Ea(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Or(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Mr(e,r,tr())))}),t)}var Da=Y(`$ZodUnion`,(e,t)=>{Ui.init(e,t),X(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),X(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),X(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),X(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>or(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ea(t,r,e,i)):Ea(o,r,e,i)}}),Oa=Y(`$ZodIntersection`,(e,t)=>{Ui.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Aa(e,t,n)):Aa(e,i,a)}});function ka(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(hr(e)&&hr(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=ka(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=ka(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Aa(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Or(e))return e;let o=ka(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ja=Y(`$ZodRecord`,(e,t)=>{Ui.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!hr(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Mr(e,r,tr())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Ar(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Ar(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ei.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Mr(e,r,tr())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ar(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ar(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ma=Y(`$ZodEnum`,(e,t)=>{Ui.init(e,t);let n=nr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>_r.has(typeof e)).map(e=>typeof e==`string`?vr(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Na=Y(`$ZodTransform`,(e,t)=>{Ui.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Qn;return n.value=i,n.fallback=!0,n}});function Pa(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Fa=Y(`$ZodOptional`,(e,t)=>{Ui.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,X(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),X(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${or(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Pa(e,r)):Pa(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Ia=Y(`$ZodExactOptional`,(e,t)=>{Fa.init(e,t),X(e._zod,`values`,()=>t.innerType._zod.values),X(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),La=Y(`$ZodNullable`,(e,t)=>{Ui.init(e,t),X(e._zod,`optin`,()=>t.innerType._zod.optin),X(e._zod,`optout`,()=>t.innerType._zod.optout),X(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${or(e.source)}|null)$`):void 0}),X(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ra=Y(`$ZodDefault`,(e,t)=>{Ui.init(e,t),e._zod.optin=`optional`,X(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>za(e,t)):za(r,t)}});function za(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ba=Y(`$ZodPrefault`,(e,t)=>{Ui.init(e,t),e._zod.optin=`optional`,X(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Va=Y(`$ZodNonOptional`,(e,t)=>{Ui.init(e,t),X(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ha(t,e)):Ha(i,e)}});function Ha(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Ua=Y(`$ZodCatch`,(e,t)=>{Ui.init(e,t),e._zod.optin=`optional`,X(e._zod,`optout`,()=>t.innerType._zod.optout),X(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Mr(e,n,tr()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Mr(e,n,tr()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Wa=Y(`$ZodPipe`,(e,t)=>{Ui.init(e,t),X(e._zod,`values`,()=>t.in._zod.values),X(e._zod,`optin`,()=>t.in._zod.optin),X(e._zod,`optout`,()=>t.out._zod.optout),X(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ga(e,t.in,n)):Ga(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ga(e,t.out,n)):Ga(r,t.out,n)}});function Ga(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Ka=Y(`$ZodReadonly`,(e,t)=>{Ui.init(e,t),X(e._zod,`propValues`,()=>t.innerType._zod.propValues),X(e._zod,`values`,()=>t.innerType._zod.values),X(e._zod,`optin`,()=>t.innerType?._zod?.optin),X(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(qa):qa(r)}});function qa(e){return e.value=Object.freeze(e.value),e}var Ja=Y(`$ZodCustom`,(e,t)=>{ki.init(e,t),Ui.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ya(t,n,r,e));Ya(i,n,r,e)}});function Ya(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Pr(e))}}var Xa,Za=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Qa(){return new Za}(Xa=globalThis).__zod_globalRegistry??(Xa.__zod_globalRegistry=Qa());var $a=globalThis.__zod_globalRegistry;function eo(e,t){return new e({type:`string`,...Z(t)})}function to(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Z(t)})}function no(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Z(t)})}function ro(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Z(t)})}function io(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Z(t)})}function ao(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Z(t)})}function oo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Z(t)})}function so(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Z(t)})}function co(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Z(t)})}function lo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Z(t)})}function uo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Z(t)})}function fo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Z(t)})}function po(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Z(t)})}function mo(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Z(t)})}function ho(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Z(t)})}function go(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Z(t)})}function _o(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Z(t)})}function vo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Z(t)})}function yo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Z(t)})}function bo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Z(t)})}function xo(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Z(t)})}function So(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Z(t)})}function Co(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Z(t)})}function wo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Z(t)})}function To(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Z(t)})}function Eo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Z(t)})}function Do(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Z(t)})}function Oo(e){return new e({type:`unknown`})}function ko(e,t){return new e({type:`never`,...Z(t)})}function Ao(e,t){return new Ai({check:`max_length`,...Z(t),maximum:e})}function jo(e,t){return new ji({check:`min_length`,...Z(t),minimum:e})}function Mo(e,t){return new Mi({check:`length_equals`,...Z(t),length:e})}function No(e,t){return new Pi({check:`string_format`,format:`regex`,...Z(t),pattern:e})}function Po(e){return new Fi({check:`string_format`,format:`lowercase`,...Z(e)})}function Fo(e){return new Ii({check:`string_format`,format:`uppercase`,...Z(e)})}function Io(e,t){return new Li({check:`string_format`,format:`includes`,...Z(t),includes:e})}function Lo(e,t){return new Ri({check:`string_format`,format:`starts_with`,...Z(t),prefix:e})}function Ro(e,t){return new zi({check:`string_format`,format:`ends_with`,...Z(t),suffix:e})}function zo(e){return new Bi({check:`overwrite`,tx:e})}function Bo(e){return zo(t=>t.normalize(e))}function Vo(){return zo(e=>e.trim())}function Ho(){return zo(e=>e.toLowerCase())}function Uo(){return zo(e=>e.toUpperCase())}function Wo(){return zo(e=>dr(e))}function Go(e,t,n){return new e({type:`array`,element:t,...Z(n)})}function Ko(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Z(n)})}function qo(e,t){let n=Jo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Pr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Pr(r))}},e(t.value,t)),t);return n}function Jo(e,t){let n=new ki({check:`custom`,...Z(t)});return n._zod.check=e,n}function Yo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??$a,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Xo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Xo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&$o(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Zo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
76
76
|
|
|
77
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Qo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ts(t,`input`,e.processors),output:ts(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function $o(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return $o(r.element,n);if(r.type===`set`)return $o(r.valueType,n);if(r.type===`lazy`)return $o(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return $o(r.innerType,n);if(r.type===`intersection`)return $o(r.left,n)||$o(r.right,n);if(r.type===`record`||r.type===`map`)return $o(r.keyType,n)||$o(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:$o(r.in,n)||$o(r.out,n);if(r.type===`object`){for(let e in r.shape)if($o(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if($o(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if($o(e,n))return!0;return!!(r.rest&&$o(r.rest,n))}return!1}var es=(e,t={})=>n=>{let r=Yo({...n,processors:t});return Xo(e,r),Zo(r,e),Qo(r,e)},ts=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Yo({...i??{},target:a,io:t,processors:n});return Xo(e,o),Zo(o,e),Qo(o,e)},ns={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},rs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ns[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},is=(e,t,n,r)=>{n.not={}},as=(e,t,n,r)=>{let i=e._zod.def,a=nr(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ss=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},cs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Xo(a.element,t,{...r,path:[...r.path,`items`]})},ls=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Xo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Xo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},us=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Xo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ds=(e,t,n,r)=>{let i=e._zod.def,a=Xo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Xo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},fs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Xo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Xo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Xo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ps=(e,t,n,r)=>{let i=e._zod.def,a=Xo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ms=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},hs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},gs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},_s=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},vs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Xo(o,t,r);let s=t.seen.get(e);s.ref=o},ys=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=Y(`ZodISODateTime`,(e,t)=>{na.init(e,t),$.init(e,t)});function Ss(e){return wo(xs,e)}var Cs=Y(`ZodISODate`,(e,t)=>{ra.init(e,t),$.init(e,t)});function ws(e){return To(Cs,e)}var Ts=Y(`ZodISOTime`,(e,t)=>{ia.init(e,t),$.init(e,t)});function Es(e){return Eo(Ts,e)}var Ds=Y(`ZodISODuration`,(e,t)=>{aa.init(e,t),$.init(e,t)});function Os(e){return Do(Ds,e)}var ks=Y(`ZodError`,(e,t)=>{Ir.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>zr(e,t)},flatten:{value:t=>Rr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,rr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,rr,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),As=Br(ks),js=Vr(ks),Ms=Hr(ks),Ns=Wr(ks),Ps=Kr(ks),Fs=qr(ks),Is=Jr(ks),Ls=Yr(ks),Rs=Xr(ks),zs=Zr(ks),Bs=Qr(ks),Vs=$r(ks),Hs=new WeakMap;function Us(e,t,n){let r=Object.getPrototypeOf(e),i=Hs.get(r);if(i||(i=new Set,Hs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Ws=Y(`ZodType`,(e,t)=>(Ui.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ts(e,`input`),output:ts(e,`output`)}}),e.toJSONSchema=es(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>As(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ms(e,t,n),e.parseAsync=async(t,n)=>js(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ns(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ps(e,t,n),e.decode=(t,n)=>Fs(e,t,n),e.encodeAsync=async(t,n)=>Is(e,t,n),e.decodeAsync=async(t,n)=>Ls(e,t,n),e.safeEncode=(t,n)=>Rs(e,t,n),e.safeDecode=(t,n)=>zs(e,t,n),e.safeEncodeAsync=async(t,n)=>Bs(e,t,n),e.safeDecodeAsync=async(t,n)=>Vs(e,t,n),Us(e,`ZodType`,{check(...e){let t=this.def;return this.clone(lr(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return yr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xc(e,t))},superRefine(e,t){return this.check(Zc(e,t))},overwrite(e){return this.check(zo(e))},optional(){return Mc(this)},exactOptional(){return Pc(this)},nullable(){return Ic(this)},nullish(){return Mc(Ic(this))},nonoptional(e){return Hc(this,e)},array(){return vc(this)},or(e){return Sc([this,e])},and(e){return wc(this,e)},transform(e){return Kc(this,Ac(e))},default(e){return Rc(this,e)},prefault(e){return Bc(this,e)},catch(e){return Wc(this,e)},pipe(e){return Kc(this,e)},readonly(){return Jc(this)},describe(e){let t=this.clone();return $a.add(t,{description:e}),t},meta(...e){if(e.length===0)return $a.get(this);let t=this.clone();return $a.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return $a.get(e)?.description},configurable:!0}),e)),Gs=Y(`_ZodString`,(e,t)=>{Wi.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Us(e,`_ZodString`,{regex(...e){return this.check(No(...e))},includes(...e){return this.check(Io(...e))},startsWith(...e){return this.check(Lo(...e))},endsWith(...e){return this.check(Ro(...e))},min(...e){return this.check(jo(...e))},max(...e){return this.check(Ao(...e))},length(...e){return this.check(Mo(...e))},nonempty(...e){return this.check(jo(1,...e))},lowercase(e){return this.check(Po(e))},uppercase(e){return this.check(Fo(e))},trim(){return this.check(Vo())},normalize(...e){return this.check(Bo(...e))},toLowerCase(){return this.check(Ho())},toUpperCase(){return this.check(Uo())},slugify(){return this.check(Wo())}})}),Ks=Y(`ZodString`,(e,t)=>{Wi.init(e,t),Gs.init(e,t),e.email=t=>e.check(to(Js,t)),e.url=t=>e.check(so(Zs,t)),e.jwt=t=>e.check(Co(fc,t)),e.emoji=t=>e.check(co(Qs,t)),e.guid=t=>e.check(no(Ys,t)),e.uuid=t=>e.check(ro(Xs,t)),e.uuidv4=t=>e.check(io(Xs,t)),e.uuidv6=t=>e.check(ao(Xs,t)),e.uuidv7=t=>e.check(oo(Xs,t)),e.nanoid=t=>e.check(lo($s,t)),e.guid=t=>e.check(no(Ys,t)),e.cuid=t=>e.check(uo(ec,t)),e.cuid2=t=>e.check(fo(tc,t)),e.ulid=t=>e.check(po(nc,t)),e.base64=t=>e.check(bo(lc,t)),e.base64url=t=>e.check(xo(uc,t)),e.xid=t=>e.check(mo(rc,t)),e.ksuid=t=>e.check(ho(ic,t)),e.ipv4=t=>e.check(go(ac,t)),e.ipv6=t=>e.check(_o(oc,t)),e.cidrv4=t=>e.check(vo(sc,t)),e.cidrv6=t=>e.check(yo(cc,t)),e.e164=t=>e.check(So(dc,t)),e.datetime=t=>e.check(Ss(t)),e.date=t=>e.check(ws(t)),e.time=t=>e.check(Es(t)),e.duration=t=>e.check(Os(t))});function qs(e){return eo(Ks,e)}var $=Y(`ZodStringFormat`,(e,t)=>{Q.init(e,t),Gs.init(e,t)}),Js=Y(`ZodEmail`,(e,t)=>{qi.init(e,t),$.init(e,t)}),Ys=Y(`ZodGUID`,(e,t)=>{Gi.init(e,t),$.init(e,t)}),Xs=Y(`ZodUUID`,(e,t)=>{Ki.init(e,t),$.init(e,t)}),Zs=Y(`ZodURL`,(e,t)=>{Ji.init(e,t),$.init(e,t)}),Qs=Y(`ZodEmoji`,(e,t)=>{Yi.init(e,t),$.init(e,t)}),$s=Y(`ZodNanoID`,(e,t)=>{Xi.init(e,t),$.init(e,t)}),ec=Y(`ZodCUID`,(e,t)=>{Zi.init(e,t),$.init(e,t)}),tc=Y(`ZodCUID2`,(e,t)=>{Qi.init(e,t),$.init(e,t)}),nc=Y(`ZodULID`,(e,t)=>{$i.init(e,t),$.init(e,t)}),rc=Y(`ZodXID`,(e,t)=>{ea.init(e,t),$.init(e,t)}),ic=Y(`ZodKSUID`,(e,t)=>{ta.init(e,t),$.init(e,t)}),ac=Y(`ZodIPv4`,(e,t)=>{oa.init(e,t),$.init(e,t)}),oc=Y(`ZodIPv6`,(e,t)=>{sa.init(e,t),$.init(e,t)}),sc=Y(`ZodCIDRv4`,(e,t)=>{ca.init(e,t),$.init(e,t)}),cc=Y(`ZodCIDRv6`,(e,t)=>{la.init(e,t),$.init(e,t)}),lc=Y(`ZodBase64`,(e,t)=>{da.init(e,t),$.init(e,t)}),uc=Y(`ZodBase64URL`,(e,t)=>{pa.init(e,t),$.init(e,t)}),dc=Y(`ZodE164`,(e,t)=>{ma.init(e,t),$.init(e,t)}),fc=Y(`ZodJWT`,(e,t)=>{ga.init(e,t),$.init(e,t)}),pc=Y(`ZodUnknown`,(e,t)=>{_a.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mc(){return Oo(pc)}var hc=Y(`ZodNever`,(e,t)=>{va.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function gc(e){return ko(hc,e)}var _c=Y(`ZodArray`,(e,t)=>{ba.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.element=t.element,Us(e,`ZodArray`,{min(e,t){return this.check(jo(e,t))},nonempty(e){return this.check(jo(1,e))},max(e,t){return this.check(Ao(e,t))},length(e,t){return this.check(Mo(e,t))},unwrap(){return this.element}})});function vc(e,t){return Go(_c,e,t)}var yc=Y(`ZodObject`,(e,t)=>{Ta.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),X(e,`shape`,()=>t.shape),Us(e,`ZodObject`,{keyof(){return Oc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mc()})},loose(){return this.clone({...this._zod.def,catchall:mc()})},strict(){return this.clone({...this._zod.def,catchall:gc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Cr(this,e)},safeExtend(e){return wr(this,e)},merge(e){return Tr(this,e)},pick(e){return xr(this,e)},omit(e){return Sr(this,e)},partial(...e){return Er(jc,this,e[0])},required(...e){return Dr(Vc,this,e[0])}})});function bc(e,t){return new yc({type:`object`,shape:e??{},...Z(t)})}var xc=Y(`ZodUnion`,(e,t)=>{Da.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...Z(t)})}var Cc=Y(`ZodIntersection`,(e,t)=>{Oa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function wc(e,t){return new Cc({type:`intersection`,left:e,right:t})}var Tc=Y(`ZodRecord`,(e,t)=>{ja.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ec(e,t,n){return!t||!t._zod?new Tc({type:`record`,keyType:qs(),valueType:e,...Z(t)}):new Tc({type:`record`,keyType:e,valueType:t,...Z(n)})}var Dc=Y(`ZodEnum`,(e,t)=>{Ma.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Dc({...t,checks:[],...Z(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Dc({...t,checks:[],...Z(r),entries:i})}});function Oc(e,t){return new Dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var kc=Y(`ZodTransform`,(e,t)=>{Na.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Pr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Pr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ac(e){return new kc({type:`transform`,transform:e})}var jc=Y(`ZodOptional`,(e,t)=>{Fa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e){return new jc({type:`optional`,innerType:e})}var Nc=Y(`ZodExactOptional`,(e,t)=>{Ia.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Nc({type:`optional`,innerType:e})}var Fc=Y(`ZodNullable`,(e,t)=>{La.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ic(e){return new Fc({type:`nullable`,innerType:e})}var Lc=Y(`ZodDefault`,(e,t)=>{Ra.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rc(e,t){return new Lc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():gr(t)}})}var zc=Y(`ZodPrefault`,(e,t)=>{Ba.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bc(e,t){return new zc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():gr(t)}})}var Vc=Y(`ZodNonOptional`,(e,t)=>{Va.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e,t){return new Vc({type:`nonoptional`,innerType:e,...Z(t)})}var Uc=Y(`ZodCatch`,(e,t)=>{Ua.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wc(e,t){return new Uc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Gc=Y(`ZodPipe`,(e,t)=>{Wa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.in=t.in,e.out=t.out});function Kc(e,t){return new Gc({type:`pipe`,in:e,out:t})}var qc=Y(`ZodReadonly`,(e,t)=>{Ka.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e){return new qc({type:`readonly`,innerType:e})}var Yc=Y(`ZodCustom`,(e,t)=>{Ja.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Xc(e,t={}){return Ko(Yc,e,t)}function Zc(e,t){return qo(e,t)}var Qc=function(e){return e.AUTHENTICATION_FAILED=`authentication_failed`,e.TOKEN_EXPIRED=`token_expired`,e.INVALID_API_KEY=`invalid_api_key`,e.FORBIDDEN=`forbidden`,e.RATE_LIMIT_EXCEEDED=`rate_limit_exceeded`,e.SESSION_NOT_FOUND=`session_not_found`,e.TEMPLATE_NOT_FOUND=`template_not_found`,e.SESSION_EXPIRED=`session_expired`,e.INVALID_REQUEST=`invalid_request`,e.INVALID_AUDIO_FORMAT=`invalid_audio_format`,e.CHUNK_TOO_LARGE=`chunk_too_large`,e.INVALID_TEMPLATE=`invalid_template`,e.MISSING_REQUIRED_FIELD=`missing_required_field`,e.PROCESSING_FAILED=`processing_failed`,e.AUDIO_QUALITY_POOR=`audio_quality_poor`,e.AUDIO_TOO_SHORT=`audio_too_short`,e.LANGUAGE_UNSUPPORTED=`language_unsupported`,e.INTERNAL_ERROR=`internal_error`,e.SERVICE_UNAVAILABLE=`service_unavailable`,e.DISCOVERY_FAILED=`discovery_failed`,e.TRANSPORT_ERROR=`transport_error`,e.WORKER_ERROR=`worker_error`,e.UPLOAD_FAILED=`upload_failed`,e.VAD_ERROR=`vad_error`,e.CHUNK_LENGTH_EXCEEDED=`chunk_length_exceeded`,e.CHUNK_LIMIT_REACHED=`chunk_limit_reached`,e.CHUNK_CREATION_FAILED=`chunk_creation_failed`,e.WORKER_POST_FAILED=`worker_post_failed`,e.SESSION_CREATION_FAILED=`session_creation_failed`,e.RECORDER_INIT_FAILED=`recorder_init_failed`,e.RECORDER_START_FAILED=`recorder_start_failed`,e.VAD_START_FAILED=`vad_start_failed`,e.STOP_FAILED=`stop_failed`,e.INTERNAL_RETRY_FAILED=`internal_retry_failed`,e.SESSION_END_FAILED=`session_end_failed`,e.UNSUPPORTED_STORAGE_PROVIDER=`unsupported_storage_provider`,e}({}),$c=class e extends Error{constructor(t,n=Qc.INTERNAL_ERROR,r,i){super(t),this.name=`ScribeError`,this.code=n,this.httpStatus=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}static fromApiError(t,n){return new e(t.message,t.code,n,t.details)}toJSON(){return{name:this.name,message:this.message,code:this.code,httpStatus:this.httpStatus,details:this.details}}},el=class extends $c{constructor(e,t,n){super(e,Qc.UPLOAD_FAILED,void 0,n),this.name=`UploadError`,this.failedFiles=t}toJSON(){return{...super.toJSON(),failedFiles:this.failedFiles}}},tl=class extends $c{constructor(e){super(`Storage provider '${e||`(none)`}' is not supported by this SDK build.`,Qc.UNSUPPORTED_STORAGE_PROVIDER,void 0,{provider:e}),this.name=`UnsupportedStorageProviderError`,this.provider=e}},nl=bc({uploadData:bc({url:qs().min(1,`uploadData.url is required`),fields:Ec(qs(),qs())}),folderPath:qs().optional(),txn_id:qs().optional()}),rl=`key`,il="${filename}",al=`Content-Type`,ol=`audio/mp3`,sl=class{constructor(){this.name=`aws`}prepareUpload({fileName:e,blob:t,upload:n}){let r=nl.safeParse(n);if(!r.success)throw new el(`Invalid AWS upload payload in session response: ${r.error.message}`,[e]);let{uploadData:i}=r.data,a={};for(let[t,n]of Object.entries(i.fields))a[t]=t===rl?n.split(il).join(e):n;if(!(al in a)){let e=t?.type;a[al]=e&&e.startsWith(`audio/`)?e:ol}return{url:i.url,method:`POST`,bodyMode:`multipart`,formFields:a,fileFieldName:`file`,headers:{},attachAuth:!1}}},cl=qs().trim().min(1,`upload_url is required`),ll=`file`,ul=class{constructor(){this.name=`backend`}prepareUpload({fileName:e,blob:t,upload:n}){let r=cl.safeParse(n);if(!r.success)throw new el(`Invalid backend upload payload: expected an upload_url string, got ${typeof n}`,[e]);return{url:`${r.data.replace(/\/+$/,``)}/${encodeURIComponent(e)}`,method:`POST`,bodyMode:`multipart`,fileFieldName:ll,headers:{},attachAuth:!0}}},dl={aws:()=>new sl,backend:()=>new ul};function fl(e){return typeof e==`string`?e.trim().toLowerCase():``}function pl(e){let t=dl[fl(e)];if(!t)throw new tl(e);return t()}var ml=2,hl=2e3,gl=1e4,_l,vl=[],yl=new Map,bl=null,xl=new Map;function Sl(e,t){let n=xl.get(e);if(n){xl.delete(e);for(let e of n)e(t)}}function Cl(e,t){try{e.postMessage(t)}catch{}}function wl(e){for(let t of vl)Cl(t,e)}function Tl(){return new Promise(e=>{let t=bl;bl=()=>{t?.(),e()},setTimeout(()=>{e()},gl)})}function El(e){return new Promise(t=>{let n=xl.get(e);n||(n=new Set,xl.set(e,n)),n.add(t),setTimeout(()=>{let n=xl.get(e);n?.has(t)&&(n.delete(t),n.size===0&&xl.delete(e),t(null))},gl)})}function Dl(e,t,n,r){let i={...e.headers};e.attachAuth&&(Object.assign(i,r),_l&&(i.Authorization=`Bearer ${_l}`));let a;if(e.bodyMode===`multipart`&&e.formFields){let r=new FormData;for(let[t,n]of Object.entries(e.formFields))r.append(t,n);r.append(e.fileFieldName??`file`,n,t),a=r}else a=n,i[`Content-Type`]||=`audio/mp3`;return{method:e.method,body:a,headers:i,credentials:e.attachAuth?`include`:`omit`}}async function Ol(e,t,n,r,i){Cl(e,{type:`upload_url_required`,fileName:n});let a=await El(e);if(!a)return i;try{return pl(t).prepareUpload({fileName:n,blob:r,upload:a})}catch{return i}}async function kl(e,t,n,r,i,a){let o=`Upload failed after retries`,s;for(let c=0;c<=ml;c++)try{let l=await fetch(e.url,Dl(e,t,n,r));if(l.ok)return{success:!0};if(s=l.status,o=await Al(l),l.status===401&&e.attachAuth){wl({type:`token_required`}),await Tl();continue}if(c<ml){e=await Ol(a,i,t,n,e),await jl(hl);continue}return{success:!1,error:o,statusCode:s}}catch(r){o=r?.message??`Network error`,c<ml&&(e=await Ol(a,i,t,n,e),await jl(hl))}return{success:!1,error:o,statusCode:s}}async function Al(e){try{let t=await e.json();return t?.error?.message??t?.message??e.statusText??`Request failed`}catch{return e.statusText??`HTTP ${e.status}`}}function jl(e){return new Promise(t=>setTimeout(t,e))}async function Ml(e,t,n,r,i,a){try{let o=Xn(e);if(!o){Cl(a,{type:`upload_failed`,fileName:t,error:`MP3 encoding failed`});return}Cl(a,{type:`chunk_encoded`,fileName:t,chunkData:o.chunks});let s;try{s=pl(n).prepareUpload({fileName:t,blob:o.blob,upload:r})}catch(e){Cl(a,{type:`upload_failed`,fileName:t,error:e?.message??`Failed to prepare upload`,chunkData:o.chunks});return}let c=await kl(s,t,o.blob,i,n,a);c.success?Cl(a,{type:`upload_success`,fileName:t}):Cl(a,{type:`upload_failed`,fileName:t,error:c.error??`Upload failed after retries`,chunkData:o.chunks})}catch(e){Cl(a,{type:`upload_failed`,fileName:t,error:e?.message??`Unknown error`})}}function Nl(e,t){switch(e.type){case`compress_and_upload`:{yl.has(t)||yl.set(t,new Set);let n=yl.get(t),r=Ml(e.audioFrames,e.fileName,e.storageProvider,e.upload,e.headers,t);n.add(r),r.finally(()=>n.delete(r));break}case`wait_for_all_uploads`:{let e=yl.get(t)??new Set;Promise.all(e).then(()=>{Cl(t,{type:`all_uploads_complete`})});break}case`update_auth_token`:_l=e.token,bl&&=(bl(),null);break;case`update_upload_url`:Sl(t,e.upload);break;case`terminate`:{let e=vl.indexOf(t);e>=0&&vl.splice(e,1),yl.delete(t),Sl(t,null);try{t.close()}catch{}vl.length===0&&self.close();break}}}var Pl=self;Pl.onconnect=e=>{let t=e.ports[0];vl.push(t),t.onmessage=e=>{Nl(e.data,t)},t.start()}})();
|
|
77
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Qo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ts(t,`input`,e.processors),output:ts(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function $o(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return $o(r.element,n);if(r.type===`set`)return $o(r.valueType,n);if(r.type===`lazy`)return $o(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return $o(r.innerType,n);if(r.type===`intersection`)return $o(r.left,n)||$o(r.right,n);if(r.type===`record`||r.type===`map`)return $o(r.keyType,n)||$o(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:$o(r.in,n)||$o(r.out,n);if(r.type===`object`){for(let e in r.shape)if($o(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if($o(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if($o(e,n))return!0;return!!(r.rest&&$o(r.rest,n))}return!1}var es=(e,t={})=>n=>{let r=Yo({...n,processors:t});return Xo(e,r),Zo(r,e),Qo(r,e)},ts=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Yo({...i??{},target:a,io:t,processors:n});return Xo(e,o),Zo(o,e),Qo(o,e)},ns={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},rs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ns[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},is=(e,t,n,r)=>{n.not={}},as=(e,t,n,r)=>{let i=e._zod.def,a=nr(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ss=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},cs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Xo(a.element,t,{...r,path:[...r.path,`items`]})},ls=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Xo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Xo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},us=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Xo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ds=(e,t,n,r)=>{let i=e._zod.def,a=Xo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Xo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},fs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Xo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Xo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Xo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ps=(e,t,n,r)=>{let i=e._zod.def,a=Xo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ms=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},hs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},gs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},_s=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},vs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Xo(o,t,r);let s=t.seen.get(e);s.ref=o},ys=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bs=(e,t,n,r)=>{let i=e._zod.def;Xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=Y(`ZodISODateTime`,(e,t)=>{na.init(e,t),$.init(e,t)});function Ss(e){return wo(xs,e)}var Cs=Y(`ZodISODate`,(e,t)=>{ra.init(e,t),$.init(e,t)});function ws(e){return To(Cs,e)}var Ts=Y(`ZodISOTime`,(e,t)=>{ia.init(e,t),$.init(e,t)});function Es(e){return Eo(Ts,e)}var Ds=Y(`ZodISODuration`,(e,t)=>{aa.init(e,t),$.init(e,t)});function Os(e){return Do(Ds,e)}var ks=Y(`ZodError`,(e,t)=>{Ir.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>zr(e,t)},flatten:{value:t=>Rr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,rr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,rr,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),As=Br(ks),js=Vr(ks),Ms=Hr(ks),Ns=Wr(ks),Ps=Kr(ks),Fs=qr(ks),Is=Jr(ks),Ls=Yr(ks),Rs=Xr(ks),zs=Zr(ks),Bs=Qr(ks),Vs=$r(ks),Hs=new WeakMap;function Us(e,t,n){let r=Object.getPrototypeOf(e),i=Hs.get(r);if(i||(i=new Set,Hs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Ws=Y(`ZodType`,(e,t)=>(Ui.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ts(e,`input`),output:ts(e,`output`)}}),e.toJSONSchema=es(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>As(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ms(e,t,n),e.parseAsync=async(t,n)=>js(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ns(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ps(e,t,n),e.decode=(t,n)=>Fs(e,t,n),e.encodeAsync=async(t,n)=>Is(e,t,n),e.decodeAsync=async(t,n)=>Ls(e,t,n),e.safeEncode=(t,n)=>Rs(e,t,n),e.safeDecode=(t,n)=>zs(e,t,n),e.safeEncodeAsync=async(t,n)=>Bs(e,t,n),e.safeDecodeAsync=async(t,n)=>Vs(e,t,n),Us(e,`ZodType`,{check(...e){let t=this.def;return this.clone(lr(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return yr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xc(e,t))},superRefine(e,t){return this.check(Zc(e,t))},overwrite(e){return this.check(zo(e))},optional(){return Mc(this)},exactOptional(){return Pc(this)},nullable(){return Ic(this)},nullish(){return Mc(Ic(this))},nonoptional(e){return Hc(this,e)},array(){return vc(this)},or(e){return Sc([this,e])},and(e){return wc(this,e)},transform(e){return Kc(this,Ac(e))},default(e){return Rc(this,e)},prefault(e){return Bc(this,e)},catch(e){return Wc(this,e)},pipe(e){return Kc(this,e)},readonly(){return Jc(this)},describe(e){let t=this.clone();return $a.add(t,{description:e}),t},meta(...e){if(e.length===0)return $a.get(this);let t=this.clone();return $a.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return $a.get(e)?.description},configurable:!0}),e)),Gs=Y(`_ZodString`,(e,t)=>{Wi.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Us(e,`_ZodString`,{regex(...e){return this.check(No(...e))},includes(...e){return this.check(Io(...e))},startsWith(...e){return this.check(Lo(...e))},endsWith(...e){return this.check(Ro(...e))},min(...e){return this.check(jo(...e))},max(...e){return this.check(Ao(...e))},length(...e){return this.check(Mo(...e))},nonempty(...e){return this.check(jo(1,...e))},lowercase(e){return this.check(Po(e))},uppercase(e){return this.check(Fo(e))},trim(){return this.check(Vo())},normalize(...e){return this.check(Bo(...e))},toLowerCase(){return this.check(Ho())},toUpperCase(){return this.check(Uo())},slugify(){return this.check(Wo())}})}),Ks=Y(`ZodString`,(e,t)=>{Wi.init(e,t),Gs.init(e,t),e.email=t=>e.check(to(Js,t)),e.url=t=>e.check(so(Zs,t)),e.jwt=t=>e.check(Co(fc,t)),e.emoji=t=>e.check(co(Qs,t)),e.guid=t=>e.check(no(Ys,t)),e.uuid=t=>e.check(ro(Xs,t)),e.uuidv4=t=>e.check(io(Xs,t)),e.uuidv6=t=>e.check(ao(Xs,t)),e.uuidv7=t=>e.check(oo(Xs,t)),e.nanoid=t=>e.check(lo($s,t)),e.guid=t=>e.check(no(Ys,t)),e.cuid=t=>e.check(uo(ec,t)),e.cuid2=t=>e.check(fo(tc,t)),e.ulid=t=>e.check(po(nc,t)),e.base64=t=>e.check(bo(lc,t)),e.base64url=t=>e.check(xo(uc,t)),e.xid=t=>e.check(mo(rc,t)),e.ksuid=t=>e.check(ho(ic,t)),e.ipv4=t=>e.check(go(ac,t)),e.ipv6=t=>e.check(_o(oc,t)),e.cidrv4=t=>e.check(vo(sc,t)),e.cidrv6=t=>e.check(yo(cc,t)),e.e164=t=>e.check(So(dc,t)),e.datetime=t=>e.check(Ss(t)),e.date=t=>e.check(ws(t)),e.time=t=>e.check(Es(t)),e.duration=t=>e.check(Os(t))});function qs(e){return eo(Ks,e)}var $=Y(`ZodStringFormat`,(e,t)=>{Q.init(e,t),Gs.init(e,t)}),Js=Y(`ZodEmail`,(e,t)=>{qi.init(e,t),$.init(e,t)}),Ys=Y(`ZodGUID`,(e,t)=>{Gi.init(e,t),$.init(e,t)}),Xs=Y(`ZodUUID`,(e,t)=>{Ki.init(e,t),$.init(e,t)}),Zs=Y(`ZodURL`,(e,t)=>{Ji.init(e,t),$.init(e,t)}),Qs=Y(`ZodEmoji`,(e,t)=>{Yi.init(e,t),$.init(e,t)}),$s=Y(`ZodNanoID`,(e,t)=>{Xi.init(e,t),$.init(e,t)}),ec=Y(`ZodCUID`,(e,t)=>{Zi.init(e,t),$.init(e,t)}),tc=Y(`ZodCUID2`,(e,t)=>{Qi.init(e,t),$.init(e,t)}),nc=Y(`ZodULID`,(e,t)=>{$i.init(e,t),$.init(e,t)}),rc=Y(`ZodXID`,(e,t)=>{ea.init(e,t),$.init(e,t)}),ic=Y(`ZodKSUID`,(e,t)=>{ta.init(e,t),$.init(e,t)}),ac=Y(`ZodIPv4`,(e,t)=>{oa.init(e,t),$.init(e,t)}),oc=Y(`ZodIPv6`,(e,t)=>{sa.init(e,t),$.init(e,t)}),sc=Y(`ZodCIDRv4`,(e,t)=>{ca.init(e,t),$.init(e,t)}),cc=Y(`ZodCIDRv6`,(e,t)=>{la.init(e,t),$.init(e,t)}),lc=Y(`ZodBase64`,(e,t)=>{da.init(e,t),$.init(e,t)}),uc=Y(`ZodBase64URL`,(e,t)=>{pa.init(e,t),$.init(e,t)}),dc=Y(`ZodE164`,(e,t)=>{ma.init(e,t),$.init(e,t)}),fc=Y(`ZodJWT`,(e,t)=>{ga.init(e,t),$.init(e,t)}),pc=Y(`ZodUnknown`,(e,t)=>{_a.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mc(){return Oo(pc)}var hc=Y(`ZodNever`,(e,t)=>{va.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function gc(e){return ko(hc,e)}var _c=Y(`ZodArray`,(e,t)=>{ba.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.element=t.element,Us(e,`ZodArray`,{min(e,t){return this.check(jo(e,t))},nonempty(e){return this.check(jo(1,e))},max(e,t){return this.check(Ao(e,t))},length(e,t){return this.check(Mo(e,t))},unwrap(){return this.element}})});function vc(e,t){return Go(_c,e,t)}var yc=Y(`ZodObject`,(e,t)=>{Ta.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),X(e,`shape`,()=>t.shape),Us(e,`ZodObject`,{keyof(){return Oc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mc()})},loose(){return this.clone({...this._zod.def,catchall:mc()})},strict(){return this.clone({...this._zod.def,catchall:gc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Cr(this,e)},safeExtend(e){return wr(this,e)},merge(e){return Tr(this,e)},pick(e){return xr(this,e)},omit(e){return Sr(this,e)},partial(...e){return Er(jc,this,e[0])},required(...e){return Dr(Vc,this,e[0])}})});function bc(e,t){return new yc({type:`object`,shape:e??{},...Z(t)})}var xc=Y(`ZodUnion`,(e,t)=>{Da.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...Z(t)})}var Cc=Y(`ZodIntersection`,(e,t)=>{Oa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function wc(e,t){return new Cc({type:`intersection`,left:e,right:t})}var Tc=Y(`ZodRecord`,(e,t)=>{ja.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ec(e,t,n){return!t||!t._zod?new Tc({type:`record`,keyType:qs(),valueType:e,...Z(t)}):new Tc({type:`record`,keyType:e,valueType:t,...Z(n)})}var Dc=Y(`ZodEnum`,(e,t)=>{Ma.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Dc({...t,checks:[],...Z(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Dc({...t,checks:[],...Z(r),entries:i})}});function Oc(e,t){return new Dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var kc=Y(`ZodTransform`,(e,t)=>{Na.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Pr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Pr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ac(e){return new kc({type:`transform`,transform:e})}var jc=Y(`ZodOptional`,(e,t)=>{Fa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e){return new jc({type:`optional`,innerType:e})}var Nc=Y(`ZodExactOptional`,(e,t)=>{Ia.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Nc({type:`optional`,innerType:e})}var Fc=Y(`ZodNullable`,(e,t)=>{La.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ic(e){return new Fc({type:`nullable`,innerType:e})}var Lc=Y(`ZodDefault`,(e,t)=>{Ra.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rc(e,t){return new Lc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():gr(t)}})}var zc=Y(`ZodPrefault`,(e,t)=>{Ba.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bc(e,t){return new zc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():gr(t)}})}var Vc=Y(`ZodNonOptional`,(e,t)=>{Va.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e,t){return new Vc({type:`nonoptional`,innerType:e,...Z(t)})}var Uc=Y(`ZodCatch`,(e,t)=>{Ua.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wc(e,t){return new Uc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Gc=Y(`ZodPipe`,(e,t)=>{Wa.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.in=t.in,e.out=t.out});function Kc(e,t){return new Gc({type:`pipe`,in:e,out:t})}var qc=Y(`ZodReadonly`,(e,t)=>{Ka.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e){return new qc({type:`readonly`,innerType:e})}var Yc=Y(`ZodCustom`,(e,t)=>{Ja.init(e,t),Ws.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Xc(e,t={}){return Ko(Yc,e,t)}function Zc(e,t){return qo(e,t)}var Qc=function(e){return e.AUTHENTICATION_FAILED=`authentication_failed`,e.TOKEN_EXPIRED=`token_expired`,e.INVALID_API_KEY=`invalid_api_key`,e.FORBIDDEN=`forbidden`,e.RATE_LIMIT_EXCEEDED=`rate_limit_exceeded`,e.SESSION_NOT_FOUND=`session_not_found`,e.TEMPLATE_NOT_FOUND=`template_not_found`,e.SESSION_EXPIRED=`session_expired`,e.INVALID_REQUEST=`invalid_request`,e.INVALID_AUDIO_FORMAT=`invalid_audio_format`,e.CHUNK_TOO_LARGE=`chunk_too_large`,e.INVALID_TEMPLATE=`invalid_template`,e.MISSING_REQUIRED_FIELD=`missing_required_field`,e.PROCESSING_FAILED=`processing_failed`,e.AUDIO_QUALITY_POOR=`audio_quality_poor`,e.AUDIO_TOO_SHORT=`audio_too_short`,e.LANGUAGE_UNSUPPORTED=`language_unsupported`,e.INTERNAL_ERROR=`internal_error`,e.SERVICE_UNAVAILABLE=`service_unavailable`,e.DISCOVERY_FAILED=`discovery_failed`,e.TRANSPORT_ERROR=`transport_error`,e.WORKER_ERROR=`worker_error`,e.UPLOAD_FAILED=`upload_failed`,e.VAD_ERROR=`vad_error`,e.CHUNK_LENGTH_EXCEEDED=`chunk_length_exceeded`,e.CHUNK_LIMIT_REACHED=`chunk_limit_reached`,e.CHUNK_CREATION_FAILED=`chunk_creation_failed`,e.WORKER_POST_FAILED=`worker_post_failed`,e.SESSION_CREATION_FAILED=`session_creation_failed`,e.RECORDER_INIT_FAILED=`recorder_init_failed`,e.RECORDER_START_FAILED=`recorder_start_failed`,e.VAD_START_FAILED=`vad_start_failed`,e.STOP_FAILED=`stop_failed`,e.INTERNAL_RETRY_FAILED=`internal_retry_failed`,e.SESSION_END_FAILED=`session_end_failed`,e.UNSUPPORTED_STORAGE_PROVIDER=`unsupported_storage_provider`,e}({}),$c=class e extends Error{constructor(t,n=Qc.INTERNAL_ERROR,r,i){super(t),this.name=`ScribeError`,this.code=n,this.httpStatus=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}static fromApiError(t,n){return new e(t.message,t.code,n,t.details)}toJSON(){return{name:this.name,message:this.message,code:this.code,httpStatus:this.httpStatus,details:this.details}}},el=class extends $c{constructor(e,t,n){super(e,Qc.UPLOAD_FAILED,void 0,n),this.name=`UploadError`,this.failedFiles=t}toJSON(){return{...super.toJSON(),failedFiles:this.failedFiles}}},tl=class extends $c{constructor(e){super(`Storage provider '${e||`(none)`}' is not supported by this SDK build.`,Qc.UNSUPPORTED_STORAGE_PROVIDER,void 0,{provider:e}),this.name=`UnsupportedStorageProviderError`,this.provider=e}},nl=bc({uploadData:bc({url:qs().min(1,`uploadData.url is required`),fields:Ec(qs(),qs())}),folderPath:qs().optional(),txn_id:qs().optional()}),rl=`key`,il="${filename}",al=`Content-Type`,ol=`audio/mp3`,sl=class{constructor(){this.name=`aws`}prepareUpload({fileName:e,blob:t,upload:n}){let r=nl.safeParse(n);if(!r.success)throw new el(`Invalid AWS upload payload in session response: ${r.error.message}`,[e]);let{uploadData:i}=r.data,a={};for(let[t,n]of Object.entries(i.fields))a[t]=t===rl?n.split(il).join(e):n;if(!(al in a)){let e=t?.type;a[al]=e&&e.startsWith(`audio/`)?e:ol}return{url:i.url,method:`POST`,bodyMode:`multipart`,formFields:a,fileFieldName:`file`,headers:{},attachAuth:!1}}},cl=qs().trim().min(1,`upload_url is required`),ll=`Content-Type`,ul=`audio/mp3`,dl=new Set([`audio/webm;codecs=opus`,`audio/wav`,`audio/ogg`,`audio/ogg;codecs=opus`,`audio/mp4`,`audio/m4a`,`audio/mp3`]),fl={mp3:`audio/mp3`,webm:`audio/webm;codecs=opus`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/m4a`,mp4:`audio/mp4`};function pl(e,t){let n=fl[e.split(`.`).pop()?.toLowerCase()??``];if(n)return n;let r=t?.type;return r&&dl.has(r)?r:ul}var ml=class{constructor(){this.name=`backend`}prepareUpload({fileName:e,blob:t,upload:n}){let r=cl.safeParse(n);if(!r.success)throw new el(`Invalid backend upload payload: expected an upload_url string, got ${typeof n}`,[e]);return{url:`${r.data.replace(/\/+$/,``)}/${encodeURIComponent(e)}`,method:`POST`,bodyMode:`binary`,headers:{[ll]:pl(e,t)},attachAuth:!0}}},hl={aws:()=>new sl,backend:()=>new ml};function gl(e){return typeof e==`string`?e.trim().toLowerCase():``}function _l(e){let t=hl[gl(e)];if(!t)throw new tl(e);return t()}var vl=2,yl=2e3,bl=1e4,xl,Sl=[],Cl=new Map,wl=null,Tl=new Map;function El(e,t){let n=Tl.get(e);if(n){Tl.delete(e);for(let e of n)e(t)}}function Dl(e,t){try{e.postMessage(t)}catch{}}function Ol(e){for(let t of Sl)Dl(t,e)}function kl(){return new Promise(e=>{let t=wl;wl=()=>{t?.(),e()},setTimeout(()=>{e()},bl)})}function Al(e){return new Promise(t=>{let n=Tl.get(e);n||(n=new Set,Tl.set(e,n)),n.add(t),setTimeout(()=>{let n=Tl.get(e);n?.has(t)&&(n.delete(t),n.size===0&&Tl.delete(e),t(null))},bl)})}function jl(e,t,n,r){let i={...e.headers};e.attachAuth&&(Object.assign(i,r),xl&&(i.Authorization=`Bearer ${xl}`));let a;if(e.bodyMode===`multipart`){let r=new FormData;for(let[t,n]of Object.entries(e.formFields??{}))r.append(t,n);r.append(e.fileFieldName??`file`,n,t),a=r}else a=n,i[`Content-Type`]||=`audio/mp3`;return{method:e.method,body:a,headers:i,credentials:e.attachAuth?`include`:`omit`}}async function Ml(e,t,n,r,i){Dl(e,{type:`upload_url_required`,fileName:n});let a=await Al(e);if(!a)return i;try{return _l(t).prepareUpload({fileName:n,blob:r,upload:a})}catch{return i}}async function Nl(e,t,n,r,i,a){let o=`Upload failed after retries`,s;for(let c=0;c<=vl;c++)try{let l=await fetch(e.url,jl(e,t,n,r));if(l.ok)return{success:!0};if(s=l.status,o=await Pl(l),l.status===401&&e.attachAuth){Ol({type:`token_required`}),await kl();continue}if(c<vl){e=await Ml(a,i,t,n,e),await Fl(yl);continue}return{success:!1,error:o,statusCode:s}}catch(r){o=r?.message??`Network error`,c<vl&&(e=await Ml(a,i,t,n,e),await Fl(yl))}return{success:!1,error:o,statusCode:s}}async function Pl(e){try{let t=await e.json();return t?.error?.message??t?.message??e.statusText??`Request failed`}catch{return e.statusText??`HTTP ${e.status}`}}function Fl(e){return new Promise(t=>setTimeout(t,e))}async function Il(e,t,n,r,i,a){try{let o=Xn(e);if(!o){Dl(a,{type:`upload_failed`,fileName:t,error:`MP3 encoding failed`});return}Dl(a,{type:`chunk_encoded`,fileName:t,chunkData:o.chunks});let s;try{s=_l(n).prepareUpload({fileName:t,blob:o.blob,upload:r})}catch(e){Dl(a,{type:`upload_failed`,fileName:t,error:e?.message??`Failed to prepare upload`,chunkData:o.chunks});return}let c=await Nl(s,t,o.blob,i,n,a);c.success?Dl(a,{type:`upload_success`,fileName:t}):Dl(a,{type:`upload_failed`,fileName:t,error:c.error??`Upload failed after retries`,chunkData:o.chunks})}catch(e){Dl(a,{type:`upload_failed`,fileName:t,error:e?.message??`Unknown error`})}}function Ll(e,t){switch(e.type){case`compress_and_upload`:{Cl.has(t)||Cl.set(t,new Set);let n=Cl.get(t),r=Il(e.audioFrames,e.fileName,e.storageProvider,e.upload,e.headers,t);n.add(r),r.finally(()=>n.delete(r));break}case`wait_for_all_uploads`:{let e=Cl.get(t)??new Set;Promise.all(e).then(()=>{Dl(t,{type:`all_uploads_complete`})});break}case`update_auth_token`:xl=e.token,wl&&=(wl(),null);break;case`update_upload_url`:El(t,e.upload);break;case`terminate`:{let e=Sl.indexOf(t);e>=0&&Sl.splice(e,1),Cl.delete(t),El(t,null);try{t.close()}catch{}Sl.length===0&&self.close();break}}}var Rl=self;Rl.onconnect=e=>{let t=e.ports[0];Sl.push(t),t.onmessage=e=>{Ll(e.data,t)},t.start()}})();
|